diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b0e2e219..cecc93b2 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,6 +13,7 @@ env: on: release: types: [ published ] + workflow_dispatch: jobs: generate-and-push-docs: diff --git a/docs/ExamplesDocGen/Program.cs b/docs/ExamplesDocGen/Program.cs index 2538b48d..8070dac0 100644 --- a/docs/ExamplesDocGen/Program.cs +++ b/docs/ExamplesDocGen/Program.cs @@ -36,19 +36,14 @@ 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('.'); + 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 {optionsStr}``` @@ -56,4 +51,23 @@ private static string ParseConfigNode(YamlNode node)
"""; } + + 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"))) + 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