Skip to content

Commit 3e78625

Browse files
committed
Redundancy cleanup
1 parent e4e5543 commit 3e78625

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,16 @@ export class OfficeYamlDocumenter extends YamlDocumenter {
9191
const snippets: string[] | undefined = this._snippets[nameWithoutPackage];
9292
if (snippets) {
9393
delete this._snippets[nameWithoutPackage];
94-
94+
const snippetText: string = this._generateExampleSnippetText(snippets);
9595
if (yamlItem.remarks) {
96-
yamlItem.remarks += this._generateSnippetText(snippets);
96+
yamlItem.remarks += snippetText;
9797
} else if (yamlItem.syntax && yamlItem.syntax.return) {
9898
if (!yamlItem.syntax.return.description) {
9999
yamlItem.syntax.return.description = '';
100100
}
101-
yamlItem.syntax.return.description += this._generateSnippetText(snippets);
101+
yamlItem.syntax.return.description += snippetText;
102102
} else {
103-
yamlItem.remarks = '';
104-
yamlItem.remarks += this._generateSnippetText(snippets);
103+
yamlItem.remarks = snippetText;
105104
}
106105
}
107106
}
@@ -148,15 +147,19 @@ export class OfficeYamlDocumenter extends YamlDocumenter {
148147
return text;
149148
}
150149

151-
private _generateSnippetText(snippets: string[]): string {
152-
let text: string = '\n\n#### Examples\n';
150+
private _generateExampleSnippetText(snippets: string[]): string {
151+
const text: string[] = ['\n#### Examples\n'];
153152
for (const snippet of snippets) {
154153
if (snippet.search(/await/) === -1) {
155-
text += '\n```javascript\n' + snippet + '\n```\n';
154+
text.push('```javascript');
155+
156156
} else {
157-
text += '\n```typescript\n' + snippet + '\n```\n';
157+
text.push('```typescript');
158158
}
159+
160+
text.push(snippet);
161+
text.push('```');
159162
}
160-
return text;
163+
return text.join('\n');
161164
}
162165
}

0 commit comments

Comments
 (0)