Skip to content
nene edited this page Mar 19, 2012 · 27 revisions

Synopsis:

@class [<name>]

Documents the name of the class; or leaves the name for auto-detection and forces the documented entity to be treated as class.

Example:

/**
 * @class Ext.Component
 * @extends Ext.AbstractComponent
 * Base class for all Ext components.
 */

Auto-detection

This tag is auto-detected when class comment is right above Ext.define. The following code is equivalent of the above one:

/**
 * Provides searching of Components.
 */
Ext.define("Ext.Component", {
    extend: "Ext.AbstractComponent",
    ...
});

Note: When no extend: or @extends used with Ext.define, the parent class will default to Ext.Base. When not using Ext.define the parent class will default to Object.

Auto-detection of Ext3 style class definition with Ext.extend is also supported:

/**
 * Provides searching of Components.
 */
Ext.Component = Ext.extend(Ext.AbstractComponent, {
    ...
});

Finally a class will be detected when doc-comment is before a variable looking like a class name. This code is again equivalent to the above ones:

/**
 * A simple class.
 * @extends Ext.AbstractComponent
 */
Ext.Component = function() {
};

Function declaration works too. Here a Component class extending Object will be detected:

/**
 * A simple class.
 */
function Component() {
}

But when the last part of the name begins with a lowercase letter, class auto-detection fails:

/**
 * I meant this to be a class, but JSDuck thinks it's not.
 */
Ext.supports = {};

In such case use the @class tags to force JSDuck treat it as class:

/**
 * @class
 * I'm a class now.
 */
Ext.supports = {};

@constructor tag inside class

This use is deprecated. See @constructor for details.

@cfg tags inside class

For backwards compatibility with old ext-doc the class documentation may contain @cfg tags:

/**
 * @class Ext.Panel
 * The one-and-only panel class.
 *
 * @cfg {Boolean} hidden
 * True if panel should be hidden at first.
 * @cfg {String} title
 * Text to use as the title of the panel.
 */

Instead of doing this, JSDuck recommends you document each configuration option separately:

/**
 * @class Ext.Panel
 * The one-and-only panel class.
 */

    /**
     * @cfg {Boolean} hidden
     * True if panel should be hidden at first.
     */
    /**
     * @cfg {String} title
     * Text to use as the title of the panel.
     */

The code is a bit longer, but it's now consistent with how other members are documented, plus it allows using additional tags like @private on each config option separately.

Clone this wiki locally