Skip to content

Conversation

siamakp-elastic
Copy link

Added a Markdown validation exporter. It collects the document titles and at the end of the build reports the repeated document titles.

This PR is not complete. It currently reports the repeated document titles by writing to the console. The StopAsync() method of an exporter doesn't have access to a build context to report the errors to the build.

… and at the end of the build reports the repeated document titles.
markdownExporters.Add(new ElasticsearchMarkdownSemanticExporter(logFactory, context.Collector, indexNamespace, context.Endpoints));
if (exportOptions.Contains(Exporter.ElasticsearchNoSemantic))
markdownExporters.Add(new ElasticsearchMarkdownExporter(logFactory, context.Collector, indexNamespace, context.Endpoints));
markdownExporters.Add(new MarkdownValidationExporter());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
markdownExporters.Add(new MarkdownValidationExporter());
markdownExporters.Add(new MarkdownValidationExporter(context.Collector));


namespace Elastic.Markdown.Exporters;

public class MarkdownValidationExporter : IMarkdownExporter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class MarkdownValidationExporter : IMarkdownExporter
public class MarkdownValidationExporter(IDiagnosticsCollector collector) : IMarkdownExporter

{
var title = kv.Key;
var filePaths = string.Join(", ", files.Select(f => f.FilePath));
Console.WriteLine($"Error: Title '{title}' is used in multiple files: {filePaths}");
Copy link
Member

@Mpdreamz Mpdreamz Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Console.WriteLine($"Error: Title '{title}' is used in multiple files: {filePaths}");
collector.EmitError(filePaths.First(), $"Title '{title}' is used in multiple files: {filePaths}");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants