如何使用jsdoc-toolkit记录匿名函数(闭包)

Jes*_*son 33 javascript closures comments anonymous-function jsdoc

我正在尝试使用JSDoc-toolkit记录我的代码.我的代码首先包含一个自执行的匿名函数.我怎么在世界上记录这个?我几乎整天都在这上面.JS Docs不会识别匿名函数闭包内部的任何内容,因为它不知道如何处理它.它打破了,我的评论都没有通过.

我的代码看起来像这样.

/** 
 * @fileoverview BLA BLA BLA
 */

/**
 * This is where I don't know what to put.
 */
 (function () {
     "use strict";

     /** or here */
     var stlib = function (param, param, param) {
         /** or here */
         var share = {
             /** or here */
             config: {
                 button: DOM Element,
                 property: blablabla
             },

             init: function () { ...some init code here}
         };

         share.init();
     };

     widgets.add("share", stlib);
 }());
Run Code Online (Sandbox Code Playgroud)

谢谢!

Mic*_*fed 4

您可以将 @namespace 与 @name 和 @lends 一起使用,如下所示:

/**
* @name MyNamespace
* @namespace Hold all functionality
*/
(function () {
    "use strict";
    /** @lends MyNamespace*/
    var stlib = function (param, param, param) { ...All of my code...};
}());
Run Code Online (Sandbox Code Playgroud)

  • @Raynos 它们不是语言有什么区别?它们是[in](http://code.google.com/p/jsdoc-toolkit/wiki/TagNamespace) jsdoc。也许这在语义上并不正确,但我写的东西是有效的。 (3认同)