最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Documenting member functions with JSDoc - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question edited Jul 17, 2015 at 17:11 famousgarkin 14.1k5 gold badges59 silver badges74 bronze badges asked Sep 23, 2013 at 11:49 ChrisChris 7,8558 gold badges53 silver badges103 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 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.

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){
   }
}

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.

发布评论

评论列表(0)

  1. 暂无评论