Skip to main content

Namepaths

What is a namepath?

A namepath is a string that uniquely identifies a symbol in your documentation. JSDoc uses namepaths in {@link} tags, @augments, @memberof, @borrows, and many other places.

The separator between path components tells you the relationship:

SeparatorMeaning
.Static member
#Instance member
~Inner member

Building namepaths

Top-level symbols

MyClass
myFunction
MY_CONSTANT

Static member

A static method or property belongs to the class itself:

MyClass.staticMethod
MyClass.STATIC_PROP

Instance member

An instance method or property belongs to each object created by new MyClass():

MyClass#instanceMethod
MyClass#instanceProp

Inner symbol

An inner symbol is defined inside a function and not exposed outside it:

MyClass~innerHelper
myModule~privateFunc

Module members

Prefix with module: and the module name:

module:utils
module:utils.format
module:utils~_helper

Namespaced members

MyApp.utils.format
MyApp.models.User#save

Examples

/**
* @class
*/
function Person(name) {
/**
* The person's name.
* @instance
* @type {string}
*/
this.name = name;

/**
* Internal ID — not part of public API.
* @inner
* @type {string}
*/
var _id = generateId();
}

/**
* Greet another person.
* @instance
* @param {Person} other - See {@link Person#name}.
* @returns {string}
*/
Person.prototype.greet = function (other) {
return `Hi ${other.name}, I'm ${this.name}`;
};

Namepaths for the above:

  • Person — the class
  • Person#name — instance property
  • Person~_id — inner variable
  • Person#greet — instance method

Special characters

If a name contains a ., #, ~, or other special character, escape it with a backslash:

module:my\.module

See also

Official reference: jsdoc.app/about-namepaths