How to document a function/method with unknown number & type of optional params?

36 views
Skip to first unread message

Bnaya Peretz

unread,
Jun 12, 2013, 9:20:22 AM6/12/13
to jsdoc...@googlegroups.com
For methods like backbone trigger http://backbonejs.org/#Events-trigger
Its there a structured way of doing that or a common convention ?
I can't find any refrance in http://usejsdoc.org/tags-param.html

Thanks!

Bnaya Peretz

unread,
Jun 12, 2013, 9:23:24 AM6/12/13
to jsdoc...@googlegroups.com
My bad, its looks like there is the Variable parameter
{...type}

Bnaya Peretz

unread,
Jun 12, 2013, 9:32:44 AM6/12/13
to jsdoc...@googlegroups.com
Its looks like i can't declare it as optional or/and multiple typeable.

I'm getting parse errors with all the combinations i was able to think about

exception from uncaught JavaScript throw: Error: cannot create a doclet for the comment "/**         * lalal         * @param  {String} topic The name of the notification to notify         * @param  {...[Number]} args Arguments to send the notification handlers         */": unable to parse the type expression "...[Number]": Expected "$", "*", "?", "\\", "_", "null", "undefined", Unicode letter number, Unicode lowercase letter, Unicode modifier letter, Unicode other letter, Unicode titlecase letter or Unicode uppercase letter but "[" found.

Jeff Williams

unread,
Jun 12, 2013, 11:52:03 AM6/12/13
to Bnaya Peretz, jsdoc...@googlegroups.com
Hi Bnaya,

I haven't tested this, but I think {...Number=} will give you what you're looking for.

It'd be nice if {...[Number]} worked as well, though, so I'll file a ticket for that.

- Jeff

--
You received this message because you are subscribed to the Google Groups "JSDoc Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsdoc-users...@googlegroups.com.
To post to this group, send email to jsdoc...@googlegroups.com.
Visit this group at http://groups.google.com/group/jsdoc-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bnaya Peretz

unread,
Jun 14, 2013, 10:59:56 PM6/14/13
to jsdoc...@googlegroups.com, Bnaya Peretz
Great, thanks!
Reply all
Reply to author
Forward
0 new messages