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

javascript - JS Doc comment link method - Stack Overflow

programmeradmin2浏览0评论

In JavaScript comments, I want to mention a method present in some file. How can I link to that method in comment? Eg.

Say my method is:

function xyz() {
}

and say I am writing a comment like

// See also {method-link to xyz}

What should {method-link} be?

In JavaScript comments, I want to mention a method present in some file. How can I link to that method in comment? Eg.

Say my method is:

function xyz() {
}

and say I am writing a comment like

// See also {method-link to xyz}

What should {method-link} be?

Share Improve this question edited Mar 18, 2019 at 6:13 Dan Dascalescu 152k64 gold badges332 silver badges419 bronze badges asked Nov 3, 2017 at 4:43 ChachaChacha 4411 gold badge5 silver badges13 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 26

To link to "something else" in JSDoc, including another method, use the {@link ...} tag. In your case, you would use:

// See also {@link xyz}

You'll then be able to Ctrl+click on xyz in WebStorm.

The JSDoc terminology for that "something else" is "namepath". Below follows the original answer by Andrew, which explains namepaths.


JSDoc3 styles:

Basic Syntax Examples of Namepaths in JSDoc 3

myFunction
MyConstructor
MyConstructor#instanceMember
MyConstructor.staticMember
MyConstructor~innerMember // note that JSDoc 2 uses a dash

Special cases: modules, externals and events.

/** A module. Its name is module:foo/bar.
 * @module foo/bar
 */

/** The built in string object. Its name is       external:String.
 * @external String
 */

 /** An event. Its name is module:foo/bar.event:MyEvent.
 * @event module:foo/bar.event:MyEvent
 */

For easy coding, I sometime use markdown style in comment:

// see function name in file dir/file.name

// see the method [named of the method](file-name #method name)
发布评论

评论列表(0)

  1. 暂无评论