Skip to content

Commit

Permalink
Support # as an external type URL
Browse files Browse the repository at this point in the history
Closes #2855
Closes #2853
  • Loading branch information
Gerrit0 committed Feb 21, 2025
1 parent 61149b0 commit e61de01
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ title: Changelog
### Features

- The `--favicon` option may now be given a link starting with `https?://` instead of a path, #2851.
- TypeDoc now supports specifying `#` as the link in `externalSymbolLinkMappings` to indicate the type should not be linked to, #2853.

### Bug Fixes

Expand Down
5 changes: 4 additions & 1 deletion site/development/third-party-symbols.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ Plugins can add support for linking to third party sites by calling

If the given symbol is unknown, or does not appear in the documentation site,
the resolver may return `undefined` and no link will be rendered unless provided
by another resolver.
by another resolver. The string `"#"` may also be returned to indicate that
TypeDoc should mark the symbol as externally resolved, but not produce a link
to it. This can be useful if you want to keep the link for usage in VSCode,
but not include it in the documentation.

The following plugin will resolve a few types from React to links on the
official React documentation site.
Expand Down
19 changes: 19 additions & 0 deletions site/options/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,22 @@ the special `global` package reserved for global types.
}
}
```

The string `"#"` may also be specified to indicate to TypeDoc that the type should be marked as resolved
but no link should be created.

```json
// typedoc.json
{
"externalSymbolLinkMappings": {
// used by {@link !Promise}
"global": {
"Promise": "#"
},
// used by type Foo = Promise<string>
"typescript": {
"Promise": "#"
}
}
}
```
24 changes: 15 additions & 9 deletions src/lib/output/formatter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -515,15 +515,21 @@ const typeBuilder: TypeVisitor<
);
}
} else if (type.externalUrl) {
name = simpleElement(
<a
href={type.externalUrl}
class="tsd-signature-type external"
target="_blank"
>
{type.name}
</a>,
);
if (type.externalUrl === "#") {
name = simpleElement(
<span class="tsd-signature-type external">{type.name}</span>,
);
} else {
name = simpleElement(
<a
href={type.externalUrl}
class="tsd-signature-type external"
target="_blank"
>
{type.name}
</a>,
);
}
} else if (type.refersToTypeParameter) {
name = simpleElement(
<span class="tsd-signature-type tsd-kind-type-parameter">
Expand Down

0 comments on commit e61de01

Please sign in to comment.