How to document a CommonJS module (exports) - jsdoc2md/jsdoc-to-markdown GitHub Wiki
1. Say your module exports variable, class or function identifiers:
/**
* @module example
*/
/**
* @type {number}
*/
var one = 1
/**
* A method
*/
function two () {}
exports.one = one
exports.two = two
2. As the two inner declarations have documentation, they are shown in the output (not the exports
expressions, as they are not documented):
Kind: inner property of example
A method
Kind: inner method of example
3. To correctly represent those inner declarations as the exported values, we need to set @alias
tags:
/**
* @module example
*/
/**
* @type {number}
* @alias module:example.one
*/
var one = 1
/**
* @type {number}
* @alias module:example.two
*/
var two = 2
exports.one = one
exports.two = two
4. Using the @static
tag has the exact same effect, and looks cleaner:
/**
* @module example
*/
/**
* @type {number}
* @static
*/
var one = 1
/**
* @type {number}
* @static
*/
var two = 2
exports.one = one
exports.two = two
5. Now the output looks more realistic:
Kind: static property of example
Kind: static property of example