Search code examples
javascriptdocumentationyuidoc

How to document an "object" parameter of a method


I'm trying to write some documentation for a JavaScript method using YUIDoc. It looks like:

/** 
    Returns an instance of className

    @method getInstance
    @param {string} className the of the class used to create the instance
    @param {Object} options these are options used to create the instance
**/
function getInstance(className, options) { ..... }

Now, the options object can have several parameters, like options.id, options.single, etc.

How do I add this information to the documentation of this @param?


Solution

  • From reference: http://yui.github.com/yuidoc/syntax/index.html

    "As shown in the example, you can also nest @param tags. This enables you to document object parameters that have their own particular nested structure."

    @param {Object} [options] Data 
      to be mixed into the event 
      facade of the `change` 
      event(s) for these attributes.
      @param {Boolean} [options.silent]
        If `true`, no `change` event 
        will be fired.