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 = {};
Clone this wiki locally