Documentation Tool 1 Docusaurus - Sa-dia/SmartClassRoutineManagementSystem GitHub Wiki
Trisha Sarkar
What is Docusaurus?
Docusaurus is a static-site generator. It builds a single-page application with fast client-side navigation, leveraging the full power of React to make your site interactive. It provides out-of-the-box documentation features but can be used to create any kind of site (personal website, product, blog, marketing landing pages, etc).
Node.js Installation and Version Requirements
Ensure that you have Node.js version 18.0 or above and npm installed. You can check your current version by running:
- node -v
- npm -v
Use the following command to install Docusaurus globally:
This allows you to initialize and use Docusaurus from any directory on your system.
Alternatively you, can set up Docusaurus for a specific project by following steps
npx create-docusaurus@latest my-website classic
: This command uses npx to create a new Docusaurus site in a directory named my-website using the classic template.
cd my-website
: Navigates into the newly created project directory.
npm install
: Installs all the dependencies for the project.
For example if you choose the classic template and named your site as my-website
, you will see the following files generated under a new directory my-website/
:
After installing start the development server with:
By default, a browser window will open at http://localhost:3000/
Manually change the version number in package.json to the desired version. Note that all @docusaurus/-namespaced packages should be using the same version.
Then, in the directory containing package.json, run your package manager's install command:
To check that the update occurred successfully, run:
Click : Video Link.
Docusaurus is highly customizable, offering a wide range of options to personalize your documentation website.
A docusaurus project typically consists of three main components:
- Docs - Where all your markdown-based doumentation files are stored.
- Blog - A place to write articles or updates, useful for project announcements.
-
Pages - Individual pages like
About
,Contact
or any other custom content.
To add new content to your Docusaurus site, create markdown files in the docs/
folder.
For example, adding a new file my-first-doc.md
in the docs/
folder will automatically be included in your documentation website:
One of the powerful features of Docusaurus is versioning, which allows us to maintain multiple versions of our documentation as our project evolves.
Creating a New Version: To create a new version of our documentation, For example to create version 2.0 of our documentation run the following command:
This will create a version-2.0/
folder in the docs/
directory, allowing you to maintain separate versions of our documentation.
The docusaurus.config.js
file is run in Node.js and should export either:
- a config object
- a function that creates the config object
Docusaurus gives us the ability to declare its configuration in various equivalent ways, and all the following config examples lead to the exact same result:
Click : here.
Deploying a Docusaurus site is simple and can be done with a single command. The default deployment target is Github Pages, but Docusaurus can also be hosted on Netlify, Vercel, or any other hosting provider.
Ensure that our docusaurus.config,js
file is set up with the correct URL and base URL. Then run the following command to build and deploy our site:
This will build the site and push the build/
directory to your Github Pages branch.
Click : here .
Feature-Rich: Docusaurus offers a wide range of features out of the box, such as versioning, multi-language support, theming, and plugin systems. This makes it suitable for creating complex documentation websites, not just API documentation.
Customizable and Extensible: It allows extensive customization with React components, allowing you to create custom pages and dynamic content easily. Markdown Support: Docusaurus uses Markdown for creating documentation, which is easy to write and read. It also supports MDX, allowing React components within Markdown files for more interactive documentation.
Versioning: Docusaurus supports documentation versioning, making it easy to maintain different versions of your project documentation, which is particularly useful for libraries or frameworks with multiple versions.
Built-in Search: It comes with a built-in search functionality (powered by Algolia) that can be easily integrated into the documentation site, enhancing the user experience.
Static Site Generation: Docusaurus generates a static website that can be deployed anywhere, making it fast and easy to host on services like GitHub Pages, Netlify, or Vercel.
Multi-language Support: Built-in support for internationalization (i18n) to create documentation in multiple languages. Community and Ecosystem: Being backed by Facebook, Docusaurus has a strong community and ecosystem with regular updates and a variety of plugins and themes.
-
Steeper Learning Curve
- Requires React knowledge for advanced customizations.
- Complex configuration can be overwhelming for beginners.
-
Manual API Documentation
- Does not automatically generate documentation from code comments.
- No built-in code parsing like JSDoc or ESDoc.
-
Overkill for Small Projects
- Can be too complex for simple documentation needs.
- Higher setup and maintenance time compared to simpler tools.
-
Performance Considerations
- Long build times for large documentation sites.
- Static content requires a rebuild for updates.
-
Dependency on JavaScript Ecosystem
- Requires Node.js to run.
- Potential for dependency conflicts or version issues.
-
Limited Built-in Advanced Features:
- Advanced features may require plugins or custom code.
- Not a CMS, so lacks features like WYSIWYG editors and content workflows.
-
SEO and Accessibility
- Static nature can limit dynamic SEO optimizations.
- Accessibility requires extra effort, especially with custom components.
Docusaurus is often compared to other documentation tools like JSDoc or GitBook. Here's how it stands out:
-
Dynamic Documentation: Unlike static documentation tools, Docusaurus provides a full-fledged website with a blog, a theme system, and SEO features.
-
Versioning: It supports multiple versions of documentation, making it ideal for projects that have long-term support for various releases.
-
Built-in Search: Docusaurus comes with out-of-the-box search functionality using Algolia, making it easy for users to find the content they need.
Docusaurus has a rich ecosystem of plugins and themes. We can easily extend our documentation site with additional features such as Google Analytics, RSS feeds, or custom UI components.
-
@docusaurus/plugin-content-blog- Adds a blog to our site.
-
@docusaurus/plugin-pwa- Turns our Docusaurus site into a Progressive Web App(PWA).
-
@docusaurus.plugin-sitemap- Generates a sitemap for better SEO.
-
Purpose: Docusaurus is for full documentation websites; JSDoc and ESDoc are for API documentation from code comments.
-
Content Focus: Docusaurus requires manual content creation; JSDoc and ESDoc auto-generate documentation.
-
Ease of Use: Docusaurus has a steeper learning curve; JSDoc and ESDoc are simpler to set up.
-
Customization: Docusaurus is highly customizable with React; JSDoc has limited customization, while ESDoc offers more flexibility.
-
Output: Docusaurus creates full static websites; JSDoc generates simple HTML pages, and ESDoc provides more visually detailed output.
-
Automatic Documentation: Docusaurus does not auto-generate documentation; JSDoc and ESDoc do.
-
Use Cases: Docusaurus is ideal for comprehensive documentation sites; JSDoc and ESDoc are better for API documentation.
-
Pros and Cons: Docusaurus is feature-rich but complex; JSDoc is simple but limited, while ESDoc enhances JSDoc with modern JS support.
Feature | JSDoc | ESDoc | Docusaurus |
---|---|---|---|
Purpose | Generates documentation from JavaScript comments using the JSDoc syntax. | Similar to JSDoc but with more ES6+ features. | Primarily a static site generator focused on documentation, blog, and custom pages. |
Support for JavaScript | Strong support for JS (ES5, ES6), TypeScript support via plugins. | Tailored for ES6+ and supports more advanced ES features. | Does not directly generate documentation from JS code. |
Ease of Setup | Easy to set up with npm and minimal configuration. | Easy to set up but requires a more modern codebase (ES6+). | Requires more setup (static site generation) and configuration. |
Popularity | Very popular, widely adopted. | Gaining traction, but less popular than JSDoc. | Widely used for project websites, less used for code documentation. |
Customization | Supports themes, plugins, and templates for customization. | Limited customization compared to JSDoc. | Highly customizable through React components and Markdown. |
Static Site Generation | No built-in static site generation. | No built-in static site generation. | Excellent static site generation (focuses on full documentation websites). |
Integration with Build Tools | Can be integrated with various build tools (e.g., Gulp, Grunt, Webpack). | Similar to JSDoc, integration available for modern ES tools. | Requires separate configuration to integrate with build tools. |
Output Style | Produces HTML documentation. | Similar HTML output as JSDoc, but less customization available. | Creates full websites with docs, versioning, blog, and custom content. |
Focus | Primarily focused on JavaScript code documentation. | Focused on ES6+ codebases, similar to JSDoc but more modern. | Focuses on creating full documentation websites, not directly tied to code comments. |
Learning Curve | Simple and beginner-friendly. | Slightly steeper learning curve (ES6+ features). | Higher learning curve (requires knowledge of React, Markdown, etc.). |
Community Support | Large community with extensive support and plugins. | Smaller community compared to JSDoc. | Large community, especially for project website generation, but less so for code documentation. |