How to use JSDoc3 to document nested namespaces

梦想的初衷 提交于 2020-01-14 07:35:07

问题


I'm having trouble using JSDoc3 to document code that's structured along these lines

/**
 * @namespace MyNamespace.MySubNamespace
 */

(function (MyNamespace) {
    MyNamespace.MySubNamespace.Foo = {
        doSomething: function (someParam) {
            // doing it
        }
    }
})(window.MyNamespace)

How would I use JSDoc3 to document that MyNamespace contains MySubNamespace which contains Foo? Further how would I associate doSomething with Foo and document its parameter someParam?

A limitation I have is that I can't add documentation to the file in which MyNamespace and MySubNamespace are declared.

Thanks much!


回答1:


Figured it out. Hope this solution helps others.

/**
 * @namespace MyNamespace.MySubNamespace
 */

 (function (MyNamespace) {
     /**
      * Foo namespace
      * @namespace Foo
      * @memberOf MyNamespace.MySubNamespace
      */ 
     var Foo = {
         /**
          * Does something.
          * @memberOf MyNamespace.MySubNamespace.Foo
          * @param {object} someParam Some parameter.
          */
         doSomething: function (someParam) {
             // doing it
         }
     };
     MyNamespace.MySubNamespace.Foo = Foo;
 })(window.MyNamespace)    


来源:https://stackoverflow.com/questions/17119100/how-to-use-jsdoc3-to-document-nested-namespaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!