Skip to content

Commit

Permalink
Merge pull request #2102 from mistic100/external-wildcard
Browse files Browse the repository at this point in the history
Fix #2101 support externalSymbolLinkMappings wildcard
  • Loading branch information
Gerrit0 committed Nov 13, 2022
2 parents 1ab233b + 4b0a9b0 commit 0ba5af5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Unreleased

### Features

- Allow to define wildcard mapping in `externalSymbolLinkMappings`.

## v0.23.20 (2022-11-03)

### Bug Fixes
Expand Down
14 changes: 14 additions & 0 deletions internal-docs/third-party-symbols.md
Expand Up @@ -32,6 +32,20 @@ detected as belonging to the `typescript` package rather than the `global` packa
}
```

A wildcard can be used to provide a fallback link to any unmapped type.

```jsonc
// typedoc.json
{
"externalSymbolLinkMappings": {
"external-lib": {
"SomeObject": "https://external-lib.site/docs/SomeObject",
"*": "https://external-lib.site/docs"
}
}
}
```

Plugins can add support for linking to third party sites by calling `app.converter.addUnknownSymbolResolver`.

If the given symbol is unknown, or does not appear in the documentation site, the resolver may return `undefined`
Expand Down
3 changes: 3 additions & 0 deletions src/lib/converter/converter.ts
Expand Up @@ -190,6 +190,9 @@ export class Converter extends ChildableComponent<
if (typeof modLinks[name] === "string") {
return modLinks[name];
}
if (typeof modLinks["*"] === "string") {
return modLinks["*"];
}
});
}

Expand Down
12 changes: 12 additions & 0 deletions src/test/behaviorTests.ts
Expand Up @@ -225,6 +225,10 @@ export const behaviorTests: {
typescript: {
Promise: "/promise2",
},
"@types/marked": {
Lexer: "https://marked.js.org/using_pro#lexer",
"*": "https://marked.js.org",
},
});
},
externalSymbols(project) {
Expand All @@ -238,6 +242,14 @@ export const behaviorTests: {

equal(p.type?.type, "reference" as const);
equal(p.type.externalUrl, "/promise2");

const m = query(project, "L");
equal(m.type?.type, "reference" as const);
equal(m.type.externalUrl, "https://marked.js.org/using_pro#lexer");

const s = query(project, "S");
equal(s.type?.type, "reference" as const);
equal(s.type.externalUrl, "https://marked.js.org");
},

groupTag(project) {
Expand Down
5 changes: 5 additions & 0 deletions src/test/converter2/behavior/externalSymbols.ts
@@ -1,5 +1,10 @@
import { Lexer, Slugger } from "marked";

/**
* Testing custom external link resolution
* {@link !Promise}
*/
export type P = Promise<string>;

export const L = new Lexer();
export const S = new Slugger();

0 comments on commit 0ba5af5

Please sign in to comment.