@@ -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