documentation icon indicating copy to clipboard operation
documentation copied to clipboard

CommonJS exporting a hash of functions not working

Open Eschon opened this issue 6 years ago • 2 comments

I have a few js files that group together some utility functions that are structured like this example:

/** @module calculator */

/**
 * Adds two numbers
 * @param {number} a - The first number
 * @param {number} b - The second number
 * @returns {number} - The addition result
 */
function add(a, b) {
  return a + b;
}

module.exports = {
  add,
};

Running the documentaionjs 8.1.2 cli on this gives me an empty module calculator and the function add. Since I export add as part of the module I would expect it to be documented as part of it.

Eschon avatar Sep 05 '18 11:09 Eschon

We don't really support the @module tag at this point, because it doesn't have a clear meaning; JavaScript has npm modules, and it has ES6 modules, and the JSDoc concept of 'modules' doesn't map to either. As far as I can tell, it's a remnant of a pre-module JavaScript ecosystem, and there isn't any strong reason to add support. That said, documentation.js should probably emit a warning or something for similarly unsupported tags.

tmcw avatar Oct 21 '18 20:10 tmcw

Try adding a @memberof calculator tag to the add function. I believe this is how we group our module items together.

MichelSimonot avatar Jan 03 '19 13:01 MichelSimonot