Andy Hin Andy Hin - 1 year ago 89
Javascript Question

How to describe "object" arguments in jsdoc?

// My function does X and Y.
// @params {object} parameters An object containing the parameters
// @params {function} callback The callback function
function(parameters, callback) {

But how do I describe how the parameters object should be structured? For example it should be something like:

setting1 : 123, // (required, integer)
setting2 : 'asdf' // (optional, string)

Answer Source

From the @param wiki page:

Parameters With Properties

If a parameter is expected to have a particular property, you can document that immediately after the @param tag for that parameter, like so:

  * @param userInfo Information about the user.
  * @param The name of the user.
  * @param The email of the user.
 function logIn(userInfo) {

There used to be a @config tag which immediately followed the corresponding @param, but it appears to have been deprecated (example here).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download