Skip to content

Commit 5b6b8a0

Browse files
kbrandlpgonzal
authored andcommitted
Update Office Extension to API Documenter (microsoft#575)
* Minor changes to OfficeYamlDocumenter.ts for autogeneration of Office Add-ins docs. * Fix typo in regex. * Change sequence of regex checks. * Change 'Api set' to 'API set'. * Add change logs. * Fix issues reported by tslint. * Update email address in change logs.
1 parent 75e8115 commit 5b6b8a0

File tree

4 files changed

+57
-7
lines changed

4 files changed

+57
-7
lines changed

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

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,43 @@ export class OfficeYamlDocumenter extends YamlDocumenter {
6363
yamlItem.remarks = '';
6464
}
6565

66-
yamlItem.remarks += '\n\n## Snippets\n';
66+
yamlItem.remarks += '\n\n#### Examples\n';
6767
for (const snippet of snippets) {
68-
yamlItem.remarks += '\n```typescript\n' + snippet + '\n```\n';
68+
if (snippet.search(/await/) === -1) {
69+
yamlItem.remarks += '\n```javascript\n' + snippet + '\n```\n';
70+
} else {
71+
yamlItem.remarks += '\n```typescript\n' + snippet + '\n```\n';
72+
}
6973
}
7074
}
7175

7276
if (yamlItem.summary) {
73-
yamlItem.summary = this._fixupApiSet(yamlItem.summary);
77+
yamlItem.summary = this._fixupApiSet(yamlItem.summary, yamlItem.uid);
7478
}
7579
if (yamlItem.remarks) {
76-
yamlItem.remarks = this._fixupApiSet(yamlItem.remarks);
80+
yamlItem.remarks = this._fixupApiSet(yamlItem.remarks, yamlItem.uid);
7781
}
7882
}
7983

80-
private _fixupApiSet(markup: string): string {
84+
private _fixupApiSet(markup: string, uid: string): string {
8185
// Search for a pattern such as this:
8286
// \[Api set: ExcelApi 1.1\]
8387
//
8488
// Hyperlink it like this:
85-
// \[ [Api set: ExcelApi 1.1](http://bing.com) \]
86-
return markup.replace(/\\\[(Api set:[^\]]+)\\\]/, `\\[ [$1](http://bing.com) \\]`);
89+
// \[ [API set: ExcelApi 1.1](http://bing.com?type=excel) \]
90+
markup = markup.replace(/Api/, 'API');
91+
if (uid.search(/Excel/i) !== -1) {
92+
return markup.replace(/\\\[(API set:[^\]]+)\\\]/, `\\[ [$1](http://bing.com?type=excel) \\]`);
93+
} else if (uid.search(/OneNote/i) !== -1) {
94+
return markup.replace(/\\\[(API set:[^\]]+)\\\]/, `\\[ [$1](http://bing.com?type=onenote) \\]`);
95+
} else if (uid.search(/Visio/i) !== -1) {
96+
return markup.replace(/\\\[(API set:[^\]]+)\\\]/, `\\[ [$1](http://bing.com?type=visio) \\]`);
97+
} else if (uid.search(/Outlook/i) !== -1) {
98+
return markup.replace(/\\\[(API set:[^\]]+)\\\]/, `\\[ [$1](http://bing.com?type=outlook) \\]`);
99+
} else if (uid.search(/Word/i) !== -1) {
100+
return markup.replace(/\\\[(API set:[^\]]+)\\\]/, `\\[ [$1](http://bing.com?type=word) \\]`);
101+
} else {
102+
return markup.replace(/\\\[(API set:[^\]]+)\\\]/, `\\[ [$1](http://bing.com) \\]`);
103+
}
87104
}
88105
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/api-documenter",
5+
"comment": "Change heading for code snippets section from `## Snippets` to `#### Examples`.",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@microsoft/api-documenter",
10+
"email": "kibrandl@users.noreply.github.com"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/api-documenter",
5+
"comment": "Customize the `API Set #.#` hyperlink target by host. ",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@microsoft/api-documenter",
10+
"email": "kibrandl@users.noreply.github.com"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/api-documenter",
5+
"comment": "Designate proper language for each code snippet (TypeScript or JavaScript).",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@microsoft/api-documenter",
10+
"email": "kibrandl@users.noreply.github.com"
11+
}

0 commit comments

Comments
 (0)