0

callback.rows is array of arbitrary length with a number of repeating fields.

How can I document each field (type, property, description) in JSDoc?

Is there possible to apply this method?

Or may be this solution can be accepted:

/**
* Get list of all documents
* @param {Function} callback                      Standard callback function
* @param {Error}    callback.err                  Error object if any
* @param {Array}    callback.rows                 Rows list
* @param {String}   callback.rows[0].field1       field1
*/
var myFunc = function (callback) {
   // Function body
}
1
  • I always write the parameters of the callback in the description. Who reads the docs anyways :)? Commented Nov 24, 2014 at 15:46

2 Answers 2

3

Try:

/**@param {string[]} callback.rows*/

Note that you can put any type there, not just string... Such as

/**@param {{field1: string}[]} callback.rows */

Sign up to request clarification or add additional context in comments.

1 Comment

The second option is OK for me
0

As I mentioned the best documentation for your code is unit tests.

In JSDoc should be only main parameters documented. I.e. callback is Function. The last 3 lines should be moved into your unit test.

This art of documentation is more maintainable and provable.

Extensive JSDocs are hard to read and maintain. Not all behavior can be documented.

Not all people can correct understand this documentation. Some people will try to change documentation on your own flavor.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.