diff --git a/CHANGELOG.md b/CHANGELOG.md index 26c5ad255..4bc1211ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Features +- Added `navigationLeaves` option to remove branches from the navigation tree, #2382. - Improved support for multi-word searches, #2400. ### Bug Fixes diff --git a/src/lib/output/themes/default/DefaultTheme.tsx b/src/lib/output/themes/default/DefaultTheme.tsx index d351cd0ec..9b5a2ac24 100644 --- a/src/lib/output/themes/default/DefaultTheme.tsx +++ b/src/lib/output/themes/default/DefaultTheme.tsx @@ -246,6 +246,7 @@ export class DefaultTheme extends Theme { // eslint-disable-next-line @typescript-eslint/no-this-alias const theme = this; const opts = this.application.options.getValue("navigation"); + const leaves = this.application.options.getValue("navigationLeaves"); if (opts.fullTree) { this.application.logger.warn( @@ -288,6 +289,10 @@ export class DefaultTheme extends Theme { return parent.children.map(toNavigation); } + if (leaves.includes(parent.getFullName())) { + return; + } + if (!parent.kindOf(ReflectionKind.SomeModule | ReflectionKind.Project)) { return; } diff --git a/src/lib/utils/options/declaration.ts b/src/lib/utils/options/declaration.ts index 80983a955..6dcf0f90e 100644 --- a/src/lib/utils/options/declaration.ts +++ b/src/lib/utils/options/declaration.ts @@ -139,6 +139,7 @@ export interface TypeDocOptionMap { titleLink: string; navigationLinks: ManuallyValidatedOption>; sidebarLinks: ManuallyValidatedOption>; + navigationLeaves: string[]; navigation: { includeCategories: boolean; includeGroups: boolean; diff --git a/src/lib/utils/options/sources/typedoc.ts b/src/lib/utils/options/sources/typedoc.ts index 1d3c02754..6ea6cb592 100644 --- a/src/lib/utils/options/sources/typedoc.ts +++ b/src/lib/utils/options/sources/typedoc.ts @@ -447,7 +447,11 @@ export function addTypeDocOptions(options: Pick) { } }, }); - + options.addDeclaration({ + name: "navigationLeaves", + help: "Branches of the navigation tree which should not be expanded.", + type: ParameterType.Array, + }); options.addDeclaration({ name: "navigation", help: "Determines how the navigation sidebar is organized.",