Reputation: 7337
In dynamic languages like JavaScript or PHP it is common practise to pass only one argument to the function. This argument is an object which encapsulate all options. What is the best way of documenting these options with ScriptDoc (or similar)?
Upvotes: 3
Views: 148
Reputation: 15042
Using JSDoc it can be done as follows:
/**
* @param {Object} o Object containing function params.
* @param {String} o.bar Example String param.
* @param {Number} o.baz Example Number param.
*/
function foo(o) {
}
More information can be found in the Parameters with Properties section of JSDoc's TagParam documentation.
Upvotes: 3