Documentation generation tools are essential for creating structured and easily navigable documentation from source code comments. These tools parse specially formatted comments in the code and generate HTML, Markdown, or other formats, making it easier for developers to understand and use libraries, frameworks, or applications. They help automate the documentation process, ensuring that it stays up-to-date with the codebase, and can include features like type inference, code examples, and customizable templates. Tools like jsdoc, typedoc, and @microsoft/tsdoc are popular choices, each with unique features and strengths.
Npm Package Weekly Downloads Trend
3 Years
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
@microsoft/tsdoc
6,081,389
4,895
2.3 MB
148
7 days ago
MIT
typedoc
2,416,624
8,284
2.15 MB
8
a month ago
Apache-2.0
jsdoc
2,061,309
15,352
1.47 MB
452
a month ago
Apache-2.0
Feature Comparison: @microsoft/tsdoc vs typedoc vs jsdoc
TypeScript Support
@microsoft/tsdoc:
@microsoft/tsdoc is designed specifically for TypeScript, providing a framework for writing and parsing documentation comments that are type-aware. It helps enforce best practices in documentation for TypeScript projects.
typedoc:
typedoc is built for TypeScript and fully utilizes its type system to generate documentation. It provides rich type information, including interfaces, classes, and generics, making it the best choice for TypeScript projects.
jsdoc:
jsdoc supports TypeScript to some extent, especially with the use of the --typescript flag. However, its primary focus is on JavaScript, and it may not fully leverage TypeScript's type information without additional configuration.
Customization
@microsoft/tsdoc:
@microsoft/tsdoc provides a structured approach to documentation but is not a documentation generator itself. It focuses on defining a standard for TSDoc comments, which can be implemented by other tools for customization.
typedoc:
typedoc allows for some customization, particularly in the theming and layout of the generated documentation. However, it is more opinionated than JSDoc, focusing on type-driven documentation.
jsdoc:
jsdoc offers extensive customization options, including the ability to create custom tags, templates, and themes. Its flexibility allows developers to tailor the documentation output to meet specific needs.
Output Formats
@microsoft/tsdoc:
@microsoft/tsdoc does not generate output formats directly. Instead, it provides a specification for TSDoc comments, which can be implemented by other tools to produce HTML, Markdown, or other formats.
typedoc:
typedoc primarily generates documentation in HTML format, with some support for Markdown. It focuses on creating a structured and navigable representation of TypeScript code.
jsdoc:
jsdoc generates documentation in HTML, Markdown, and other formats. It is highly configurable, allowing developers to choose the output format that best suits their needs.
Community and Ecosystem
@microsoft/tsdoc:
@microsoft/tsdoc is backed by Microsoft and has a growing community focused on improving TypeScript documentation standards. Its ecosystem is still developing, with tools and integrations emerging.
typedoc:
typedoc has an active community of contributors and users, particularly within the TypeScript ecosystem. It is continually evolving, with new features and improvements being added regularly.
jsdoc:
jsdoc has a large and established community with a rich ecosystem of plugins, themes, and tools. Its long history and widespread use make it a reliable choice for documentation generation.
Ease of Use: Code Examples
@microsoft/tsdoc:
@microsoft/tsdoc provides a clear and structured way to write documentation comments, but it requires integration with a documentation generator to produce output. Example of TSDoc comment:
/**
* A simple calculator class.
*
* @remarks This class provides basic arithmetic operations.
* @public
*/
class Calculator {
/**
* Adds two numbers.
*
* @param a - The first number.
* @param b - The second number.
* @returns The sum of the two numbers.
* @example
* const calc = new Calculator();
* const sum = calc.add(2, 3);
* console.log(sum); // 5
*/
add(a: number, b: number): number {
return a + b;
}
}
typedoc:
typedoc is straightforward to use for TypeScript developers, as it leverages TypeScript's type system. Example of TypeDoc comment:
/**
* A simple calculator class.
*
* @class
* @classdesc This class provides basic arithmetic operations.
* @example
* const calc = new Calculator();
* const sum = calc.add(2, 3);
* console.log(sum); // 5
*/
class Calculator {
/**
* Adds two numbers.
*
* @param a - The first number.
* @param b - The second number.
* @returns The sum of the two numbers.
*/
add(a: number, b: number): number {
return a + b;
}
}
jsdoc:
jsdoc is easy to use, especially for those familiar with JavaScript. It uses a simple comment-based syntax to generate documentation. Example of JSDoc comment:
/**
* A simple calculator class.
*
* @class
* @classdesc This class provides basic arithmetic operations.
* @example
* const calc = new Calculator();
* const sum = calc.add(2, 3);
* console.log(sum); // 5
*/
class Calculator {
/**
* Adds two numbers.
*
* @param {number} a - The first number.
* @param {number} b - The second number.
* @returns {number} The sum of the two numbers.
*/
add(a, b) {
return a + b;
}
}
How to Choose: @microsoft/tsdoc vs typedoc vs jsdoc
@microsoft/tsdoc:
Choose @microsoft/tsdoc if you are developing a TypeScript library and want to establish a standardized documentation format that integrates well with other tools. It is particularly useful for projects that prioritize consistency and interoperability in documentation.
typedoc:
Choose typedoc if you are working on a TypeScript project and want to generate documentation that fully leverages TypeScript's type system. It produces detailed, type-aware documentation and is ideal for projects where type information is crucial for understanding the code.
jsdoc:
Choose jsdoc if you need a versatile and widely-used documentation generator that works with both JavaScript and TypeScript. It offers extensive customization options, supports various output formats, and has a large ecosystem of plugins and themes.
Popular Comparisons
Similar Npm Packages to @microsoft/tsdoc
@microsoft/tsdoc is a documentation generator specifically designed for TypeScript projects. It provides a standardized way to write and generate documentation comments, ensuring that TypeScript code is well-documented and easy to understand. TSDoc aims to improve the quality of documentation in TypeScript libraries and applications by offering a clear syntax and guidelines for writing comments that can be processed by various tools. This makes it an excellent choice for developers looking to maintain high-quality documentation in their TypeScript codebases.
While TSDoc is a powerful tool for TypeScript projects, there are other documentation generation tools available that cater to different needs. Here are a few alternatives:
jsdoc is a widely-used documentation generator for JavaScript projects. It allows developers to write comments in a specific format that can be parsed to create comprehensive documentation. JSDoc is highly customizable and supports various output formats, making it a popular choice for JavaScript developers. If you are working on a JavaScript project and need a robust solution for generating documentation, JSDoc is a great option.
typedoc is another documentation generator specifically designed for TypeScript projects. It generates documentation from TypeScript source files and provides a clean and organized output. Typedoc focuses on leveraging TypeScript's type information to create rich documentation, making it an excellent choice for TypeScript developers who want to showcase their code's structure and types. If you prefer a tool that integrates closely with TypeScript's type system, Typedoc is worth considering.
typedoc is a documentation generator specifically designed for TypeScript projects. It extracts type information and generates comprehensive documentation in various formats, including HTML and JSON. With its focus on TypeScript, typedoc provides detailed insights into types, interfaces, and classes, making it an excellent choice for developers looking to create well-structured documentation for their TypeScript codebases. Its ability to generate documentation directly from the source code helps maintain accuracy and consistency, ensuring that the documentation evolves alongside the code.
While typedoc is a powerful tool for TypeScript documentation, there are several alternatives available for generating documentation in JavaScript and TypeScript projects. Here are a few noteworthy options:
documentation is a documentation generator that works with JavaScript codebases. It analyzes comments in the source code and produces documentation in various formats, including HTML and Markdown. documentation is particularly useful for projects that use JSDoc-style comments, allowing developers to create clear and concise documentation without the need for extensive configuration. If you're working with JavaScript and prefer a straightforward approach to documentation generation, documentation is a solid choice.
esdoc is another documentation generator tailored for JavaScript projects. It focuses on providing a simple and effective way to generate documentation from ES6+ code. esdoc supports various features, including plugins for additional functionality, and it can produce documentation in HTML format. If you're looking for a documentation generator that caters specifically to modern JavaScript features, esdoc might be the right fit for your project.
jsdoc is one of the most popular documentation generators for JavaScript. It allows developers to write documentation directly in their code using JSDoc comments, which are then parsed to generate comprehensive documentation in HTML format. jsdoc has a large community and extensive plugin support, making it a versatile choice for projects of all sizes. If you're working with JavaScript and want a well-established documentation tool, jsdoc is a reliable option.
jsdoc is a popular documentation generator for JavaScript projects. It allows developers to create comprehensive and structured documentation directly from the comments in their source code. By using JSDoc annotations, developers can provide detailed descriptions of functions, classes, and methods, which can then be transformed into HTML documentation. This tool is widely used in the JavaScript community due to its simplicity and effectiveness in generating documentation that is easy to navigate and understand.
While JSDoc is a powerful tool, there are several alternatives available that cater to different needs and preferences:
documentation is a documentation generator that focuses on simplicity and ease of use. It parses your JavaScript code and generates documentation in various formats, including HTML and Markdown. Unlike JSDoc, which relies heavily on comments, documentation can also infer information from the code itself, making it a good choice for projects where comments may be sparse. It is particularly useful for developers looking for a straightforward solution to generate clean and readable documentation.
esdoc is another documentation generator that is specifically designed for ES6 (ECMAScript 2015) and later versions. It provides a rich set of features, including support for plugins, automatic API documentation generation, and the ability to generate documentation in multiple formats. esdoc is ideal for projects that utilize modern JavaScript features and require a robust documentation solution that can keep pace with the evolving language.
typedoc is a documentation generator for TypeScript projects. It extracts type information from TypeScript code and generates documentation that reflects the types and interfaces used in the codebase. If you are working on a TypeScript project and want to leverage the type information to create comprehensive documentation, typedoc is the best choice. It provides a seamless integration with TypeScript, ensuring that your documentation is always up to date with the code.
This library is the reference implementation of a parser for the TSDoc syntax. Using this library is an easy way to ensure that your tool is 100% compatible with the standard.
What is TSDoc?
TSDoc is a proposal to standardize the doc comments used in TypeScript source files. It allows different tools to extract content from comments without getting confused by each other's syntax. The TSDoc notation looks pretty familiar:
export class Statistics {
/**
* Returns the average of two numbers.
*
* @remarks
* This method is part of the {@link core-library#Statistics | Statistics subsystem}.
*
* @param x - The first input number
* @param y - The second input number
* @returns The arithmetic mean of `x` and `y`
*
* @beta
*/
public static getAverage(x: number, y: number): number {
return (x + y) / 2.0;
}
}
Give it a try!
Check out the TSDoc Playground for a cool live demo of our parser!
API Usage
The api-demo folder on GitHub illustrates how
to invoke the TSDoc parser.
The TSDoc project is actively evolving. Please visit the website for the latest documentation, instructions for building/debugging the projects, and other resources: