Convert Figma logo to code with AI

TypeStrong logotypedoc

Documentation generator for TypeScript projects.

7,644
690
7,644
15

Top Related Projects

4,710

A doc comment standard for TypeScript

14,962

An API documentation generator for JavaScript.

:book: documentation for modern JavaScript

:notebook_with_decorative_cover: The missing documentation tool for your Angular, Nest & Stencil application

12,836

TypeScript execution and REPL for node.js

Quick Overview

TypeDoc is a documentation generator for TypeScript projects. It converts comments in TypeScript source code into rendered HTML documentation or a JSON model. TypeDoc extends TypeScript's compiler to extract information from source files and generates a static documentation website.

Pros

  • Generates comprehensive documentation from TypeScript code comments
  • Supports various output formats, including HTML and JSON
  • Integrates well with TypeScript projects and respects TypeScript's type system
  • Customizable through themes and plugins

Cons

  • Learning curve for proper documentation syntax and configuration
  • May produce overly verbose output for simple projects
  • Requires manual updates to keep documentation in sync with code changes
  • Some users report issues with complex type definitions or certain TypeScript features

Code Examples

  1. Basic usage in a TypeScript file:
/**
 * Calculates the sum of two numbers.
 * @param a The first number.
 * @param b The second number.
 * @returns The sum of a and b.
 */
function add(a: number, b: number): number {
    return a + b;
}
  1. Documenting a class with methods:
/**
 * Represents a simple calculator.
 */
class Calculator {
    /**
     * Multiplies two numbers.
     * @param x The first factor.
     * @param y The second factor.
     * @returns The product of x and y.
     */
    multiply(x: number, y: number): number {
        return x * y;
    }
}
  1. Using advanced TypeDoc features:
/**
 * @typedef {Object} User
 * @property {string} name - The user's name.
 * @property {number} age - The user's age.
 */

/**
 * Greets a user.
 * @param {User} user - The user to greet.
 * @returns {string} A greeting message.
 * @example
 * const user = { name: "Alice", age: 30 };
 * greetUser(user); // Returns: "Hello, Alice!"
 */
function greetUser(user: User): string {
    return `Hello, ${user.name}!`;
}

Getting Started

  1. Install TypeDoc in your project:

    npm install --save-dev typedoc
    
  2. Add a TypeDoc script to your package.json:

    "scripts": {
      "docs": "typedoc --out docs src"
    }
    
  3. Run the documentation generator:

    npm run docs
    

This will generate documentation for your TypeScript files in the src directory and output them to a docs folder.

Competitor Comparisons

4,710

A doc comment standard for TypeScript

Pros of TSDoc

  • Designed as a specification, allowing for broader adoption and standardization
  • Focuses on parsing and extracting documentation, enabling integration with various tools
  • Supported and maintained by Microsoft, ensuring long-term stability

Cons of TSDoc

  • Less feature-rich out-of-the-box compared to TypeDoc
  • Requires additional tooling to generate documentation output
  • Smaller community and ecosystem of plugins/extensions

Code Comparison

TSDoc example:

/**
 * @param x - The first number to add
 * @param y - The second number to add
 * @returns The sum of x and y
 */
function add(x: number, y: number): number {
  return x + y;
}

TypeDoc example:

/**
 * Adds two numbers together
 * @param x The first number to add
 * @param y The second number to add
 * @returns The sum of x and y
 */
function add(x: number, y: number): number {
  return x + y;
}

While the syntax is similar, TSDoc uses hyphen-prefixed descriptions for parameters, whereas TypeDoc uses a more traditional JSDoc-style format.

14,962

An API documentation generator for JavaScript.

Pros of JSDoc

  • Broader language support: Works with JavaScript, TypeScript, and other languages
  • Extensive plugin ecosystem for customization
  • Well-established with a large community and extensive documentation

Cons of JSDoc

  • Less intuitive for TypeScript projects
  • Requires more manual effort to document types and interfaces
  • Output can be less visually appealing compared to TypeDoc

Code Comparison

JSDoc:

/**
 * @param {string} name - The name of the person
 * @param {number} age - The age of the person
 * @returns {Object} An object containing the person's details
 */
function createPerson(name, age) {
    return { name, age };
}

TypeDoc:

/**
 * Creates a person object
 * @param name The name of the person
 * @param age The age of the person
 * @returns An object containing the person's details
 */
function createPerson(name: string, age: number): { name: string; age: number } {
    return { name, age };
}

TypeDoc leverages TypeScript's type system, resulting in cleaner documentation with less manual type annotation. JSDoc requires explicit type declarations in comments, which can be more verbose but offers flexibility for JavaScript projects.

:book: documentation for modern JavaScript

Pros of documentation

  • Supports multiple languages (JavaScript, TypeScript, Flow)
  • Generates documentation in various formats (HTML, Markdown, JSON)
  • Highly customizable output with themes and plugins

Cons of documentation

  • Less TypeScript-specific features compared to typedoc
  • May require more configuration for complex projects
  • Smaller community and fewer third-party themes/plugins

Code Comparison

typedoc:

/**
 * @param {string} name - The name of the person
 * @returns {string} A greeting message
 */
function greet(name: string): string {
    return `Hello, ${name}!`;
}

