0

I'm trying to document something similar to the following where baz1 and bazzed are properties contained in the bar and bar is a member of Foo

/**
 * @class
 */
function Foo(){
  this.bar = {
     /**
      * The baz function
      */
     baz1: function(){},
     /**
      * The baz1 function
      */
     bazzed: 'bazzed'
  }
}

var foo = new Foo();

//call baz and baz1
foo.bar.baz();
foo.bar.baz1;

Right now JSDoc documents Foo and bar, but it misses baz1 and bazzed.

I realize that I could do something like this

/**
 * @class
 */
function Foo(){
  /**
   * @property {function} baz - Does baz
   * @proprety {string} baz1 - Stores baz1
   */
  this.bar = {
     /**
      * The baz function
      */
     baz1: function(){},
     /**
      * The baz1 function
      */
     bazzed: 'bazzed'
  }
}

but I prefer not to for three reasons:

  1. Some classes have baz2:function(){} through baz10:function(){}
  2. Some baz's have large comment blocks and it doesn't seem to make sense to include in bar's comment block.
  3. In some places the code has foo.bar.baz.buzz() which only compounds reasons 1 and 2.

I know this is a really long question, but I've spent the past 4 hours searching to come up empty.

wharding28
  • 1,047
  • 9
  • 13

1 Answers1

0

What about listing bar as a child class of Foo?

/**
 * @class
 */
function Foo(){
    /**
     * @class
     * @type {{baz1: baz1, bazzed: string}}
     */
    this.bar = {
        /**
         * The baz function
         */
        baz1: function(){},
        /**
         * The baz1 function
         */
        bazzed: 'bazzed'
    }
}
nopuck4you
  • 1,561
  • 13
  • 19