senchalabs / jsduck

Simple JavaScript Duckumentation generator.
http://docs.sencha.com/
GNU General Public License v3.0
1.5k stars 238 forks source link

Callback parameters for multiple types #643

Open rivo opened 8 years ago

rivo commented 8 years ago

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.

nene commented 8 years ago

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.

rivo commented 8 years ago

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

nene commented 8 years ago

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

rivo commented 8 years ago

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. ;-)