documentation
documentation copied to clipboard
ES6 class constructor doesn't support destructured function parameters
Information
- Node.js version: 12.14.1
- npm version: 6.11.3
- Documentation.js version: 12.1.4
- Method of running:
- Node.js / npm
- Installed documentation.js globally using
npm install -g documentation - Running
documentation build test.js -f md > test.md
- Expected behavior
- Parameters block for class constructor should use
animalsinstead of$0and maintain documentation forfishesparameters
- Parameters block for class constructor should use
Input code (test.js)
/** test class */
export class Test {
/**
* This method has hierarchical params
* @param {Object} animals different kinds of animals
* @param {String} animals.fishes number of kinds of fish
*/
constructor({ fishes, foxes }) {
return fishes + foxes;
}
/**
* This method has hierarchical params
* @param {Object} animals different kinds of animals
* @param {String} animals.fishes number of kinds of fish
*/
method1({ fishes, foxes }) {
return fishes + foxes;
}
}
Output documentation (test.md)
Table of Contents
- Test
- Parameters
- method1
- Parameters
Test
test class
Parameters
method1
This method has hierarchical params
Parameters
Not sure whether it is a proper solution or not, but if you move the description of the constructor to the description of the class, it will work:
/** test class
* @param {Object} animals different kinds of animals
* @param {String} animals.fishes number of kinds of fish
*/
module.exports = class Test {
constructor({ fishes, foxes }) {
this.fishes = fishes;
this.foxes = foxes;
}
/**
* This method has hierarchical params
* @param {Object} animals different kinds of animals
* @param {String} animals.fishes number of kinds of fish
*/
method1({ fishes, foxes }) {
return fishes + foxes;
}
};
Demo:
Test
test class
Parameters
method1
This method has hierarchical params