JSDoc Toolkit - How to specify @param and @property on the same line

Is there a way to avoid the need to type two separate lines for @property and @param, if, as in the example, the parameters and properties are identically named on the constructor.

/** * Class for representing a point in 2D space. * @property {number} x The x coordinate of this point. * @property {number} y The y coordinate of this point. * @constructor * @param {number} x The x coordinate of this point. * @param {number} y The y coordinate of this point. * @return {Point} A new Point */ Point = function (x, y) { this.x = x; this.y = y; } 
+8
javascript documentation documentation-generation jsdoc
source share
1 answer

Not. This is impossible, because the arguments of the function and the properties of the object are different variables, they cannot be both functional parameters and properties of the object. Moreover, such documentation would only confuse the developer, but would not help to understand the API.

I would advise you not to use @properties in this part of the documentation, but use @type:

 /** * Class for representing a point in 2D space. * @constructor * @param {number} x The x coordinate of this point. * @param {number} y The y coordinate of this point. * @return {Point} A new Point */ Point = function (x, y) { /** * The x coordinate. * @type number */ this.x = x; /** * The y coordinate. * @type number */ this.y = y; } 

But in fact, such detailed documentation is useless. What we say in the code Point.x = x is clear to any student.

+3
source share

All Articles