Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
achingbrain opened this issue Nov 7, 2023 · 3 comments
Closed

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

achingbrain opened this issue Nov 7, 2023 · 3 comments
Labels
bug Functionality does not match expectation

Comments

@achingbrain
Copy link

achingbrain commented Nov 7, 2023

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
@achingbrain achingbrain added the bug Functionality does not match expectation label Nov 7, 2023
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 11, 2023

This seems like a reasonable way to handle things 👍 JSDoc <caption>s should be put there too.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 11, 2023

Hmm... and what happens if there's a {@link} in the first line? name is a string, so can't support complex content.

VSCode doesn't support this idea as a thing, just rendering it on the next line after the block.

image

Since TS doesn't even parse @link tags in @example blocks, it's probably reasonable to assert that they just can't appear there, and will be treated as regular text, but that feels ugly. The alternative is a new heading?: CommentDisplayPart[] attribute on CommentTag... which feels ugly. I'm leaning towards name right now, and emitting a warning if the heading contains rich content. Going to let this one sit for a while before deciding...

If you toss an @example block with a heading into https://tsdoc.org/play/, the official parser's AST doesn't place it somewhere you can tell either. It looks like I'm not the first to notice this. API extractor (the "official" tsdoc documentation generator written by the microsoft people who wanted TSDoc to begin with) doesn't mention this feature in their docs either, so I suspect don't support it

@achingbrain
Copy link
Author

I'm leaning towards name right now, and emitting a warning if the heading contains rich content.

This seems reasonable to me. I guess any more might need a change to the tsdoc specs?

Simek added a commit to expo/expo that referenced this issue Jan 11, 2024
…#26343)

# Why

Update TypeDoc to the latest release to keep up to day and officially
support package source build with TS 5.2+.

All data files have been changed, since TypeDoc removed on of legacy the
entry Kind enum values (`ObjectLiteral`) which caused a shift of
existing values after it.

# How

Update TypeDoc to the latest version, rewrite TypeDoc Application calls
execution, update Docs snapshot and unit tests to match the data.

Unfortunately, the data generation command outputs not valid for our use
case warning due to TypeStrong/typedoc#2440,
but it doesn't matter in our case due to using the JSON data only, and
custom renderers, which can handle both comment structures correctly, so
those warning can be ignored. We can alter source comments in the
future, when stable SDK 50 will be releases to avoid shipping large
amount of changes in preview/RC stage.

> [!important]
> No backport of `expo-assets` data for SDK 50 has been made due to
#26310, which probably did not become part od SDK 50, but if will land,
we will need to backport the package data, since the structure and
exported fields have changed.

# Test Plan

The changes have been reviewed locally. Reference doc pages contains a
full, and expected data. All lint checks and tests are passing.
onizam95 pushed a commit to onizam95/expo-av-drm that referenced this issue Jan 15, 2024
…expo#26343)

# Why

Update TypeDoc to the latest release to keep up to day and officially
support package source build with TS 5.2+.

All data files have been changed, since TypeDoc removed on of legacy the
entry Kind enum values (`ObjectLiteral`) which caused a shift of
existing values after it.

# How

Update TypeDoc to the latest version, rewrite TypeDoc Application calls
execution, update Docs snapshot and unit tests to match the data.

Unfortunately, the data generation command outputs not valid for our use
case warning due to TypeStrong/typedoc#2440,
but it doesn't matter in our case due to using the JSON data only, and
custom renderers, which can handle both comment structures correctly, so
those warning can be ignored. We can alter source comments in the
future, when stable SDK 50 will be releases to avoid shipping large
amount of changes in preview/RC stage.

> [!important]
> No backport of `expo-assets` data for SDK 50 has been made due to
expo#26310, which probably did not become part od SDK 50, but if will land,
we will need to backport the package data, since the structure and
exported fields have changed.

# Test Plan

The changes have been reviewed locally. Reference doc pages contains a
full, and expected data. All lint checks and tests are passing.
hoodmane added a commit to pyodide/sphinx-js-fork that referenced this issue Apr 23, 2024
Fix minor breakages from last 7 months. Add handling for this typedoc change:
TypeStrong/typedoc#2440
hoodmane added a commit to pyodide/sphinx-js-fork that referenced this issue Apr 23, 2024
Fix minor breakages from last 7 months. Add handling for this typedoc change:
TypeStrong/typedoc#2440
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants