Skip to main content

Block and Inline Tags

Block tags

Block tags occupy their own line in a JSDoc comment. They describe the symbol as a whole — its parameters, return value, type, visibility, metadata, etc.

/**
* Calculate the hypotenuse.
*
* @param {number} a - First leg.
* @param {number} b - Second leg.
* @returns {number} The length of the hypotenuse.
*/
function hypotenuse(a, b) {
return Math.sqrt(a * a + b * b);
}

Block tags always start with @. Everything after the tag name (until the next @ tag or the end of the comment) belongs to that tag.

Inline tags

Inline tags appear inside the text of a description or another tag's value. They are surrounded by {curly braces} and also begin with @.

/**
* Parses a string using the {@link Tokenizer} class.
* See the {@tutorial parsing-guide} for a full walk-through.
*
* @param {string} input - The raw input string.
* @returns {Token[]} An array of {@link Token} objects.
*/
function parse(input) {}

JSDoc currently recognises two inline tags:

TagPurpose
{@link namepath}Hyperlink to a symbol or URL
{@tutorial id}Hyperlink to a tutorial

Where inline tags can appear

Inline tags can appear in:

  • The description text of any symbol
  • The description text of a @param, @returns, @property, etc.
  • The value of a @see tag
  • The value of a @deprecated tag

Combining block and inline tags

/**
* Validates a {@link User} object before saving.
*
* @param {User} user - The user to validate.
* @throws {ValidationError} When required fields are missing.
* See {@link User#email} and {@link User#name}.
* @returns {boolean} `true` if valid.
* @see {@link https://example.com/validation-rules Validation rules}
* @deprecated Use {@link validateUserAsync} instead.
*/
function validateUser(user) {}

See also