简体   繁体   English

JSDoc和JavaScript单例文档

[英]JSDoc and JavaScript singleton documentation

I have a JavaScript singleton defined as: 我有一个JavaScript单例定义为:

/**
 * A description here
 * @class
 */
com.mydomain.ClassName = (function(){

/**
 * @constructor
 * @lends com.mydomain.ClassName
 */ 
var ClassName = function(){};

/**
 * method description
 * @public
 * @lends com.mydomain.ClassName
*/
ClassName.prototype.method1 = function(){};

return new ClassName();

})();

No warnings are printed in verbose mode (-v), but the documentation reports only "com.mydomain.ClassName()" with "A description here" as description... how can I generate documentation for ClassName's methods too? 没有以详细模式(-v)打印警告,但文档仅报告“com.mydomain.ClassName()”和“此处描述”作为描述...如何为ClassName的方法生成文档?

I solved! 我解决了! :) :)

  /**
 * A description here
 * @class
 */
com.mydomain.ClassName = (function(){

/**
 * @constructor
 * @name com.mydomain.ClassName
 */ 
var ClassName = function(){};

/**
 * method description
 * @public
 * @name com.mydomain.ClassName.method1
*/
ClassName.prototype.method1 = function(){};

return new ClassName();

})();

I just replaced @lends with @name! 我刚刚用@name替换了@lends!

UPDATE: the right approach in order to have the full documentation is the following: 更新:正确的方法,以获得完整的文档如下:

/**
 * A description here
 * @class
 */
com.mydomain.ClassName = (function(){

var ClassName = function(){};

/**
 * method description
 * @memberOf com.mydomain.ClassName
*/
ClassName.prototype.method1 = function(){};

return new ClassName();

})();

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

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