-
Notifications
You must be signed in to change notification settings - Fork 240
@accessor
(Updated for JSDuck 4)
Synopsis:
@accessor
Generates documentation for getters and setters of a config option.
Ext4 generates get/set accessor methods for the configs defined inside config: {}
block. JSDuck 4 recognizes this automatically, so most of the time you don't need to add this tag:
Ext.define("MyClass", {
config: {
/**
* @cfg {Ext.data.Store} store (required)
* The store to use for this view.
*/
store: undefined
}
});
JSDuck will then generate documentation for the getters and setters as if you had documented the following methods:
/**
* @method setStore
* Sets the value of {@link #store}.
* @param {Ext.data.Store} store
*/
/**
* @method getStore
* Returns the value of {@link #store}.
* @return {Ext.data.Store}
*/
With JSDuck 3 you needed to add @accessor
to all configs inside config: {}
. But there are cases where even JSDuck 4 can't auto-detect and you need to use @accessor
manually:
Ext.define("MyClass", function() {
return {
config: {
/**
* @cfg {Ext.data.Store} store (required)
* The store to use for this view.
* @accessor
*/
store: undefined
}
};
});
Additionally the config options may be defined inside eventedConfig:
block. Again, JSDuck 4 auto-detects this in the common case:
Ext.define("MyClass", {
eventedConfig: {
/**
* @cfg {Ext.data.Store} store (required)
* The store to use for this view.
*/
store: undefined
}
});
This will result in documentation for event <cfg-name>change
to be created. In the above case it's as if you had also documented the following event:
/**
* @event storechange
* Fires when the {@link #store} configuration is changed by {@link #setStore}.
* @param {MyClass} this The MyClass instance.
* @param {Ext.data.Store} value The new value being set.
* @param {Ext.data.Store} oldValue The existing value.
*/
In JSDuck 3 and when JSDuck 4 auto-detection doesn't work such case you also need to document that explicitly using both @accessor
and @evented tag: