Skip to content

Commit 693b32d

Browse files
fix: empty options usecase in ExamplesDocGen
1 parent 07ba684 commit 693b32d

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

.github/workflows/docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ env:
1313
on:
1414
release:
1515
types: [ published ]
16+
workflow_dispatch:
17+
push:
18+
branches: [ fix-empty-options-usecase-in-docsgen ]
1619

1720
jobs:
1821
generate-and-push-docs:

docs/ExamplesDocGen/Program.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ private static string ParseConfigNode(YamlNode node)
3636
if (testClassName.Contains("Legacy"))
3737
testClassName = testClassName.Replace("Legacy", "");
3838

39-
var yamlStream = new YamlStream();
40-
var yamlDocument = new YamlDocument(codegenObj["options"]);
41-
yamlStream.Documents.Add(yamlDocument);
42-
using var optionsWriter = new StringWriter();
43-
yamlStream.Save(optionsWriter, false);
44-
var optionsStr = optionsWriter.ToString().Trim().TrimEnd('.');
45-
4639
return $"""
4740
<details>
4841
<summary>{projectName.Replace("Example", "")}</summary>
@@ -51,9 +44,21 @@ private static string ParseConfigNode(YamlNode node)
5144
### [Schema]({item["schema"][0]}) | [Queries]({item["queries"][0]}) | [End2End Test](end2end/{testProject}/{testClassName}.cs)
5245
### Config
5346
```yaml
54-
{optionsStr}```
47+
{StringifyOptions(codegenObj)}```
5548
5649
</details>
5750
""";
5851
}
52+
53+
private static string StringifyOptions(YamlMappingNode codegenObj)
54+
{
55+
if (!codegenObj.Children.ContainsKey(new YamlScalarNode("options")))
56+
return string.Empty;
57+
58+
var yamlStream = new YamlStream();
59+
yamlStream.Documents.Add(new YamlDocument(codegenObj["options"]));
60+
using var writer = new StringWriter();
61+
yamlStream.Save(writer, false);
62+
return writer.ToString().Trim().TrimEnd('.');
63+
}
5964
}

0 commit comments

Comments
 (0)