docgen helps you to generate the public API of your code. Given an entry point file, it outputs the ES6 export statements and their corresponding JSDoc comments in human-readable format.
Some characteristics:
- If the export statement doesn't contain any JSDoc, it'll look up for JSDoc up to the declaration.
- It can resolve relative dependencies, either files or directories. For example,
import default from './dependency'will finddependency.jsordependency/index.js
node src/cli.js <entry-point.js>
This command will generate a file named entry-point-api.md containing all the exports and its JSDoc comments.
Entry point:
/**
* Adds two numbers.
*/
export default function addition( term1, term2 ) {
// Implementation would go here.
}Output:
# API
## default
Adds two numbers.Entry point:
/**
* Adds two numbers.
*/
function addition( term1, term2 ) {
// Implementation would go here.
}
export { count };Output:
# API
## count
Adds two numbers.Let count/index.js be:
/**
* Substracts two numbers.
*/
export function substraction( term1, term2 ) {
// Implementation would go here.
}
/**
* Adds two numbers.
*/
export function addition( term1, term2 ) {
// Implementation would go here.
}And the entry point:
export * from './count';Output would be:
# API
## addition
Adds two numbers.
## substraction
Substracts two numbers.