Javascript JSDoc中实例与静态方法名路径的文档

Javascript JSDoc中实例与静态方法名路径的文档,javascript,documentation,jsdoc,Javascript,Documentation,Jsdoc,在记录javascript方法时,我知道在名称路径中使用#表示实例方法,如: function Class() {} /** * Class#method1 */ Class.prototype.method1 = function () {} 然而,我也看到了~和的用法。那些是用来干什么的 /** * Class~method2 * Class.method3 */ 还有其他语法我也应该注意吗?您可以查看变量/方法命名约定的详细信息 用于表示类方法(也称为静态方法),而不是实例

在记录javascript方法时,我知道在名称路径中使用
#
表示实例方法,如:

function Class() {}

/**
 * Class#method1
 */
Class.prototype.method1 = function () {}
然而,我也看到了
~
的用法。那些是用来干什么的

/**
 * Class~method2
 * Class.method3
 */

还有其他语法我也应该注意吗?

您可以查看变量/方法命名约定的详细信息

用于表示类方法(也称为静态方法),而不是实例方法。这意味着在类的实例(使用
new
创建的对象)上不能调用类方法

例如:

Class.foo = function () {
  // ...
};

var blah = new Class();
blah.foo();  // throws an error

Class.foo();  // actually calls the function
function Class() {
  // this function is not accessible outside of the constructor
  function inner() {
  }

  // unless we give it some other reference that is visible:
  this.accessInner = inner;
}

blah = new Class();
blah.inner();        // throws an error
Class.inner();       // also throws an error
blah.accessInner();  // will actually call inner
~
用于表示内部方法(也称为私有方法),它是使用
函数
在类的方法内部定义的方法。这些类型的方法通常无法从方法外部访问,因此您很少会看到这些文档

例如:

Class.foo = function () {
  // ...
};

var blah = new Class();
blah.foo();  // throws an error

Class.foo();  // actually calls the function
function Class() {
  // this function is not accessible outside of the constructor
  function inner() {
  }

  // unless we give it some other reference that is visible:
  this.accessInner = inner;
}

blah = new Class();
blah.inner();        // throws an error
Class.inner();       // also throws an error
blah.accessInner();  // will actually call inner

啊,文档中的其他地方描述了它,我将用详细信息更新我的答案。
accessInner
也将被记录为
Class。accessInner
Class~accessInner
将是
Class\accessInner
,因为它是使用
this
附加到实例的。在这种情况下,
Class#accessInner
Class~inner
将引用相同的方法。好的。我还找到了这个页面,它解释了所有JSDoc名称路径。是的,我把那个链接贴在了我答案的顶部;)