Skip to content

Commit 626c75a

Browse files
authored
Enhance the consistency, usability, maintainability, and overall developer experience of the api-docs across all RWS products. (#235)
Make reference to: https://rws-dev.atlassian.net/wiki/spaces/LTApp/pages/930645143/Developer+Documentation+Improvement+Proposal
1 parent a7d7d31 commit 626c75a

File tree

119 files changed

+1752
-12771
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1752
-12771
lines changed

TradosStudioTemplate/ManagedReference.common.js renamed to RWSTemplate/ManagedReference.common.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
23
var common = require('./common.js');
34
var classCategory = 'class';
45
var namespaceCategory = 'ns';
@@ -20,7 +21,6 @@ exports.transform = function (model) {
2021
case 'namespace':
2122
model.isNamespace = true;
2223
if (model.children) groupChildren(model, namespaceCategory);
23-
model[getTypePropertyName(model.type)] = true;
2424
break;
2525
case 'class':
2626
case 'interface':
@@ -36,6 +36,10 @@ exports.transform = function (model) {
3636
}
3737
}
3838

39+
if (model.summary && !model.description) {
40+
model.description = model.summary.replace(/<.*?>/gi, '').replace(/(\r\n|\n|\r)/gm, ' ').trim();
41+
}
42+
3943
return model;
4044
}
4145

@@ -193,12 +197,14 @@ function handleItem(vm, gitContribute, gitUrlPattern) {
193197
vm.sourceurl = common.getViewSourceHref(vm, null, gitUrlPattern);
194198

195199
// set to null incase mustache looks up
196-
vm.summary = vm.summary || null;
197-
vm.remarks = vm.remarks || null;
198-
vm.conceptual = vm.conceptual || null;
199-
vm.syntax = vm.syntax || null;
200-
vm.implements = vm.implements || null;
201-
vm.example = vm.example || null;
200+
vm.summary = vm.summary || "";
201+
vm.description = vm.description || "";
202+
vm.remarks = vm.remarks || "";
203+
vm.conceptual = vm.conceptual || "";
204+
vm.syntax = vm.syntax || "";
205+
vm.implements = vm.implements || "";
206+
vm.example = vm.example || "";
207+
vm.seealso = vm.seealso || [];
202208
common.processSeeAlso(vm);
203209

204210
// id is used as default template's bookmark
@@ -255,4 +261,9 @@ function handleItem(vm, gitContribute, gitUrlPattern) {
255261

256262
return array;
257263
}
258-
}
264+
if(vm.syntax.typeParameters) {
265+
vm.syntax.typeParameters.forEach(item => {
266+
item.description = item.description || "";
267+
});
268+
}
269+
}

TradosStudioTemplate/ManagedReference.extension.js renamed to RWSTemplate/ManagedReference.extension.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
23

34
/**
45
* This method will be called at the start of exports.transform in ManagedReference.html.primary.js
@@ -12,4 +13,4 @@ exports.preTransform = function (model) {
1213
*/
1314
exports.postTransform = function (model) {
1415
return model;
15-
}
16+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
var common = require('./ManagedReference.common.js');
5+
var extension = require('./ManagedReference.extension.js');
6+
var overwrite = require('./ManagedReference.overwrite.js');
7+
8+
exports.transform = function (model) {
9+
model.yamlmime = "ManagedReference";
10+
11+
if (overwrite && overwrite.transform) {
12+
return overwrite.transform(model);
13+
}
14+
15+
if (extension && extension.preTransform) {
16+
model = extension.preTransform(model);
17+
}
18+
19+
if (common && common.transform) {
20+
model = common.transform(model);
21+
}
22+
if (model.type.toLowerCase() === "enum") {
23+
model.isClass = false;
24+
model.isEnum = true;
25+
}
26+
if(model._disableToc === undefined) {
27+
model._disableToc = model._disableToc || !model._tocPath || (model._navPath === model._tocPath);
28+
}
29+
model._disableNextArticle = true;
30+
31+
if (extension && extension.postTransform) {
32+
if (model._splitReference) {
33+
model = postTransformMemberPage(model);
34+
}
35+
36+
model = extension.postTransform(model);
37+
}
38+
39+
return model;
40+
}
41+
42+
exports.getOptions = function (model) {
43+
if (overwrite && overwrite.getOptions) {
44+
return overwrite.getOptions(model);
45+
}
46+
var ignoreChildrenBookmarks = model._splitReference && model.type && common.getCategory(model.type) === 'ns';
47+
48+
return {
49+
"bookmarks": common.getBookmarks(model, ignoreChildrenBookmarks)
50+
};
51+
}
52+
53+
function postTransformMemberPage(model) {
54+
var type = model.type.toLowerCase();
55+
var category = common.getCategory(type);
56+
if (category == 'class') {
57+
var typePropertyName = common.getTypePropertyName(type);
58+
if (typePropertyName) {
59+
model[typePropertyName] = true;
60+
}
61+
if (model.children && model.children.length > 0) {
62+
model.isCollection = true;
63+
common.groupChildren(model, 'class');
64+
} else {
65+
model.isItem = true;
66+
}
67+
}
68+
return model;
69+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{!Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license.}}
2+
{{!master(layout/_master.tmpl)}}
3+
4+
{{#isNamespace}}
5+
{{>partials/namespace}}
6+
{{/isNamespace}}
7+
8+
{{#_splitReference}}
9+
{{#isClass}}
10+
{{>partials/class.memberpage}}
11+
{{/isClass}}
12+
{{/_splitReference}}
13+
{{^_splitReference}}
14+
{{#isClass}}
15+
{{>partials/class}}
16+
{{/isClass}}
17+
{{/_splitReference}}
18+
19+
{{#isEnum}}
20+
{{>partials/enum}}
21+
{{/isEnum}}
22+
{{>partials/customMREFContent}}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{!Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license.}}
2+
<!DOCTYPE html>
3+
<html {{#_lang}}lang="{{_lang}}"{{/_lang}}>
4+
<head>
5+
<meta charset="utf-8">
6+
<meta http-equiv="refresh" content="0;URL='{{redirect_url}}'">
7+
</head>
8+
</html>

TradosStudioTemplate/RestApi.common.js renamed to RWSTemplate/RestApi.common.js

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
23
var common = require('./common.js');
34

45
exports.transform = function (model) {
@@ -80,6 +81,21 @@ exports.transform = function (model) {
8081
model.children = model.children.filter(function (o) { return o; });
8182
}
8283
}
84+
model.definitions = [];
85+
if (model.tags) {
86+
model.tags.forEach(function(tag) {
87+
(tag.children || []).forEach(function(child) {
88+
(child.parameters || []).forEach(function(parameter) { addComplexTypeMetadata(parameter.schema, model.definitions); });
89+
(child.responses || []).forEach(function(response) { addComplexTypeMetadata(response.schema, model.definitions); });
90+
});
91+
});
92+
}
93+
if (model.children) {
94+
model.children.forEach(function(child) {
95+
(child.parameters || []).forEach(function(parameter) { addComplexTypeMetadata(parameter.schema, model.definitions); });
96+
(child.responses || []).forEach(function(response) { addComplexTypeMetadata(response.schema, model.definitions); });
97+
});
98+
}
8399

84100
return model;
85101

@@ -256,6 +272,72 @@ exports.transform = function (model) {
256272
}
257273
return path;
258274
}
275+
276+
function addDefinition(definition, definitions) {
277+
278+
if (!definition) {
279+
return;
280+
}
281+
282+
var xRefName = definition.items && definition.items['x-internal-ref-name']
283+
? definition.items['x-internal-ref-name']
284+
: definition['x-internal-ref-name'];
285+
286+
// Not complex type.
287+
if (!xRefName) {
288+
return;
289+
}
290+
291+
// Definition already exists return.
292+
if (definitions.some(function(d) { return d['x-internal-ref-name'] == xRefName; })) {
293+
return;
294+
}
295+
296+
// Create clone to not affect object structure used in original location
297+
definition = JSON.parse(JSON.stringify(definition));
298+
299+
// Unify different object structure to be the same
300+
301+
// Sometimes properties is under items sometimes not
302+
if (definition.items && definition.items.properties) {
303+
definition.properties = definition.items.properties;
304+
}
305+
306+
// Sometimes ref-name is under items sometimes not
307+
definition['x-internal-ref-name'] = xRefName;
308+
309+
// Sometimes properties are key/value pairs sometimes not
310+
if (definition.properties && !Array.isArray(definition.properties)) {
311+
definition.properties = Object.keys(definition.properties).map(function(key) {
312+
return {
313+
key: key,
314+
value: definition.properties[key]
315+
}
316+
});
317+
}
318+
319+
// Add definition to definitions list.
320+
definitions.push(definition);
321+
322+
// Loop through properties that refer to other definitions.
323+
(definition.properties || []).forEach(function(property) {
324+
addComplexTypeMetadata(property.value, definitions);
325+
});
326+
}
327+
328+
function addComplexTypeMetadata(child, definitions) {
329+
// Add variations of x-internal-ref-name to support
330+
if (child && child['x-internal-ref-name']) {
331+
child.cTypeId = child['x-internal-ref-name'].replace(/\./g, '_');
332+
child.cType = child['x-internal-ref-name'].replace(/([A-Z])/g, '<wbr>$1');
333+
}
334+
if (child && child.items && child.items['x-internal-ref-name']) {
335+
child.cTypeId = child.items['x-internal-ref-name'].replace(/\./g, '_');
336+
child.cType = child.items['x-internal-ref-name'].replace(/([A-Z])/g, '<wbr>$1');
337+
child.cTypeIsArray = true;
338+
}
339+
addDefinition(child, definitions);
340+
}
259341
}
260342

261343
exports.getBookmarks = function (model) {

TradosStudioTemplate/RestApi.extension.js renamed to RWSTemplate/RestApi.extension.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
23

34
/**
45
* This method will be called at the start of exports.transform in RestApi.html.primary.js
@@ -12,4 +13,4 @@ exports.preTransform = function (model) {
1213
*/
1314
exports.postTransform = function (model) {
1415
return model;
15-
}
16+
}

TradosStudioTemplate/RestApi.html.primary.js renamed to RWSTemplate/RestApi.html.primary.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
23

34
var restApiCommon = require('./RestApi.common.js');
45
var extension = require('./RestApi.extension.js')
@@ -11,7 +12,10 @@ exports.transform = function (model) {
1112
if (restApiCommon && restApiCommon.transform) {
1213
model = restApiCommon.transform(model);
1314
}
14-
model._disableToc = model._disableToc || !model._tocPath || (model._navPath === model._tocPath);
15+
if(model._disableToc === undefined) {
16+
model._disableToc = model._disableToc || !model._tocPath || (model._navPath === model._tocPath);
17+
}
18+
model._disableNextArticle = true;
1519

1620
if (extension && extension.postTransform) {
1721
model = extension.postTransform(model);
@@ -22,4 +26,4 @@ exports.transform = function (model) {
2226

2327
exports.getOptions = function (model) {
2428
return { "bookmarks": restApiCommon.getBookmarks(model) };
25-
}
29+
}

RWSTemplate/RestApi.html.primary.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{!Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license.}}
2+
{{!master(layout/_master.tmpl)}}
3+
{{>partials/rest}}

TradosStudioTemplate/UniversalReference.common.js renamed to RWSTemplate/UniversalReference.common.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
23

34
var common = require('./common.js');;
45
var classCategory = 'class';
@@ -81,7 +82,7 @@ function handleItem(vm, gitContribute, gitUrlPattern) {
8182
if (vm.inheritance) {
8283
normalizeLanguageValuePairs(vm.inheritance).forEach(handleInheritance);
8384
}
84-
85+
8586
common.processSeeAlso(vm);
8687

8788
// id is used as default template's bookmark

TradosStudioTemplate/UniversalReference.extension.js renamed to RWSTemplate/UniversalReference.extension.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
23

34
/**
45
* This method will be called at the start of exports.transform in UniversalReference.html.primary.js
@@ -12,4 +13,4 @@ exports.preTransform = function (model) {
1213
*/
1314
exports.postTransform = function (model) {
1415
return model;
15-
}
16+
}

TradosStudioTemplate/UniversalReference.html.primary.js renamed to RWSTemplate/UniversalReference.html.primary.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
23

34
var urefCommon = require('./UniversalReference.common.js');
45
var extension = require('./UniversalReference.extension.js');
@@ -12,7 +13,10 @@ exports.transform = function (model) {
1213
model = urefCommon.transform(model);
1314
}
1415

15-
model._disableToc = model._disableToc || !model._tocPath || (model._navPath === model._tocPath);
16+
if(model._disableToc === undefined) {
17+
model._disableToc = model._disableToc || !model._tocPath || (model._navPath === model._tocPath);
18+
}
19+
model._disableNextArticle = true;
1620

1721
if (extension && extension.postTransform) {
1822
model = extension.postTransform(model);
@@ -25,4 +29,4 @@ exports.getOptions = function (model) {
2529
return {
2630
"bookmarks": urefCommon.getBookmarks(model)
2731
};
28-
}
32+
}

TradosStudioTemplate/UniversalReference.html.primary.tmpl renamed to RWSTemplate/UniversalReference.html.primary.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}}
1+
{{!Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license.}}
22
{{!master(layout/_master.tmpl)}}
33

44
{{#isNamespace}}

0 commit comments

Comments
 (0)