Skip to content

Commit 9f75d2a

Browse files
committed
fix(docs): Deduplicate virtual sources
1 parent 50ac3d5 commit 9f75d2a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

packages/docusaurus/src/typedoc/plugin.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {mapAndFilter} from '@yarnpkg/core/sources/miscUtils';
12
import pnpApi from 'pnpapi';
23
import {Application, Converter, DeclarationReflection, ProjectReflection, SignatureReflection} from 'typedoc';
34

@@ -6,11 +7,20 @@ function resolveVirtual(path: string) {
67
}
78

89
function remapPaths(context, ref: DeclarationReflection | ProjectReflection | SignatureReflection) {
9-
if (`sources` in ref) {
10-
for (const source of ref.sources ?? []) {
10+
if (`sources` in ref && ref.sources !== undefined) {
11+
const seen = new Set<string>();
12+
ref.sources = mapAndFilter(ref.sources, source => {
1113
source.fileName = resolveVirtual(source.fileName);
1214
source.fullFileName = resolveVirtual(source.fullFileName);
13-
}
15+
16+
const key = `${source.fullFileName}:${source.line}:${source.character}`;
17+
if (seen.has(key)) {
18+
return mapAndFilter.skip;
19+
} else {
20+
seen.add(key);
21+
return source;
22+
}
23+
});
1424
}
1525
}
1626

0 commit comments

Comments
 (0)