@progress/kendo-typescript-api-tasks 1.1.2-dev.9 → 2.0.1-dev.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/CHANGELOG.md +23 -0
- package/index.js +14 -5
- package/lib/class-page.js +2 -2
- package/lib/comment.js +16 -11
- package/lib/component-page.js +4 -4
- package/lib/generator.js +29 -21
- package/lib/is-constructor.js +2 -1
- package/lib/is-method.js +2 -1
- package/lib/map-constructors.js +9 -10
- package/lib/map-methods.js +4 -6
- package/lib/map-props.js +10 -9
- package/lib/plugins/decorators.js +44 -0
- package/lib/react/component-page.js +2 -2
- package/lib/return-type.js +11 -11
- package/lib/source.js +13 -0
- package/lib/type-utils.js +7 -6
- package/lib/warn.js +3 -8
- package/package.json +6 -5
- package/test/api.js +22 -15
- package/test/class.json +29 -9
- package/test/components-def.json +56 -16
- package/test/events-def.json +39 -8
- package/test/fields-def.json +62 -12
- package/test/fn-def.json +41 -10
- package/test/fn.json +62 -13
- package/test/inputs-def.json +27 -3
- package/test/interface-comments.json +84 -23
- package/test/intersection.json +1 -1
- package/test/package.json +7 -6
- package/test/warning.js +27 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.0.0](https://github.com/telerik/kendo-build-tasks/compare/@progress/kendo-typescript-api-tasks@1.1.1...@progress/kendo-typescript-api-tasks@2.0.0) (2023-10-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **typescript-api-tasks:** list file location in warnings ([79d12fc](https://github.com/telerik/kendo-build-tasks/commit/79d12fcba72bdd8fda6f1933828adc41d920bf49))
|
|
12
|
+
* **typescript-api-tasks:** read comments from all base types ([e1dd708](https://github.com/telerik/kendo-build-tasks/commit/e1dd70810d01a9f4462b3d6ed988478ce70daf3c))
|
|
13
|
+
* **typescript-api-tasks:** support decorators for TS 4.6 ([12046b7](https://github.com/telerik/kendo-build-tasks/commit/12046b768016b75612e1e7ca8779bc39cb70dffb))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **kendo-typescript-api-tasks:** upgrade to Typedoc 0.25 ([802666f](https://github.com/telerik/kendo-build-tasks/commit/802666f570e2e4f46fa532a57393ffa18b5902f5))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### BREAKING CHANGES
|
|
22
|
+
|
|
23
|
+
* **kendo-typescript-api-tasks:** No longer compatible with TypeScript < 4.6
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
## [1.1.1](https://github.com/telerik/kendo-build-tasks/compare/@progress/kendo-typescript-api-tasks@1.1.0...@progress/kendo-typescript-api-tasks@1.1.1) (2022-12-05)
|
|
7
30
|
|
|
8
31
|
|
package/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
const execSync = require('child_process').execSync;
|
|
2
4
|
const fs = require('fs');
|
|
3
5
|
const path = require('path');
|
|
@@ -18,7 +20,8 @@ const defaultConfig = {
|
|
|
18
20
|
}
|
|
19
21
|
};
|
|
20
22
|
|
|
21
|
-
module.exports =
|
|
23
|
+
module.exports.ReflectionKind = typedoc.ReflectionKind;
|
|
24
|
+
module.exports.addAPITasks = (gulp, userConfig) => {
|
|
22
25
|
const series = gulp.series;
|
|
23
26
|
|
|
24
27
|
const config = merge({}, defaultConfig, userConfig);
|
|
@@ -33,11 +36,17 @@ module.exports = (gulp, userConfig) => {
|
|
|
33
36
|
...(config.externalApi || [])
|
|
34
37
|
];
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
let app = await typedoc.Application.bootstrapWithPlugins(
|
|
40
|
+
{
|
|
41
|
+
...config.typedoc,
|
|
42
|
+
entryPoints,
|
|
43
|
+
plugin: [ path.join(__dirname, './lib/plugins/decorators.js') ]
|
|
44
|
+
}, [
|
|
45
|
+
new typedoc.TSConfigReader()
|
|
46
|
+
]
|
|
47
|
+
);
|
|
39
48
|
|
|
40
|
-
const project = app.convert();
|
|
49
|
+
const project = await app.convert();
|
|
41
50
|
if (!project) {
|
|
42
51
|
done(new Error('Unable to initialize TypeDoc.'));
|
|
43
52
|
return;
|
package/lib/class-page.js
CHANGED
|
@@ -17,8 +17,8 @@ const classPage = (member, meta) => {
|
|
|
17
17
|
let constructors = null;
|
|
18
18
|
if (member.children) {
|
|
19
19
|
constructors = mapConstructors(member);
|
|
20
|
-
methods = mapMethods(member.children, member
|
|
21
|
-
props = mapProps(member.children, member
|
|
20
|
+
methods = mapMethods(member.children, member);
|
|
21
|
+
props = mapProps(member.children, member);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
return classTemplate(Object.assign({}, meta, {
|
package/lib/comment.js
CHANGED
|
@@ -8,12 +8,12 @@ const commentTemplate = template.compileFrom('comment-tags.hbs');
|
|
|
8
8
|
|
|
9
9
|
const commentTags = (comment, member) =>
|
|
10
10
|
commentTemplate({
|
|
11
|
-
tags: comment.
|
|
12
|
-
let text = tag.text.trim();
|
|
11
|
+
tags: comment.blockTags.map(tag => {
|
|
12
|
+
let text = tag.content.map(c => c.text).join('').trim();
|
|
13
13
|
|
|
14
|
-
if (tag.tag === 'example') {
|
|
14
|
+
if (tag.tag === '@example') {
|
|
15
15
|
text = text.replace(/_@/g, '@');
|
|
16
|
-
} else if (tag.tag === 'see') {
|
|
16
|
+
} else if (tag.tag === '@see') {
|
|
17
17
|
const linkSlug = slug(member.packageName, text);
|
|
18
18
|
text = `\n\nSee [${text}]({% slug ${linkSlug} %})`;
|
|
19
19
|
} else {
|
|
@@ -26,7 +26,15 @@ const commentTags = (comment, member) =>
|
|
|
26
26
|
})
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
const
|
|
29
|
+
const commentSummary = (comment) => {
|
|
30
|
+
if (!comment.summary) {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return comment.summary.map(c => c.text).join('').trim();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const formatComment = (member, parent) => {
|
|
30
38
|
let signatures;
|
|
31
39
|
if (member.type && member.type.declaration) {
|
|
32
40
|
signatures = member.type.declaration.signatures;
|
|
@@ -35,17 +43,14 @@ const formatComment = (member, parentName, memberKind) => {
|
|
|
35
43
|
const comment = member.comment || signatures && signatures[0] && signatures[0].comment;
|
|
36
44
|
|
|
37
45
|
if (!comment) {
|
|
38
|
-
warn(member,
|
|
46
|
+
warn(member, parent);
|
|
39
47
|
|
|
40
48
|
return '';
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
let output = comment
|
|
44
|
-
if (comment.text) {
|
|
45
|
-
output += '\n\n' + comment.text;
|
|
46
|
-
}
|
|
51
|
+
let output = commentSummary(comment);
|
|
47
52
|
|
|
48
|
-
if (comment.
|
|
53
|
+
if (comment.blockTags) {
|
|
49
54
|
output += commentTags(comment, member);
|
|
50
55
|
}
|
|
51
56
|
|
package/lib/component-page.js
CHANGED
|
@@ -44,10 +44,10 @@ const componentPage = (component, meta) => {
|
|
|
44
44
|
let events;
|
|
45
45
|
let methods;
|
|
46
46
|
if (component.children) {
|
|
47
|
-
fields = ignoreWithoutComment(mapProps(component.children.filter(isField), component
|
|
48
|
-
inputs = mapProps(component.children.filter(isInput), component
|
|
49
|
-
events = mapProps(component.children.filter(isEvent), component
|
|
50
|
-
methods = mapMethods(component.children, component
|
|
47
|
+
fields = ignoreWithoutComment(mapProps(component.children.filter(isField), component));
|
|
48
|
+
inputs = ignoreWithoutComment(mapProps(component.children.filter(isInput), component));
|
|
49
|
+
events = mapProps(component.children.filter(isEvent), component);
|
|
50
|
+
methods = mapMethods(component.children, component);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
return componentTemplate(Object.assign({}, meta, {
|
package/lib/generator.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
const fs = require('fs');
|
|
2
4
|
const mkdirp = require('mkdirp');
|
|
3
5
|
const path = require('path');
|
|
@@ -5,11 +7,12 @@ const indexPage = require('./index-page.js');
|
|
|
5
7
|
const memberPage = require('./member-page.js');
|
|
6
8
|
const slug = require('./slug.js');
|
|
7
9
|
const utils = require('./utils.js');
|
|
10
|
+
const { ReflectionKind } = require('typedoc');
|
|
8
11
|
|
|
9
|
-
const moduleFilter = (module) => module.children;
|
|
12
|
+
const moduleFilter = (module) => module.kind === ReflectionKind.Module && module.children;
|
|
10
13
|
|
|
11
14
|
const kind = (member, module) => {
|
|
12
|
-
let kind = member.
|
|
15
|
+
let kind = ReflectionKind.singularString(member.kind).toLowerCase();
|
|
13
16
|
const notBaseType = kind !== 'function' && kind !== 'enumeration' && kind !== 'interface' &&
|
|
14
17
|
kind !== 'object literal' && kind !== 'module';
|
|
15
18
|
|
|
@@ -30,10 +33,10 @@ const kind = (member, module) => {
|
|
|
30
33
|
|
|
31
34
|
const addTypeSlug = (element, knownTypes, typeLinks) => {
|
|
32
35
|
if (element.type === 'reference' ||
|
|
33
|
-
(typeof element.type !== 'string' && knownTypes[element.
|
|
34
|
-
const type = knownTypes[element.
|
|
36
|
+
(typeof element.type !== 'string' && knownTypes[element.target])) {
|
|
37
|
+
const type = knownTypes[element.target];
|
|
35
38
|
if (type) {
|
|
36
|
-
element.
|
|
39
|
+
element.slug = type.slug;
|
|
37
40
|
} else if (typeLinks[element.name]) {
|
|
38
41
|
element.typeLink = typeLinks[element.name];
|
|
39
42
|
}
|
|
@@ -88,24 +91,27 @@ const normalizeUnionReferences = (element, members) => {
|
|
|
88
91
|
const normalizeMembers = (members) => {
|
|
89
92
|
traverseElements(members, (element) => {
|
|
90
93
|
normalizeUnionReferences(element, members);
|
|
94
|
+
mergeBaseOptions(element, members);
|
|
91
95
|
|
|
92
|
-
if (!element.comment && element.
|
|
93
|
-
|
|
94
|
-
const interfaceOptions = members.find((child) => child.name === interfaceName);
|
|
95
|
-
|
|
96
|
-
if (interfaceOptions) {
|
|
97
|
-
const baseOption = interfaceOptions.children.find(child => child.name === element.name);
|
|
98
|
-
if (baseOption) {
|
|
99
|
-
mergeComments(element, baseOption);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
96
|
+
if (!element.comment && element.kind === ReflectionKind.Accessor) {
|
|
97
|
+
element.comment = (element.setSignature || {}).comment || (element.getSignature || {}).comment || [];
|
|
102
98
|
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const mergeBaseOptions = (element, members) => {
|
|
103
|
+
if (!element.comment && (element.implementationOf || element.inheritedFrom)) {
|
|
104
|
+
const interfaceName = (element.implementationOf || element.inheritedFrom).name.split('.')[0];
|
|
105
|
+
const interfaceOptions = members.find((child) => child.name === interfaceName);
|
|
103
106
|
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
+
if (interfaceOptions) {
|
|
108
|
+
const baseOption = interfaceOptions.children.find(child => child.name === element.name);
|
|
109
|
+
if (baseOption) {
|
|
110
|
+
mergeBaseOptions(baseOption, members);
|
|
111
|
+
mergeComments(element, baseOption);
|
|
112
|
+
}
|
|
107
113
|
}
|
|
108
|
-
}
|
|
114
|
+
}
|
|
109
115
|
};
|
|
110
116
|
|
|
111
117
|
const mergeComments = (root, src) => {
|
|
@@ -140,9 +146,10 @@ const extractMembers = (packageName, modules, config) => {
|
|
|
140
146
|
|
|
141
147
|
const models = nonEmptyModules.map(module => module
|
|
142
148
|
.children
|
|
143
|
-
.filter(child => child.
|
|
149
|
+
.filter(child => child.kind !== ReflectionKind.Reference)
|
|
144
150
|
.filter(child => child.name !== 'core')
|
|
145
151
|
.filter(child => child.sources && !child.sources[0].fileName.includes('prosemirror'))
|
|
152
|
+
.filter(child => child.sources && !child.sources[0].fileName.includes('@types'))
|
|
146
153
|
.map(child => {
|
|
147
154
|
const fullName = moduleFullName(module.name, packageName, rootModules);
|
|
148
155
|
|
|
@@ -158,6 +165,7 @@ const extractMembers = (packageName, modules, config) => {
|
|
|
158
165
|
packageName: fullName,
|
|
159
166
|
url: `${child.name}`,
|
|
160
167
|
signatures: child.signatures,
|
|
168
|
+
sources: child.sources,
|
|
161
169
|
slug: slug(fullName, child.name),
|
|
162
170
|
typeParameter: child.typeParameter
|
|
163
171
|
};
|
|
@@ -190,7 +198,7 @@ const namespacesAsModules = data => {
|
|
|
190
198
|
.children
|
|
191
199
|
.filter(child => child.name !== 'core')
|
|
192
200
|
.forEach(child => {
|
|
193
|
-
if (child.
|
|
201
|
+
if (child.kind === ReflectionKind.Module && child.children) {
|
|
194
202
|
modules.push(child);
|
|
195
203
|
}
|
|
196
204
|
})
|
package/lib/is-constructor.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const { ReflectionKind } = require('typedoc');
|
|
3
4
|
const isPublic = require('./is-public');
|
|
4
5
|
|
|
5
6
|
const isConstructor = (prop) =>
|
|
6
|
-
prop.
|
|
7
|
+
prop.kind && prop.kind === ReflectionKind.Constructor && isPublic(prop);
|
|
7
8
|
|
|
8
9
|
module.exports = isConstructor;
|
|
9
10
|
|
package/lib/is-method.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const { ReflectionKind } = require('typedoc');
|
|
3
4
|
const isPublic = require('./is-public');
|
|
4
5
|
const isInput = require('./is-input');
|
|
5
6
|
|
|
6
7
|
const isMethod = (prop) =>
|
|
7
|
-
prop.
|
|
8
|
+
prop.kind && prop.kind === ReflectionKind.Method && isPublic(prop) && !isInput(prop);
|
|
8
9
|
|
|
9
10
|
module.exports = isMethod;
|
|
10
11
|
|
package/lib/map-constructors.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
+
const { ReflectionKind } = require('typedoc');
|
|
3
4
|
const comment = require('./comment');
|
|
4
5
|
const isPublic = require('./is-public');
|
|
5
6
|
const types = require('./type-utils');
|
|
6
7
|
const utils = require('./utils');
|
|
7
8
|
|
|
8
9
|
const isConstructor = (prop) =>
|
|
9
|
-
prop.
|
|
10
|
+
prop.kind && prop.kind === ReflectionKind.Constructor && isPublic(prop);
|
|
10
11
|
|
|
11
12
|
const mapConstructors = (member) => {
|
|
12
13
|
if (member.decorators && member.decorators.find(d => d.name === 'NgModule')) {
|
|
@@ -14,16 +15,14 @@ const mapConstructors = (member) => {
|
|
|
14
15
|
return [];
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
return utils.flatten(member.children.filter(isConstructor).map(ctr =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return ctr.signatures.map((signature) => ({
|
|
18
|
+
return utils.flatten(member.children.filter(isConstructor).map(ctr =>
|
|
19
|
+
ctr.signatures.map((signature) => ({
|
|
21
20
|
signature: types.callSignature(signature),
|
|
22
|
-
comment: comment(signature
|
|
21
|
+
comment: comment(signature),
|
|
23
22
|
name: types.fullName(member),
|
|
24
|
-
params: types.params(signature
|
|
25
|
-
}))
|
|
26
|
-
|
|
23
|
+
params: types.params(signature)
|
|
24
|
+
}))
|
|
25
|
+
));
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
module.exports = mapConstructors;
|
package/lib/map-methods.js
CHANGED
|
@@ -6,16 +6,14 @@ const isMethod = require('./is-method.js');
|
|
|
6
6
|
const returnType = require('./return-type');
|
|
7
7
|
const utils = require('./utils');
|
|
8
8
|
|
|
9
|
-
const mapMethods = (children,
|
|
9
|
+
const mapMethods = (children, parent) =>
|
|
10
10
|
utils.flatten(children.filter(isMethod).map(method => {
|
|
11
11
|
const name = method.name;
|
|
12
|
-
const source = `${parentName}.${name}`;
|
|
13
|
-
|
|
14
12
|
return method.signatures.map((signature) => ({
|
|
15
|
-
comment: comment(signature,
|
|
13
|
+
comment: comment(signature, parent),
|
|
16
14
|
name: name,
|
|
17
|
-
returns: returnType(signature,
|
|
18
|
-
params: types.params(signature,
|
|
15
|
+
returns: returnType(signature, parent),
|
|
16
|
+
params: types.params(signature, parent)
|
|
19
17
|
}));
|
|
20
18
|
}));
|
|
21
19
|
|
package/lib/map-props.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const { ReflectionKind } = require('typedoc');
|
|
3
4
|
const comment = require('./comment');
|
|
4
5
|
const types = require('./type-utils');
|
|
5
6
|
const isConstructor = require('./is-constructor');
|
|
@@ -9,22 +10,22 @@ const isMethod = require('./is-method');
|
|
|
9
10
|
const isPublic = require('./is-public');
|
|
10
11
|
|
|
11
12
|
const defaultValue = prop => {
|
|
12
|
-
const { comment: {
|
|
13
|
-
const {
|
|
13
|
+
const { comment: { blockTags = [] } = {} } = prop;
|
|
14
|
+
const { content = [ { text: '' } ] } = blockTags.find(t => t.tag === '@default') || {};
|
|
14
15
|
|
|
15
|
-
return
|
|
16
|
+
return content && content.map(c => c.text).join(' ').replace(/```ts\n/g, '').replace(/\n```/g, '').trim();
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const accessor = signature => (Array.isArray(signature) ? signature[0] : signature);
|
|
19
20
|
|
|
20
21
|
const isProp = (prop) => isPublic(prop) && !isConstructor(prop) && !isMethod(prop);
|
|
21
|
-
const mapProps = (children,
|
|
22
|
+
const mapProps = (children, parent) =>
|
|
22
23
|
children.filter(isProp).map(prop => {
|
|
23
24
|
let type;
|
|
24
25
|
let commentProp = prop;
|
|
25
26
|
if (prop.type) {
|
|
26
27
|
type = types.typeString(prop);
|
|
27
|
-
} else if (prop.
|
|
28
|
+
} else if (prop.kind === ReflectionKind.Accessor) {
|
|
28
29
|
const getter = prop.getSignature;
|
|
29
30
|
const setter = prop.setSignature;
|
|
30
31
|
|
|
@@ -33,7 +34,7 @@ const mapProps = (children, parentName) =>
|
|
|
33
34
|
accessor(setter).parameters[0] :
|
|
34
35
|
accessor(getter)
|
|
35
36
|
);
|
|
36
|
-
} else if (prop.
|
|
37
|
+
} else if (prop.kind === ReflectionKind.Method) {
|
|
37
38
|
type = types.callType(prop.signatures[0]);
|
|
38
39
|
commentProp = prop.signatures[0];
|
|
39
40
|
}
|
|
@@ -41,9 +42,9 @@ const mapProps = (children, parentName) =>
|
|
|
41
42
|
let name = prop.name;
|
|
42
43
|
if (isInput(prop) || isEvent(prop)) {
|
|
43
44
|
const inputArgs = prop.decorators ? prop.decorators[0].arguments : {};
|
|
44
|
-
if (inputArgs.
|
|
45
|
+
if (inputArgs.obj) {
|
|
45
46
|
/* eslint-disable no-eval */
|
|
46
|
-
name = eval(inputArgs.
|
|
47
|
+
name = eval(inputArgs.obj);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -55,7 +56,7 @@ const mapProps = (children, parentName) =>
|
|
|
55
56
|
name: name,
|
|
56
57
|
type: type,
|
|
57
58
|
defaultValue: defaultValue(prop),
|
|
58
|
-
comment: comment(commentProp,
|
|
59
|
+
comment: comment(commentProp, parent)
|
|
59
60
|
};
|
|
60
61
|
});
|
|
61
62
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const td = require('typedoc');
|
|
2
|
+
const ts = td.TypeScript;
|
|
3
|
+
|
|
4
|
+
/** @param {td.Application} app */
|
|
5
|
+
exports.load = function(app) {
|
|
6
|
+
// Add decorator info to reflections
|
|
7
|
+
app.converter.on(td.Converter.EVENT_CREATE_DECLARATION, addDecoratorInfo);
|
|
8
|
+
|
|
9
|
+
// Add decorator info to serialized json
|
|
10
|
+
app.serializer.addSerializer({
|
|
11
|
+
priority: 0,
|
|
12
|
+
supports(item) {
|
|
13
|
+
return item instanceof td.DeclarationReflection;
|
|
14
|
+
},
|
|
15
|
+
toObject(item, obj) {
|
|
16
|
+
if (item.decorators) {
|
|
17
|
+
obj.decorators = item.decorators;
|
|
18
|
+
}
|
|
19
|
+
return obj;
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function addDecoratorInfo(context, decl) {
|
|
25
|
+
const symbol = context.project.getSymbolFromReflection(decl);
|
|
26
|
+
if (!symbol) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const declaration = symbol.valueDeclaration;
|
|
31
|
+
if (!declaration) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const decorators = (declaration.decorators ?? declaration.modifiers ?? [])
|
|
36
|
+
.filter(ts.isDecorator).map((d) => ({
|
|
37
|
+
name: d.expression.expression.getText(),
|
|
38
|
+
arguments: { obj: d.expression.arguments[0]?.getText() }
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
if (decorators && decorators.length > 0) {
|
|
42
|
+
decl.decorators = decorators;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -14,8 +14,8 @@ const componentPage = (component, meta) => {
|
|
|
14
14
|
let properties;
|
|
15
15
|
let methods;
|
|
16
16
|
if (component.children) {
|
|
17
|
-
properties = mapProps(component.children.filter(isField), component
|
|
18
|
-
methods = mapMethods(component.children, component
|
|
17
|
+
properties = mapProps(component.children.filter(isField), component);
|
|
18
|
+
methods = mapMethods(component.children, component);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
return componentTemplate(Object.assign({}, meta, {
|
package/lib/return-type.js
CHANGED
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
const types = require('./type-utils.js');
|
|
4
4
|
const utils = require('./utils.js');
|
|
5
|
+
const source = require('./source');
|
|
5
6
|
|
|
6
|
-
const returnType = (definition,
|
|
7
|
+
const returnType = (definition, parent) => {
|
|
7
8
|
if (definition.type.name === 'void') {
|
|
8
9
|
return undefined;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
let
|
|
12
|
-
if (definition.comment) {
|
|
13
|
-
|
|
12
|
+
let tag;
|
|
13
|
+
if (definition.comment && definition.comment.blockTags) {
|
|
14
|
+
tag = definition.comment.blockTags.find(t => t.tag === '@returns');
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
utils.warn('Undocumented return type', source);
|
|
17
|
+
let comment = '';
|
|
18
|
+
if ((!tag && definition.type.name !== 'void') || (tag && tag.content.length === 0)) {
|
|
19
|
+
utils.warn('Undocumented return type', source(definition, parent));
|
|
20
|
+
} else {
|
|
21
|
+
comment = tag.content.map(c => c.text).join('').trim();
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
return {
|
|
25
25
|
type: types.typeString(definition),
|
|
26
|
-
comment
|
|
26
|
+
comment
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
|
package/lib/source.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const source = (member, parent) => {
|
|
2
|
+
const source = member.sources[0];
|
|
3
|
+
let sourceFile = `${source.fileName}:${source.line}`;
|
|
4
|
+
if (parent) {
|
|
5
|
+
const parentSource = parent.sources[0];
|
|
6
|
+
if (parentSource.fileName !== source.fileName) {
|
|
7
|
+
sourceFile = `${parentSource.fileName}:${parentSource.line} -> ` + sourceFile;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return `'${member.name}' ${sourceFile}`;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = source;
|
package/lib/type-utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const { ReflectionKind } = require('typedoc');
|
|
3
4
|
const comment = require('./comment');
|
|
4
5
|
|
|
5
6
|
const unionTypes = (member) =>
|
|
@@ -34,9 +35,9 @@ const anonParams = (definition) => {
|
|
|
34
35
|
return params;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
const params = (definition,
|
|
38
|
+
const params = (definition, parent) => {
|
|
38
39
|
const paramComment = (param) =>
|
|
39
|
-
comment(param,
|
|
40
|
+
comment(param, parent, 'parameter').trim();
|
|
40
41
|
|
|
41
42
|
const params = anonParams(definition);
|
|
42
43
|
params.forEach((param) => {
|
|
@@ -78,8 +79,8 @@ const callType = (definition) => {
|
|
|
78
79
|
|
|
79
80
|
const typeName = (type) => {
|
|
80
81
|
const name = type.name;
|
|
81
|
-
if (type.
|
|
82
|
-
return `[${ name }]({% slug ${ type.
|
|
82
|
+
if (type.slug) {
|
|
83
|
+
return `[${ name }]({% slug ${ type.slug } %})`;
|
|
83
84
|
} else if (type.typeLink) {
|
|
84
85
|
return `[${ name }](${ type.typeLink })`;
|
|
85
86
|
} else if (type.type === 'array') {
|
|
@@ -104,7 +105,7 @@ const singleTypeString = (type) => {
|
|
|
104
105
|
const decl = type.declaration;
|
|
105
106
|
if (decl.signatures) {
|
|
106
107
|
const sig = decl.signatures[0];
|
|
107
|
-
if (decl.name === '__type' && sig.
|
|
108
|
+
if (decl.name === '__type' && sig.kind === ReflectionKind.CallSignature) {
|
|
108
109
|
return callType(sig);
|
|
109
110
|
}
|
|
110
111
|
} else if (decl.indexSignature) {
|
|
@@ -139,7 +140,7 @@ const singleTypeString = (type) => {
|
|
|
139
140
|
const typeString = (prop) => {
|
|
140
141
|
const type = prop.type;
|
|
141
142
|
|
|
142
|
-
if (!type && prop.
|
|
143
|
+
if (!type && prop.kind === ReflectionKind.Method) {
|
|
143
144
|
return singleTypeString(prop.signatures[0]);
|
|
144
145
|
}
|
|
145
146
|
|
package/lib/warn.js
CHANGED
|
@@ -2,20 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
const utils = require('./utils.js');
|
|
4
4
|
const rules = require('./warning-rules.js');
|
|
5
|
+
const source = require('./source');
|
|
5
6
|
|
|
6
7
|
const runner = rules => member =>
|
|
7
8
|
rules.reduce((result, rule) => result && rule(member), true);
|
|
8
9
|
|
|
9
|
-
const warn = (member,
|
|
10
|
+
const warn = (member, parent, kind = 'member') => {
|
|
10
11
|
const shouldWarn = runner(rules);
|
|
11
|
-
let source = member.name;
|
|
12
|
-
|
|
13
|
-
if (parentName) {
|
|
14
|
-
source = `${parentName}.${source}`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
12
|
if (shouldWarn(member)) {
|
|
18
|
-
utils.warn(`Undocumented ${kind}`, source);
|
|
13
|
+
utils.warn(`Undocumented ${kind}`, source(member, parent));
|
|
19
14
|
}
|
|
20
15
|
};
|
|
21
16
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-typescript-api-tasks",
|
|
3
3
|
"description": "Kendo UI API docs package gulp tasks",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1-dev.0+f675627",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"API Generation"
|
|
15
15
|
],
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"typescript": "4.
|
|
17
|
+
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"glob": "^8.0.3",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"handlebars": "^4.7.7",
|
|
23
23
|
"lodash": "^4.17.21",
|
|
24
24
|
"mkdirp": "^1.0.4",
|
|
25
|
-
"typedoc": "0.
|
|
25
|
+
"typedoc": "0.25.2"
|
|
26
26
|
},
|
|
27
27
|
"overrides": {
|
|
28
28
|
"chokidar": "^3.0.0",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"jest-cli": "^29.2.2"
|
|
40
|
+
"jest-cli": "^29.2.2",
|
|
41
|
+
"typescript": "5.2.2"
|
|
41
42
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "f675627f612cd05d7c8c46c1058840a11b7147cb"
|
|
43
44
|
}
|