Skip to content

Commit 4aa1a6f

Browse files
authored
Merge branch 'main' into feature/disable-edit-gh-link-2
2 parents 18ca638 + fb91e75 commit 4aa1a6f

File tree

7 files changed

+31
-23
lines changed

7 files changed

+31
-23
lines changed

config/legacy-url-mappings.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# TODO: Refactor the model, for now we just use the first element as current version
55
#############################################
66

7-
stack: &stack [ '9.0+', '8.18', '8.17', '8.16', '8.15', '8.14', '8.13', '8.12', '8.11', '8.10', '8.9', '8.8', '8.7', '8.6', '8.5', '8.4', '8.3', '8.2', '8.1', '8.0', '7.17' ]
7+
stack: &stack [ '9.0+', '8.19', '8.18', '8.17', '8.16', '8.15', '8.14', '8.13', '8.12', '8.11', '8.10', '8.9', '8.8', '8.7', '8.6', '8.5', '8.4', '8.3', '8.2', '8.1', '8.0', '7.17' ]
88

99
mappings:
1010
en/apm/agent/android/: [ '1.0.0' , '0.x' ]
@@ -32,7 +32,7 @@ mappings:
3232
en/beats/topbeat/: *stack
3333
en/beats/winlogbeat/: *stack
3434
en/cloud-heroku/: []
35-
en/cloud-on-k8s/: [ '3.0.0', '2.16', '2.15', '2.14', '2.13', '2.12', '2.11', '2.10', '2.9', '2.8', '2.7', '2.6', '2.5', '2.4', '2.3', '2.2', '2.1', '2.0', '1.9', '1.8', '1.7', '1.6', '1.5', '1.4', '1.3', '1.2', '1.1', '1.0' ]
35+
en/cloud-on-k8s/: [ '3.0+', '2.16', '2.15', '2.14', '2.13', '2.12', '2.11', '2.10', '2.9', '2.8', '2.7', '2.6', '2.5', '2.4', '2.3', '2.2', '2.1', '2.0', '1.9', '1.8', '1.7', '1.6', '1.5', '1.4', '1.3', '1.2', '1.1', '1.0' ]
3636
en/cloud/: []
3737
en/cloud-enterprise/: [ '4.0', '3.8', '3.7', '3.6', '3.5', '3.4', '3.3', '3.2', '3.1', '3.0', '2.13', '2.12', '2.11', '2.10', '2.9', '2.8', '2.7', '2.6', '2.5', '2.4', '2.3', '2.2', '2.1', '2.0', '1.1', '1.0' ]
3838
en/ecctl/: [ '1.14+', '1.13', '1.12', '1.11', '1.10', '1.9', '1.8', '1.7', '1.6', '1.5', '1.4', '1.3', '1.2', '1.1', '1.0' ]

config/versions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ versioning_systems:
1919
ech: *all
2020
eck:
2121
base: 3.0
22-
current: 3.0.0
22+
current: 3.1.0
2323
ess: *all
2424
self: *stack
2525
ecctl:
@@ -82,7 +82,7 @@ versioning_systems:
8282
current: 1.5.0
8383
edot_node:
8484
base: 1.0
85-
current: 1.1.1
85+
current: 1.2.0
8686
edot_php:
8787
base: 1.0
8888
current: 1.1.1
2.5 KB
Binary file not shown.

src/Elastic.Markdown/Myst/Directives/Image/ImageBlock.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public class ImageBlock(DirectiveBlockParser parser, ParserContext context)
6868

6969
public string? Label { get; private set; }
7070

