Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grouping Functions In JSDoc Generated Documentation

I'm using documentationjs (which uses jsdoc under the hood) to handle the generation of docs for a lib I'm working on. My lib is written is ES6 and is fully functional, and at present the documentation generated is an alphabetical list of all the functions from all the modules in the lib. This makes it very hard to find what you are looking for. How should I use jsdoc comments so that functions from one file are grouped together in the documentation?

For example, given the following file …

/**
 * Docs for alpha
 */
export const alpha = () {};

/**
 * Docs for beta
 */
export const beta = ()  {};

/**
 * Docs for charlie
 */
export const charlie = () {};

… how should I use jsdoc comments to ensure the three functions are grouped together under 'Example' in the documentation?

I have tried defining a module at the top of the class: /** @module Example */ but although this generates an item called 'Example' in the docs, the functions are not grouped underneath it.

I have tried adding @memberof Example to the documentation of the individual functions, but this has no effect.

I am aware of this question, but it doesn't work for me, possibly because of the ES6 imports. There is no mention of its use with @module in the docs.

like image 260
Undistraction Avatar asked Sep 27 '17 17:09

Undistraction


1 Answers

It appears that documentationjs doesn't support JSDoc style grouping in its generated docs, however, it is possible to group functions using a slightly different syntax. I discovered this through trial and error due to documentationjs's (ironically) poor documentation:

/** @module Example **/

/**
 * @memberof Example
 */
const alpha = () => {};

Note: there is no module: prefix for the @member argument.

like image 54
Undistraction Avatar answered Sep 22 '22 22:09

Undistraction