Design Framework JavaScript documentation
- We use JSDoc for our JavaScript documentation.
- These pages are generated manually by running
npm run jsdoc
from the root of the repo.
JSDoc syntax for the revealing module pattern
It took a while to work out how to get JSDoc to work with the revealing module pattern.
Eventually, this post came to the rescue.
Each module needs to be described as a namespace:
/**
* Multiple action button component.
* @namespace multiactionButtons
* @memberof UCASDesignFramework
*/
Then each public function or property needs to be attached to that namespace, using @memberof!
/**
* Initialise plugin.
* @function init
* @memberof! UCASDesignFramework.multiactionButtons
* @public
* @param {Node} [context=document] - DOM element we're limiting selection to
* @param {string} [selector='[data-multiaction-button]'] - CSS selector
*/
Private functions, which won't appear in the documentation, don't need all of this: just add a description and document the parameters and returns.
Other things that can be documented include events and classes.