Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JS Doc comment link method

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?

like image 775
Chacha Avatar asked Nov 03 '17 04:11

Chacha


1 Answers

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)
like image 103
Andrew_1510 Avatar answered Oct 24 '22 07:10

Andrew_1510