Skip to content

@example tag titles cannot be derived from CommentTag type #2440

@achingbrain

Description

@achingbrain

Search terms

  • example tag
  • title

Actual Behavior

The tsdoc website says:

Any subsequent text that appears on the same line as the @example tag should be interpreted as a title for the example.

The example is parsed as a CommentTag which has content and tag fields and an optional name field.

Any text on the same line as the @example tag appears in the content list along with any other text.

E.g.

/**
 * @example This is how to do a thing
 *
 * Here is some more explantation.
*/

Becomes:

{
  tag: "@example",
  content: [{
    kind: "text",
    text: "This is how to do a thing\n\n"
  }, {
    kind: "text",
    text: "Here is some more explantation.\n\n"
  }]
}

So it's impossible to tell if there was a title for the example.

Expected Behavior

The CommentTag.name field docs say:

Some tags, (@typedef, @param, @property, etc.) may have a user defined identifier associated with them. If this tag is one of those, it will be parsed out and included here.

So if present, the example title should probably be in the name field?

{
  tag: "@example",
  name: "This is how to do a thing",
  content: [{
    kind: "text",
    text: "Here is some more explantation.\n\n"
  }]
}

Environment

  • Typedoc version: 0.25.3
  • TypeScript version: 5.2.2
  • Node.js version: 20.8.0
  • OS: Mac OS X 13.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions