Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to document an array of objects in JSDOC

I have a function with an array of objects as parameter and would like to describe the parameter (including the properties of the objects in the array) using JSDOC like in this example:

/**
 * @param {Array.<Object>} filter - array of filter objects
 * @param ...
 */
function doSomething(filter) {
}

where filter is something like this:

filter = [
   {id: 'session', value: 1},
   {id: 'name', value: 'john'}
]

How would I document the properties id and value in jsdoc3 ?

like image 994
doberkofler Avatar asked Aug 30 '15 09:08

doberkofler


1 Answers

like this:

/**
 * @param {Object[]} filter - a list of literal filter objects
 * @param {string} filter[].id -  id to filter against...
 * @param {string|number} filter[].value - value to filter for...
 */
function doSomething(filter) {
    // do stuff
}

taken from http://usejsdoc.org/tags-param.html

like image 68
stolli Avatar answered Nov 06 '22 07:11

stolli