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
9 changes: 5 additions & 4 deletions src/tooling/docs-assembler/AssembleSources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,15 +50,15 @@ public class AssembleSources

public PublishEnvironmentUriResolver UriResolver { get; }

public static async Task<AssembleSources> AssembleAsync(ILoggerFactory logger, AssembleContext context, Checkout[] checkouts, Cancel ctx)
public static async Task<AssembleSources> 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);
Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/tooling/docs-assembler/Cli/RepositoryCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public async Task<int> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public AssemblerDocumentationSet(
AssembleContext context,
Checkout checkout,
CrossLinkResolver crossLinkResolver,
TableOfContentsTreeCollector treeCollector)
TableOfContentsTreeCollector treeCollector,
VersionsConfiguration versionsConfiguration)
{
AssembleContext = context;
Checkout = checkout;
Expand All @@ -49,26 +50,11 @@ public AssemblerDocumentationSet(
Branch = checkout.Repository.GitReferenceCurrent
};

var versionsConfig = new VersionsConfiguration
{
VersioningSystems = new Dictionary<VersioningSystemId, VersioningSystem>
{
{
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,8 +63,21 @@ private async Task<AssembleSources> 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, VersioningSystem>
{
{
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;
}

Expand Down Expand Up @@ -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, VersioningSystem>
{
{
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();
Expand Down
Loading