@progress/kendo-typescript-api-tasks 1.0.1-dev.1531

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.
Files changed (60) hide show
  1. package/README.md +11 -0
  2. package/index.js +70 -0
  3. package/jest.config.js +3 -0
  4. package/lib/class-page.hbs +27 -0
  5. package/lib/class-page.js +35 -0
  6. package/lib/code-block.hbs +7 -0
  7. package/lib/comment-tags.hbs +7 -0
  8. package/lib/comment.js +56 -0
  9. package/lib/component-page.hbs +101 -0
  10. package/lib/component-page.js +67 -0
  11. package/lib/constant-page.hbs +4 -0
  12. package/lib/constant-page.js +15 -0
  13. package/lib/constructor.hbs +21 -0
  14. package/lib/enum-page.hbs +11 -0
  15. package/lib/enum-page.js +25 -0
  16. package/lib/fn-page.hbs +18 -0
  17. package/lib/fn-page.js +24 -0
  18. package/lib/generator.js +264 -0
  19. package/lib/index-page.hbs +54 -0
  20. package/lib/index-page.js +15 -0
  21. package/lib/is-constructor.js +9 -0
  22. package/lib/is-event.js +7 -0
  23. package/lib/is-field.js +7 -0
  24. package/lib/is-input.js +7 -0
  25. package/lib/is-method.js +10 -0
  26. package/lib/is-public.js +8 -0
  27. package/lib/map-constructors.js +30 -0
  28. package/lib/map-methods.js +23 -0
  29. package/lib/map-props.js +63 -0
  30. package/lib/member-meta.hbs +7 -0
  31. package/lib/member-page.js +41 -0
  32. package/lib/methods.hbs +109 -0
  33. package/lib/property.hbs +38 -0
  34. package/lib/react/component-page.hbs +26 -0
  35. package/lib/react/component-page.js +30 -0
  36. package/lib/return-type.js +30 -0
  37. package/lib/slug.js +9 -0
  38. package/lib/template-utils.js +40 -0
  39. package/lib/type-utils.js +179 -0
  40. package/lib/union-page.hbs +14 -0
  41. package/lib/union-page.js +17 -0
  42. package/lib/utils.js +40 -0
  43. package/lib/warn.js +22 -0
  44. package/lib/warning-rules.js +14 -0
  45. package/package.json +43 -0
  46. package/test/api.js +339 -0
  47. package/test/class.json +73 -0
  48. package/test/components-def.json +98 -0
  49. package/test/events-def.json +163 -0
  50. package/test/fields-def.json +203 -0
  51. package/test/fn-def.json +80 -0
  52. package/test/fn.json +89 -0
  53. package/test/inputs-def.json +98 -0
  54. package/test/interface-comments.json +412 -0
  55. package/test/intersection.json +67 -0
  56. package/test/package.json +175 -0
  57. package/test/type-union-operators.json +42 -0
  58. package/test/type-union.json +70 -0
  59. package/test/warning.js +91 -0
  60. package/type-links.json +3 -0
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # Kendo UI for Angular
2
+
3
+ This package is part of the [Kendo UI for Angular](http://www.telerik.com/kendo-angular-ui/) suite.
4
+
5
+ ## License
6
+
7
+ This is commercial software. To use it, you need to agree to the [**Telerik End User License Agreement for Kendo UI Complete**](http://www.telerik.com/purchase/license-agreement/kendo-ui-complete). If you do not own a commercial license, this file shall be governed by the trial license terms.
8
+
9
+ All available Kendo UI commercial licenses may be obtained at http://www.telerik.com/purchase/kendo-ui.
10
+
11
+ *Copyright © 2022 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.*
package/index.js ADDED
@@ -0,0 +1,70 @@
1
+ const execSync = require('child_process').execSync;
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const { merge } = require('lodash');
5
+ const typedoc = require('typedoc');
6
+ const glob = require('glob');
7
+ const generator = require('./lib/generator.js');
8
+ const typeLinks = require('./type-links.json');
9
+
10
+ const defaultConfig = {
11
+ outPath: 'docs/api',
12
+ warningsAsErrors: true,
13
+ jsonPath: path.resolve('./api.json'),
14
+ typeLinksPath: path.resolve('./api-type-links.json'),
15
+ typeLinks,
16
+ typedoc: {
17
+ excludeExternals: false
18
+ }
19
+ };
20
+
21
+ module.exports = (gulp, userConfig) => {
22
+ const series = gulp.series;
23
+
24
+ const config = merge({}, defaultConfig, userConfig);
25
+
26
+ if (fs.existsSync(config.typeLinksPath)) {
27
+ Object.assign(config.typeLinks, require(config.typeLinksPath));
28
+ }
29
+
30
+ gulp.task('api-json', async(done) => {
31
+ const entryPoints = [
32
+ ...glob.sync("src/**/*.{ts,tsx}"),
33
+ ...(config.externalApi || [])
34
+ ];
35
+
36
+ const app = new typedoc.Application();
37
+ app.options.addReader(new typedoc.TSConfigReader());
38
+ app.bootstrap({ ...config.typedoc, entryPoints });
39
+
40
+ const project = app.convert();
41
+ if (!project) {
42
+ done(new Error('Unable to initialize TypeDoc.'));
43
+ return;
44
+ }
45
+
46
+ await app.generateJson(project, config.jsonPath);
47
+ if (app.logger.hasErrors()) {
48
+ done(new Error('Unable to generate API reference, see messages above.'));
49
+ return;
50
+ }
51
+
52
+ done();
53
+ });
54
+
55
+ gulp.task('api-clean', (done) => {
56
+ execSync(`rm -rf docs/api`, { stdio: [ 0,1,2 ] });
57
+ done();
58
+ });
59
+
60
+ gulp.task('api', series('api-json', 'api-clean', (done) => {
61
+ const packageJson = path.join(process.cwd(), 'package.json');
62
+ const packageInfo = require(packageJson);
63
+ generator.generate(done, config, packageInfo);
64
+ }));
65
+
66
+ gulp.task('api-check', series('api', (done) => {
67
+ execSync(`git diff --exit-code --color -- ${config.outPath}`,{ stdio: [ 0,1,2 ] });
68
+ done();
69
+ }));
70
+ };
package/jest.config.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ testMatch: [ '<rootDir>/test/**/*.js' ]
3
+ };
@@ -0,0 +1,27 @@
1
+ {{> member_meta}}
2
+
3
+ # {{name}}
4
+ {{comment}}
5
+
6
+ {{#if props}}
7
+
8
+ <table class="api-table api-table-properties">
9
+ <thead>
10
+ <tr>
11
+ <th class="th-name">Name</th>
12
+ <th class="th-type">Type</th>
13
+ <th class="th-default">Default</th>
14
+ <th class="th-desc">Description</th>
15
+ </tr>
16
+ </thead>
17
+ <tbody class="api-table-body">
18
+ {{#each props}}
19
+ {{> property this }}
20
+ {{/each}}
21
+ </tbody>
22
+ </table>
23
+
24
+ {{/if}}
25
+
26
+ {{> constructor}}
27
+ {{> methods}}
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ const template = require('./template-utils');
4
+ const comment = require('./comment');
5
+ const mapProps = require('./map-props');
6
+ const mapConstructors = require('./map-constructors');
7
+ const mapMethods = require('./map-methods');
8
+ const fullName = require('./type-utils').fullName;
9
+
10
+ const classTemplate = template.compileFrom('class-page.hbs');
11
+ template.partialFrom('methods', 'methods.hbs');
12
+ template.partialFrom('constructor', 'constructor.hbs');
13
+
14
+ const classPage = (member, meta) => {
15
+ let props = null;
16
+ let methods = null;
17
+ let constructors = null;
18
+ if (member.children) {
19
+ constructors = mapConstructors(member);
20
+ methods = mapMethods(member.children, member.name);
21
+ props = mapProps(member.children, member.name);
22
+ }
23
+
24
+ return classTemplate(Object.assign({}, meta, {
25
+ comment: comment(member),
26
+ constructors: constructors,
27
+ props: props,
28
+ methods: methods,
29
+ name: fullName(member),
30
+ slug: member.slug
31
+ }));
32
+ };
33
+
34
+ module.exports = classPage;
35
+
@@ -0,0 +1,7 @@
1
+ <code>
2
+
3
+
4
+ {{ this }}
5
+
6
+
7
+ </code>
@@ -0,0 +1,7 @@
1
+ {{#if tags}}
2
+ {{#each tags}}
3
+
4
+
5
+ {{text}}
6
+ {{/each}}
7
+ {{/if}}
package/lib/comment.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ const template = require('./template-utils.js');
4
+ const slug = require('./slug.js');
5
+ const warn = require('./warn.js');
6
+
7
+ const commentTemplate = template.compileFrom('comment-tags.hbs');
8
+
9
+ const commentTags = (comment, member) =>
10
+ commentTemplate({
11
+ tags: comment.tags.map(tag => {
12
+ let text = tag.text.trim();
13
+
14
+ if (tag.tag === 'example') {
15
+ text = text.replace(/_@/g, '@');
16
+ } else if (tag.tag === 'see') {
17
+ const linkSlug = slug(member.packageName, text);
18
+ text = `\n\nSee [${text}]({% slug ${linkSlug} %})`;
19
+ } else {
20
+ text = '';
21
+ }
22
+
23
+ return {
24
+ text: text
25
+ };
26
+ })
27
+ });
28
+
29
+ const formatComment = (member, parentName, memberKind) => {
30
+ let signatures;
31
+ if (member.type && member.type.declaration) {
32
+ signatures = member.type.declaration.signatures;
33
+ }
34
+
35
+ const comment = member.comment || signatures && signatures[0] && signatures[0].comment;
36
+
37
+ if (!comment) {
38
+ warn(member, parentName, memberKind);
39
+
40
+ return '';
41
+ }
42
+
43
+ let output = comment.shortText || "";
44
+ if (comment.text) {
45
+ output += '\n\n' + comment.text;
46
+ }
47
+
48
+ if (comment.tags) {
49
+ output += commentTags(comment, member);
50
+ }
51
+
52
+ return output;
53
+ };
54
+
55
+ module.exports = formatComment;
56
+
@@ -0,0 +1,101 @@
1
+ {{> member_meta}}
2
+
3
+ # {{name}}
4
+ {{comment}}
5
+
6
+ ## Selector
7
+ `{{selector}}`
8
+ {{#if exportAs}}
9
+
10
+ ## Export Name
11
+ Accessible in templates as `#{{exportName}}="{{exportAs}}"`
12
+ {{/if}}
13
+
14
+ {{#if inputs}}
15
+
16
+ ## Inputs
17
+
18
+ <table class="api-table api-table-inputs">
19
+ <thead>
20
+ <tr>
21
+ <th class="th-name">Name</th>
22
+ <th class="th-type">Type</th>
23
+ <th class="th-default">Default</th>
24
+ <th class="th-desc">Description</th>
25
+ </tr>
26
+ </thead>
27
+ <tbody class="api-table-body">
28
+ {{#each inputs}}
29
+ {{> property this }}
30
+ {{/each}}
31
+ </tbody>
32
+ </table>
33
+
34
+ {{/if}}
35
+
36
+ {{#if fields}}
37
+
38
+ ## Fields
39
+
40
+ <table class="api-table api-table-fields">
41
+ <thead>
42
+ <tr>
43
+ <th class="th-name">Name</th>
44
+ <th class="th-type">Type</th>
45
+ <th class="th-default">Default</th>
46
+ <th class="th-desc">Description</th>
47
+ </tr>
48
+ </thead>
49
+ <tbody class="api-table-body">
50
+ {{#each fields}}
51
+ {{> property this }}
52
+ {{/each}}
53
+ </tbody>
54
+ </table>
55
+
56
+ {{/if}}
57
+
58
+ {{#if events}}
59
+
60
+ ## Events
61
+
62
+ <table class="api-table api-table-events">
63
+ <thead>
64
+ <tr>
65
+ <th class="th-name">Name</th>
66
+ <th class="th-type">Type</th>
67
+ <th class="th-desc">Description</th>
68
+ </tr>
69
+ </thead>
70
+ <tbody class="api-table-body">
71
+ {{#each events}}
72
+ <tr>
73
+ <td class="table-cell-name">
74
+
75
+
76
+ #### {{name}}
77
+
78
+
79
+ </td>
80
+ <td type class="table-cell-type">
81
+
82
+
83
+ {{> code_block type }}
84
+
85
+
86
+ </td>
87
+ <td class="table-cell-comment">
88
+
89
+
90
+ {{comment}}
91
+
92
+
93
+ </td>
94
+ </tr>
95
+ {{/each}}
96
+ </tbody>
97
+ </table>
98
+
99
+ {{/if}}
100
+
101
+ {{> methods}}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ const utils = require('./utils.js');
4
+ const isEvent = require('./is-event.js');
5
+ const isInput = require('./is-input.js');
6
+ const template = require('./template-utils.js');
7
+ const comment = require('./comment.js');
8
+ const mapProps = require('./map-props.js');
9
+ const mapMethods = require('./map-methods.js');
10
+ const isField = require('./is-field.js');
11
+
12
+ const ignoreWithoutComment = utils.ignore(utils.hasProp('comment'));
13
+
14
+ const componentTemplate = template.compileFrom('component-page.hbs');
15
+ template.partialFrom('member_meta', 'member-meta.hbs');
16
+ template.partialFrom('methods', 'methods.hbs');
17
+
18
+ const findDecorator = (decorators) => ((decorators || []).find(d =>
19
+ d.name === 'Component' || d.name === 'Directive'
20
+ ));
21
+
22
+ const decoratorProp = (prop) => (decorators) => {
23
+ const compDecorator = findDecorator(decorators);
24
+
25
+ if (compDecorator) {
26
+ const regExp = new RegExp(`${prop}:\\s?['"](.+?)['"]`);
27
+ const match = compDecorator.arguments.obj.match(regExp);
28
+
29
+ return match ? match[1] : undefined;
30
+ }
31
+
32
+ return undefined;
33
+ };
34
+
35
+ const selector = decoratorProp('selector');
36
+
37
+ const exportAs = decoratorProp('exportAs');
38
+
39
+ const exportName = (name) => `kendo${name.replace(/Component|Directive/, '')}Instance`;
40
+
41
+ const componentPage = (component, meta) => {
42
+ let inputs;
43
+ let fields;
44
+ let events;
45
+ let methods;
46
+ if (component.children) {
47
+ fields = ignoreWithoutComment(mapProps(component.children.filter(isField), component.name));
48
+ inputs = mapProps(component.children.filter(isInput), component.name);
49
+ events = mapProps(component.children.filter(isEvent), component.name);
50
+ methods = mapMethods(component.children, component.name);
51
+ }
52
+
53
+ return componentTemplate(Object.assign({}, meta, {
54
+ name: component.name,
55
+ selector: selector(component.decorators),
56
+ exportAs: exportAs(component.decorators),
57
+ exportName: exportName(component.name),
58
+ comment: comment(component),
59
+ inputs: inputs,
60
+ fields: fields,
61
+ events: events,
62
+ methods: methods,
63
+ slug: component.slug
64
+ }));
65
+ };
66
+
67
+ module.exports = componentPage;
@@ -0,0 +1,4 @@
1
+ {{> member_meta}}
2
+
3
+ # {{name}}
4
+ {{comment}}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ const template = require('./template-utils.js');
4
+ const comment = require('./comment.js');
5
+
6
+ const constantTemplate = template.compileFrom('constant-page.hbs');
7
+ const constantPage = (member, meta) =>
8
+ constantTemplate(Object.assign({}, meta, {
9
+ comment: comment(member),
10
+ name: member.name,
11
+ slug: member.slug
12
+ }));
13
+
14
+ module.exports = constantPage;
15
+
@@ -0,0 +1,21 @@
1
+ {{#if constructors}}
2
+
3
+ ## Constructors
4
+
5
+ {{#each constructors}}
6
+ ### {{name}}
7
+ {{> code_block signature }}
8
+ {{comment}}
9
+
10
+ {{#if params}}
11
+ #### Parameters
12
+ {{#each params}}
13
+ ##### {{name}}
14
+ {{> code_block type }}
15
+ {{comment}}
16
+
17
+ {{/each}}
18
+ {{/if}}
19
+
20
+ {{/each}}
21
+ {{/if}}
@@ -0,0 +1,11 @@
1
+ {{> member_meta}}
2
+
3
+ # {{name}}
4
+ {{comment}}
5
+
6
+ ## Values
7
+
8
+ {{#each values}}
9
+ ### {{name}}
10
+ {{comment}}
11
+ {{/each}}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ const template = require('./template-utils.js');
4
+ const comment = require('./comment.js');
5
+
6
+ function enumValues(member) {
7
+ return member.children.sort((a, b) => a.id - b.id).map(function(child) {
8
+ return {
9
+ comment: comment(child),
10
+ name: child.name
11
+ };
12
+ });
13
+ }
14
+
15
+ const enumTemplate = template.compileFrom('enum-page.hbs');
16
+ const enumPage = (member, meta) =>
17
+ enumTemplate(Object.assign({}, meta, {
18
+ comment: comment(member),
19
+ name: member.name,
20
+ values: enumValues(member),
21
+ slug: member.slug
22
+ }));
23
+
24
+ module.exports = enumPage;
25
+
@@ -0,0 +1,18 @@
1
+ {{> member_meta}}
2
+
3
+ # {{name}}
4
+ {{comment}}
5
+
6
+ {{#if params}}
7
+ #### Parameters
8
+ {{#each params}}
9
+ ##### {{name}}
10
+ {{> code_block type }}
11
+ {{comment}}
12
+
13
+ {{/each}}
14
+ {{/if}}
15
+ {{#if returns}}
16
+ #### Returns
17
+ {{> code_block returns.type }}{{#if returns.comment}} {{returns.comment}}{{/if}}
18
+ {{/if}}
package/lib/fn-page.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ const template = require('./template-utils.js');
4
+ const comment = require('./comment.js');
5
+ const returnType = require('./return-type');
6
+ const types = require('./type-utils.js');
7
+
8
+ const fnTemplate = template.compileFrom('fn-page.hbs');
9
+
10
+ const fnPage = (member, meta) => {
11
+ const signature = member.signatures[0];
12
+ const commentRoot = member.comment ? member : signature;
13
+
14
+ return fnTemplate(Object.assign({}, meta, {
15
+ comment: comment(commentRoot),
16
+ name: types.fullName(signature),
17
+ params: types.params(signature),
18
+ returns: returnType(signature),
19
+ slug: member.slug
20
+ }));
21
+ };
22
+
23
+ module.exports = fnPage;
24
+