-
Notifications
You must be signed in to change notification settings - Fork 151
How to document an AMD module
Lorin Halpert edited this page Nov 26, 2021
·
1 revision
1. Say you have an AMD module you'd like to document.
define(function () {
function add (a, b) {
return a + b
}
return add
})
2. Given that jsdoc2md only generates markdown for documented identifiers and modules, you must document each identifier you want to appear in output - including the module. Therefore, you must use @module
at the top of file to document the module.
/**
* A module for adding two values.
* @module add-two-values
*/
define(function () {
/**
* Add two values.
*/
function add (a, b) {
return a + b
}
return add
})
3. Still, the add
function above will not appear in output as jsdoc3 neither documents IIFE internals nor understands it's the exported value. So, we explicitly declare it as the exported value by marking it as an @alias
of the module:
/**
* A module for adding two values.
* @module add-two-values
*/
define(function () {
/**
* Add two values.
* @alias module:add-two-values
*/
function add (a, b) {
return a + b
}
return add
})
4. This file will now appear in jsdoc2md output. Without the @module
tag it will not appear.
- 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