JSDoc
Documenting you code with labels
Installing
Install with the following command:
npm i jsdoc --save-dev
Configuration
In order for JSDoc to scan the required file types, we need a jsdoc config file.
JSDoc config
Create a jsdoc.conf.json file in the root of your project, then populate it with the following:
{
"source": {
"include": ["src"],
"includePattern": ".+\\.(m?js(doc|x)?|cjs|ts)$",
"excludePattern": "(^|\\/|\\\\)_"
},
"plugins": [],
"opts": {
"encoding": "utf8",
"destination": "./docs",
"recurse": true,
"verbose": true
}
}
Package script
Edit your package.json file and add the following to the scripts section:
"doc": "cls && node ./node_modules/jsdoc/jsdoc.js -c ./jsdoc.conf.json"
You can now create JSDocs with npm run doc
Git ignore
Edit your .gitignore file and add a line to ignore dynamically created doco.
/docs
Creating documentation
Create documentation by running the following command:
npm run doc
This will create a /docs folder with html documentation.