To document instance members, use @name Class#member
:
/**
* Construct a new component
*
* @class Component
* @classdesc A generic component
*
* @param {Object} options - Options to initialize the component with
* @param {String} options.name - This component's name, sets {@link Component#name}
* @param {Boolean} options.visible - Whether this component is visible, sets {@link Component#visible}
*/
function Component(options) {
/**
* Whether this component is visible or not
*
* @name Component#visible
* @type Boolean
* @default false
*/
this.visible = options.visible;
/**
* This component's name
*
* @name Component#name
* @type String
* @default "Component"
* @readonly
*/
Object.defineProperty(this, 'name', {
value: options.name || 'Component',
writable: false
});
}
This results in a Members section in the documentation that lists each member, its type, default value, and whether it’s read only.
The output as generated by jsdoc@3.3.0-alpha3 looks like this:
See also:
- JSDoc namepaths
@instance
tag@readonly
tag@type
tag