diff --git a/src/tooling/docs-assembler/AssembleSources.cs b/src/tooling/docs-assembler/AssembleSources.cs index 49187a1b7..1bdcf6396 100644 --- a/src/tooling/docs-assembler/AssembleSources.cs +++ b/src/tooling/docs-assembler/AssembleSources.cs @@ -11,6 +11,7 @@ using Elastic.Documentation.Configuration; using Elastic.Documentation.Configuration.Assembler; using Elastic.Documentation.Configuration.Builder; +using Elastic.Documentation.Configuration.Versions; using Elastic.Documentation.LinkIndex; using Elastic.Markdown.IO.Navigation; using Elastic.Markdown.Links.CrossLinks; @@ -49,15 +50,15 @@ public class AssembleSources public PublishEnvironmentUriResolver UriResolver { get; } - public static async Task AssembleAsync(ILoggerFactory logger, AssembleContext context, Checkout[] checkouts, Cancel ctx) + public static async Task AssembleAsync(ILoggerFactory logger, AssembleContext context, Checkout[] checkouts, VersionsConfiguration versionsConfiguration, Cancel ctx) { - var sources = new AssembleSources(logger, context, checkouts); + var sources = new AssembleSources(logger, context, checkouts, versionsConfiguration); foreach (var (_, set) in sources.AssembleSets) await set.DocumentationSet.ResolveDirectoryTree(ctx); return sources; } - private AssembleSources(ILoggerFactory logger, AssembleContext assembleContext, Checkout[] checkouts) + private AssembleSources(ILoggerFactory logger, AssembleContext assembleContext, Checkout[] checkouts, VersionsConfiguration versionsConfiguration) { AssembleContext = assembleContext; TocTopLevelMappings = GetConfiguredSources(assembleContext); @@ -68,7 +69,7 @@ private AssembleSources(ILoggerFactory logger, AssembleContext assembleContext, var crossLinkResolver = new CrossLinkResolver(crossLinkFetcher, UriResolver); AssembleSets = checkouts .Where(c => c.Repository is { Skip: false }) - .Select(c => new AssemblerDocumentationSet(logger, assembleContext, c, crossLinkResolver, TreeCollector)) + .Select(c => new AssemblerDocumentationSet(logger, assembleContext, c, crossLinkResolver, TreeCollector, versionsConfiguration)) .ToDictionary(s => s.Checkout.Repository.Name, s => s) .ToFrozenDictionary(); diff --git a/src/tooling/docs-assembler/Cli/RepositoryCommands.cs b/src/tooling/docs-assembler/Cli/RepositoryCommands.cs index b09691413..b2b514cb9 100644 --- a/src/tooling/docs-assembler/Cli/RepositoryCommands.cs +++ b/src/tooling/docs-assembler/Cli/RepositoryCommands.cs @@ -123,7 +123,7 @@ public async Task BuildAll( throw new Exception("No checkouts found"); _log.LogInformation("Preparing all assemble sources for build"); - var assembleSources = await AssembleSources.AssembleAsync(logger, assembleContext, checkouts, ctx); + var assembleSources = await AssembleSources.AssembleAsync(logger, assembleContext, checkouts, versionsConfigOption.Value, ctx); var navigationFile = new GlobalNavigationFile(assembleContext, assembleSources); _log.LogInformation("Create global navigation"); diff --git a/src/tooling/docs-assembler/Navigation/AssemblerDocumentationSet.cs b/src/tooling/docs-assembler/Navigation/AssemblerDocumentationSet.cs index 9ae2885d8..723a5d2c2 100644 --- a/src/tooling/docs-assembler/Navigation/AssemblerDocumentationSet.cs +++ b/src/tooling/docs-assembler/Navigation/AssemblerDocumentationSet.cs @@ -29,7 +29,8 @@ public AssemblerDocumentationSet( AssembleContext context, Checkout checkout, CrossLinkResolver crossLinkResolver, - TableOfContentsTreeCollector treeCollector) + TableOfContentsTreeCollector treeCollector, + VersionsConfiguration versionsConfiguration) { AssembleContext = context; Checkout = checkout; @@ -49,26 +50,11 @@ public AssemblerDocumentationSet( Branch = checkout.Repository.GitReferenceCurrent }; - var versionsConfig = new VersionsConfiguration - { - VersioningSystems = new Dictionary - { - { - VersioningSystemId.Stack, new VersioningSystem - { - Id = VersioningSystemId.Stack, - Current = new SemVersion(8, 0, 0), - Base = new SemVersion(8, 0, 0) - } - } - } - }; - var buildContext = new BuildContext( context.Collector, context.ReadFileSystem, context.WriteFileSystem, - versionsConfig, + versionsConfiguration, path, output, gitConfiguration diff --git a/tests/docs-assembler.Tests/src/docs-assembler.Tests/GlobalNavigationTests.cs b/tests/docs-assembler.Tests/src/docs-assembler.Tests/GlobalNavigationTests.cs index 9d7117b90..6ba63df13 100644 --- a/tests/docs-assembler.Tests/src/docs-assembler.Tests/GlobalNavigationTests.cs +++ b/tests/docs-assembler.Tests/src/docs-assembler.Tests/GlobalNavigationTests.cs @@ -5,8 +5,10 @@ using System.IO.Abstractions; using Documentation.Assembler.Navigation; using Documentation.Assembler.Sourcing; +using Elastic.Documentation; using Elastic.Documentation.Configuration; using Elastic.Documentation.Configuration.Assembler; +using Elastic.Documentation.Configuration.Versions; using Elastic.Documentation.Diagnostics; using Elastic.Documentation.Site.Navigation; using Elastic.Markdown.IO; @@ -61,8 +63,21 @@ private async Task Setup() ) .ToArray(); var checkouts = repos.Select(r => CreateCheckout(FileSystem, r)).ToArray(); - - var assembleSources = await AssembleSources.AssembleAsync(NullLoggerFactory.Instance, Context, checkouts, TestContext.Current.CancellationToken); + var versionsConfig = new VersionsConfiguration + { + VersioningSystems = new Dictionary + { + { + VersioningSystemId.Stack, new VersioningSystem + { + Id = VersioningSystemId.Stack, + Current = new SemVersion(8, 0, 0), + Base = new SemVersion(8, 0, 0) + } + } + } + }; + var assembleSources = await AssembleSources.AssembleAsync(NullLoggerFactory.Instance, Context, checkouts, versionsConfig, TestContext.Current.CancellationToken); return assembleSources; } @@ -267,8 +282,21 @@ public async Task UriResolving() .Concat([NarrativeRepository.RepositoryName]) .ToArray(); var checkouts = repos.Select(r => CreateCheckout(fs, r)).ToArray(); - - var assembleSources = await AssembleSources.AssembleAsync(NullLoggerFactory.Instance, assembleContext, checkouts, TestContext.Current.CancellationToken); + var versionsConfig = new VersionsConfiguration + { + VersioningSystems = new Dictionary + { + { + VersioningSystemId.Stack, new VersioningSystem + { + Id = VersioningSystemId.Stack, + Current = new SemVersion(8, 0, 0), + Base = new SemVersion(8, 0, 0) + } + } + } + }; + var assembleSources = await AssembleSources.AssembleAsync(NullLoggerFactory.Instance, assembleContext, checkouts, versionsConfig, TestContext.Current.CancellationToken); var globalNavigationFile = new GlobalNavigationFile(assembleContext, assembleSources); globalNavigationFile.TableOfContents.Should().NotBeNull().And.NotBeEmpty();