documentation
documentation copied to clipboard
CommonJS exporting a hash of functions not working
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.
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.
Try adding a @memberof calculator
tag to the add
function. I believe this is how we group our module items together.