Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

/**
 * 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;
}
like image 636
justtryingtomakealiving Avatar asked Jun 25 '11 07:06

justtryingtomakealiving


1 Answers

You do not. It is impossible, because the arguments of the function and properties of an object - these are different variables, they can not be both function parameters and object properties. Moreover, such documentation would only confuse the developer, but does not help to understand the API.

I would advise you not to use the @properties in this piece of 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 are we talking in code Point.x = x is clear to any schoolchild.

like image 96
Microfed Avatar answered Oct 08 '22 00:10

Microfed