Skip to content

Commit 73e1dd6

Browse files
committed
Add navigation.compactFolders option
Resolves #2667
1 parent 3673a4d commit 73e1dd6

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Use of the `@extends` block tag no longer produces warnings, #2659.
66
This tag should only be used in JavaScript projects to specify the type parameters used when extending a parent class. It will not be rendered.
7+
- Added new `navigation.compactFolders` option to prevent TypeDoc from compacting folders, similar to the VSCode option. #2667.
78

89
### Bug Fixes
910

src/lib/output/themes/default/DefaultTheme.tsx

+15-13
Original file line numberDiff line numberDiff line change
@@ -445,19 +445,21 @@ export class DefaultTheme extends Theme {
445445

446446
// Now merge single-possible-paths together so we don't have folders in our navigation
447447
// which contain only another single folder.
448-
const queue = [...result];
449-
while (queue.length) {
450-
const review = queue.shift()!;
451-
queue.push(...(review.children || []));
452-
if (review.kind || review.path) continue;
453-
454-
if (review.children?.length === 1) {
455-
const copyFrom = review.children[0];
456-
const fullName = `${review.text}/${copyFrom.text}`;
457-
delete review.children;
458-
Object.assign(review, copyFrom);
459-
review.text = fullName;
460-
queue.push(review);
448+
if (opts.compactFolders) {
449+
const queue = [...result];
450+
while (queue.length) {
451+
const review = queue.shift()!;
452+
queue.push(...(review.children || []));
453+
if (review.kind || review.path) continue;
454+
455+
if (review.children?.length === 1) {
456+
const copyFrom = review.children[0];
457+
const fullName = `${review.text}/${copyFrom.text}`;
458+
delete review.children;
459+
Object.assign(review, copyFrom);
460+
review.text = fullName;
461+
queue.push(review);
462+
}
461463
}
462464
}
463465

src/lib/utils/options/declaration.ts

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ export interface TypeDocOptionMap {
180180
includeCategories: boolean;
181181
includeGroups: boolean;
182182
includeFolders: boolean;
183+
compactFolders: boolean;
183184
};
184185
visibilityFilters: ManuallyValidatedOption<{
185186
protected?: boolean;

src/lib/utils/options/sources/typedoc.ts

+1
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {
548548
includeCategories: false,
549549
includeGroups: false,
550550
includeFolders: true,
551+
compactFolders: true,
551552
},
552553
});
553554

0 commit comments

Comments
 (0)