Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
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.
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
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 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.
Create api documentations for typescript projects.
TypeDoc runs on Node.js and is available as an NPM package. You can install TypeDoc in your project's directory as usual:
$ npm install typedoc --save-dev
Like the TypeScript compiler, TypeDoc comes with a binary that can be called from anywhere
if you install TypeDoc as a global module. The name of the executable is typedoc
.
$ npm install typedoc --global
$ typedoc
If you want to know what a documentation created with TypeDoc looks like, head over to the GitHub page of the project. It contains an api documentation of TypeDoc generated with TypeDoc:
http://sebastian-lenz.github.io/typedoc
TypeDoc accepts most of the command line arguments that the TypeScript compiler accepts. One major difference is the fact that one may pass an entire directory instead of individual files to the documentation generator. So in order to create a documentation for an entire project you simply type:
$ typedoc --out path/to/documentation/ path/to/typescript/project/
--out <path/to/documentation/>
Specifies the location the documentation should be written to.
--name <Documentation title>
Set the name of the project that will be used in the header of the template.
--module <commonjs or amd>
Specify module code generation: "commonjs" or "amd"
--target <ES3 or ES5>
Specify ECMAScript target version: "ES3" (default), or "ES5"
--exclude <pattern>
Exclude files by the given pattern when a path is provided as source
--theme <path/to/theme>
Specify the path to the theme that should be used
--includeDeclarations
Turn on parsing of .d.ts declaration files.
--externalPattern <pattern>
Define a pattern for files that should be considered being external.
--excludeExternals
Prevent externally resolved TypeScript files from being documented.
--verbose
Print more information while TypeDoc is running.
There is a plugin available to run TypeDoc with Gulp created by Rogier Schouten. You can find it on NPM: https://www.npmjs.org/package/gulp-typedoc/
There is a plugin available to run TypeDoc with Grunt created by Bart van der Schoor. You can find it on NPM: https://www.npmjs.org/package/grunt-typedoc
TypeDoc runs the TypeScript compiler and extracts type information from the generated compiler symbols. Therefore you don't have to include additional metadata within your comments, TypeScript specific elements like classes, enumerations or property types and access modifiers will be automatically detected.
All comments parsed as markdown. TypeDoc uses the Marked (https://github.com/chjj/marked) markdown parser and HighlightJS (https://github.com/isagalaev/highlight.js) to highlight code blocks within markdown sections. Additionally you can link to other classes, members or functions using double angle brackets.
The documentation generator currently understands these javadoc tags:
@param <param name>
@retrun(s)
All other tags will be rendered as definition lists, so they are not lost.
When writing documentation for function signatures, you don't have to repeat yourself. TypeDoc automatically copies comments and tags of the function implementation to its signatures for you. Of course you can still overwrite them if you wish to.
/**
* @param text Comment for parameter ´text´.
*/
function doSomething(target:any, text:string):number;
/**
* @param value Comment for parameter ´value´.
* @returns Comment for special return value.
*/
function doSomething(target:any, value:number):number;
/**
* Comment for method ´doSomething´.
* @param target Comment for parameter ´target´.
* @returns Comment for return value.
*/
function doSomething(target:any, arg:any):number {
return 0;
}
FAQs
Create api documentation for TypeScript projects.
The npm package typedoc receives a total of 1,229,438 weekly downloads. As such, typedoc popularity was classified as popular.
We found that typedoc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.