Skip to content

Commit 0ba5af5

Browse files
authored
Merge pull request #2102 from mistic100/external-wildcard
Fix #2101 support externalSymbolLinkMappings wildcard
2 parents 1ab233b + 4b0a9b0 commit 0ba5af5

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Unreleased
22

3+
### Features
4+
5+
- Allow to define wildcard mapping in `externalSymbolLinkMappings`.
6+
37
## v0.23.20 (2022-11-03)
48

59
### Bug Fixes

internal-docs/third-party-symbols.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ detected as belonging to the `typescript` package rather than the `global` packa
3232
}
3333
```
3434

35+
A wildcard can be used to provide a fallback link to any unmapped type.
36+
37+
```jsonc
38+
// typedoc.json
39+
{
40+
"externalSymbolLinkMappings": {
41+
"external-lib": {
42+
"SomeObject": "https://external-lib.site/docs/SomeObject",
43+
"*": "https://external-lib.site/docs"
44+
}
45+
}
46+
}
47+
```
48+
3549
Plugins can add support for linking to third party sites by calling `app.converter.addUnknownSymbolResolver`.
3650

3751
If the given symbol is unknown, or does not appear in the documentation site, the resolver may return `undefined`

src/lib/converter/converter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ export class Converter extends ChildableComponent<
190190
if (typeof modLinks[name] === "string") {
191191
return modLinks[name];
192192
}
193+
if (typeof modLinks["*"] === "string") {
194+
return modLinks["*"];
195+
}
193196
});
194197
}
195198

src/test/behaviorTests.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ export const behaviorTests: {
225225
typescript: {
226226
Promise: "/promise2",
227227
},
228+
"@types/marked": {
229+
Lexer: "https://marked.js.org/using_pro#lexer",
230+
"*": "https://marked.js.org",
231+
},
228232
});
229233
},
230234
externalSymbols(project) {
@@ -238,6 +242,14 @@ export const behaviorTests: {
238242

239243
equal(p.type?.type, "reference" as const);
240244
equal(p.type.externalUrl, "/promise2");
245+
246+
const m = query(project, "L");
247+
equal(m.type?.type, "reference" as const);
248+
equal(m.type.externalUrl, "https://marked.js.org/using_pro#lexer");
249+
250+
const s = query(project, "S");
251+
equal(s.type?.type, "reference" as const);
252+
equal(s.type.externalUrl, "https://marked.js.org");
241253
},
242254

243255
groupTag(project) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import { Lexer, Slugger } from "marked";
2+
13
/**
24
* Testing custom external link resolution
35
* {@link !Promise}
46
*/
57
export type P = Promise<string>;
8+
9+
export const L = new Lexer();
10+
export const S = new Slugger();

0 commit comments

Comments
 (0)