Skip to content

Commit 98439f9

Browse files
committed
Additional cleanups and test fixtures
1 parent 234055b commit 98439f9

File tree

27 files changed

+42
-186
lines changed

27 files changed

+42
-186
lines changed

src/Elastic.ApiExplorer/ApiIndexLeafNavigation.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public class ApiIndexLeafNavigation<TModel>(
3131
/// <inheritdoc />
3232
public int NavigationIndex { get; set; }
3333

34-
/// <inheritdoc />
35-
public bool IsCrossLink { get; }
36-
3734
/// <inheritdoc />
3835
public TModel Model { get; } = model;
3936
}

src/Elastic.ApiExplorer/Landing/LandingNavigationItem.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public class LandingNavigationItem : IApiGroupingNavigationItem<ApiLanding, INav
2828
{
2929
public IRootNavigationItem<INavigationModel, INavigationItem> NavigationRoot { get; }
3030
public string Id { get; }
31-
public int Depth { get; }
3231
public ILeafNavigationItem<ApiLanding> Index { get; }
3332
public IReadOnlyCollection<INavigationItem> NavigationItems { get; set; } = [];
3433
public INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }
@@ -42,7 +41,6 @@ public class LandingNavigationItem : IApiGroupingNavigationItem<ApiLanding, INav
4241

4342
public LandingNavigationItem(string url)
4443
{
45-
Depth = 0;
4644
NavigationRoot = this;
4745
Id = ShortId.Create("root");
4846
var landing = new ApiLanding();
@@ -90,9 +88,6 @@ INodeNavigationItem<INavigationModel, INavigationItem> parent
9088

9189
public Uri Identifier { get; } = new Uri("todo://");
9290

93-
/// <inheritdoc />
94-
public int Depth => 0;
95-
9691
/// <inheritdoc />
9792
public abstract string Id { get; }
9893

@@ -154,9 +149,6 @@ public class EndpointNavigationItem(ApiEndpoint endpoint, IRootNavigationItem<IA
154149
public int NavigationIndex { get; set; }
155150
public bool IsCrossLink => false; // API endpoint items are never cross-links
156151

157-
/// <inheritdoc />
158-
public int Depth => 0;
159-
160152
/// <inheritdoc />
161153
public string Id { get; } = ShortId.Create(nameof(EndpointNavigationItem), endpoint.Operations.First().ApiName, endpoint.Operations.First().Route);
162154

src/Elastic.Documentation.Configuration/Builder/ConfigurationFile.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
using DotNet.Globbing;
77
using Elastic.Documentation.Configuration.DocSet;
88
using Elastic.Documentation.Configuration.Products;
9-
using Elastic.Documentation.Configuration.Suggestions;
109
using Elastic.Documentation.Configuration.Versions;
1110
using Elastic.Documentation.Links;
12-
using Elastic.Documentation.Navigation;
1311

1412
namespace Elastic.Documentation.Configuration.Builder;
1513

src/Elastic.Documentation.Configuration/Converters/HintTypeSetConverter.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ public class HintTypeSetConverter : IYamlTypeConverter
3434
if (parser.Current is Scalar scalar)
3535
{
3636
var value = scalar.Value;
37-
if (!string.IsNullOrWhiteSpace(value) &&
38-
Enum.TryParse<HintType>(value, ignoreCase: true, out var hintType))
39-
{
37+
if (!string.IsNullOrWhiteSpace(value) && Enum.TryParse<HintType>(value, ignoreCase: true, out var hintType))
4038
_ = result.Add(hintType);
41-
}
4239
}
4340
_ = parser.MoveNext();
4441
}
@@ -59,9 +56,7 @@ public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializ
5956

6057
emitter.Emit(new SequenceStart(null, null, false, SequenceStyle.Block));
6158
foreach (var hint in set)
62-
{
6359
emitter.Emit(new Scalar(hint.ToString()));
64-
}
6560
emitter.Emit(new SequenceEnd());
6661
}
6762
}

src/Elastic.Documentation.Configuration/DocSet/DocumentationSetFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static FileRef[] GetFileRefs(ITableOfContentsItem item)
7171
return folderRef.Children.SelectMany(GetFileRefs).ToArray();
7272
if (item is IsolatedTableOfContentsRef tocRef)
7373
return tocRef.Children.SelectMany(GetFileRefs).ToArray();
74-
if (item is CrossLinkRef crossLinkRef)
74+
if (item is CrossLinkRef)
7575
return [];
7676
throw new Exception($"Unexpected item type {item.GetType().Name}");
7777
}