71+
private static readonly HashSet<string> AllowedUriHosts = ["epr.elastic.co"];
72+
7173
public override void FinalizeAndValidate(ParserContext context)
7274
{
7375
Label = Prop("label", "name");
@@ -98,7 +100,9 @@ private void ExtractImageUrl(ParserContext context)
98100

99101
if (Uri.TryCreate(imageUrl, UriKind.Absolute, out var uri) && uri.Scheme.StartsWith("http"))
100102
{
101-
this.EmitWarning($"{Directive} is using an external URI: {uri} ");
103+
if (!AllowedUriHosts.Contains(uri.Host))
104+
this.EmitWarning($"{Directive} is using an external URI: {uri} ");
105+
102106
Found = true;
103107
ImageUrl = imageUrl;
104108
return;

src/tooling/docs-assembler/Cli/RepositoryCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public async Task<int> BuildAll(
169169
var navigation = new GlobalNavigation(assembleSources, navigationFile);
170170

171171
var pathProvider = new GlobalNavigationPathProvider(navigationFile, assembleSources, assembleContext);
172-
var htmlWriter = new GlobalNavigationHtmlWriter(logFactory, navigation);
172+
var htmlWriter = new GlobalNavigationHtmlWriter(logFactory, navigation, collector);
173173
var legacyPageChecker = new LegacyPageChecker();
174174
var historyMapper = new PageLegacyUrlMapper(legacyPageChecker, assembleSources.HistoryMappings);
175175

src/tooling/docs-assembler/Navigation/GlobalNavigation.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public GlobalNavigation(AssembleSources assembleSources, GlobalNavigationFile na
4747

4848
var navigationIndex = 0;
4949
var allNavigationItems = new HashSet<INavigationItem>();
50-
UpdateParent(allNavigationItems, NavigationItems, null);
50+
UpdateParent(allNavigationItems, NavigationItems, null, null);
5151
UpdateNavigationIndex(NavigationItems, ref navigationIndex);
5252
TopLevelItems = NavigationItems.OfType<TableOfContentsTree>().Where(t => !t.Hidden).ToList();
5353
NavigationLookup = TopLevelItems.ToDictionary(kv => kv.Source, kv => kv);
@@ -64,23 +64,30 @@ public GlobalNavigation(AssembleSources assembleSources, GlobalNavigationFile na
6464
private void UpdateParent(
6565
HashSet<INavigationItem> allNavigationItems,
6666
IReadOnlyCollection<INavigationItem> navigationItems,
67-
INodeNavigationItem<INavigationModel, INavigationItem>? parent
67+
INodeNavigationItem<INavigationModel, INavigationItem>? parent,
68+
IRootNavigationItem<INavigationModel, INavigationItem>? topLevelNavigation
6869
)
6970
{
71+
if (parent is IRootNavigationItem<INavigationModel, INavigationItem> tree)
72+
topLevelNavigation ??= tree;
7073
foreach (var item in navigationItems)
7174
{
7275
switch (item)
7376
{
7477
case FileNavigationItem fileNavigationItem:
7578
if (parent is not null)
7679
fileNavigationItem.Parent = parent;
80+
if (topLevelNavigation is not null)
81+
fileNavigationItem.Model.NavigationRoot = topLevelNavigation;
7782
_ = allNavigationItems.Add(fileNavigationItem);
7883
break;
7984
case DocumentationGroup documentationGroup:
8085
if (parent is not null)
8186
documentationGroup.Parent = parent;
87+
if (topLevelNavigation is not null)
88+
documentationGroup.Index.NavigationRoot = topLevelNavigation;
8289
_ = allNavigationItems.Add(documentationGroup);
83-
UpdateParent(allNavigationItems, documentationGroup.NavigationItems, documentationGroup);
90+
UpdateParent(allNavigationItems, documentationGroup.NavigationItems, documentationGroup, topLevelNavigation);
8491
break;
8592
default:
8693
_navigationFile.EmitError($"Unhandled navigation item type: {item.GetType()}");

src/tooling/docs-assembler/Navigation/GlobalNavigationHtmlWriter.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,45 @@
33
// See the LICENSE file in the project root for more information
44

55
using System.Collections.Concurrent;
6+
using Elastic.Documentation.Diagnostics;
67
using Elastic.Documentation.Site.Navigation;
78
using Elastic.Markdown.IO.Navigation;
89
using Microsoft.Extensions.Logging;
910

1011
namespace Documentation.Assembler.Navigation;
1112

12-
public class GlobalNavigationHtmlWriter(ILoggerFactory logFactory, GlobalNavigation globalNavigation) : INavigationHtmlWriter
13+
public class GlobalNavigationHtmlWriter(ILoggerFactory logFactory, GlobalNavigation globalNavigation, DiagnosticsCollector collector) : INavigationHtmlWriter
1314
{
1415
private readonly ILogger<Program> _logger = logFactory.CreateLogger<Program>();
1516

1617
private readonly ConcurrentDictionary<(string, int), string> _renderedNavigationCache = [];
1718

1819
public async Task<NavigationRenderResult> RenderNavigation(IRootNavigationItem<INavigationModel, INavigationItem> currentRootNavigation, int maxLevel, Cancel ctx = default)
1920
{
20-
INodeNavigationItem<INavigationModel, INavigationItem> lastParentBeforeRoot = currentRootNavigation;
21-
INodeNavigationItem<INavigationModel, INavigationItem> parent = currentRootNavigation;
22-
while (parent.Parent is not null)
23-
{
24-
lastParentBeforeRoot = parent;
25-
parent = parent.Parent;
26-
}
27-
if (_renderedNavigationCache.TryGetValue((lastParentBeforeRoot.Id, maxLevel), out var html))
21+
if (currentRootNavigation.Parent is not null && currentRootNavigation.Parent.Depth != 0)
22+
collector.EmitGlobalError($"Passed root is not actually a top level navigation item {currentRootNavigation.NavigationTitle} ({currentRootNavigation.Id}) in {currentRootNavigation.Url}");
23+
24+
if (_renderedNavigationCache.TryGetValue((currentRootNavigation.Id, maxLevel), out var html))
2825
{
2926
return new NavigationRenderResult
3027
{
3128
Html = html,
32-
Id = lastParentBeforeRoot.Id
29+
Id = currentRootNavigation.Id
3330
};
3431
}
3532

36-
_logger.LogInformation("Rendering navigation for {NavigationTitle} ({Id})", lastParentBeforeRoot.NavigationTitle, lastParentBeforeRoot.Id);
33+
_logger.LogInformation("Rendering navigation for {NavigationTitle} ({Id})", currentRootNavigation.NavigationTitle, currentRootNavigation.Id);
3734

38-
if (lastParentBeforeRoot is not DocumentationGroup group)
35+
if (currentRootNavigation is not DocumentationGroup group)
3936
return NavigationRenderResult.Empty;
4037

4138
var model = CreateNavigationModel(group, maxLevel);
4239
html = await ((INavigationHtmlWriter)this).Render(model, ctx);
43-
_renderedNavigationCache[(lastParentBeforeRoot.Id, maxLevel)] = html;
40+
_renderedNavigationCache[(currentRootNavigation.Id, maxLevel)] = html;
4441
return new NavigationRenderResult
4542
{
4643
Html = html,
47-
Id = lastParentBeforeRoot.Id
44+
Id = currentRootNavigation.Id
4845
};
4946
}
5047

0 commit comments

Comments
 (0)