How to create API Documentation of any Typescript Project?
I love to create automatic API Documentation of my project. Regardless I work on Angular, React or VueJS as far as it uses Typescript. Did you know you could generate your project API Wikipedia kind of documentation within blink of eyes if you are using Typescript? Please read this blog to find out how easy it is.
Documentation for Any Typescript Node JS Project
Install typedoc
by running npm i -D typedoc
then add below in your script of package.json
file
"typedoc": "typedoc --out docs --mode modules --tsconfig tsconfig.json src/",
Documentation for Webpack enabled Typescript Project
Install typedoc-webpack-plugin
by running below script in your project.
npm i -D typedoc-webpack-plugin typedoc
Next you can add this plugin to your production version of the webpack config file. I normally add in webpack-prod.config.js
file
const TypedocWebpackPlugin = require('typedoc-webpack-plugin');
...
plugins: [ new TypedocWebpackPlugin({ out : 'dist/docs/api' }) ]
The options for the plugin mirror the options that are passed to typedoc. Refer to https://github.com/TypeStrong/typedoc for full options.
The default options that are set by the plugin are:
{
out: './docs',
module: 'commonjs',
target: 'es5',
exclude: '**/node_modules/**/*.*',
experimentalDecorators: true,
excludeExternals: true
}
Here is an example of a more expanded configuration:
plugins: [
new TypedocWebpackPlugin({
name: 'Contoso'
mode: 'file',
theme: './typedoc-theme/',
includeDeclarations: false,
ignoreCompilerErrors: true,
})
]
Comments