documentation:

/**
 * Greet a person
 * @param {string} name - The name of the person
 * @returns {string} A greeting message
 */
function greet(name) {
    return `Hello, ${name}!`;
}

Both tools generate similar documentation from these code snippets, but typedoc provides more detailed type information for TypeScript projects. documentation offers a more language-agnostic approach, supporting multiple JavaScript flavors.

:notebook_with_decorative_cover: The missing documentation tool for your Angular, Nest & Stencil application

Pros of Compodoc

  • Specifically designed for Angular projects, offering better integration and support for Angular-specific features
  • Provides a more visually appealing and customizable documentation output
  • Includes built-in search functionality and a responsive layout for better user experience

Cons of Compodoc

  • Limited to Angular projects, lacking versatility for other TypeScript-based frameworks
  • May have a steeper learning curve for users not familiar with Angular-specific concepts
  • Less frequent updates and smaller community compared to TypeDoc

Code Comparison

TypeDoc:

/**
 * @param name The name of the person
 * @returns A greeting message
 */
function greet(name: string): string {
    return `Hello, ${name}!`;
}

Compodoc:

/**
 * Greets a person
 * @param name The name of the person
 * @returns A greeting message
 */
@Injectable()
export class GreetingService {
    greet(name: string): string {
        return `Hello, ${name}!`;
    }
}

TypeDoc is more general-purpose and can be used with any TypeScript project, while Compodoc is tailored for Angular applications, providing better support for Angular-specific decorators and structures.

12,836

TypeScript execution and REPL for node.js

Pros of ts-node

  • Enables direct execution of TypeScript files without separate compilation step
  • Provides a REPL for interactive TypeScript development
  • Supports ESM and CommonJS modules out of the box

Cons of ts-node

  • May have slower startup times for large projects compared to pre-compiled JavaScript
  • Limited to Node.js environment, not suitable for browser-based TypeScript execution

Code Comparison

ts-node:

// Execute TypeScript directly
ts-node script.ts

// Start REPL
ts-node

typedoc:

// Generate documentation
typedoc --entryPoints src/index.ts

// Configure output
typedoc --out docs src

Key Differences

ts-node focuses on runtime execution of TypeScript in Node.js, while typedoc is a documentation generator for TypeScript projects. ts-node is essential for development and testing, whereas typedoc is used for creating API documentation.

ts-node is more versatile for day-to-day TypeScript development, offering features like a REPL and direct script execution. typedoc, on the other hand, specializes in generating comprehensive documentation from TypeScript source code, which is crucial for maintaining large-scale projects and creating developer resources.

While both tools enhance the TypeScript ecosystem, they serve different purposes in the development lifecycle. ts-node streamlines the development process, and typedoc improves project maintainability and accessibility.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

TypeDoc

Documentation generator for TypeScript projects.

CI NPM Version

Documentation

For more detailed documentation, the changelog, and TypeDoc documentation rendered with TypeDoc, see https://typedoc.org.

Installation

TypeDoc runs on Node.js and is available as a NPM package.

npm install typedoc --save-dev

Usage

To generate documentation TypeDoc needs to know your project entry point and TypeScript compiler options. It will automatically try to find your tsconfig.json file, so you can just specify the entry point of your library:

typedoc src/index.ts

If you have multiple entry points, specify each of them.

typedoc package1/index.ts package2/index.ts

If you specify a directory, TypeDoc will use the entryPointStrategy option to determine how to resolve it. By default, TypeDoc will search for a file called index under the directory.

Monorepos / Workspaces

If your codebase is comprised of one or more npm packages, you can build documentation for each of them individually and merge the results together into a single site by setting entryPointStrategy to packages. In this mode TypeDoc requires configuration to be present in each directory to specify the entry points. For an example setup, see https://github.com/Gerrit0/typedoc-packages-example

Arguments

For a complete list of the command line arguments run typedoc --help or visit our website.

  • --out <path/to/documentation/>
    Specifies the location the documentation should be written to. Defaults to ./docs
  • --json <path/to/output.json>
    Specifies the location and file name a json file describing the project is written to. When specified no documentation will be generated unless --out is also specified.
  • --options
    Specify a json option file that should be loaded. If not specified TypeDoc will look for 'typedoc.json' in the current directory.
  • --tsconfig <path/to/tsconfig.json>
    Specify a typescript config file that should be loaded. If not specified TypeDoc will look for 'tsconfig.json' in the current directory.
  • --exclude <pattern>
    Exclude files by the given pattern when a path is provided as source. Supports standard minimatch patterns.

Theming

  • --theme <default|plugin defined theme>
    Specify the theme that should be used.
  • --name <Documentation title>
    Set the name of the project that will be used in the header of the template.
  • --readme <path/to/readme|none>
    Path to the readme file that should be displayed on the index page. Pass none to disable the index page and start the documentation on the globals page.

Miscellaneous

  • --version
    Display the version number of TypeDoc.
  • --help
    Display all TypeDoc options.

Contributing

This project is maintained by a community of developers. Contributions are welcome and appreciated. You can find TypeDoc on GitHub; feel free to open an issue or create a pull request: https://github.com/TypeStrong/typedoc

For more information, read the contribution guide.

NPM DownloadsLast 30 Days