Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 6 additions & 3 deletions src/tooling/docs-assembler/Building/AssemblerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public enum ExportOption
{
Html = 0,
LLMText = 1,
Elasticsearch = 2
Elasticsearch = 2,
Configuration = 3
}

public class AssemblerBuilder(
Expand Down Expand Up @@ -55,9 +56,11 @@ public async Task BuildAllAsync(FrozenDictionary<string, AssemblerDocumentationS
var markdownExporters = new List<IMarkdownExporter>(3);
if (exportOptions.Contains(ExportOption.LLMText))
markdownExporters.Add(new LLMTextExporter());
if (exportOptions.Contains(ExportOption.Configuration))
markdownExporters.Add(new ConfigurationExporter(logFactory, context));
if (exportOptions.Contains(ExportOption.Elasticsearch) && esExporter is { })
markdownExporters.Add(esExporter);
var noopBuild = !exportOptions.Contains(ExportOption.Html);
var noHtmlOutput = !exportOptions.Contains(ExportOption.Html);

var tasks = markdownExporters.Select(async e => await e.StartAsync(ctx));
await Task.WhenAll(tasks);
Expand All @@ -73,7 +76,7 @@ public async Task BuildAllAsync(FrozenDictionary<string, AssemblerDocumentationS

try
{
var result = await BuildAsync(set, noopBuild, markdownExporters.ToArray(), ctx);
var result = await BuildAsync(set, noHtmlOutput, markdownExporters.ToArray(), ctx);
CollectRedirects(redirects, result.Redirects, checkout.Repository.Name, set.DocumentationSet.LinkResolver);
}
catch (Exception e) when (e.Message.Contains("Can not locate docset.yml file in"))
Expand Down
5 changes: 3 additions & 2 deletions src/tooling/docs-assembler/Cli/RepositoryCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public async Task<int> BuildAll(
[ExporterParser] IReadOnlySet<ExportOption>? exporters = null,
Cancel ctx = default)
{
exporters ??= new HashSet<ExportOption>([ExportOption.Html]);
exporters ??= new HashSet<ExportOption>([ExportOption.Html, ExportOption.Configuration]);

AssignOutputLogger();
var githubEnvironmentInput = githubActionsService.GetInput("environment");
Expand Down Expand Up @@ -223,7 +223,7 @@ public class ExporterParserAttribute : Attribute, IArgumentParser<IReadOnlySet<E
{
public static bool TryParse(ReadOnlySpan<char> s, out IReadOnlySet<ExportOption> result)
{
result = new HashSet<ExportOption>([ExportOption.Html]);
result = new HashSet<ExportOption>([ExportOption.Html, ExportOption.Configuration]);
var set = new HashSet<ExportOption>();
var ranges = s.Split(',');
foreach (var range in ranges)
Expand All @@ -235,6 +235,7 @@ public static bool TryParse(ReadOnlySpan<char> s, out IReadOnlySet<ExportOption>
"es" => ExportOption.Elasticsearch,
"elasticsearch" => ExportOption.Elasticsearch,
"html" => ExportOption.Html,
"config" => ExportOption.Configuration,
_ => null
};
if (export.HasValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,43 @@

namespace Documentation.Assembler.Exporters;

public class ConfigurationExporter(ILoggerFactory logFactory, AssembleContext context) : IMarkdownExporter
{
private readonly ILogger<ConfigurationExporter> _logger = logFactory.CreateLogger<ConfigurationExporter>();

/// <inheritdoc />
public ValueTask StartAsync(CancellationToken ctx = default) => default;

/// <inheritdoc />
public ValueTask StopAsync(CancellationToken ctx = default) => default;

/// <inheritdoc />
public ValueTask<bool> ExportAsync(MarkdownExportFileContext fileContext, CancellationToken ctx) => default;

/// <inheritdoc />
public ValueTask<bool> FinishExportAsync(IDirectoryInfo outputFolder, CancellationToken ctx)
{
_logger.LogInformation("Exporting configuration");
var config = context.ConfigurationPath;
var fs = context.WriteFileSystem;
var configFolder = fs.DirectoryInfo.New(Path.Combine(context.OutputDirectory.FullName, "config"));
if (!configFolder.Exists)
configFolder.Create();

_logger.LogInformation("Exporting {Name} to {ConfigFolder}", config.Name, configFolder.FullName);
context.WriteFileSystem.File.Copy(config.FullName, Path.Combine(configFolder.FullName, config.Name), true);

_logger.LogInformation("Exporting {Name} to {ConfigFolder}", context.NavigationPath.Name, configFolder.FullName);
context.WriteFileSystem.File.Copy(context.NavigationPath.FullName, Path.Combine(configFolder.FullName, context.NavigationPath.Name), true);

_logger.LogInformation("Exporting {Name} to {ConfigFolder}", context.HistoryMappingPath.Name, configFolder.FullName);
context.WriteFileSystem.File.Copy(context.HistoryMappingPath.FullName, Path.Combine(configFolder.FullName, context.HistoryMappingPath.Name), true);


return default;
}
}

public class ElasticsearchMarkdownExporter : IMarkdownExporter, IDisposable
{
private readonly DiagnosticsCollector _collector;
Expand Down
Loading