Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use JSDoc3 to document nested namespaces

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!

like image 544
Julian A. Avatar asked Jun 15 '13 00:06

Julian A.


1 Answers

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)    
like image 80
Julian A. Avatar answered Sep 17 '22 23:09

Julian A.