Skip to content

Commit 0a135ad

Browse files
authored
Assembler share single crosslink resolver over all the builds (#726)
1 parent 5bdd697 commit 0a135ad

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

src/docs-assembler/Building/AssemblerBuilder.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using Documentation.Assembler.Sourcing;
66
using Elastic.Markdown;
7+
using Elastic.Markdown.CrossLinks;
78
using Elastic.Markdown.IO;
89
using Microsoft.Extensions.Logging;
910

@@ -15,11 +16,13 @@ public class AssemblerBuilder(ILoggerFactory logger, AssembleContext context)
1516

1617
public async Task BuildAllAsync(IReadOnlyCollection<Checkout> checkouts, Cancel ctx)
1718
{
19+
var crossLinkResolver = new CrossLinkResolver(new AssemblerCrossLinkFetcher(logger, context.Configuration));
20+
1821
foreach (var checkout in checkouts)
1922
{
2023
try
2124
{
22-
await BuildAsync(checkout, ctx);
25+
await BuildAsync(checkout, crossLinkResolver, ctx);
2326
}
2427
catch (Exception e) when (e.Message.Contains("Can not locate docset.yml file in"))
2528
{
@@ -34,7 +37,7 @@ public async Task BuildAllAsync(IReadOnlyCollection<Checkout> checkouts, Cancel
3437
}
3538
}
3639

37-
private async Task BuildAsync(Checkout checkout, Cancel ctx)
40+
private async Task BuildAsync(Checkout checkout, CrossLinkResolver crossLinkResolver, Cancel ctx)
3841
{
3942
var path = checkout.Directory.FullName;
4043
var pathPrefix = checkout.Repository.PathPrefix;
@@ -46,7 +49,8 @@ private async Task BuildAsync(Checkout checkout, Cancel ctx)
4649
Force = true,
4750
AllowIndexing = true
4851
};
49-
var set = new DocumentationSet(buildContext, logger);
52+
53+
var set = new DocumentationSet(buildContext, logger, crossLinkResolver);
5054
var generator = new DocumentationGenerator(set, logger);
5155
await generator.GenerateAll(ctx);
5256
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.Collections.Frozen;
6+
using Documentation.Assembler.Configuration;
7+
using Elastic.Markdown.CrossLinks;
8+
using Elastic.Markdown.IO.State;
9+
using Microsoft.Extensions.Logging;
10+
11+
namespace Documentation.Assembler.Building;
12+
13+
public class AssemblerCrossLinkFetcher(ILoggerFactory logger, AssemblyConfiguration configuration) : CrossLinkFetcher(logger)
14+
{
15+
public override async Task<FetchedCrossLinks> Fetch()
16+
{
17+
var dictionary = new Dictionary<string, LinkReference>();
18+
var declaredRepositories = new HashSet<string>();
19+
var repositories = configuration.ReferenceRepositories.Values.Concat<Repository>([configuration.Narrative]);
20+
21+
foreach (var repository in repositories)
22+
{
23+
if (repository.Skip)
24+
continue;
25+
var repositoryName = repository.Name;
26+
_ = declaredRepositories.Add(repositoryName);
27+
var linkReference = await Fetch(repositoryName);
28+
dictionary.Add(repositoryName, linkReference);
29+
}
30+
31+
return new FetchedCrossLinks
32+
{
33+
DeclaredRepositories = declaredRepositories,
34+
LinkReferences = dictionary.ToFrozenDictionary(),
35+
FromConfiguration = true
36+
};
37+
}
38+
}

src/docs-assembler/Configuration/Repository.cs

+3
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,7 @@ public virtual string? PathPrefix
3434
get => _pathPrefix ?? $"reference/{Name}";
3535
set => _pathPrefix = value;
3636
}
37+
38+
[YamlMember(Alias = "skip")]
39+
public bool Skip { get; set; }
3740
}

src/docs-assembler/assembler.yml

+16
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,29 @@ references:
77
apm-agent-ios:
88
apm-agent-java:
99
apm-agent-nodejs:
10+
skip: true
1011
apm-agent-php:
12+
skip: true
1113
apm-agent-python:
14+
skip: true
1215
apm-agent-ruby:
16+
skip: true
1317
apm-agent-rum-js:
18+
skip: true
1419
apm-aws-lambda:
1520
apm-k8s-attacher:
1621
beats:
22+
skip: true
1723
cloud-on-k8s:
1824
cloud:
1925
current: master
26+
skip: true
2027
curator:
2128
current: master
29+
skip: true
2230
ecctl:
2331
current: master
32+
skip: true
2433
ecs-dotnet:
2534
ecs-logging-go-logrus:
2635
ecs-logging-go-zap:
@@ -32,22 +41,29 @@ references:
3241
ecs-logging-ruby:
3342
ecs-logging:
3443
ecs:
44+
skip: true
3545
eland:
3646
elastic-serverless-forwarder:
3747
elasticsearch-hadoop:
3848
elasticsearch-java:
3949
elasticsearch-js:
4050
elasticsearch-net:
51+
# failures on main https://github.com/elastic/elasticsearch-net/actions/runs/13594875271/job/38009389173
52+
skip: true
4153
elasticsearch-php:
4254
elasticsearch-py:
4355
elasticsearch-rs:
56+
# needs a dummy PR to docs
57+
skip: true
4458
elasticsearch-ruby:
4559
elasticsearch:
4660
go-elasticsearch:
4761
integrations:
4862
kibana:
4963
logstash-docs:
64+
skip: true
5065
logstash:
5166
search-ui:
5267
integration-docs:
68+
skip: true
5369
security-docs:

0 commit comments

Comments
 (0)