Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using ConsoleAppFramework;
using Elastic.Documentation.Configuration;
using Elastic.Documentation.Configuration.Assembler;
using Elastic.Documentation.Tooling.Exporters;
using Elastic.Markdown.Exporters;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -60,7 +61,8 @@ public static class ExporterExtensions
public static IReadOnlyCollection<IMarkdownExporter> CreateMarkdownExporters(
this IReadOnlySet<Exporter> exportOptions,
ILoggerFactory logFactory,
IDocumentationConfigurationContext context
IDocumentationConfigurationContext context,
PublishEnvironment? environment = null
)
{
var markdownExporters = new List<IMarkdownExporter>(3);
Expand All @@ -71,7 +73,11 @@ IDocumentationConfigurationContext context
if (exportOptions.Contains(Elasticsearch))
markdownExporters.Add(new ElasticsearchMarkdownExporter(logFactory, context.Collector, context.Endpoints));
if (exportOptions.Contains(SemanticElasticsearch))
markdownExporters.Add(new ElasticsearchMarkdownSemanticExporter(logFactory, context.Collector, context.Endpoints));
{
if (environment is null)
throw new ArgumentNullException(nameof(environment), "A publish environment is required when using the semantic elasticsearch exporter");
markdownExporters.Add(new ElasticsearchMarkdownSemanticExporter(environment, logFactory, context.Collector, context.Endpoints));
}
return markdownExporters;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO.Abstractions;
using Elastic.Channels;
using Elastic.Documentation.Configuration;
using Elastic.Documentation.Configuration.Assembler;
using Elastic.Documentation.Diagnostics;
using Elastic.Documentation.Search;
using Elastic.Documentation.Serialization;
Expand Down Expand Up @@ -36,7 +37,7 @@ public class ElasticsearchMarkdownExporter(ILoggerFactory logFactory, IDiagnosti
protected override CatalogIndexChannel<DocumentationDocument> NewChannel(CatalogIndexChannelOptions<DocumentationDocument> options) => new(options);
}

public class ElasticsearchMarkdownSemanticExporter(ILoggerFactory logFactory, IDiagnosticsCollector collector, DocumentationEndpoints endpoints)
public class ElasticsearchMarkdownSemanticExporter(PublishEnvironment environment, ILoggerFactory logFactory, IDiagnosticsCollector collector, DocumentationEndpoints endpoints)
: ElasticsearchMarkdownExporterBase<SemanticIndexChannelOptions<DocumentationDocument>, SemanticIndexChannel<DocumentationDocument>>
(logFactory, collector, endpoints)
{
Expand All @@ -45,8 +46,8 @@ public class ElasticsearchMarkdownSemanticExporter(ILoggerFactory logFactory, ID
{
GetMapping = (inferenceId, _) => CreateMapping(inferenceId),
GetMappingSettings = (_, _) => CreateMappingSetting(),
IndexFormat = "semantic-documentation-{0:yyyy.MM.dd.HHmmss}",
ActiveSearchAlias = "semantic-documentation",
IndexFormat = $"semantic-docs-{environment.Name}-{{0:yyyy.MM.dd.HHmmss}}",
ActiveSearchAlias = $"semantic-docs-{environment.Name}",
IndexNumThreads = IndexNumThreads,
InferenceCreateTimeout = TimeSpan.FromMinutes(4)
};
Expand Down
5 changes: 3 additions & 2 deletions src/tooling/docs-assembler/Building/AssemblerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text.Json;
using Documentation.Assembler.Navigation;
using Elastic.Documentation;
using Elastic.Documentation.Configuration.Assembler;
using Elastic.Documentation.Legacy;
using Elastic.Documentation.Links;
using Elastic.Documentation.Serialization;
Expand All @@ -32,15 +33,15 @@ public class AssemblerBuilder(

private ILegacyUrlMapper? LegacyUrlMapper { get; } = legacyUrlMapper;

public async Task BuildAllAsync(FrozenDictionary<string, AssemblerDocumentationSet> assembleSets, IReadOnlySet<Exporter> exportOptions, Cancel ctx)
public async Task BuildAllAsync(PublishEnvironment environment, FrozenDictionary<string, AssemblerDocumentationSet> assembleSets, IReadOnlySet<Exporter> exportOptions, Cancel ctx)
{
if (context.OutputDirectory.Exists)
context.OutputDirectory.Delete(true);
context.OutputDirectory.Create();

var redirects = new Dictionary<string, string>();

var markdownExporters = exportOptions.CreateMarkdownExporters(logFactory, context);
var markdownExporters = exportOptions.CreateMarkdownExporters(logFactory, context, environment);

var tasks = markdownExporters.Select(async e => await e.StartAsync(ctx));
await Task.WhenAll(tasks);
Expand Down
3 changes: 2 additions & 1 deletion src/tooling/docs-assembler/Cli/RepositoryCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ public async Task<int> BuildAll(
var historyMapper = new PageLegacyUrlMapper(legacyPageChecker, assembleSources.HistoryMappings);

var builder = new AssemblerBuilder(logFactory, assembleContext, navigation, htmlWriter, pathProvider, historyMapper);
await builder.BuildAllAsync(assembleSources.AssembleSets, exporters, ctx);

await builder.BuildAllAsync(assembleContext.Environment, assembleSources.AssembleSets, exporters, ctx);

if (exporters.Contains(Exporter.LinkMetadata))
await cloner.WriteLinkRegistrySnapshot(checkoutResult.LinkRegistrySnapshot, ctx);
Expand Down
Loading