Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

docgen

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 find dependency.js or dependency/index.js

Usage

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.

Examples

Default export

Entry point:

/**
 * Adds two numbers.
 */
export default function addition( term1, term2 ) {
	// Implementation would go here.
}

Output:

# API

## default

Adds two numbers.

Named export

Entry point:

/**
 * Adds two numbers.
 */
function addition( term1, term2 ) {
	// Implementation would go here.
}

export { count };

Output:

# API

## count

Adds two numbers.

Namespace export

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.