Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSDoc inheriting parameter documentation

Tags:

jsdoc

Let's say I have two functions, where one extends the other.

/**
* @abstract
* @param {Object} settings
* @param {Number} settings.x
* @param {Number} settings.y
* 
*/
function Base(settings) {
    this.x = settings.x;
    this.y = settings.y;
}

/**
* @extends Base
*/
function Foo(settings) {
    Base.call(this, settings);    
}

These two functions are in two separate files. Is there any way I can inherit the parameter documentation from the Base function in my Foo function, or do I have to write the documentation twice?

I have tried making settings a @typedef like this:

/**
 * @typedef {Object} BaseSettings
 * @property {Number} x
 * @property {Number} y
 *
 */

/**
* @extends Base
* @param {BaseSettings} settings
*/
function Foo(settings) {
    Base.call(this, settings);    
}

But this just links to a global Type Definitions, and I want the parameter documented on the same page as the function. But is this even possible, without writing the documentation twice?

like image 589
LongInt Avatar asked Apr 08 '15 17:04

LongInt


1 Answers

I don't think this can be done. You can document it via @typedef as in your question but it will just link the type to its definition. I'm not aware of a way of inlining a defined type.

like image 89
SGD Avatar answered Oct 12 '22 12:10

SGD