Skip to content

Commit 3433fa0

Browse files
Merge branch 'main' into add-performance-benchmark-with-efcore
2 parents cdd82d8 + d9c88a9 commit 3433fa0

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

.github/workflows/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
on:
1414
release:
1515
types: [ published ]
16+
workflow_dispatch:
1617

1718
jobs:
1819
generate-and-push-docs:

docs/ExamplesDocGen/Program.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,38 @@ 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('.');
39+
var optionsStr = StringifyOptions(codegenObj);
4540

4641
return $"""
4742
<details>
4843
<summary>{projectName.Replace("Example", "")}</summary>
4944
5045
## Engine `{item["engine"]}`: [{projectName}]({outputDirectory})
51-
### [Schema]({item["schema"][0]}) | [Queries]({item["queries"][0]}) | [End2End Test](end2end/{testProject}/{testClassName}.cs)
46+
### [Schema]({GetYamlFirstValue(item["schema"])}) | [Queries]({GetYamlFirstValue(item["queries"])}) | [End2End Test](end2end/{testProject}/{testClassName}.cs)
5247
### Config
5348
```yaml
5449
{optionsStr}```
5550
5651
</details>
5752
""";
5853
}
54+
55+
private static string GetYamlFirstValue(YamlNode node)
56+
{
57+
return node is YamlSequenceNode sequence
58+
? sequence[0].ToString()
59+
: node.ToString();
60+
}
61+
62+
private static string StringifyOptions(YamlMappingNode codegenObj)
63+
{
64+
if (!codegenObj.Children.ContainsKey(new YamlScalarNode("options")))
65+
return string.Empty;
66+
67+
var yamlStream = new YamlStream();
68+
yamlStream.Documents.Add(new YamlDocument(codegenObj["options"]));
69+
using var writer = new StringWriter();
70+
yamlStream.Save(writer, false);
71+
return writer.ToString().Trim().TrimEnd('.');
72+
}
5973
}

0 commit comments

Comments
 (0)