Reputation: 441
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?
Upvotes: 21
Views: 18516
Reputation: 13526
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.
myFunction
MyConstructor
MyConstructor#instanceMember
MyConstructor.staticMember
MyConstructor~innerMember // note that JSDoc 2 uses a dash
/** 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
*/
markdown
style in comment:// see function name in file dir/file.name
// see the method [named of the method](file-name #method name)
Upvotes: 26