JsDoc for Arrays, how to do it?

2,110 views
Skip to first unread message

Chris Wilson

unread,
Apr 25, 2013, 2:58:53 AM4/25/13
to Google Closure Discuss
Hi all,

I'm trying to annotate a method that takes an array of strings and an
array of objects as its parameters.

Following the Annotating JavaScript document, I tried this:
[https://developers.google.com/closure/compiler/docs/js-for-compiler]

* @param {Array<string>} columns The names of the columns in this
* data source.
* @param {Array<Object>} data The initial contents of the data
* source, which can be an empty array. Rows can be added using

But JsDoc doesn't like this at all, and it nests my Method Detail under my
class's Parameters section, in fixed font, which looks horrible.

The JsDoc wiki seems to think we should use array syntax instead,
something like this:
[https://code.google.com/p/jsdoc-toolkit/wiki/TagParam#Parameter_Type_Information]

* @param {String[]} columns The names of the columns in this
* data source.
* @param {Object[]} data The initial contents of the data
* source, which can be an empty array. Rows can be added using

But since this isn't documented as supported by Closure Compiler, does it
work and will it be supported in future? And what's the proper way to do
this that's supported by both Closure and JsDoc?

Cheers, Chris.
--
_____ __ _
\ __/ / ,__(_)_ | Chris Wilson <chri...@qwirx.com> Cambs UK |
/ (_/ ,\/ _/ /_ \ | Security/C/C++/Java/Ruby/Perl/SQL Developer |
\__/_/_/_//_/___/ | We are GNU : free your mind & your software |

Ilia Mirkin

unread,
Apr 25, 2013, 3:30:29 AM4/25/13
to closure-lib...@googlegroups.com
Array.<string>
> --
>
> --- You received this message because you are subscribed to the Google
> Groups "Closure Library Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to closure-library-d...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Chris Wilson

unread,
Apr 25, 2013, 3:59:18 AM4/25/13
to closure-lib...@googlegroups.com
Hi Ilia,

On Thu, 25 Apr 2013, Ilia Mirkin wrote:

> Array.<string>

Sorry, I made a typo, that is what I tried and what JsDoc doesn't like. So
it's out for me unless I can fix jsdoc.

Tom Payne

unread,
Apr 25, 2013, 4:29:31 AM4/25/13
to closure-lib...@googlegroups.com
jsdoc3 is somewhat less broken than jsdoc for parsing Closure-style
type annotations:
https://github.com/jsdoc3/jsdoc

This project is an effort to parse type annotations correctly:
http://orgachem.github.io/jsdoctypeparser/

It would be nice to see it integrated into jsdoc3.

Regards,
Tom
Reply all
Reply to author
Forward
0 new messages