Skip to content

Commit 398b366

Browse files
committed
Reuse LlmMarkdownExporter.ConvertToLlmMarkdown
1 parent 202d428 commit 398b366

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

src/Elastic.Markdown/DocumentationGenerator.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,7 @@ public async Task<string> RenderLlmMarkdown(MarkdownFile markdown, Cancel ctx)
347347
{
348348
await DocumentationSet.Tree.Resolve(ctx);
349349
var document = await markdown.ParseFullAsync(ctx);
350-
return DocumentationObjectPoolProvider.UseLlmMarkdownRenderer(DocumentationSet.Context, renderer =>
351-
{
352-
_ = renderer.Render(document);
353-
}).Trim();
350+
return LlmMarkdownExporter.ConvertToLlmMarkdown(document, DocumentationSet.Context);
354351
}
355352

356353
public async Task<RenderResult> RenderLayout(MarkdownFile markdown, Cancel ctx)

src/Elastic.Markdown/Exporters/LlmMarkdownExporter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.IO.Abstractions;
66
using System.IO.Compression;
77
using System.Text;
8+
using Elastic.Documentation.Configuration;
89
using Elastic.Documentation.Configuration.Builder;
910
using Elastic.Markdown.Helpers;
1011
using Elastic.Markdown.Myst.Renderers.LlmMarkdown;
@@ -45,7 +46,7 @@ public ValueTask<bool> FinishExportAsync(IDirectoryInfo outputFolder, Cancel ctx
4546

4647
public async ValueTask<bool> ExportAsync(MarkdownExportFileContext fileContext, Cancel ctx)
4748
{
48-
var llmMarkdown = ConvertToLlmMarkdown(fileContext.Document, fileContext);
49+
var llmMarkdown = ConvertToLlmMarkdown(fileContext.Document, fileContext.BuildContext);
4950
var outputFile = GetLlmOutputFile(fileContext);
5051
if (outputFile.Directory is { Exists: false })
5152
outputFile.Directory.Create();
@@ -59,8 +60,8 @@ await fileContext.SourceFile.SourceFile.FileSystem.File.WriteAllTextAsync(
5960
return true;
6061
}
6162

62-
public static string ConvertToLlmMarkdown(MarkdownDocument document, MarkdownExportFileContext context) =>
63-
DocumentationObjectPoolProvider.UseLlmMarkdownRenderer(context.BuildContext, renderer =>
63+
public static string ConvertToLlmMarkdown(MarkdownDocument document, BuildContext context) =>
64+
DocumentationObjectPoolProvider.UseLlmMarkdownRenderer(context, renderer =>
6465
{
6566
_ = renderer.Render(document);
6667
});

tests/authoring/Framework/LlmMarkdownAssertions.fs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@ module LlmMarkdownAssertions =
1616

1717
let toLlmMarkdown (actual: MarkdownResult) =
1818
use writer = new StringWriter()
19-
let markdownExportFileContext = MarkdownExportFileContext(
20-
BuildContext = actual.Context.Generator.Context,
21-
Resolvers = actual.Context.Set.MarkdownParser.Resolvers,
22-
Document = actual.Document,
23-
SourceFile = actual.File,
24-
DefaultOutputFile = actual.File.SourceFile
25-
)
26-
LlmMarkdownExporter.ConvertToLlmMarkdown(actual.Document, markdownExportFileContext).Trim()
19+
LlmMarkdownExporter.ConvertToLlmMarkdown(actual.Document, actual.Context.Generator.Context).Trim()
2720

2821
[<DebuggerStepThrough>]
2922
let convertsToNewLLM ([<LanguageInjection("markdown")>]expected: string) (actual: Lazy<GeneratorResults>) =

0 commit comments

Comments
 (0)