Skip to content

Commit c5f5b15

Browse files
committed
reorg
1 parent 98439f9 commit c5f5b15

29 files changed

+148
-57
lines changed

src/Elastic.Documentation.Navigation/Assembler/AssembledNavigation.cs renamed to src/Elastic.Documentation.Navigation/Assembler/SiteNavigation.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
using Elastic.Documentation.Configuration.DocSet;
99
using Elastic.Documentation.Extensions;
1010
using Elastic.Documentation.Navigation.Isolated;
11+
using Elastic.Documentation.Navigation.Isolated.Node;
1112

1213
namespace Elastic.Documentation.Navigation.Assembler;
1314

14-
public record SiteNavigationNoIndexFile(string NavigationTitle) : IDocumentationFile;
15-
16-
1715
[DebuggerDisplay("{Url}")]
1816
public class SiteNavigation : IRootNavigationItem<IDocumentationFile, INavigationItem>
1917
{
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
namespace Elastic.Documentation.Navigation;
6+
7+
/// <summary>
8+
/// Represents a documentation file that can be used in navigation.
9+
/// Extends <see cref="INavigationModel"/> with a navigation title.
10+
/// </summary>
11+
public interface IDocumentationFile : INavigationModel
12+
{
13+
/// <summary>
14+
/// Gets the title to display in navigation for this documentation file.
15+
/// </summary>
16+
string NavigationTitle { get; }
17+
}

src/Elastic.Documentation.Navigation/Isolated/IPathPrefixProvider.cs renamed to src/Elastic.Documentation.Navigation/INavigationHomeProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
// See the LICENSE file in the project root for more information
44

55
using System.Diagnostics;
6-
using Elastic.Documentation.Navigation.Assembler;
76

8-
namespace Elastic.Documentation.Navigation.Isolated;
7+
namespace Elastic.Documentation.Navigation;
98

109
public interface INavigationHomeProvider
1110
{
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
using System.IO.Abstractions;
6+
using Elastic.Documentation.Navigation.Isolated.Leaf;
7+
using Elastic.Documentation.Navigation.Isolated.Node;
8+
9+
namespace Elastic.Documentation.Navigation.Isolated;
10+
11+
/// <summary>
12+
/// Factory interface for creating documentation file models from file system paths.
13+
/// </summary>
14+
/// <typeparam name="TModel">The type of documentation file to create</typeparam>
15+
public interface IDocumentationFileFactory<out TModel> where TModel : IDocumentationFile
16+
{
17+
/// <summary>
18+
/// Attempts to create a documentation file model from the given file path.
19+
/// </summary>
20+
/// <param name="path">The file path to create a model for</param>
21+
/// <param name="readFileSystem">The file system to read from</param>
22+
/// <returns>A documentation file model, or null if creation failed</returns>
23+
TModel? TryCreateDocumentationFile(IFileInfo path, IFileSystem readFileSystem);
24+
}
25+
26+
/// <summary>
27+
/// Factory for creating navigation items from documentation files.
28+
/// </summary>
29+
public static class DocumentationNavigationFactory
30+
{
31+
/// <summary>
32+
/// Creates a file navigation leaf from a documentation file model.
33+
/// </summary>
34+
public static ILeafNavigationItem<TModel> CreateFileNavigationLeaf<TModel>(TModel model, IFileInfo fileInfo, FileNavigationArgs args)
35+
where TModel : IDocumentationFile =>
36+
new FileNavigationLeaf<TModel>(model, fileInfo, args) { NavigationIndex = args.NavigationIndex };
37+
38+
/// <summary>
39+
/// Creates a virtual file navigation node from a documentation file model.
40+
/// </summary>
41+
public static VirtualFileNavigation<TModel> CreateVirtualFileNavigation<TModel>(TModel model, IFileInfo fileInfo, VirtualFileNavigationArgs args)
42+
where TModel : IDocumentationFile =>
43+
new(model, fileInfo, args) { NavigationIndex = args.NavigationIndex };
44+
}

src/Elastic.Documentation.Navigation/Isolated/CrossLinkNavigationLeaf.cs renamed to src/Elastic.Documentation.Navigation/Isolated/Leaf/CrossLinkNavigationLeaf.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44

55
using System.Diagnostics;
66

7-
namespace Elastic.Documentation.Navigation.Isolated;
7+
namespace Elastic.Documentation.Navigation.Isolated.Leaf;
88

9+
/// <summary>
10+
/// Represents a cross-link to an external documentation resource.
11+
/// </summary>
12+
/// <param name="CrossLinkUri">The URI pointing to the external resource</param>
13+
/// <param name="NavigationTitle">The title to display in navigation</param>
914
public record CrossLinkModel(Uri CrossLinkUri, string NavigationTitle) : IDocumentationFile;
1015

1116
[DebuggerDisplay("{Url}")]
@@ -19,13 +24,13 @@ INavigationHomeAccessor homeAccessor
1924
: ILeafNavigationItem<CrossLinkModel>
2025
{
2126
/// <inheritdoc />
22-
public CrossLinkModel Model { get; init; } = model;
27+
public CrossLinkModel Model { get; } = model;
2328

2429
/// <inheritdoc />
25-
public string Url { get; init; } = url;
30+
public string Url { get; } = url;
2631

2732
/// <inheritdoc />
28-
public bool Hidden { get; init; } = hidden;
33+
public bool Hidden { get; } = hidden;
2934

3035
/// <inheritdoc />
3136
public IRootNavigationItem<INavigationModel, INavigationItem> NavigationRoot => homeAccessor.HomeProvider.NavigationRoot;
@@ -39,7 +44,4 @@ INavigationHomeAccessor homeAccessor
3944
/// <inheritdoc />
4045
public int NavigationIndex { get; set; }
4146

42-
/// <inheritdoc />
43-
public bool IsCrossLink => true;
44-
4547
}

src/Elastic.Documentation.Navigation/Isolated/FileNavigationLeaf.cs renamed to src/Elastic.Documentation.Navigation/Isolated/Leaf/FileNavigationLeaf.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,7 @@
77
using Elastic.Documentation.Extensions;
88
using Elastic.Documentation.Navigation.Assembler;
99

10-
namespace Elastic.Documentation.Navigation.Isolated;
11-
12-
public record FileNavigationArgs(
13-
string RelativePathToDocumentationSet,
14-
string RelativePathToTableOfContents,
15-
bool Hidden,
16-
int NavigationIndex,
17-
INodeNavigationItem<INavigationModel, INavigationItem>? Parent,
18-
INavigationHomeAccessor HomeAccessor
19-
);
10+
namespace Elastic.Documentation.Navigation.Isolated.Leaf;
2011

2112
[DebuggerDisplay("{Url}")]
2213
public class FileNavigationLeaf<TModel>(TModel model, IFileInfo fileInfo, FileNavigationArgs args) : ILeafNavigationItem<TModel>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
namespace Elastic.Documentation.Navigation.Isolated;
6+
7+
/// <summary>
8+
/// Arguments for creating a file navigation leaf.
9+
/// </summary>
10+
/// <param name="RelativePathToDocumentationSet">The relative path from the documentation set root</param>
11+
/// <param name="RelativePathToTableOfContents">The relative path from the table of contents root</param>
12+
/// <param name="Hidden">Whether this navigation item should be hidden from navigation</param>
13+
/// <param name="NavigationIndex">The index position in navigation</param>
14+
/// <param name="Parent">The parent navigation item</param>
15+
/// <param name="HomeAccessor">The home accessor for this navigation item</param>
16+
public record FileNavigationArgs(
17+
string RelativePathToDocumentationSet,
18+
string RelativePathToTableOfContents,
19+
bool Hidden,
20+
int NavigationIndex,
21+
INodeNavigationItem<INavigationModel, INavigationItem>? Parent,
22+
INavigationHomeAccessor HomeAccessor
23+
);
24+
25+
/// <summary>
26+
/// Arguments for creating a virtual file navigation node.
27+
/// </summary>
28+
/// <param name="RelativePathToDocumentationSet">The relative path from the documentation set root</param>
29+
/// <param name="RelativePathToTableOfContents">The relative path from the table of contents root</param>
30+
/// <param name="Hidden">Whether this navigation item should be hidden from navigation</param>
31+
/// <param name="NavigationIndex">The index position in navigation</param>
32+
/// <param name="Parent">The parent navigation item</param>
33+
/// <param name="HomeAccessor">The home accessor for this navigation item</param>
34+
public record VirtualFileNavigationArgs(
35+
string RelativePathToDocumentationSet,
36+
string RelativePathToTableOfContents,
37+
bool Hidden,
38+
int NavigationIndex,
39+
INodeNavigationItem<INavigationModel, INavigationItem>? Parent,
40+
INavigationHomeAccessor HomeAccessor
41+
);

src/Elastic.Documentation.Navigation/Isolated/DocumentationSetNavigation.cs renamed to src/Elastic.Documentation.Navigation/Isolated/Node/DocumentationSetNavigation.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,9 @@
66
using System.IO.Abstractions;
77
using Elastic.Documentation.Configuration.DocSet;
88
using Elastic.Documentation.Extensions;
9+
using Elastic.Documentation.Navigation.Isolated.Leaf;
910

10-
namespace Elastic.Documentation.Navigation.Isolated;
11-
12-
// A model for nodes in the navigation representing directories e.g., sets, toc's and folders.
13-
public interface IDocumentationFileFactory<out TModel> where TModel : IDocumentationFile
14-
{
15-
TModel? TryCreateDocumentationFile(IFileInfo path, IFileSystem readFileSystem);
16-
}
17-
18-
public static class DocumentationNavigationFactory
19-
{
20-
public static ILeafNavigationItem<TModel> CreateFileNavigationLeaf<TModel>(TModel model, IFileInfo fileInfo, FileNavigationArgs args)
21-
where TModel : IDocumentationFile =>
22-
new FileNavigationLeaf<TModel>(model, fileInfo, args) { NavigationIndex = args.NavigationIndex };
23-
24-
public static VirtualFileNavigation<TModel> CreateVirtualFileNavigation<TModel>(TModel model, IFileInfo fileInfo, VirtualFileNavigationArgs args)
25-
where TModel : IDocumentationFile =>
26-
new(model, fileInfo, args) { NavigationIndex = args.NavigationIndex };
27-
}
11+
namespace Elastic.Documentation.Navigation.Isolated.Node;
2812

2913
public interface IDocumentationSetNavigation
3014
{

src/Elastic.Documentation.Navigation/Isolated/FolderNavigation.cs renamed to src/Elastic.Documentation.Navigation/Isolated/Node/FolderNavigation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Diagnostics;
66
using Elastic.Documentation.Extensions;
77

8-
namespace Elastic.Documentation.Navigation.Isolated;
8+
namespace Elastic.Documentation.Navigation.Isolated.Node;
99

1010
[DebuggerDisplay("{Url}")]
1111
public class FolderNavigation<TModel>(

src/Elastic.Documentation.Navigation/Isolated/TableOfContentsNavigation.cs renamed to src/Elastic.Documentation.Navigation/Isolated/Node/TableOfContentsNavigation.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
using System.IO.Abstractions;
77
using Elastic.Documentation.Extensions;
88

9-
namespace Elastic.Documentation.Navigation.Isolated;
10-
11-
public interface IDocumentationFile : INavigationModel
12-
{
13-
string NavigationTitle { get; }
14-
}
9+
namespace Elastic.Documentation.Navigation.Isolated.Node;
1510

1611
[DebuggerDisplay("{Url}")]
1712
public class TableOfContentsNavigation<TModel> : IRootNavigationItem<TModel, INavigationItem>

0 commit comments

Comments
 (0)