8

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.

Undistraction
  • 38,727
  • 46
  • 165
  • 296

3 Answers3

4

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.

Undistraction
  • 38,727
  • 46
  • 165
  • 296
1

Perhaps you can try this workaround for now, until jsdoc implements grouping.

How to display Javascript methods in a 'group' in JSDOC?

Felipe Valdes
  • 1,705
  • 10
  • 22
-1

I think you need to use @module in this way:

/** @module myModule */

/** will be module:myModule~foo */
var foo = 1;

/** will be module:myModule.bar */
var bar = function() {};

As described here.

Mohamed Chaawa
  • 888
  • 1
  • 9
  • 20