Skip to content

Commit d4f0f7b

Browse files
authored
Pass the instantiated VersionsConfiguration to AssemblerDocumentationSet (#1490)
1 parent dbf6d53 commit d4f0f7b

File tree

4 files changed

+41
-26
lines changed

4 files changed

+41
-26
lines changed

src/tooling/docs-assembler/AssembleSources.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Elastic.Documentation.Configuration;
1212
using Elastic.Documentation.Configuration.Assembler;
1313
using Elastic.Documentation.Configuration.Builder;
14+
using Elastic.Documentation.Configuration.Versions;
1415
using Elastic.Documentation.LinkIndex;
1516
using Elastic.Markdown.IO.Navigation;
1617
using Elastic.Markdown.Links.CrossLinks;
@@ -49,15 +50,15 @@ public class AssembleSources
4950

5051
public PublishEnvironmentUriResolver UriResolver { get; }
5152

52-
public static async Task<AssembleSources> AssembleAsync(ILoggerFactory logger, AssembleContext context, Checkout[] checkouts, Cancel ctx)
53+
public static async Task<AssembleSources> AssembleAsync(ILoggerFactory logger, AssembleContext context, Checkout[] checkouts, VersionsConfiguration versionsConfiguration, Cancel ctx)
5354
{
54-
var sources = new AssembleSources(logger, context, checkouts);
55+
var sources = new AssembleSources(logger, context, checkouts, versionsConfiguration);
5556
foreach (var (_, set) in sources.AssembleSets)
5657
await set.DocumentationSet.ResolveDirectoryTree(ctx);
5758
return sources;
5859
}
5960

60-
private AssembleSources(ILoggerFactory logger, AssembleContext assembleContext, Checkout[] checkouts)
61+
private AssembleSources(ILoggerFactory logger, AssembleContext assembleContext, Checkout[] checkouts, VersionsConfiguration versionsConfiguration)
6162
{
6263
AssembleContext = assembleContext;
6364
TocTopLevelMappings = GetConfiguredSources(assembleContext);
@@ -68,7 +69,7 @@ private AssembleSources(ILoggerFactory logger, AssembleContext assembleContext,
6869
var crossLinkResolver = new CrossLinkResolver(crossLinkFetcher, UriResolver);
6970
AssembleSets = checkouts
7071
.Where(c => c.Repository is { Skip: false })
71-
.Select(c => new AssemblerDocumentationSet(logger, assembleContext, c, crossLinkResolver, TreeCollector))
72+
.Select(c => new AssemblerDocumentationSet(logger, assembleContext, c, crossLinkResolver, TreeCollector, versionsConfiguration))
7273
.ToDictionary(s => s.Checkout.Repository.Name, s => s)
7374
.ToFrozenDictionary();
7475

src/tooling/docs-assembler/Cli/RepositoryCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public async Task<int> BuildAll(
123123
throw new Exception("No checkouts found");
124124

125125
_log.LogInformation("Preparing all assemble sources for build");
126-
var assembleSources = await AssembleSources.AssembleAsync(logger, assembleContext, checkouts, ctx);
126+
var assembleSources = await AssembleSources.AssembleAsync(logger, assembleContext, checkouts, versionsConfigOption.Value, ctx);
127127
var navigationFile = new GlobalNavigationFile(assembleContext, assembleSources);
128128

129129
_log.LogInformation("Create global navigation");

src/tooling/docs-assembler/Navigation/AssemblerDocumentationSet.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public AssemblerDocumentationSet(
2929
AssembleContext context,
3030
Checkout checkout,
3131
CrossLinkResolver crossLinkResolver,
32-
TableOfContentsTreeCollector treeCollector)
32+
TableOfContentsTreeCollector treeCollector,
33+
VersionsConfiguration versionsConfiguration)
3334
{
3435
AssembleContext = context;
3536
Checkout = checkout;
@@ -49,26 +50,11 @@ public AssemblerDocumentationSet(
4950
Branch = checkout.Repository.GitReferenceCurrent
5051
};
5152

52-
var versionsConfig = new VersionsConfiguration
53-
{
54-
VersioningSystems = new Dictionary<VersioningSystemId, VersioningSystem>
55-
{
56-
{
57-
VersioningSystemId.Stack, new VersioningSystem
58-
{
59-
Id = VersioningSystemId.Stack,
60-
Current = new SemVersion(8, 0, 0),
61-
Base = new SemVersion(8, 0, 0)
62-
}
63-
}
64-
}
65-
};
66-
6753
var buildContext = new BuildContext(
6854
context.Collector,
6955
context.ReadFileSystem,
7056
context.WriteFileSystem,
71-
versionsConfig,
57+
versionsConfiguration,
7258
path,
7359
output,
7460
gitConfiguration

tests/docs-assembler.Tests/src/docs-assembler.Tests/GlobalNavigationTests.cs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
using System.IO.Abstractions;
66
using Documentation.Assembler.Navigation;
77
using Documentation.Assembler.Sourcing;
8+
using Elastic.Documentation;
89
using Elastic.Documentation.Configuration;
910
using Elastic.Documentation.Configuration.Assembler;
11+
using Elastic.Documentation.Configuration.Versions;
1012
using Elastic.Documentation.Diagnostics;
1113
using Elastic.Documentation.Site.Navigation;
1214
using Elastic.Markdown.IO;
@@ -61,8 +63,21 @@ private async Task<AssembleSources> Setup()
6163
)
6264
.ToArray();
6365
var checkouts = repos.Select(r => CreateCheckout(FileSystem, r)).ToArray();
64-
65-
var assembleSources = await AssembleSources.AssembleAsync(NullLoggerFactory.Instance, Context, checkouts, TestContext.Current.CancellationToken);
66+
var versionsConfig = new VersionsConfiguration
67+
{
68+
VersioningSystems = new Dictionary<VersioningSystemId, VersioningSystem>
69+
{
70+
{
71+
VersioningSystemId.Stack, new VersioningSystem
72+
{
73+
Id = VersioningSystemId.Stack,
74+
Current = new SemVersion(8, 0, 0),
75+
Base = new SemVersion(8, 0, 0)
76+
}
77+
}
78+
}
79+
};
80+
var assembleSources = await AssembleSources.AssembleAsync(NullLoggerFactory.Instance, Context, checkouts, versionsConfig, TestContext.Current.CancellationToken);
6681
return assembleSources;
6782
}
6883

@@ -267,8 +282,21 @@ public async Task UriResolving()
267282
.Concat([NarrativeRepository.RepositoryName])
268283
.ToArray();
269284
var checkouts = repos.Select(r => CreateCheckout(fs, r)).ToArray();
270-
271-
var assembleSources = await AssembleSources.AssembleAsync(NullLoggerFactory.Instance, assembleContext, checkouts, TestContext.Current.CancellationToken);
285+
var versionsConfig = new VersionsConfiguration
286+
{
287+
VersioningSystems = new Dictionary<VersioningSystemId, VersioningSystem>
288+
{
289+
{
290+
VersioningSystemId.Stack, new VersioningSystem
291+
{
292+
Id = VersioningSystemId.Stack,
293+
Current = new SemVersion(8, 0, 0),
294+
Base = new SemVersion(8, 0, 0)
295+
}
296+
}
297+
}
298+
};
299+
var assembleSources = await AssembleSources.AssembleAsync(NullLoggerFactory.Instance, assembleContext, checkouts, versionsConfig, TestContext.Current.CancellationToken);
272300
var globalNavigationFile = new GlobalNavigationFile(assembleContext, assembleSources);
273301

274302
globalNavigationFile.TableOfContents.Should().NotBeNull().And.NotBeEmpty();

0 commit comments

Comments
 (0)