6

I have something like this:

/**
Diese Klasse bla bla...
@constructor 
**/
my.namespace.ClassA = function(type)
{
   /**
   This function does something
   **/
   this.doSomething = function(param){
   }
}

The class will get listed in the generated documentation. The function won't. Is there a way to tell JSDoc (3) that this is a member function of the class ClassA?

famousgarkin
  • 13,687
  • 5
  • 58
  • 74
Chris
  • 7,675
  • 8
  • 51
  • 101

3 Answers3

12

Try this!

/**
  * Diese Klasse bla bla...
  * @constructor 
*/
my.namespace.ClassA = function(type)
{
   /**
    * This function does something
    * @function doSomething
    * @memberOf my.namespace.ClassA#
   */
   this.doSomething = function(param){
   };
};

JSDoc seems quite clunky in this area :/ The key is to specify both memberof and the name of the function. See also.

Chris
  • 5,876
  • 3
  • 43
  • 69
6

JSDoc needs some additional information to recognize the function as member function:

/**
  * Diese Klasse bla bla...
  * @constructor 
*/
my.namespace.ClassA = function(type)
{
   /**
    * This function does something
    * @function
    * @memberOf my.namespace.ClassA
   */
   this.doSomething = function(param){
   }
}
Matti Lehtinen
  • 1,694
  • 2
  • 15
  • 22
0

You need to explicitly describe the function using full namepath. There are 3 types of namepath syntaxes to describe functions:

Person#say  // the instance method named "say."
Person.say  // the static method named "say."
Person~say  // the inner method named "say."

See details in this page.

Patrick Hund
  • 19,163
  • 11
  • 66
  • 95
gm2008
  • 4,245
  • 1
  • 36
  • 38