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

Fix #2101 support externalSymbolLinkMappings wildcard #2102

Merged
merged 1 commit into from Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();