jsduck icon indicating copy to clipboard operation
jsduck copied to clipboard

Callback parameters for multiple types

Open rivo opened this issue 9 years ago • 4 comments

I often have a situation where two types are allowed for a parameter or config. If one of them is a function, I would like to be able to specify the function's signature but that currently does not work. Here's an example:

/**
 * @cfg {number/Function} myCfg This can be either a number or a function.
 * When I specify the signature of the function, however, the result is not
 * as I expect.
 * @cfg {string} myCfg.in Some input string.
 * @cfg {string} myCfg.return Some return value.
 */

This turns into:

image

It works ok if the accepted type for this config is just {Function} but not if multiple types are allowed like {number/Function}. Is there a way to have jsduck recognize that what follows is the function's signature?

I understand that there may be an ambiguity if one specifies {Object/Function} but in that case, I would be ok with a fixed preference, e.g. additional subparameters would be interpreted as object fields.

rivo avatar Mar 16 '16 20:03 rivo

Yeah, it would make sense to detect if the type contains "Function" instead of checking that it strictly equals to "Function".

But truth to be told, the development of JSDuck has kinda stagnated. No idea when this might be implemented.

Thanks for suggestion.

nene avatar Mar 17 '16 07:03 nene

Out of curiosity, what's the reason for that stagnation?

rivo avatar Mar 17 '16 10:03 rivo

That's just me not being really motivated to develop it as I'm not developing with Sencha stack any more.

nene avatar Mar 17 '16 11:03 nene

Ok, I understand. Actually, I'm not using it for a Sencha project. I like that JSDuck is so flexible that it will adapt to my own style and code organization while still generating very precise documentation.

I would probably contribute but I'm not very familiar with the stack (and I kind of skipped ruby) so there's a bit of a learning curve.

Anyway, it still works for now. It would be great if it could at least remain on life support. ;-)

rivo avatar Mar 17 '16 18:03 rivo