简体   繁体   中英

How do I document symbols with a depth greater than 2 in JSDoc?

I have an object that contains multiple methods and is a member of a class. How would I document this with JSDoc?

Here's my attempt. With this SomeClass#helperFunctions is documented, but both of it's methods are omitted.

 /** * @class SomeClass * @param name */ var SomeClass = function(name) {}; /** * @member SomeClass#helperFunctions */ SomeClass.prototype.helperFunctions = { /** * @method SomeClass#helperFunctions.doSomething * @param {Array} arr */ doSomething: function(arr) {} }; /** * @method SomeClass#helperFunctions.doSomethingElse * @param {Array} arr */ SomeClass.protype.helperFunctions.doSomethingElse = function(arr) {}; 

This is the best I could come up with.

I document methods of SomeClass#helperFunctions as globals then include them as properties of SomeClass#helperFunctions using links.

/**
 * @class SomeClass
 * @param {String} name
 */
var SomeClass = function(name) {};

/**
 * @member SomeClass#helperFunctions
 * @property {Function} doSomething [_doSomething]{@link _doSomething}
 * @property {Function} doSomethingElse [_doSomethingElse]{@link _doSomethingElse}
 */
SomeClass.prototype.helperFunctions = {
  doSomething: _doSomething,
  doSomethingElse: _doSomethingElse
};

/**
 * @function _doSomething
 * @param {Array} arr
 */
_doSomething = function(arr) {};

/**
 * @function _doSomethingElse
 * @param {Array} arr
 */
_doSomethingElse = function(arr) {};

In my actual application SomeClass was also a module so it was written as:

/**
 * @module path/to/SomeClass
 */

/**
 * @class module:path/to/SomeClass
 */
var SomeClass = module.exports = function() {};

Then the links were written as {@link module:path/to/SomeClass~_doSomething} so it would link to it's spot on the module page instead of looking for them in Globals.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM