Skip to content

Commit

Permalink
Add navigationLeaves option
Browse files Browse the repository at this point in the history
Resolves #2382
  • Loading branch information
Gerrit0 committed Oct 6, 2023
1 parent 2cabd22 commit b12258d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/lib/output/themes/default/DefaultTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/utils/options/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export interface TypeDocOptionMap {
titleLink: string;
navigationLinks: ManuallyValidatedOption<Record<string, string>>;
sidebarLinks: ManuallyValidatedOption<Record<string, string>>;
navigationLeaves: string[];
navigation: {
includeCategories: boolean;
includeGroups: boolean;
Expand Down
6 changes: 5 additions & 1 deletion src/lib/utils/options/sources/typedoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,11 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {
}
},
});

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.",
Expand Down

0 comments on commit b12258d

Please sign in to comment.