Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
on:
release:
types: [ published ]
workflow_dispatch:

jobs:
generate-and-push-docs:
Expand Down
28 changes: 21 additions & 7 deletions docs/ExamplesDocGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,38 @@ 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 $"""
<details>
<summary>{projectName.Replace("Example", "")}</summary>

## 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}```

</details>
""";
}

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('.');
}
}
Loading