What is typedoc?
TypeDoc is a documentation generator for TypeScript projects. It reads your TypeScript source code and its comments and produces an HTML documentation website. It is capable of creating readable and user-friendly documentation for TypeScript projects, which can be very helpful for both maintaining internal code and for sharing code with external users.
What are typedoc's main functionalities?
Generating Documentation
This command generates documentation for the TypeScript source files located in the 'src' directory and outputs the result to the 'docs' directory.
typedoc --out docs src
Customizing the Theme
This command generates documentation with a minimal theme, which is one of the built-in themes provided by TypeDoc.
typedoc --out docs src --theme minimal
Excluding Private Members
This command generates documentation while excluding private members from the output, making the documentation cleaner if private members are not intended to be part of the public API.
typedoc --out docs src --excludePrivate
Including Declaration Files
This command includes type declaration files (d.ts files) in the documentation generation process, which can be useful for documenting the types that are part of the project's external API.
typedoc --out docs src --includeDeclarations
Other packages similar to typedoc
jsdoc
JSDoc is a popular documentation generator for JavaScript. It uses comments in the source code to generate comprehensive documentation. While similar in purpose to TypeDoc, JSDoc is tailored for JavaScript and requires additional plugins to work well with TypeScript.
esdoc
ESDoc is another documentation generator for JavaScript, with support for ES6+ syntax. It provides features like coverage reporting and integrated test codes in the documentation. ESDoc is not as TypeScript-focused as TypeDoc and may require additional configuration for TypeScript projects.
TypeDoc
Documentation generator for TypeScript projects.
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 pass the paths to these
packages and TypeDoc will attempt to determine entry points based on package.json
's main
property (with default value index.js
) and if it wasn't found, based on types
property.
If any of the packages given are the root of an npm Workspace
or a Yarn Workspace TypeDoc will find all
the workspaces
defined in the package.json
. In order to find your entry points, TypeDoc requires
either that you turn on sourcemaps so that it can discover the original TS file, or that you
specify "typedocMain": "src/index.ts"
to explicitly state where the package entry point is.
Supports wildcard paths in the same fashion as those found in npm or Yarn workspaces.
Single npm module
typedoc --entryPointStrategy packages .
Monorepo with npm/Yarn workspace at the root
typedoc --entryPointStrategy packages .
Monorepo with manually specified sub-packages to document
This can be useful if you do not want all your workspaces to be processed.
Accepts the same paths as would go in the package.json
's workspaces
typedoc --entryPointStrategy packages a-package 'some-more-packages/*' 'some-other-packages/*'
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.--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.
Source file handling
--exclude <pattern>
Exclude files by the given pattern when a path is provided as source.
Supports standard minimatch patterns.--excludeNotDocumented
Only document items which have a doc comment. This option is useful, if you
want to document only small part of your symbols and do not show the
remaining ones in the documentation.
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
--listInvalidSymbolLinks
Display the list of links that don't point to actual code symbols.--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.
License
Copyright (c) 2015 Sebastian Lenz.
Copyright (c) 2016-2021 TypeDoc Contributors.
Licensed under the Apache License 2.0.