Search code examples
javascriptjsdoc

Document constructor with multiple signatures


I'd like to know how can I define two signatures for the constructor with jsdoc:

makeClass("Person",
/** @lends Person */
{
    /**
        @constructs
        @param {int} p1
    */
    /**
        @constructs
        @param {string} p1
    */
    constructor: function () {

    },

    /**
        @name Person.prototype.func
        @function
        @param {object} arg arg desc
    */
    /**
        @name Person.prototype.func^2
        @function
        @param {int} arg arg desc
        @param {int} arg2 arg2 desc
    */
    func: function () {

    }
});

This produces one constructor with {string} p1.

Thanks for your help


Solution

  • JSDoc doesn't have a concept comparable to the Visual Studio XML Doc multiple signatures. One option would be to document parameters as having multiple possible types, and marking some optional.

    /**
     * @param {Number|Object} arg Description of arg
     * @param {Number} [arg2] Description of arg2
     */