Skip to content

Commit bb5a5ae

Browse files
committed
feat: The exclude option will now remove symbols re-exported from excluded files
Resolves #1578.
1 parent dc8416a commit bb5a5ae

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

src/lib/converter/converter.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class Converter extends ChildableComponent<
4040
@BindOption("externalPattern")
4141
externalPattern!: string[];
4242
private externalPatternCache?: IMinimatch[];
43+
private excludeCache?: IMinimatch[];
4344

4445
@BindOption("excludeExternals")
4546
excludeExternals!: boolean;
@@ -384,13 +385,33 @@ export class Converter extends ChildableComponent<
384385
return true;
385386
}
386387

388+
if (this.isExcluded(symbol)) {
389+
return true;
390+
}
391+
387392
if (!this.excludeExternals) {
388393
return false;
389394
}
390395

391396
return this.isExternal(symbol);
392397
}
393398

399+
private isExcluded(symbol: ts.Symbol) {
400+
this.excludeCache ??= createMinimatch(this.application.exclude);
401+
402+
for (const node of symbol.getDeclarations() ?? []) {
403+
if (
404+
this.excludeCache.some((p) =>
405+
p.match(node.getSourceFile().fileName)
406+
)
407+
) {
408+
return true;
409+
}
410+
}
411+
412+
return false;
413+
}
414+
394415
/** @internal */
395416
isExternal(symbol: ts.Symbol) {
396417
this.externalPatternCache ??= createMinimatch(this.externalPattern);

src/test/converter2.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,14 @@ const issueTests: Record<string, (project: ProjectReflection) => void> = {
186186
equal(query(project, "emptyObj").defaultValue, "{}");
187187
equal(query(project, "nonEmptyObj").defaultValue, "...");
188188
},
189+
190+
gh1578(project) {
191+
ok(query(project, "notIgnored"));
192+
ok(
193+
!project.findReflectionByName("ignored"),
194+
"Symbol re-exported from ignored file is ignored."
195+
);
196+
},
189197
};
190198

191199
describe("Converter2", () => {
@@ -221,7 +229,7 @@ describe("Converter2", () => {
221229
join(base, "issues", `${entry}.d.ts`),
222230
join(base, "issues", `${entry}.tsx`),
223231
join(base, "issues", `${entry}.js`),
224-
join(base, "issues", entry),
232+
join(base, "issues", entry, "index.ts"),
225233
].find(existsSync);
226234

227235
ok(entryPoint, `No entry point found for ${entry}`);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const ignored = true;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { ignored } from "./ignored";
2+
export const notIgnored = true;

src/test/converter2/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88

99
// See #1524. We might force this to false eventually.
1010
"skipLibCheck": true
11+
},
12+
"typedocOptions": {
13+
"exclude": ["**/ignored.ts"]
1114
}
1215
}

0 commit comments

Comments
 (0)