简体   繁体   English

如何在JSDoc中记录深度大于2的符号?

[英]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? 我将如何使用JSDoc进行记录?

Here's my attempt. 这是我的尝试。 With this SomeClass#helperFunctions is documented, but both of it's methods are omitted. 有了此SomeClass#helperFunctions的文档,但省略了这两种方法。

 /** * @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. 我将SomeClass#helperFunctions方法SomeClass#helperFunctions为全局变量,然后使用链接将它们包含为SomeClass#helperFunctions属性。

/**
 * @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: 在我的实际应用程序中, SomeClass也是一个模块,因此它写为:

/**
 * @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. 然后,链接被写为{@link module:path/to/SomeClass~_doSomething}因此它将链接到模块页面上的该位置,而不是在Globals中寻找它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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