Skip to content

Commit e61de01

Browse files
committed
Support # as an external type URL
Closes #2855 Closes #2853
1 parent 61149b0 commit e61de01

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ title: Changelog
77
### Features
88

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

1112
### Bug Fixes
1213

Diff for: site/development/third-party-symbols.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ Plugins can add support for linking to third party sites by calling
6565

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

7073
The following plugin will resolve a few types from React to links on the
7174
official React documentation site.

Diff for: site/options/comments.md

+19
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,22 @@ the special `global` package reserved for global types.
267267
}
268268
}
269269
```
270+
271+
The string `"#"` may also be specified to indicate to TypeDoc that the type should be marked as resolved
272+
but no link should be created.
273+
274+
```json
275+
// typedoc.json
276+
{
277+
"externalSymbolLinkMappings": {
278+
// used by {@link !Promise}
279+
"global": {
280+
"Promise": "#"
281+
},
282+
// used by type Foo = Promise<string>
283+
"typescript": {
284+
"Promise": "#"
285+
}
286+
}
287+
}
288+
```

Diff for: src/lib/output/formatter.tsx

+15-9
Original file line numberDiff line numberDiff line change
@@ -515,15 +515,21 @@ const typeBuilder: TypeVisitor<
515515
);
516516
}
517517
} else if (type.externalUrl) {
518-
name = simpleElement(
519-
<a
520-
href={type.externalUrl}
521-
class="tsd-signature-type external"
522-
target="_blank"
523-
>
524-
{type.name}
525-
</a>,
526-
);
518+
if (type.externalUrl === "#") {
519+
name = simpleElement(
520+
<span class="tsd-signature-type external">{type.name}</span>,
521+
);
522+
} else {
523+
name = simpleElement(
524+
<a
525+
href={type.externalUrl}
526+
class="tsd-signature-type external"
527+
target="_blank"
528+
>
529+
{type.name}
530+
</a>,
531+
);
532+
}
527533
} else if (type.refersToTypeParameter) {
528534
name = simpleElement(
529535
<span class="tsd-signature-type tsd-kind-type-parameter">

0 commit comments

Comments
 (0)