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 badges1 Answer
Reset to default 26To 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)