Related: Correct way to document open-ended argument functions in JSDoc
I've a function that accepts multiple arrays by accessing the arguments
variable:
/**
* @param options An object containing options
* @param [options.bind] blablabla (optional)
*/
function modify_function (options) {
for (var i=1; i<arguments.length; i++) {
// ...
}
}
Now, I know that each argument besides options
is an array containing values that are worth documenting:
[search_term, replacement, options]
I'm not considering putting the (lengthy) description in the variable parameter line.
@param {...} An array with search terms, replacements and its options; index 0: the search term within the function; 1: the replacement text; 2: optional options (catch_errors: catches errors and log it, escape: escape dollars in the replacement text, pos: "L" for placing the replacement before the search term, "R" for placing it after) Not a readable solution and the type is not visible.
Is there a way to document the types and values of a variable parameter?
@param {...[]} An array with search terms, replacements and its options
@param {...[0]} The search term within the function
@param {...[1]} The replacement text
@param {...[2]} An optional object with obtions for the replacement
@param {...[2].catch_errors} catches errors and log it
@param {...[2].escape} etc...
The above looks ugly, but it should give you an idea of what I'm trying to achieve:
- document the type of a variable parameter (in this case an Array)
- document the values of this array
- document the properties of an object inside this array
For laziness, I've used an array instead of a object. Other suggestions are always welcome.