Skip to content

Commit

Permalink
fix(core): expose missing entrypoints to navigation (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Aug 24, 2024
1 parent e9ceaa3 commit 310edc6
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-mice-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'typedoc-plugin-markdown': patch
---

- Expose missing entrypoints to navigation (#663)
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,25 @@ export class NavigationBuilder {
this.buildNavigationFromProject(this.project);
}

this.removeEmptyChildren(this.navigation);

return this.navigation;
}

private removeEmptyChildren(navigation: NavigationItem[]): void {
navigation.forEach((navItem) => {
if (navItem.children) {
this.removeEmptyChildren(navItem.children);
navItem.children = navItem.children.filter(
(child) => Object.keys(child).length > 0,
);
if (navItem.children.length === 0) {
delete navItem.children;
}
}
});
}

private buildNavigationFromPackage(projectChild: DeclarationReflection) {
const fileExtension = this.options.getValue('fileExtension');

Expand Down Expand Up @@ -252,10 +268,7 @@ export class NavigationBuilder {
reflection: DeclarationReflection | DocumentReflection,
outputFileStrategy?: OutputFileStrategy,
): NavigationItem[] | null {
if (
reflection instanceof DeclarationReflection &&
reflection.groups?.some((group) => group.allChildrenHaveOwnDocument())
) {
if (reflection instanceof DeclarationReflection) {
if (this.navigationOptions.excludeGroups) {
return reflection.childrenIncludingDocuments
?.filter((child) => child.hasOwnDocument)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,6 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "package-1b",
"kind": 2,
"children": [],
"path": "package-1b/index.md"
},
{
Expand Down Expand Up @@ -759,7 +758,29 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "module-1",
"kind": 2,
"path": "package-7/module-1.md"
"path": "package-7/module-1.md",
"children": [
{
"title": "submodules",
"children": [
{
"title": "submodule-3-with-modules",
"children": [
{
"title": "nested-submodule-1",
"kind": 2,
"path": "package-7/module-1/submodules/submodule-3-with-modules/nested-submodule-1.md"
},
{
"title": "nested-submodule-2",
"kind": 2,
"path": "package-7/module-1/submodules/submodule-3-with-modules/nested-submodule-2.md"
}
]
}
]
}
]
},
{
"title": "module-2",
Expand All @@ -777,13 +798,11 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "@scope/package-1",
"kind": 2,
"children": [],
"path": "package-1/README.md"
},
{
"title": "package-1b",
"kind": 2,
"children": [],
"path": "package-1b/README.md"
},
{
Expand Down Expand Up @@ -909,7 +928,29 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "module-1",
"kind": 2,
"path": "package-7/module-1.md"
"path": "package-7/module-1.md",
"children": [
{
"title": "submodules",
"children": [
{
"title": "submodule-3-with-modules",
"children": [
{
"title": "nested-submodule-1",
"kind": 2,
"path": "package-7/module-1/submodules/submodule-3-with-modules/nested-submodule-1.md"
},
{
"title": "nested-submodule-2",
"kind": 2,
"path": "package-7/module-1/submodules/submodule-3-with-modules/nested-submodule-2.md"
}
]
}
]
}
]
},
{
"title": "module-2",
Expand Down Expand Up @@ -3973,8 +4014,7 @@ exports[`Navigation should gets Navigation Json for multiple entry points: (Outp
{
"title": "has-categories",
"kind": 2,
"path": "has-categories.md",
"children": []
"path": "has-categories.md"
},
{
"title": "has-custom-groups",
Expand Down Expand Up @@ -4116,8 +4156,7 @@ exports[`Navigation should gets Navigation Json for single entry point: (Output
{
"title": "ClassWithPropCategories",
"kind": 128,
"path": "classes/ClassWithPropCategories.md",
"children": []
"path": "classes/ClassWithPropCategories.md"
},
{
"title": "ClassWithSimpleProps",
Expand Down

0 comments on commit 310edc6

Please sign in to comment.