Skip to content

Commit 657d416

Browse files
committed
Affixing examples to a full section instead of making a blank remarks
1 parent 3c64380 commit 657d416

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

apps/api-documenter/src/yaml/OfficeYamlDocumenter.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff 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(/await/) === -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(/await/) === -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
}

0 commit comments

Comments
 (0)