-
Notifications
You must be signed in to change notification settings - Fork 151
How to document a CommonJS module (exports)
Lloyd Brookes edited this page Oct 13, 2016
·
3 revisions
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
- Home
- How jsdoc2md works
- Additional jsdoc tags supported
- Cherry picking which documentation appears in output
- Showcase ...
- Create ...
- How To ...
- How to use with npm run
- How to use with gulp
- How to create one output file per class
- How to document a AMD module
- How to document a CommonJS module (exports)
- How to document a CommonJS module (module.exports)
- How to document an ES2015 module (multiple named exports)
- How to document an ES2015 module (single default export)
- How to document Promises (using custom tags)
- How to document a ToDo list
- How to document ES2017 features
- How to document TypeScript
- The @typicalname tag
- Linking to external resources
- Param list format options
- Listing namepaths
- Troubleshooting