Skip to content
Matt Flaschen edited this page May 6, 2014 · 3 revisions

Synopsis:

@constructor
Documentation for constructor.

Allows documenting the constructor within class documentation.

This tag is provided for backwards compatibility with old ext-doc. Don't use it for new code. Instead document a method named constructor (see below).

Example:

/**
 * @class Ext.Panel
 * The one-and-only panel class.
 *
 * @constructor
 * Creates a new Panel instance.
 * @param {Object} [config] Configuration.
 */

JSDuck will treat everything following @constructor as being part of a constructor method. The above is equivalent of documenting a method named constructor inside the class:

/**
 * The one-and-only panel class.
 */
Ext.define("Ext.Panel", {
    /**
     * Creates a new Panel instance.
     * @param {Object} [config] Configuration.
     */
    constructor: function() {
    }
});

This is the recommended way of documenting the constructor.

If you are using standard constructor functions, rather than Ext.define, you can do this with @method constructor. For example:

/**
 * @class myNamespace.Person
 *
 * @private
 *
 * A person
 */

/**
 * @method constructor
 *
 * @private
 *
 * This uses `foo` to construct a Person.
 */
function Person ( foo ) {
  // Constructor code
}
Clone this wiki locally