Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assembler share single crosslink resolver over all the builds #726

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/docs-assembler/Building/AssemblerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using Documentation.Assembler.Sourcing;
using Elastic.Markdown;
using Elastic.Markdown.CrossLinks;
using Elastic.Markdown.IO;
using Microsoft.Extensions.Logging;

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

public async Task BuildAllAsync(IReadOnlyCollection<Checkout> checkouts, Cancel ctx)
{
var crossLinkResolver = new CrossLinkResolver(new AssemblerCrossLinkFetcher(logger, context.Configuration));

foreach (var checkout in checkouts)
{
try
{
await BuildAsync(checkout, ctx);
await BuildAsync(checkout, crossLinkResolver, ctx);
}
catch (Exception e) when (e.Message.Contains("Can not locate docset.yml file in"))
{
Expand All @@ -34,7 +37,7 @@ public async Task BuildAllAsync(IReadOnlyCollection<Checkout> checkouts, Cancel
}
}

private async Task BuildAsync(Checkout checkout, Cancel ctx)
private async Task BuildAsync(Checkout checkout, CrossLinkResolver crossLinkResolver, Cancel ctx)
{
var path = checkout.Directory.FullName;
var pathPrefix = checkout.Repository.PathPrefix;
Expand All @@ -46,7 +49,8 @@ private async Task BuildAsync(Checkout checkout, Cancel ctx)
Force = true,
AllowIndexing = true
};
var set = new DocumentationSet(buildContext, logger);

var set = new DocumentationSet(buildContext, logger, crossLinkResolver);
var generator = new DocumentationGenerator(set, logger);
await generator.GenerateAll(ctx);
}
Expand Down
38 changes: 38 additions & 0 deletions src/docs-assembler/Building/AssemblerCrossLinkFetcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.Collections.Frozen;
using Documentation.Assembler.Configuration;
using Elastic.Markdown.CrossLinks;
using Elastic.Markdown.IO.State;
using Microsoft.Extensions.Logging;

namespace Documentation.Assembler.Building;

public class AssemblerCrossLinkFetcher(ILoggerFactory logger, AssemblyConfiguration configuration) : CrossLinkFetcher(logger)
{
public override async Task<FetchedCrossLinks> Fetch()
{
var dictionary = new Dictionary<string, LinkReference>();
var declaredRepositories = new HashSet<string>();
var repositories = configuration.ReferenceRepositories.Values.Concat<Repository>([configuration.Narrative]);

foreach (var repository in repositories)
{
if (repository.Skip)
continue;
var repositoryName = repository.Name;
_ = declaredRepositories.Add(repositoryName);
var linkReference = await Fetch(repositoryName);
dictionary.Add(repositoryName, linkReference);
}

return new FetchedCrossLinks
{
DeclaredRepositories = declaredRepositories,
LinkReferences = dictionary.ToFrozenDictionary(),
FromConfiguration = true
};
}
}
3 changes: 3 additions & 0 deletions src/docs-assembler/Configuration/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ public virtual string? PathPrefix
get => _pathPrefix ?? $"reference/{Name}";
set => _pathPrefix = value;
}

[YamlMember(Alias = "skip")]
public bool Skip { get; set; }
}
16 changes: 16 additions & 0 deletions src/docs-assembler/assembler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,29 @@ references:
apm-agent-ios:
apm-agent-java:
apm-agent-nodejs:
skip: true
apm-agent-php:
skip: true
apm-agent-python:
skip: true
apm-agent-ruby:
skip: true
apm-agent-rum-js:
skip: true
apm-aws-lambda:
apm-k8s-attacher:
beats:
skip: true
cloud-on-k8s:
cloud:
current: master
skip: true
curator:
current: master
skip: true
ecctl:
current: master
skip: true
ecs-dotnet:
ecs-logging-go-logrus:
ecs-logging-go-zap:
Expand All @@ -32,22 +41,29 @@ references:
ecs-logging-ruby:
ecs-logging:
ecs:
skip: true
eland:
elastic-serverless-forwarder:
elasticsearch-hadoop:
elasticsearch-java:
elasticsearch-js:
elasticsearch-net:
# failures on main https://github.com/elastic/elasticsearch-net/actions/runs/13594875271/job/38009389173
skip: true
elasticsearch-php:
elasticsearch-py:
elasticsearch-rs:
# needs a dummy PR to docs
skip: true
elasticsearch-ruby:
elasticsearch:
go-elasticsearch:
integrations:
kibana:
logstash-docs:
skip: true
logstash:
search-ui:
integration-docs:
skip: true
security-docs: