@microsoft/type2docfx 1.3.2-preview.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.version/PipelineAssemblyInfo.cs +3 -3
- package/.version/PipelineAssemblyInfo.h +3 -3
- package/.version/build.number.info +1 -1
- package/.version/commit.version.info +1 -1
- package/.version/numeric.fileversion.info +1 -1
- package/.version/numeric.fileversion.info.noleadingzeros +1 -1
- package/.version/numeric.packageversion.info +1 -1
- package/.version/revision.number.info +1 -1
- package/.version/semantic.fileversion.info +1 -1
- package/.version/semantic.packageversion.info +1 -1
- package/.version/versions.xml +1 -1
- package/dist/cli.js +6 -6
- package/dist/cli.js.map +1 -1
- package/dist/common/constants.js +1 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/common/error.js +38 -24
- package/dist/common/error.js.map +1 -1
- package/dist/converters/accessor.js +18 -31
- package/dist/converters/accessor.js.map +1 -1
- package/dist/converters/base.js +323 -198
- package/dist/converters/base.js.map +1 -1
- package/dist/converters/context.js +21 -38
- package/dist/converters/context.js.map +1 -1
- package/dist/converters/converter.js +19 -19
- package/dist/converters/converter.js.map +1 -1
- package/dist/converters/empty.js +5 -23
- package/dist/converters/empty.js.map +1 -1
- package/dist/converters/enum.js +14 -29
- package/dist/converters/enum.js.map +1 -1
- package/dist/converters/method.js +16 -32
- package/dist/converters/method.js.map +1 -1
- package/dist/converters/module.js +10 -28
- package/dist/converters/module.js.map +1 -1
- package/dist/converters/property.js +41 -36
- package/dist/converters/property.js.map +1 -1
- package/dist/converters/reference.js +20 -0
- package/dist/converters/reference.js.map +1 -0
- package/dist/converters/type.js +24 -36
- package/dist/converters/type.js.map +1 -1
- package/dist/helpers/linkConvertHelper.js +5 -6
- package/dist/helpers/linkConvertHelper.js.map +1 -1
- package/dist/helpers/toSdpConvertHelper.js +112 -81
- package/dist/helpers/toSdpConvertHelper.js.map +1 -1
- package/dist/idResolver.js +101 -27
- package/dist/idResolver.js.map +1 -1
- package/dist/main.js +163 -98
- package/dist/main.js.map +1 -1
- package/dist/parser.js +25 -32
- package/dist/parser.js.map +1 -1
- package/dist/postTransformer.js +34 -39
- package/dist/postTransformer.js.map +1 -1
- package/dist/tocGenerator.js +14 -15
- package/dist/tocGenerator.js.map +1 -1
- package/package.json +11 -12
- package/tsconfig.json +5 -2
- package/dist/moduleGenerator.js +0 -34
- package/dist/moduleGenerator.js.map +0 -1
- package/dist/packageGenerator.js +0 -35
- package/dist/packageGenerator.js.map +0 -1
package/dist/converters/base.js
CHANGED
|
@@ -1,149 +1,181 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.AbstractConverter = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
const idResolver_1 = require("../idResolver");
|
|
5
|
+
const linkConvertHelper_1 = require("../helpers/linkConvertHelper");
|
|
6
|
+
const error_1 = require("../common/error");
|
|
7
|
+
class AbstractConverter {
|
|
8
|
+
constructor(references) {
|
|
19
9
|
this.references = references;
|
|
20
10
|
}
|
|
21
|
-
|
|
22
|
-
var _this = this;
|
|
11
|
+
convert(node, context) {
|
|
23
12
|
var models = this.generate(node, context) || [];
|
|
24
|
-
models.forEach(
|
|
25
|
-
model.summary = linkConvertHelper_1.convertLinkToGfm(model.summary);
|
|
13
|
+
models.forEach((model, i) => {
|
|
26
14
|
model.package = context.PackageName;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
let signatureComment = undefined;
|
|
16
|
+
if (node.signatures && node.signatures.length) {
|
|
17
|
+
signatureComment = node.signatures[i].comment;
|
|
18
|
+
}
|
|
19
|
+
const anonymousComment = this.extractCommentForAnonymousFunction(node.type);
|
|
20
|
+
if (node.comment || signatureComment || anonymousComment) {
|
|
21
|
+
this.setCustomModuleName(model, node.comment);
|
|
22
|
+
const comment = node.comment || signatureComment || anonymousComment;
|
|
23
|
+
this.setDeprecated(model, comment);
|
|
24
|
+
this.setPreviewState(model, comment);
|
|
25
|
+
this.setRemarks(model, comment);
|
|
26
|
+
this.setInherits(model, comment);
|
|
34
27
|
}
|
|
35
28
|
});
|
|
36
29
|
return models;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
}
|
|
31
|
+
setDeprecated(model, comment) {
|
|
32
|
+
const deprecated = this.extractTextFromComment('@deprecated', comment);
|
|
40
33
|
if (deprecated != null) {
|
|
41
34
|
model.deprecated = {
|
|
42
|
-
content:
|
|
35
|
+
content: deprecated
|
|
43
36
|
};
|
|
44
37
|
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
model.previewState = 'alpha';
|
|
52
|
-
break; // select 'alpha' if both 'alpha' and 'beta' tags are present.
|
|
53
|
-
}
|
|
54
|
-
else if (tag.tag === 'beta') {
|
|
55
|
-
model.previewState = 'beta';
|
|
56
|
-
}
|
|
57
|
-
}
|
|
38
|
+
}
|
|
39
|
+
setPreviewState(model, comment) {
|
|
40
|
+
const existBetaTag = this.extractModifierFromComment('@beta', comment);
|
|
41
|
+
const existAlphaTag = this.extractModifierFromComment('@alpha', comment);
|
|
42
|
+
if (existBetaTag) {
|
|
43
|
+
model.previewState = 'beta';
|
|
58
44
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
45
|
+
if (existAlphaTag) {
|
|
46
|
+
model.previewState = 'alpha';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
setRemarks(model, comment) {
|
|
50
|
+
const remarks = this.extractTextFromComment('@remarks', comment);
|
|
62
51
|
if (remarks != null) {
|
|
63
|
-
model.remarks =
|
|
52
|
+
model.remarks = remarks;
|
|
64
53
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
}
|
|
55
|
+
setCustomModuleName(model, comment) {
|
|
56
|
+
const customModuleName = this.extractTextFromComment('@module', comment);
|
|
68
57
|
if (customModuleName) {
|
|
69
58
|
model.module = customModuleName;
|
|
70
59
|
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
60
|
+
}
|
|
61
|
+
setInherits(model, comment) {
|
|
62
|
+
const inherits = this.extractTextFromComment('@inherits', comment);
|
|
74
63
|
if (inherits != null) {
|
|
75
|
-
|
|
64
|
+
const tokens = (0, linkConvertHelper_1.getTextAndLink)(inherits);
|
|
76
65
|
if (tokens.length === 2) {
|
|
77
|
-
model.extends = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
66
|
+
model.extends = [{
|
|
67
|
+
name: tokens[0],
|
|
68
|
+
href: tokens[1]
|
|
69
|
+
}];
|
|
81
70
|
}
|
|
82
71
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (comment && comment.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (tag.tag === infoName) {
|
|
89
|
-
return tag.text.trim();
|
|
90
|
-
}
|
|
72
|
+
}
|
|
73
|
+
extractModifierFromComment(infoName, comment) {
|
|
74
|
+
if (comment && comment.modifierTags) {
|
|
75
|
+
if (comment.modifierTags.includes(infoName)) {
|
|
76
|
+
return true;
|
|
91
77
|
}
|
|
92
78
|
}
|
|
93
|
-
return
|
|
94
|
-
}
|
|
95
|
-
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
extractTextFromComment(infoName, comment) {
|
|
82
|
+
if (!comment) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
if (!comment.blockTags) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const tag = comment.blockTags.find(item => {
|
|
89
|
+
return item.tag === infoName;
|
|
90
|
+
});
|
|
91
|
+
if (!tag) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
return this.combineDisplayParts(tag.content);
|
|
95
|
+
}
|
|
96
|
+
getGenericType(typeParameters) {
|
|
96
97
|
if (typeParameters && typeParameters.length) {
|
|
97
|
-
|
|
98
|
+
let typeArgumentsList = typeParameters.map(item => {
|
|
98
99
|
return item.name;
|
|
99
100
|
}).join(', ');
|
|
100
101
|
return '<' + typeArgumentsList + '>';
|
|
101
102
|
}
|
|
102
103
|
return '';
|
|
103
|
-
}
|
|
104
|
-
|
|
104
|
+
}
|
|
105
|
+
extractCommentForAnonymousFunction(type) {
|
|
106
|
+
// when is a anonymous function, commont should be extract from this method
|
|
107
|
+
if (type && type.type === 'reflection' && type.declaration) {
|
|
108
|
+
const signatures = type.declaration.signatures;
|
|
109
|
+
if (signatures && signatures.length) {
|
|
110
|
+
return signatures[0].comment;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
findDescriptionInAnonymousFunction(type) {
|
|
116
|
+
/**
|
|
117
|
+
* comment for below anonymous function
|
|
118
|
+
* () => void
|
|
119
|
+
*/
|
|
120
|
+
const comment = this.extractCommentForAnonymousFunction(type);
|
|
121
|
+
if (comment) {
|
|
122
|
+
return this.findDescriptionInComment(comment);
|
|
123
|
+
}
|
|
124
|
+
return '';
|
|
125
|
+
}
|
|
126
|
+
findDescriptionInComment(comment) {
|
|
105
127
|
if (!comment) {
|
|
106
128
|
return '';
|
|
107
129
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (comment.
|
|
114
|
-
|
|
115
|
-
comment.
|
|
116
|
-
if (tag.tag === 'classdesc'
|
|
117
|
-
|| tag.tag === 'description'
|
|
118
|
-
|| tag.tag === 'exemptedapi'
|
|
119
|
-
|| tag.tag === 'property') {
|
|
120
|
-
|
|
130
|
+
const descText = this.parseDescTextFromComment(comment);
|
|
131
|
+
const tagText = this.extractTagsTextFromComment(comment);
|
|
132
|
+
return `${descText}${tagText}`;
|
|
133
|
+
}
|
|
134
|
+
parseDescTextFromComment(comment) {
|
|
135
|
+
if (comment.blockTags) {
|
|
136
|
+
let text = null;
|
|
137
|
+
comment.blockTags.forEach(tag => {
|
|
138
|
+
if (tag.tag === '@classdesc'
|
|
139
|
+
|| tag.tag === '@description'
|
|
140
|
+
|| tag.tag === '@exemptedapi'
|
|
141
|
+
|| tag.tag === '@property') {
|
|
142
|
+
text = this.combineDisplayParts(tag.content);
|
|
121
143
|
return;
|
|
122
144
|
}
|
|
123
145
|
});
|
|
124
|
-
if (
|
|
125
|
-
return
|
|
146
|
+
if (text) {
|
|
147
|
+
return text.trim();
|
|
126
148
|
}
|
|
127
149
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (comment.
|
|
132
|
-
return comment.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
150
|
+
return this.combineDisplayParts(comment.summary);
|
|
151
|
+
}
|
|
152
|
+
extractTagsTextFromComment(comment) {
|
|
153
|
+
if (comment && comment.blockTags) {
|
|
154
|
+
return comment.blockTags.map(tag => {
|
|
155
|
+
if (tag.tag === '@see') {
|
|
156
|
+
const content = this.combineDisplayParts(tag.content);
|
|
157
|
+
if (content === '') {
|
|
158
|
+
return '';
|
|
159
|
+
}
|
|
160
|
+
if (content.startsWith("- ")) {
|
|
161
|
+
// becuase combineDisplayParts will trim content, if there exist typedoc added hyphen, the prefix space will be removed, so added back
|
|
162
|
+
const preBlankContent = ` ${content}`;
|
|
163
|
+
// typedoc will merge all @see tag, so just replace the " - " to See to make it looks like old typedoc
|
|
164
|
+
return `\n\n${preBlankContent.replace(/ - /g, "See ")}`;
|
|
165
|
+
}
|
|
166
|
+
return `\n\nSee ${content}`;
|
|
167
|
+
}
|
|
168
|
+
else if (tag.tag === '@example') {
|
|
169
|
+
return `\n\n**Example**\n\n${this.combineDisplayParts(tag.content)}\n\n`;
|
|
144
170
|
}
|
|
145
|
-
else if (tag.tag === '
|
|
146
|
-
|
|
171
|
+
else if (tag.tag === '@member') {
|
|
172
|
+
const content = this.combineDisplayParts(tag.content);
|
|
173
|
+
const match = content.match(/\[.*?\] (.*)/);
|
|
174
|
+
let result = '';
|
|
175
|
+
if (match) {
|
|
176
|
+
result += `${match[1].trim()}`;
|
|
177
|
+
}
|
|
178
|
+
return result;
|
|
147
179
|
}
|
|
148
180
|
else {
|
|
149
181
|
return '';
|
|
@@ -151,10 +183,9 @@ var AbstractConverter = /** @class */ (function () {
|
|
|
151
183
|
}).join('');
|
|
152
184
|
}
|
|
153
185
|
return '';
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
var result = [];
|
|
186
|
+
}
|
|
187
|
+
extractType(type) {
|
|
188
|
+
let result = [];
|
|
158
189
|
if (type === undefined) {
|
|
159
190
|
return result;
|
|
160
191
|
}
|
|
@@ -167,8 +198,8 @@ var AbstractConverter = /** @class */ (function () {
|
|
|
167
198
|
else {
|
|
168
199
|
result.push({
|
|
169
200
|
unionType: {
|
|
170
|
-
types: type.types.map(
|
|
171
|
-
|
|
201
|
+
types: type.types.map(t => {
|
|
202
|
+
let childType = this.extractType(t)[0];
|
|
172
203
|
childType.parentType = type.type;
|
|
173
204
|
return childType;
|
|
174
205
|
})
|
|
@@ -177,43 +208,89 @@ var AbstractConverter = /** @class */ (function () {
|
|
|
177
208
|
}
|
|
178
209
|
}
|
|
179
210
|
else if (type.type === 'array') {
|
|
180
|
-
|
|
211
|
+
let newType = this.extractType(type.elementType);
|
|
181
212
|
result.push({
|
|
182
|
-
arrayType:
|
|
213
|
+
arrayType: {
|
|
214
|
+
...newType[0],
|
|
215
|
+
parentType: type.type
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
else if (type.type === 'conditional') {
|
|
220
|
+
result.push({
|
|
221
|
+
conditionalType: {
|
|
222
|
+
checkType: this.extractType(type.checkType)[0],
|
|
223
|
+
extendsType: this.extractType(type.extendsType)[0],
|
|
224
|
+
trueType: this.extractType(type.trueType)[0],
|
|
225
|
+
falseType: this.extractType(type.falseType)[0]
|
|
226
|
+
}
|
|
183
227
|
});
|
|
184
228
|
}
|
|
185
229
|
else if (type.type === 'intersection' && type.types.length) {
|
|
186
230
|
result.push({
|
|
187
231
|
intersectionType: {
|
|
188
|
-
types: type.types.map(
|
|
189
|
-
|
|
232
|
+
types: type.types.map(t => {
|
|
233
|
+
let childType = this.extractType(t)[0];
|
|
190
234
|
childType.parentType = type.type;
|
|
191
235
|
return childType;
|
|
192
236
|
})
|
|
193
237
|
}
|
|
194
238
|
});
|
|
195
239
|
}
|
|
240
|
+
else if (type.type === 'typeOperator') {
|
|
241
|
+
result.push({
|
|
242
|
+
operatorType: {
|
|
243
|
+
operator: type.operator,
|
|
244
|
+
target: this.extractType(type.target)[0]
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
else if (type.type === 'query') {
|
|
249
|
+
/**
|
|
250
|
+
* Represents a type that is constructed by querying the type of a reflection.
|
|
251
|
+
* ```ts
|
|
252
|
+
* const x = 1
|
|
253
|
+
* type Z = typeof x // query on reflection for x
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
result.push({
|
|
257
|
+
queryType: this.extractType(type.queryType)[0]
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
else if (type.type === 'indexedAccess') {
|
|
261
|
+
/**
|
|
262
|
+
* Represents an indexed access type.
|
|
263
|
+
* ```ts
|
|
264
|
+
* type X = A[keyof A]
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
result.push({
|
|
268
|
+
indexedAccessType: {
|
|
269
|
+
indexType: this.extractType(type.indexType)[0],
|
|
270
|
+
objectType: this.extractType(type.objectType)[0],
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
196
274
|
else if (type.type === 'reflection' && type.declaration) {
|
|
197
275
|
if (type.declaration.indexSignature) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
276
|
+
const signature = type.declaration.indexSignature;
|
|
277
|
+
result.push({
|
|
278
|
+
reflectedType: {
|
|
279
|
+
name: signature.parameters[0].name ?? 'key',
|
|
280
|
+
key: {
|
|
281
|
+
typeName: signature.parameters[0].type.name,
|
|
282
|
+
typeId: signature.parameters[0].type.id
|
|
283
|
+
},
|
|
284
|
+
value: {
|
|
285
|
+
typeName: signature.type.name,
|
|
286
|
+
typeId: signature.type.id
|
|
210
287
|
}
|
|
211
|
-
}
|
|
288
|
+
}
|
|
212
289
|
});
|
|
213
290
|
}
|
|
214
291
|
else if (type.declaration.signatures && type.declaration.signatures.length) {
|
|
215
292
|
result.push({
|
|
216
|
-
typeName: this.generateCallFunction('', this.fillParameters(type.declaration.signatures[0].parameters))
|
|
293
|
+
typeName: `${this.generateCallFunction('', this.fillParameters(type.declaration.signatures[0].parameters))} => ${(0, idResolver_1.typeToString)(this.extractType(type.declaration.signatures[0].type)[0])}`
|
|
217
294
|
});
|
|
218
295
|
}
|
|
219
296
|
else if (type.declaration.children && type.declaration.children.length) {
|
|
@@ -223,7 +300,7 @@ var AbstractConverter = /** @class */ (function () {
|
|
|
223
300
|
}
|
|
224
301
|
else {
|
|
225
302
|
result.push({
|
|
226
|
-
typeName: '
|
|
303
|
+
typeName: '{}'
|
|
227
304
|
});
|
|
228
305
|
}
|
|
229
306
|
}
|
|
@@ -234,26 +311,30 @@ var AbstractConverter = /** @class */ (function () {
|
|
|
234
311
|
typeName: type.name,
|
|
235
312
|
typeId: type.id
|
|
236
313
|
},
|
|
237
|
-
inner: type.typeArguments.map(
|
|
314
|
+
inner: type.typeArguments.map(t => this.extractType(t)[0])
|
|
238
315
|
}
|
|
239
316
|
});
|
|
240
317
|
}
|
|
241
318
|
else if (type.type === 'tuple' && type.elements && type.elements.length) {
|
|
242
319
|
result.push({
|
|
243
320
|
tupleType: {
|
|
244
|
-
types: type.elements.map(
|
|
321
|
+
types: type.elements.map(t => this.extractType(t)[0])
|
|
245
322
|
}
|
|
246
323
|
});
|
|
247
324
|
}
|
|
248
|
-
else if (type.
|
|
325
|
+
else if (type.type === 'literal') {
|
|
326
|
+
let typeName = `${type.value}`;
|
|
327
|
+
if (typeof type.value === "string") {
|
|
328
|
+
typeName = `"${type.value}"`;
|
|
329
|
+
}
|
|
249
330
|
result.push({
|
|
250
|
-
typeName:
|
|
251
|
-
typeId: type.id
|
|
331
|
+
typeName: typeName
|
|
252
332
|
});
|
|
253
333
|
}
|
|
254
|
-
else if (type.
|
|
334
|
+
else if (type.name) {
|
|
255
335
|
result.push({
|
|
256
|
-
typeName:
|
|
336
|
+
typeName: type.name,
|
|
337
|
+
typeId: type.id
|
|
257
338
|
});
|
|
258
339
|
}
|
|
259
340
|
else {
|
|
@@ -262,48 +343,93 @@ var AbstractConverter = /** @class */ (function () {
|
|
|
262
343
|
});
|
|
263
344
|
}
|
|
264
345
|
return result;
|
|
265
|
-
}
|
|
266
|
-
|
|
346
|
+
}
|
|
347
|
+
hasCommonPrefix(types) {
|
|
267
348
|
if (types && types.length > 1 && types[0].name) {
|
|
268
349
|
if (types[0].name.indexOf('.') < 0) {
|
|
269
350
|
return false;
|
|
270
351
|
}
|
|
271
|
-
|
|
272
|
-
return types.find(
|
|
352
|
+
const prefix = types[0].name.split('.')[0];
|
|
353
|
+
return types.find(t => !t.name || t.name.split('.')[0] !== prefix) === undefined;
|
|
273
354
|
}
|
|
274
355
|
return false;
|
|
275
|
-
}
|
|
276
|
-
|
|
356
|
+
}
|
|
357
|
+
generateCallFunction(prefix, parameters, typeParameters) {
|
|
277
358
|
if (parameters) {
|
|
278
|
-
return
|
|
359
|
+
return `${prefix}${this.getGenericType(typeParameters)}(${parameters.map(p => `${p.id}${p.optional ? '?' : ''}: ${((0, idResolver_1.typeToString)(p.type[0]))}`).join(', ')})`;
|
|
279
360
|
}
|
|
280
361
|
return '';
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
var _this = this;
|
|
362
|
+
}
|
|
363
|
+
fillParameters(parameters) {
|
|
284
364
|
if (parameters) {
|
|
285
|
-
return parameters.map(
|
|
286
|
-
|
|
365
|
+
return parameters.map(p => {
|
|
366
|
+
let description = '';
|
|
287
367
|
if (p.comment) {
|
|
288
|
-
description = (p.comment.
|
|
368
|
+
description = this.combineDisplayParts(p.comment.summary);
|
|
289
369
|
}
|
|
290
370
|
return {
|
|
291
371
|
id: p.name,
|
|
292
|
-
type:
|
|
293
|
-
description:
|
|
372
|
+
type: this.extractType(p.type),
|
|
373
|
+
description: description,
|
|
294
374
|
optional: Boolean(p.flags && p.flags.isOptional)
|
|
295
375
|
};
|
|
296
376
|
});
|
|
297
377
|
}
|
|
298
378
|
return [];
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
379
|
+
}
|
|
380
|
+
extractReturnComment(comment) {
|
|
381
|
+
const returnComment = this.extractTextFromComment('@returns', comment);
|
|
382
|
+
if (!returnComment) {
|
|
302
383
|
return '';
|
|
303
384
|
}
|
|
304
|
-
return
|
|
305
|
-
}
|
|
306
|
-
|
|
385
|
+
return returnComment;
|
|
386
|
+
}
|
|
387
|
+
combineDisplayParts(parts) {
|
|
388
|
+
let result = "";
|
|
389
|
+
for (const item of parts || []) {
|
|
390
|
+
switch (item.kind) {
|
|
391
|
+
case "text":
|
|
392
|
+
case "code":
|
|
393
|
+
result += item.text;
|
|
394
|
+
break;
|
|
395
|
+
case "inline-tag":
|
|
396
|
+
switch (item.tag) {
|
|
397
|
+
case "@label":
|
|
398
|
+
case "@inheritdoc": // Shouldn't happen
|
|
399
|
+
// ignore these content
|
|
400
|
+
break;
|
|
401
|
+
case "@linkcode":
|
|
402
|
+
result += `{${item.tag}`;
|
|
403
|
+
if (item.target && typeof item.target !== 'string') {
|
|
404
|
+
result += ` ${item.target}`;
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
result += ` ${item.text}`;
|
|
408
|
+
}
|
|
409
|
+
result += '}';
|
|
410
|
+
break;
|
|
411
|
+
case "@link":
|
|
412
|
+
case "@linkplain":
|
|
413
|
+
result += `{${item.tag}`;
|
|
414
|
+
if (item.target && item.target !== item.text) {
|
|
415
|
+
result += ` ${item.target}`;
|
|
416
|
+
}
|
|
417
|
+
result += ` ${item.text}}`;
|
|
418
|
+
break;
|
|
419
|
+
default:
|
|
420
|
+
// Hmm... probably want to be able to render these somehow, so custom inline tags can be given
|
|
421
|
+
// special rendering rules. Future capability. For now, just render their text.
|
|
422
|
+
result += `{${item.tag} ${item.text}}`;
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
break;
|
|
426
|
+
default:
|
|
427
|
+
(0, error_1.assertNever)(item);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return result.trim().replace(/\r/g, "");
|
|
431
|
+
}
|
|
432
|
+
extractInformationFromSignature(method, node, signatureIndex) {
|
|
307
433
|
if (node.signatures[signatureIndex].comment) {
|
|
308
434
|
method.summary = this.findDescriptionInComment(node.signatures[signatureIndex].comment);
|
|
309
435
|
}
|
|
@@ -320,16 +446,16 @@ var AbstractConverter = /** @class */ (function () {
|
|
|
320
446
|
if (node.signatures[signatureIndex].comment && node.signatures[signatureIndex].comment.tags) {
|
|
321
447
|
exceptions = node.signatures[signatureIndex].comment.tags.filter(tag => tag.tag === 'throws');
|
|
322
448
|
}
|
|
323
|
-
|
|
449
|
+
|
|
324
450
|
if (exceptions && exceptions.length) {
|
|
325
451
|
method.exceptions = exceptions.map(e => extractException(e));
|
|
326
452
|
}
|
|
327
453
|
*/
|
|
328
454
|
if (node.kindString === 'Method' || node.kindString === 'Function') {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
method.syntax.content =
|
|
455
|
+
const typeParameter = node.signatures[signatureIndex].typeParameter;
|
|
456
|
+
const functionBody = this.generateCallFunction(method.name, method.syntax.parameters, typeParameter);
|
|
457
|
+
const returnBody = (method.syntax.return && method.syntax.return.type.length > 0) ? `: ${(0, idResolver_1.typeToString)(method.syntax.return.type[0])}` : '';
|
|
458
|
+
method.syntax.content = `${node.flags && node.flags.isStatic ? 'static ' : ''}function ${functionBody}${returnBody}`;
|
|
333
459
|
method.type = node.kindString.toLowerCase();
|
|
334
460
|
if (node.inheritedFrom) {
|
|
335
461
|
method.inherited = true;
|
|
@@ -338,69 +464,68 @@ var AbstractConverter = /** @class */ (function () {
|
|
|
338
464
|
}
|
|
339
465
|
else {
|
|
340
466
|
method.name = method.uid.split('.').reverse()[1];
|
|
341
|
-
|
|
342
|
-
method.syntax.content =
|
|
467
|
+
const functionBody = this.generateCallFunction(method.name, method.syntax.parameters);
|
|
468
|
+
method.syntax.content = `new ${functionBody}`;
|
|
343
469
|
method.type = 'constructor';
|
|
344
470
|
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
return idResolver_1.typeToString(p.type[0]);
|
|
471
|
+
}
|
|
472
|
+
composeMethodNameFromSignature(method, typeParameters) {
|
|
473
|
+
const parameterType = method.syntax.parameters.map(p => {
|
|
474
|
+
return (0, idResolver_1.typeToString)(p.type[0]);
|
|
349
475
|
}).join(', ');
|
|
350
476
|
return method.name + this.getGenericType(typeParameters) + '(' + parameterType + ')';
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (node.
|
|
355
|
-
typeParameter = node.
|
|
477
|
+
}
|
|
478
|
+
parseTypeArgumentsForTypeAlias(node) {
|
|
479
|
+
let typeParameter;
|
|
480
|
+
if (node.typeParameters) {
|
|
481
|
+
typeParameter = node.typeParameters;
|
|
356
482
|
}
|
|
357
483
|
else if (node.typeArguments) {
|
|
358
484
|
typeParameter = node.typeArguments;
|
|
359
485
|
}
|
|
360
486
|
return this.getGenericType(typeParameter);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
return idResolver_1.typeToString(this.extractType(typeInfo)[0]);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
487
|
+
}
|
|
488
|
+
parseTypeDeclarationForTypeAlias(typeInfo) {
|
|
489
|
+
return (0, idResolver_1.typeToString)(this.extractType(typeInfo)[0]);
|
|
490
|
+
}
|
|
491
|
+
parseFunctionType(typeInfo) {
|
|
492
|
+
let typeResult = this.extractType(typeInfo);
|
|
493
|
+
let content = '';
|
|
368
494
|
if (typeResult.length) {
|
|
369
495
|
content = typeResult[0].typeName;
|
|
370
496
|
}
|
|
371
497
|
return content;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
var _this = this;
|
|
498
|
+
}
|
|
499
|
+
parseUserDefinedType(typeInfo) {
|
|
375
500
|
if (!typeInfo.declaration || !typeInfo.declaration.children) {
|
|
376
501
|
return '';
|
|
377
502
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
503
|
+
let content = typeInfo.declaration.children.map(child => {
|
|
504
|
+
let type = '';
|
|
505
|
+
let isOptional = child.flags && child.flags.isOptional;
|
|
506
|
+
let typePostFix = isOptional ? '?' : '';
|
|
507
|
+
if (child.kindString === 'Variable' || child.kindString === 'Property') {
|
|
508
|
+
type = `${child.name}${typePostFix}: ` + (0, idResolver_1.typeToString)(this.extractType(child.type)[0]);
|
|
383
509
|
}
|
|
384
|
-
else if (child.kindString === 'Function') {
|
|
385
|
-
type =
|
|
510
|
+
else if (child.kindString === 'Function' || child.kindString === 'Method') {
|
|
511
|
+
type = `${this.generateCallFunction(`${child.name}${typePostFix}`, this.fillParameters(child.signatures[0].parameters))} => ${(0, idResolver_1.typeToString)(this.extractType(child.signatures[0].type)[0])}`;
|
|
386
512
|
}
|
|
387
513
|
return type;
|
|
388
514
|
}).join(', ');
|
|
389
515
|
content = '{ ' + content + ' }';
|
|
390
516
|
return content;
|
|
391
|
-
}
|
|
392
|
-
|
|
517
|
+
}
|
|
518
|
+
generateInheritanceDescription(inheritedFrom) {
|
|
393
519
|
if (inheritedFrom) {
|
|
394
520
|
if (inheritedFrom.id) {
|
|
395
|
-
return
|
|
521
|
+
return `<b>Inherited From</b> [${inheritedFrom.name}](xref:${inheritedFrom.name})`;
|
|
396
522
|
}
|
|
397
523
|
else {
|
|
398
|
-
return
|
|
524
|
+
return `<b>Inherited From</b> ${inheritedFrom.name}`;
|
|
399
525
|
}
|
|
400
526
|
}
|
|
401
527
|
return null;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
}());
|
|
528
|
+
}
|
|
529
|
+
}
|
|
405
530
|
exports.AbstractConverter = AbstractConverter;
|
|
406
531
|
//# sourceMappingURL=base.js.map
|