1

I Cant' find it in the doc.

What I would prefer is having the type showing [{id: String, label: String}] in the generated doc, and experimentation lead me to think that the only thing I can do is specify a single alphanumeric-only String without any other character (they are ignored by the generator).

Is there really no way to do it ?

Samuel Rossille
  • 18,940
  • 18
  • 62
  • 90

2 Answers2

0

Just create a @class specifying that information (two attributes id and label) and use that class!

cancerbero
  • 6,799
  • 1
  • 32
  • 24
0

There's two solutions:

1) Create an actual named class, and use @class and @param tags to document it. Because your literal object, {id: String, label: String} is basically an inline/anonymous class. So make it non-anonymous, actually give it a name. And then you can specify that your parameter is an array of that class. Like so:


/**
 * @class MyLabel
 * @constructor
 * @param id {String}
 * @param label {String}
 */
function MyLabel(id, label) {
  this.id = id;
  this.label = label;
}

/* ... and then document your method, with the array of those objects, using: */

/**
 * @method myMethod
 * @param labels {MyLabel[]} Array of labels.
 */

So that's option 1, and requires some refactoring of your code. But, don't be afraid to name and define and document your classes, only good things can come of it.

2) The other option is that you can take a page from JSDocs, and use the pseudo-parameters syntax:


/**
 * @method myMethod
 * @param labels {Object[]} An array of label objects
 * @param labels[].id {String} Id
 * @param labels[].label {String} Label  
 */

I'm pretty sure this would render correctly in YUIdoc as well.

Dmitri Zagidulin
  • 1,117
  • 9
  • 23