src/Elastic.Documentation.LegacyDocs/PageLegacyUrlMapper.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ public PageLegacyUrlMapper(LegacyPageService legacyPageService, VersionsConfigur
2929
var mappedPage = mappedPages.First();
3030

3131
if (LegacyUrlMappings.Mappings.FirstOrDefault(x => mappedPage.Contains(x.BaseUrl, StringComparison.OrdinalIgnoreCase)) is not { } legacyMappingMatch)
32-
{
3332
return [new LegacyPageMapping(LegacyUrlMappings.Mappings.First(x => x.Product.Id.Equals("elastic-stack", StringComparison.OrdinalIgnoreCase)).Product, mappedPages.FirstOrDefault() ?? string.Empty, DefaultVersion, false)];
34-
}
3533

3634
var allVersions = new List<LegacyPageMapping>();
3735

src/Elastic.Documentation.Navigation/Assembler/AssembledNavigation.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ public SiteNavigation(
3131
// Initialize root properties
3232
NavigationRoot = this;
3333
Parent = null;
34-
Depth = 0;
3534
Hidden = false;
36-
IsCrossLink = false;
3735
Id = ShortId.Create("site");
3836
IsUsingNavigationDropdown = false;
3937
Phantoms = siteNavigationFile.Phantoms;
@@ -74,8 +72,6 @@ public SiteNavigation(
7472
Index = indexNavigation;
7573
NavigationItems = navigationItems;
7674
_ = this.UpdateNavigationIndex(context);
77-
var count = UnseenNodes.Count;
78-
var unseen = string.Join(", ", UnseenNodes);
7975
foreach (var node in UnseenNodes)
8076
{
8177
// impossible since unseen nodes are build from _nodes
@@ -127,12 +123,6 @@ public SiteNavigation(
127123
/// <inheritdoc />
128124
public int NavigationIndex { get; set; }
129125

130-
/// <inheritdoc />
131-
public bool IsCrossLink { get; }
132-
133-
/// <inheritdoc />
134-
public int Depth { get; }
135-
136126
/// <inheritdoc />
137127
public string Id { get; }
138128

src/Elastic.Documentation.Navigation/INavigationItem.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5-
using System.IO.Abstractions;
6-
75
namespace Elastic.Documentation.Navigation;
86

97
/// Represents navigation model data for documentation elements.
@@ -28,17 +26,11 @@ public interface INavigationItem
2826
/// <summary>
2927
/// Gets or sets the parent navigation item.
3028
/// </summary>
31-
/// <remarks>
32-
/// TODO: This should be read-only however currently needs the setter in assembler.
33-
/// </remarks>
3429
INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }
3530

3631
bool Hidden { get; }
3732

3833
int NavigationIndex { get; set; }
39-
40-
/// Gets whether this navigation item is a cross-link to another repository.
41-
bool IsCrossLink { get; }
4234
}
4335

4436
/// Represents a leaf node in the navigation tree with associated model data.
@@ -58,9 +50,6 @@ public interface INodeNavigationItem<out TIndex, out TChildNavigation> : INaviga
5850
where TIndex : INavigationModel
5951
where TChildNavigation : INavigationItem
6052
{
61-
/// Gets the depth level in the navigation hierarchy.
62-
int Depth { get; }
63-
6453
/// Gets the unique identifier for this node.
6554
string Id { get; }
6655

src/Elastic.Documentation.Navigation/Isolated/CrossLinkNavigationLeaf.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information
44

55
using System.Diagnostics;
6-
using System.IO.Abstractions;
76

87
namespace Elastic.Documentation.Navigation.Isolated;
98

src/Elastic.Documentation.Navigation/Isolated/DocumentationSetNavigation.cs

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ public DocumentationSetNavigation(
5454
// Initialize root properties
5555
_navigationRoot = root ?? this;
5656
Parent = parent;
57-
Depth = 0;
5857
Hidden = false;
59-
IsCrossLink = false;
6058
HomeProvider = this;
6159
Id = ShortId.Create(documentationSet.Project ?? "root");
6260
IsUsingNavigationDropdown = documentationSet.Features.PrimaryNav ?? false;
@@ -74,8 +72,7 @@ public DocumentationSetNavigation(
7472
index++,
7573
context,
7674
parent: this,
77-
homeAccessor: this,
78-
depth: Depth
75+
homeAccessor: this
7976
);
8077

8178
if (navItem != null)
@@ -134,7 +131,6 @@ public DocumentationSetNavigation(
134131
/// <inheritdoc />
135132
public string NavigationTitle => Index.NavigationTitle;
136133

137-
/// <inheritdoc />
138134
public IRootNavigationItem<INavigationModel, INavigationItem> NavigationRoot =>
139135
HomeProvider == this ? _navigationRoot : HomeProvider.NavigationRoot;
140136

@@ -147,13 +143,6 @@ public DocumentationSetNavigation(
147143
/// <inheritdoc />
148144
public int NavigationIndex { get; set; }
149145

150-
/// <inheritdoc />
151-
public bool IsCrossLink { get; }
152-
153-
/// <inheritdoc />
154-
public int Depth { get; }
155-
156-
/// <inheritdoc />
157146
public string Id { get; }
158147

159148
/// <inheritdoc />
@@ -180,15 +169,14 @@ internal void SetNavigationItems(IReadOnlyCollection<INavigationItem> navigation
180169
int index,
181170
IDocumentationSetContext context,
182171
INodeNavigationItem<INavigationModel, INavigationItem>? parent,
183-
INavigationHomeAccessor homeAccessor,
184-
int depth
172+
INavigationHomeAccessor homeAccessor
185173
) =>
186174
tocItem switch
187175
{
188176
FileRef fileRef => CreateFileNavigation(fileRef, index, context, parent, homeAccessor),
189177
CrossLinkRef crossLinkRef => CreateCrossLinkNavigation(crossLinkRef, index, parent, homeAccessor),
190-
FolderRef folderRef => CreateFolderNavigation(folderRef, index, context, parent, homeAccessor, depth),
191-
IsolatedTableOfContentsRef tocRef => CreateTocNavigation(tocRef, index, context, parent, homeAccessor, depth),
178+
FolderRef folderRef => CreateFolderNavigation(folderRef, index, context, parent, homeAccessor),
179+
IsolatedTableOfContentsRef tocRef => CreateTocNavigation(tocRef, index, context, parent, homeAccessor),
192180
_ => null
193181
};
194182

@@ -274,7 +262,6 @@ INavigationHomeAccessor homeAccessor
274262
fileRef.PathRelativeToContainer,
275263
fileRef.Hidden,
276264
index,
277-
parent?.Depth + 1 ?? 0,
278265
parent,
279266
homeAccessor
280267
);
@@ -289,8 +276,7 @@ INavigationHomeAccessor homeAccessor
289276
var childNav = ConvertToNavigationItem(
290277
child, childIndex++, context,
291278
fileNavigation,
292-
homeAccessor, // Files don't change the URL root
293-
0 // Depth will be set by child
279+
homeAccessor // Depth will be set by child
294280
);
295281
if (childNav != null)
296282
children.Add(childNav);
@@ -337,15 +323,14 @@ INavigationHomeAccessor homeAccessor
337323
int index,
338324
IDocumentationSetContext context,
339325
INodeNavigationItem<INavigationModel, INavigationItem>? parent,
340-
INavigationHomeAccessor homeAccessor,
341-
int depth
326+
INavigationHomeAccessor homeAccessor
342327
)
343328
{
344329
// FolderRef.Path already contains the correct path from LoadAndResolve
345330
var folderPath = folderRef.PathRelativeToDocumentationSet;
346331

347332
// Create folder navigation with null parent initially - we'll pass it to children but set it properly after
348-
var folderNavigation = new FolderNavigation<TModel>(depth + 1, folderPath, parent, homeAccessor)
333+
var folderNavigation = new FolderNavigation<TModel>(folderPath, parent, homeAccessor)
349334
{
350335
NavigationIndex = index
351336
};
@@ -362,8 +347,7 @@ int depth
362347
childIndex++,
363348
context,
364349
folderNavigation,
365-
homeAccessor, // Keep parent's home provider
366-
depth + 1
350+
homeAccessor
367351
);
368352

369353
if (childNav != null)
@@ -385,8 +369,7 @@ int depth
385369
int index,
386370
IDocumentationSetContext context,
387371
INodeNavigationItem<INavigationModel, INavigationItem>? parent,
388-
INavigationHomeAccessor homeAccessor,
389-
int depth
372+
INavigationHomeAccessor homeAccessor
390373
)
391374
{
392375
// tocRef.Path is now the FULL path (e.g., "guides/api" or "setup/advanced") after LoadAndResolve
@@ -407,7 +390,6 @@ int depth
407390
// Pass tocHomeProvider so the TOC uses parent's NavigationRoot (enables dynamic URL updates)
408391
var tocNavigation = new TableOfContentsNavigation<TModel>(
409392
tocDirectory,
410-
depth + 1,
411393
fullTocPath,
412394
parent, // Temporary null parent
413395
isolatedHomeProvider.PathPrefix,
@@ -433,8 +415,7 @@ int depth
433415
childIndex++,
434416
context,
435417
tocNavigation,
436-
childHomeAccessor,
437-
depth + 1
418+
childHomeAccessor
438419
);
439420

440421
if (childNav != null)

0 commit comments

Comments
 (0)