From 693b32d27a9f3227bf6c58b7dee62137593dfd68 Mon Sep 17 00:00:00 2001 From: Ilan Uzan Date: Sat, 22 Nov 2025 16:51:45 +0200 Subject: [PATCH 1/3] fix: empty options usecase in ExamplesDocGen --- .github/workflows/docs.yml | 3 +++ docs/ExamplesDocGen/Program.cs | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b0e2e219..e78a5614 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,6 +13,9 @@ env: on: release: types: [ published ] + workflow_dispatch: + push: + branches: [ fix-empty-options-usecase-in-docsgen ] jobs: generate-and-push-docs: diff --git a/docs/ExamplesDocGen/Program.cs b/docs/ExamplesDocGen/Program.cs index 2538b48d..35e9b4d8 100644 --- a/docs/ExamplesDocGen/Program.cs +++ b/docs/ExamplesDocGen/Program.cs @@ -36,13 +36,6 @@ private static string ParseConfigNode(YamlNode node) if (testClassName.Contains("Legacy")) testClassName = testClassName.Replace("Legacy", ""); - var yamlStream = new YamlStream(); - var yamlDocument = new YamlDocument(codegenObj["options"]); - yamlStream.Documents.Add(yamlDocument); - using var optionsWriter = new StringWriter(); - yamlStream.Save(optionsWriter, false); - var optionsStr = optionsWriter.ToString().Trim().TrimEnd('.'); - return $"""
{projectName.Replace("Example", "")} @@ -51,9 +44,21 @@ private static string ParseConfigNode(YamlNode node) ### [Schema]({item["schema"][0]}) | [Queries]({item["queries"][0]}) | [End2End Test](end2end/{testProject}/{testClassName}.cs) ### Config ```yaml - {optionsStr}``` + {StringifyOptions(codegenObj)}```
"""; } + + private static string StringifyOptions(YamlMappingNode codegenObj) + { + if (!codegenObj.Children.ContainsKey(new YamlScalarNode("options"))) + return string.Empty; + + var yamlStream = new YamlStream(); + yamlStream.Documents.Add(new YamlDocument(codegenObj["options"])); + using var writer = new StringWriter(); + yamlStream.Save(writer, false); + return writer.ToString().Trim().TrimEnd('.'); + } } \ No newline at end of file From c5c2a7b7aee6e4824c78329e52217d2669b9511b Mon Sep 17 00:00:00 2001 From: Ilan Uzan Date: Sat, 22 Nov 2025 16:59:56 +0200 Subject: [PATCH 2/3] fix: support quickstart format of writing config --- docs/ExamplesDocGen/Program.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/ExamplesDocGen/Program.cs b/docs/ExamplesDocGen/Program.cs index 35e9b4d8..8070dac0 100644 --- a/docs/ExamplesDocGen/Program.cs +++ b/docs/ExamplesDocGen/Program.cs @@ -36,20 +36,29 @@ private static string ParseConfigNode(YamlNode node) if (testClassName.Contains("Legacy")) testClassName = testClassName.Replace("Legacy", ""); + var optionsStr = StringifyOptions(codegenObj); + return $"""
{projectName.Replace("Example", "")} ## Engine `{item["engine"]}`: [{projectName}]({outputDirectory}) - ### [Schema]({item["schema"][0]}) | [Queries]({item["queries"][0]}) | [End2End Test](end2end/{testProject}/{testClassName}.cs) + ### [Schema]({GetYamlFirstValue(item["schema"])}) | [Queries]({GetYamlFirstValue(item["queries"])}) | [End2End Test](end2end/{testProject}/{testClassName}.cs) ### Config ```yaml - {StringifyOptions(codegenObj)}``` + {optionsStr}```
"""; } + private static string GetYamlFirstValue(YamlNode node) + { + return node is YamlSequenceNode sequence + ? sequence[0].ToString() + : node.ToString(); + } + private static string StringifyOptions(YamlMappingNode codegenObj) { if (!codegenObj.Children.ContainsKey(new YamlScalarNode("options"))) From ffc0443ed83b6129538a4f478c183c605fdbbc21 Mon Sep 17 00:00:00 2001 From: Ilan Uzan Date: Sat, 22 Nov 2025 17:01:08 +0200 Subject: [PATCH 3/3] fix: remove branch usage --- .github/workflows/docs.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e78a5614..cecc93b2 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,8 +14,6 @@ on: release: types: [ published ] workflow_dispatch: - push: - branches: [ fix-empty-options-usecase-in-docsgen ] jobs: generate-and-push-docs: