JSDoc inherit params plugin
Inherit parameters documentation from any class or function with JSDoc.
Install
With yarn:
yarn add jsdoc-inheritparams-plugin --dev
With npm:
npm install jsdoc-inheritparams-plugin --save-dev
Add the plugin to your JSDoc config:
Usage
All these examples work with any kind of function (constructor, member's function, global function).
Consider the following User
class:
/** * Represents a user. * @class User * @param * @param */ { thisfirstname = firstname thislastname = lastname }
Inherit parameters
@inheritparams
automatically determines super class from@extends
.
/** * Represents an admin user. * @class AdminUser * @extends User * @inheritparams */ { super...args thisadmin = true }
Specify super class or function
You can give an explicit super class of function to inherit parameters from.
The given class or function can be any valid JSDoc path.
/** * Represents an admin user. * @class AdminUser * @extends User * @inheritparams User */ { super...args thisadmin = true }
Add extra parameters:
/** * Represents an admin user. * @class AdminUser * @extends User * @inheritparams * @param * @param * @param */ { superfirstname lastname thisadmin = true thisusername = username thisemail = email thispassword = password }
Specify inherited parameters offset
Prefix the offset with a colon:
@inheritparams :4
.
Super class or function path can be specified before offset:@inheritparams CustomClass:4
.
The default offset is0
so inherited parameters are inserted before extra parameters (see previous example).
The offset can be negative so it start from the end of extra parameters.
/** * Represents an admin user. * @class AdminUser * @extends User * @inheritparams :1 * @param * @param * @param */ { // ... }
/** * Represents an admin user. * @class AdminUser * @extends User * @inheritparams :2 * @param * @param * @param */ { // ... }
/** * Represents an admin user. * @class AdminUser * @extends User * @inheritparams :3 * @param * @param * @param */ { // ... }
/** * Represents an admin user. * @class AdminUser * @extends User * @inheritparams :-1 * @param * @param * @param */ { // ... }
/** * Represents an admin user. * @class AdminUser * @extends User * @inheritparams :-2 * @param * @param * @param */ { // ... }