Skip to content

Commit 653b281

Browse files
committed
Respect --exclude when expanding globs in entry points
Resolves #2376
1 parent a6823cf commit 653b281

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- Improved support for optional names within JSDoc types, #2384.
2323
- Fixed duplicate rendering of reflection flags on signature parameters, #2385.
2424
- TypeDoc now handles the `intrinsic` keyword if TS intrinsic types are included in documentation.
25+
- `--exclude` is now respected when expanding globs in entry points, #2376.
2526

2627
### Thanks!
2728

src/lib/utils/entry-point.ts

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export function getEntryPoints(
5757
}
5858

5959
const entryPoints = options.getValue("entryPoints");
60+
const exclude = options.getValue("exclude");
6061

6162
// May be set explicitly to be an empty array to only include a readme for a package
6263
// See #2264
@@ -70,15 +71,15 @@ export function getEntryPoints(
7071
case EntryPointStrategy.Resolve:
7172
result = getEntryPointsForPaths(
7273
logger,
73-
expandGlobs(entryPoints, logger),
74+
expandGlobs(entryPoints, exclude, logger),
7475
options,
7576
);
7677
break;
7778

7879
case EntryPointStrategy.Expand:
7980
result = getExpandedEntryPointsForPaths(
8081
logger,
81-
expandGlobs(entryPoints, logger),
82+
expandGlobs(entryPoints, exclude, logger),
8283
options,
8384
);
8485
break;
@@ -108,17 +109,23 @@ export function getWatchEntryPoints(
108109
let result: DocumentationEntryPoint[] | undefined;
109110

110111
const entryPoints = options.getValue("entryPoints");
111-
switch (options.getValue("entryPointStrategy")) {
112+
const exclude = options.getValue("exclude");
113+
const strategy = options.getValue("entryPointStrategy");
114+
115+
switch (strategy) {
112116
case EntryPointStrategy.Resolve:
113-
result = getEntryPointsForPaths(logger, entryPoints, options, [
114-
program,
115-
]);
117+
result = getEntryPointsForPaths(
118+
logger,
119+
expandGlobs(entryPoints, exclude, logger),
120+
options,
121+
[program],
122+
);
116123
break;
117124

118125
case EntryPointStrategy.Expand:
119126
result = getExpandedEntryPointsForPaths(
120127
logger,
121-
entryPoints,
128+
expandGlobs(entryPoints, exclude, logger),
122129
options,
123130
[program],
124131
);
@@ -129,6 +136,15 @@ export function getWatchEntryPoints(
129136
"Watch mode does not support 'packages' style entry points.",
130137
);
131138
break;
139+
140+
case EntryPointStrategy.Merge:
141+
logger.error(
142+
"Watch mode does not support 'merge' style entry points.",
143+
);
144+
break;
145+
146+
default:
147+
assertNever(strategy);
132148
}
133149

134150
if (result && result.length === 0) {
@@ -228,30 +244,43 @@ export function getExpandedEntryPointsForPaths(
228244
);
229245
}
230246

231-
function expandGlobs(inputFiles: string[], logger: Logger) {
247+
function expandGlobs(inputFiles: string[], exclude: string[], logger: Logger) {
248+
const excludePatterns = createMinimatch(exclude);
249+
232250
const base = deriveRootDir(inputFiles);
233251
const result = inputFiles.flatMap((entry) => {
234252
const result = glob(entry, base, {
235253
includeDirectories: true,
236254
followSymlinks: true,
237255
});
238256

257+
const filtered = result.filter(
258+
(file) => file === entry || !matchesAny(excludePatterns, file),
259+
);
260+
239261
if (result.length === 0) {
240262
logger.warn(
241263
`The entrypoint glob ${nicePath(
242264
entry,
243265
)} did not match any files.`,
244266
);
267+
} else if (filtered.length === 0) {
268+
logger.warn(
269+
`The entrypoint glob ${nicePath(
270+
entry,
271+
)} did not match any files after applying exclude patterns.`,
272+
);
245273
} else {
246274
logger.verbose(
247-
`Expanded ${nicePath(entry)} to:\n\t${result
275+
`Expanded ${nicePath(entry)} to:\n\t${filtered
248276
.map(nicePath)
249277
.join("\n\t")}`,
250278
);
251279
}
252280

253-
return result;
281+
return filtered;
254282
});
283+
255284
return result;
256285
}
257286

src/lib/utils/jsx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export function setRenderSettings(options: { pretty: boolean }) {
108108
export const renderElement = function renderElement(
109109
element: JsxElement | null | undefined,
110110
): string {
111-
if (!element) {
111+
if (!element || typeof element === "boolean") {
112112
return "";
113113
}
114114

0 commit comments

Comments
 (0)