javascript - How do I JSDoc A Nested Object's Methods? -


i've been trying use jsdoc3 generate documentation on file, i'm having difficulty. file (which require.js module) looks this:

define([], function() {      /*      * @exports mystuff/foo      */     var foo = {         /**          * @member          */         bar: {             /**              * @method              */             baz: function() { /*...*/ }         }     };      return foo; } 

the problem is, can't baz show in generated documentation. instead documentation file foo/foo module, lists bar member, bar has no baz (just link foo's source code).

i've tried changing bar's directive @property instead, , i've tried changing baz's directive @member or @property, none of helps. no matter do, baz doesn't seem want show up.

does know directive structure use baz appear in generated documentation?

p.s. i've tried reading pages 1 on jsdoc site http://usejsdoc.org/howto-commonjs-modules.html, describes cases of foo.bar, not foo.bar.baz.

you can use combination of @module or @namespace along @memberof.

define([], function() {      /**      * test module foo      * @version 1.0      * @exports mystuff/foo      * @namespace foo      */     var foo = {         /**          * method in first level, test          * @memberof foo          * @method testfirstlvl          */         testfirstlvl: function(msg) {},         /**          * test child object child namespace          * @memberof foo          * @type {object}          * @namespace foo.bar          */         bar: {             /**              * test inner method in child namespace              * @memberof foo.bar              * @method baz              */             baz: function() { /*...*/ }         },         /**          * test child object without namespace          * @memberof foo          * @type {object}          * @property {method} baz2 child method property defination          */         bar2: {             /**              * test inner method              * @memberof foo.bar2              * @method baz2              */             baz2: function() { /*...*/ }         },         /**          * test child object namespace , property def.          * @memberof foo          * @type {object}          * @namespace foo.bar3          * @property {method} baz3 child method property defination          */         bar3: {             /**              * test inner method in child namespace              * @memberof foo.bar3              * @method baz3              */             baz3: function() { /*...*/ }         },         /**          * test child object          * @memberof foo          * @type {object}          * @property {method} baz4 child method          */         bar4: {              /**              * @alias , @memberof! tags force jsdoc document              * property `bar4.baz4` (rather `baz4`) , member of              * `data#`. can link property {@link foo#bar4.baz4}.              * @alias bar4.baz4              * @memberof! foo#              * @method bar4.baz4              */             baz4: function() { /*...*/ }         }     };      return foo; }); 

edit per comment: (single page solution module)

bar4 without ugly property table. ie @property removed bar4.

define([], function() {      /**      * test module foo      * @version 1.0      * @exports mystuff/foo      * @namespace foo      */     var foo = {         /**          * method in first level, test          * @memberof foo          * @method testfirstlvl          */         testfirstlvl: function(msg) {},         /**          * test child object          * @memberof foo          * @type {object}          */         bar4: {              /**              * @alias , @memberof! tags force jsdoc document              * property `bar4.baz4` (rather `baz4`) , member of              * `data#`. can link property {@link foo#bar4.baz4}.              * @alias bar4.baz4              * @memberof! foo#              * @method bar4.baz4              */             baz4: function() { /*...*/ },             /**              * @memberof! memeber              * @alias bar4.test              * @memberof! foo#              * @member bar4.test              */              test : true         }     };      return foo; }); 

references -

  1. another question nested namespaces
  2. for alternative way of using namespaces
  3. documenting literal objects

*note haven't tried myself. please try , share results.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -