File tree Expand file tree Collapse file tree 1 file changed +21
-10
lines changed
apps/api-documenter/src/yaml Expand file tree Collapse file tree 1 file changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -92,17 +92,16 @@ export class OfficeYamlDocumenter extends YamlDocumenter {
9292 if ( snippets ) {
9393 delete this . _snippets [ nameWithoutPackage ] ;
9494
95- if ( ! yamlItem . remarks ) {
96- yamlItem . remarks = '' ;
97- }
98-
99- yamlItem . remarks += '\n\n#### Examples\n' ;
100- for ( const snippet of snippets ) {
101- if ( snippet . search ( / a w a i t / ) === - 1 ) {
102- yamlItem . remarks += '\n```javascript\n' + snippet + '\n```\n' ;
103- } else {
104- yamlItem . remarks += '\n```typescript\n' + snippet + '\n```\n' ;
95+ if ( yamlItem . remarks ) {
96+ yamlItem . remarks += this . _generateSnippetText ( snippets ) ;
97+ } else if ( yamlItem . syntax && yamlItem . syntax . return ) {
98+ if ( ! yamlItem . syntax . return . description ) {
99+ yamlItem . syntax . return . description = '' ;
105100 }
101+ yamlItem . syntax . return . description += this . _generateSnippetText ( snippets ) ;
102+ } else {
103+ yamlItem . remarks = '' ;
104+ yamlItem . remarks += this . _generateSnippetText ( snippets ) ;
106105 }
107106 }
108107 }
@@ -148,4 +147,16 @@ export class OfficeYamlDocumenter extends YamlDocumenter {
148147 }
149148 return text ;
150149 }
150+
151+ private _generateSnippetText ( snippets : string [ ] ) : string {
152+ let text : string = '\n\n#### Examples\n' ;
153+ for ( const snippet of snippets ) {
154+ if ( snippet . search ( / a w a i t / ) === - 1 ) {
155+ text += '\n```javascript\n' + snippet + '\n```\n' ;
156+ } else {
157+ text += '\n```typescript\n' + snippet + '\n```\n' ;
158+ }
159+ }
160+ return text ;
161+ }
151162}
You can’t perform that action at this time.
0 commit comments