How to document an array of objects in JSDOC

孤者浪人 提交于 2020-12-29 05:15:42

问题


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 ?


回答1:


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



来源:https://stackoverflow.com/questions/32295263/how-to-document-an-array-of-objects-in-jsdoc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!