jsduck icon indicating copy to clipboard operation
jsduck copied to clipboard

@cfg and @property cannot coexist

Open matsbryntse opened this issue 11 years ago • 4 comments

I'd like to have a config available also as a property. Seems duck doesn't allow, duck should! :)

/**
 * @cfg {String} viewPreset
 * @property {String} viewPreset
 * A key used to lookup a predefined {@link Sch.preset.ViewPreset} (e.g. 'weekAndDay', 'hourAndDay'), managed by {@link Sch.preset.Manager}. See {@link Sch.preset.Manager} for more information.
 */
viewPreset: 'weekAndDay',

matsbryntse avatar Sep 04 '13 12:09 matsbryntse

Indeed, having a property with the same name as a config is a perfectly valid case.

canonic-epicure avatar Sep 04 '13 12:09 canonic-epicure

Yep. Agree. That's indeed a pretty common case. I'm considering something like:

/**
 * @cfgProperty {String} viewPreset
 * A key used to lookup a predefined {@link Sch.preset.ViewPreset} (e.g. 'weekAndDay', 'hourAndDay'), managed by {@link Sch.preset.Manager}. See {@link Sch.preset.Manager} for more information.
 */
viewPreset: 'weekAndDay',

nene avatar Sep 06 '13 08:09 nene

+1

Though slightly more verbose, I'd prefer Mats approach of keeping @cfg and @property logically separated, but within the same comment block. I use JSDuck more for node than I do Ext these days, and there are times when the cfg type is different from the property - think getters/setters. For example, the cfg may be set as a string, but a get may return an array. That said, a cfgProperty would be nice when they're always the same type.

coreybutler avatar Sep 22 '13 00:09 coreybutler

Hmm... I don't really like the @cfgProperty very much - although I proposed it by myself - as it would be yet another tag, and there are already quite a lot of them.

So, maybe @cfg and @property inside the same doc-comment wouldn't be so bad after all. However I still would like to avoid the duplication, and write the name and type just once:

/**
 * @cfg {String} viewPreset
 * @property
 * A key used to lookup...
 */
viewPreset: 'weekAndDay',

Or actually in this concrete case, they both should be auto-detected:

/**
 * @cfg
 * @property
 * A key used to lookup...
 */
viewPreset: 'weekAndDay',

nene avatar Sep 22 '13 16:09 nene