From cbd5feb2f6902c8a8f358297f313734e2d37ac06 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Tue, 15 Apr 2025 10:05:16 +0200 Subject: [PATCH 1/2] Ensure we set rootnavigation to the top level item, not the overall set --- src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs b/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs index a0a98dd81..58cf2b7ba 100644 --- a/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs +++ b/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs @@ -116,6 +116,8 @@ internal TableOfContentsTree( TreeCollector.Collect(source, this); } + protected override DocumentationGroup DefaultNavigation => this; + } [DebuggerDisplay("Group >{Depth} {FolderName} ({NavigationItems.Count} items)")] @@ -147,6 +149,8 @@ public class DocumentationGroup : INavigationGroup public string FolderName { get; } + protected virtual DocumentationGroup DefaultNavigation => this; + protected DocumentationGroup( TableOfContentsTreeCollector treeCollector, BuildContext context, @@ -179,6 +183,9 @@ protected DocumentationGroup( _treeCollector = treeCollector; Depth = depth; toplevelTree ??= this; + toplevelTree ??= DefaultNavigation; + if (parent?.Depth == 0) + toplevelTree = DefaultNavigation; NavigationRoot = toplevelTree; // ReSharper restore VirtualMemberCallInConstructor Index = ProcessTocItems(context, toplevelTree, index, lookups, depth, ref fileIndex, out var groups, out var files, out var navigationItems); From 17b7c69ae505781ff4310f47fa0a168abdf3ba6e Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Tue, 15 Apr 2025 10:09:30 +0200 Subject: [PATCH 2/2] address compiler warnings and erroneous assignment --- src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs b/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs index 58cf2b7ba..60b9f02c9 100644 --- a/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs +++ b/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs @@ -182,10 +182,13 @@ protected DocumentationGroup( NavigationSource = navigationSource; _treeCollector = treeCollector; Depth = depth; - toplevelTree ??= this; + // Virtual calls don't use state so while ugly not an issue + // We'll need to address this more structurally + // ReSharper disable VirtualMemberCallInConstructor toplevelTree ??= DefaultNavigation; if (parent?.Depth == 0) toplevelTree = DefaultNavigation; + // ReSharper enable VirtualMemberCallInConstructor NavigationRoot = toplevelTree; // ReSharper restore VirtualMemberCallInConstructor Index = ProcessTocItems(context, toplevelTree, index, lookups, depth, ref fileIndex, out var groups, out var files, out var navigationItems);