Improving documentation

Effective documentation is crucial for maintaining a clear and understandable codebase. One powerful tool for enhancing documentation within your code is JSDoc. JSDoc is a markup language that allows you to annotate your code with structured comments, enabling automatic generation of documentation. In this guide, we will explore the uses of JSDoc and how it can improve your project’s documentation.

Using JSDoc for Generated Documentation


One of the primary uses of JSDoc is to generate documentation directly from your codebase. By adding JSDoc comments to your functions, classes, and variables, you can provide essential information that is automatically extracted and transformed into comprehensive documentation.

To use JSDoc for generating documentation, follow these steps:

  1. Markup Comments: Add JSDoc comments directly above the code elements you want to document. Use the /*_ … _/ syntax to indicate a JSDoc comment block.

  2. Documenting Functions: Use JSDoc tags to describe function parameters, return values, and additional information. Tags like @param, @returns, and @description are commonly used for this purpose.
    Other important custom tags are @category and @subcategory, these tags help to structure the generated documentation into chapters.

    • @category: This tag is used to group modules under a common chapter. All modules under a category will be under one chapter, the chapter name will correspond to the name assigned to the category.
    • @subcategory: This tag is used to group modules under a common chapter. All modules under a subcategory will be under one chapter, the chapter name will correspond to the name assigned to the subcategory.
  1. Documenting Classes: For classes, use JSDoc comments to provide descriptions, document class properties, and document class methods. Tags like @class, @property, and @method are commonly used in this context.

  2. Running JSDoc Generation: Use a JSDoc generator tool, such as JSDoc itself or other popular tools like TypeDoc or JSDoc3, to parse your codebase and generate the documentation output. Configure the generator to target the desired output format, such as HTML or Markdown.

  3. Review and Update: Review the generated documentation and ensure it accurately represents your code. Update the JSDoc comments as needed to provide clearer explanations or additional information.

For more information on using JSDoc for generating documentation, see the JSDoc documentation or Getting started with JSDoc.

Using JSDoc for Writing Documentation


JSDoc can also be used beyond generating code documentation. Its flexible syntax and tagging system make it a valuable tool for writing other aspects of your project’s documentation, such as tutorials, guides, and reference materials.

To use JSDoc for writing documentation, consider the following approaches:

  1. Tutorials and Guides: Utilize JSDoc comments to write step-by-step tutorials and guides within your codebase. By embedding tutorial content in JSDoc comments, you can keep the documentation closely tied to the relevant code, making it easier for developers to follow along and understand the concepts.

  2. Inline Examples: Use JSDoc comments to include inline code examples that demonstrate the usage of functions, classes, or modules. These examples can serve as both instructional material and a quick reference for developers.

  3. Reference Materials: JSDoc comments can be used to provide additional information in reference materials, such as explaining design patterns, outlining best practices, or clarifying complex concepts. Leverage JSDoc tags like @example or @see to link to relevant resources or code examples.

  4. Integration with Markdown: JSDoc supports Markdown within comments, allowing you to incorporate formatted text, headings, lists, and other Markdown features into your documentation. This enables you to create more visually appealing and structured content within your JSDoc comments.

Improving JSQuarto documentation with JSDoc


The JSQuarto documentation is not yet complete. There are several areas that could be improved, including:

  • More detailed explanations of the JSQuarto project structure and codebase
  • Additional information on how to contribute to the project
  • Additional information on how to maintain the JSQuarto project
  • Additional information on how to deploy the JSQuarto project
  • Project roadmap and future plans

To improve the JSQuarto documentation, you can use JSDoc to add additional documentation directly within the codebase. This will allow you to provide more detailed explanations of the code and project structure, as well as additional information on how to contribute to the project, how to use the JSQuarto API, and how to maintain and deploy the project. As at the time of writing this, the documentation was built with other packages to improve the User interface, one of which is Better-docs.