@progress/kendo-typescript-tasks 10.0.21-ng12.37 → 10.0.22-dev.4
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/api.config.js +16 -2
- package/api.js +6 -28
- package/gulp-tasks.js +33 -18
- package/gulpfile.js +3 -6
- package/package.json +11 -13
- package/spec-bundle.js +1 -1
- package/src/api/component-page.js +2 -0
- package/src/api/enum-page.js +1 -1
- package/src/api/generator.js +27 -27
- package/src/api/map-constructors.js +2 -10
- package/src/api/map-props.js +1 -1
- package/src/api/member-page.js +0 -1
- package/src/api/return-type.js +1 -1
- package/src/api/template-utils.js +1 -1
- package/src/api/type-utils.js +3 -3
- package/src/api/utils.js +6 -6
- package/stub-loader.js +1 -1
- package/test/api.js +10 -10
- package/src/linter.js +0 -18
package/api.config.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
const os = require('os');
|
|
1
2
|
const path = require('path');
|
|
2
3
|
|
|
3
|
-
const jsonPath = path.
|
|
4
|
+
const jsonPath = path.join(os.tmpdir(), `api-${process.pid}.json`);
|
|
4
5
|
const typedoc = {
|
|
5
|
-
|
|
6
|
+
// TypeScript options
|
|
7
|
+
module: 'commonjs',
|
|
8
|
+
target: 'es6',
|
|
9
|
+
types: [],
|
|
10
|
+
experimentalDecorators: true,
|
|
11
|
+
jsx: 'react', // support for tsx files
|
|
12
|
+
|
|
13
|
+
// Output options
|
|
14
|
+
json: jsonPath,
|
|
15
|
+
|
|
16
|
+
// Typedoc options
|
|
17
|
+
excludeExternals: true,
|
|
18
|
+
ignoreCompilerErrors: false,
|
|
19
|
+
includeDeclarations: true
|
|
6
20
|
};
|
|
7
21
|
|
|
8
22
|
module.exports = {
|
package/api.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const execSync = require('child_process').execSync;
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const typedoc = require('gulp-typedoc');
|
|
5
6
|
const { merge } = require('lodash');
|
|
6
|
-
const typedoc = require('typedoc');
|
|
7
|
-
const glob = require('glob');
|
|
8
7
|
|
|
9
8
|
const api = require('./src/api/generator.js');
|
|
10
9
|
const apiConfig = require('./api.config.js');
|
|
@@ -13,34 +12,13 @@ module.exports = (gulp, userConfig) => {
|
|
|
13
12
|
const series = gulp.series;
|
|
14
13
|
|
|
15
14
|
const config = merge({}, apiConfig, userConfig);
|
|
15
|
+
const DECLARATIONS = [ "typings/index.d.ts", "node_modules/@types/core-js/index.d.ts" ];
|
|
16
16
|
|
|
17
|
-
gulp.task('api-json',
|
|
18
|
-
|
|
19
|
-
...glob.sync("src/**/*.{ts,tsx}"),
|
|
20
|
-
...(config.externalApi || [])
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
const app = new typedoc.Application();
|
|
24
|
-
app.options.addReader(new typedoc.TSConfigReader());
|
|
25
|
-
app.bootstrap({ ...config.typedoc, entryPoints });
|
|
26
|
-
|
|
27
|
-
const project = app.convert();
|
|
28
|
-
if (!project) {
|
|
29
|
-
done(new Error('Unable to initialize TypeDoc.'));
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
await app.generateJson(project, apiConfig.jsonPath);
|
|
34
|
-
if (app.logger.hasErrors()) {
|
|
35
|
-
done(new Error('Unable to generate API reference, see messages above.'));
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
done();
|
|
40
|
-
});
|
|
17
|
+
gulp.task('api-json', () => gulp.src([ "src/**/*.{ts,tsx}", ...DECLARATIONS, ...(config.externalApi || []) ], { "allowEmpty": true })
|
|
18
|
+
.pipe(typedoc(config.typedoc)));
|
|
41
19
|
|
|
42
20
|
gulp.task('api-clean', (done) => {
|
|
43
|
-
execSync(`rm -rf docs/api`, {stdio:[0,1,2]});
|
|
21
|
+
execSync(`rm -rf docs/api`, { stdio: [ 0,1,2 ] });
|
|
44
22
|
done();
|
|
45
23
|
});
|
|
46
24
|
|
|
@@ -51,7 +29,7 @@ module.exports = (gulp, userConfig) => {
|
|
|
51
29
|
}));
|
|
52
30
|
|
|
53
31
|
gulp.task('api-check', series('api', (done) => {
|
|
54
|
-
execSync(`git diff --exit-code --color -- ${config.outPath}`,{stdio:[0,1,2]});
|
|
32
|
+
execSync(`git diff --exit-code --color -- ${config.outPath}`,{ stdio: [ 0,1,2 ] });
|
|
55
33
|
done();
|
|
56
34
|
}));
|
|
57
35
|
};
|
package/gulp-tasks.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
const del = require('del');
|
|
4
4
|
const childProcess = require('child_process');
|
|
5
5
|
const path = require('path');
|
|
6
|
+
const gulpTsLint = require('gulp-tslint');
|
|
7
|
+
const tslint = require('tslint');
|
|
6
8
|
|
|
7
9
|
const apiTasks = require('./api.js');
|
|
8
10
|
const commonTasks = require('@progress/kendo-common-tasks');
|
|
9
|
-
const linter = require('./src/linter');
|
|
10
11
|
|
|
11
12
|
const webpackConfig = require('./webpack.config.js');
|
|
12
13
|
const tscPath = path.join(process.cwd(), 'node_modules', '.bin', 'tsc');
|
|
@@ -26,25 +27,39 @@ module.exports = (gulp, libraryName, compilerPath, options, webpackConfigPath) =
|
|
|
26
27
|
|
|
27
28
|
childProcess.exec(`${cmd} -p ${tsConfigPath}`, err => {
|
|
28
29
|
del.sync([ 'src/**/*.ngfactory.*', 'src/**/*.ngsummary.*',
|
|
29
|
-
|
|
30
|
-
done(err)
|
|
30
|
+
'dist/**/*.ngfactory.*', 'dist/**/*.ngsummary.*' ]);
|
|
31
|
+
done(err);
|
|
31
32
|
});
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
gulp.task('check-compilation', (done) => {
|
|
35
|
-
childProcess.execSync(`${tscPath} --noEmit`, {stdio:[0,1,2]});
|
|
36
|
-
done()
|
|
36
|
+
childProcess.execSync(`${tscPath} --noEmit`, { stdio: [ 0,1,2 ] });
|
|
37
|
+
done();
|
|
37
38
|
});
|
|
38
39
|
|
|
39
|
-
gulp.task('lint', series(
|
|
40
|
-
'
|
|
41
|
-
linter([ 'src/**/*.{ts,tsx}', 'test/**/*.{ts,tsx}', 'e2e/**/*.{ts,tsx}' ])
|
|
42
|
-
));
|
|
40
|
+
gulp.task('lint', series('check-compilation', () => {
|
|
41
|
+
const program = tslint.Linter.createProgram('./tsconfig.json', '.');
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
return gulp.src([ 'src/**/*.{ts,tsx}', 'test/**/*.{ts,tsx}', 'e2e/**/*.{ts,tsx}' ])
|
|
44
|
+
.pipe(gulpTsLint({
|
|
45
|
+
program: program,
|
|
46
|
+
formatter: 'verbose'
|
|
47
|
+
}))
|
|
48
|
+
.pipe(gulpTsLint.report());
|
|
46
49
|
}));
|
|
47
50
|
|
|
51
|
+
gulp.task('lint-docs', () => {
|
|
52
|
+
const program = tslint.Linter.createProgram('./tsconfig.docs.json', '.');
|
|
53
|
+
|
|
54
|
+
return gulp.src([ 'docs/examples/**/*.{ts,tsx}' ])
|
|
55
|
+
.pipe(gulpTsLint({
|
|
56
|
+
formatter: 'prose',
|
|
57
|
+
program: program,
|
|
58
|
+
configuration: './tslint.docs.json'
|
|
59
|
+
}))
|
|
60
|
+
.pipe(gulpTsLint.report());
|
|
61
|
+
});
|
|
62
|
+
|
|
48
63
|
gulp.task('start', (done) => {
|
|
49
64
|
const webpackPort = 8888;
|
|
50
65
|
const host = listenAddress;
|
|
@@ -53,10 +68,10 @@ module.exports = (gulp, libraryName, compilerPath, options, webpackConfigPath) =
|
|
|
53
68
|
|
|
54
69
|
const config = Object.assign({}, webpackConfig.dev);
|
|
55
70
|
config.resolve = Object.assign({}, config.resolve, {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
alias: {
|
|
72
|
+
[packageInfo.name]: process.cwd() + '/src/main'
|
|
73
|
+
},
|
|
74
|
+
modules: [ path.join(process.cwd(), 'node_modules') ]
|
|
60
75
|
});
|
|
61
76
|
|
|
62
77
|
const webpack = commonTasks.webpack(config);
|
|
@@ -71,7 +86,7 @@ module.exports = (gulp, libraryName, compilerPath, options, webpackConfigPath) =
|
|
|
71
86
|
server.listen(webpackPort, host, err => {
|
|
72
87
|
if (err) {
|
|
73
88
|
done();
|
|
74
|
-
throw new $.util.PluginError('webpack-dev-server', err);
|
|
89
|
+
throw new $.util.PluginError('webpack-dev-server', err); // eslint-disable-line no-undef
|
|
75
90
|
}
|
|
76
91
|
});
|
|
77
92
|
});
|
|
@@ -80,5 +95,5 @@ module.exports = (gulp, libraryName, compilerPath, options, webpackConfigPath) =
|
|
|
80
95
|
gulp.task('build-es-bundle', compile('tsconfig.es.json'));
|
|
81
96
|
gulp.task('build-es2015-bundle', compile('tsconfig.es2015.json'));
|
|
82
97
|
gulp.task('build-npm-bundle', compile('tsconfig.npm.json'));
|
|
83
|
-
gulp.task('build-package', series
|
|
84
|
-
|
|
98
|
+
gulp.task('build-package', series([ 'build-npm-bundle', 'build-es-bundle', 'build-cdn', 'build-systemjs-bundle' ]));
|
|
99
|
+
};
|
package/gulpfile.js
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
const gulp = require('gulp');
|
|
4
4
|
const jasmine = require('gulp-jasmine');
|
|
5
5
|
|
|
6
|
-
// kendo-common-task linter is ancient, skip it for now
|
|
7
|
-
gulp.task('lint', (done) => done());
|
|
8
|
-
|
|
9
6
|
gulp.task('test', () =>
|
|
10
7
|
gulp.src('test/**/*.js')
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
.pipe(jasmine({
|
|
9
|
+
includeStackTrace: true
|
|
10
|
+
}))
|
|
14
11
|
);
|
|
15
12
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@progress/kendo-typescript-tasks",
|
|
3
3
|
"description": "Kendo UI TypeScript package gulp tasks",
|
|
4
4
|
"main": "gulp-tasks.js",
|
|
5
|
-
"version": "10.0.
|
|
5
|
+
"version": "10.0.22-dev.4+28182b5",
|
|
6
6
|
"author": "Telerik",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"scripts": {
|
|
@@ -15,31 +15,29 @@
|
|
|
15
15
|
"API Generation"
|
|
16
16
|
],
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"typescript": "^
|
|
18
|
+
"typescript": "^3.4.5"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@progress/kendo-common-tasks": "7.9.5-
|
|
22
|
-
"
|
|
23
|
-
"@typescript-eslint/parser": "4.28.2",
|
|
24
|
-
"core-js": "^3.18.0",
|
|
21
|
+
"@progress/kendo-common-tasks": "7.9.5-dev.8+28182b5",
|
|
22
|
+
"core-js": "^2.2.2",
|
|
25
23
|
"del": "2.2.2",
|
|
26
|
-
"eslint": "7.32.0",
|
|
27
|
-
"eslint-plugin-import": "2.25.2",
|
|
28
|
-
"eslint-plugin-rxjs": "3.3.7",
|
|
29
|
-
"glob": "^7.2.0",
|
|
30
24
|
"gulp": "^4.0.0",
|
|
31
25
|
"gulp-add-src": "^1.0.0",
|
|
26
|
+
"gulp-tslint": "^8.0.0",
|
|
27
|
+
"gulp-typedoc": "~2.2.2",
|
|
32
28
|
"handlebars": "^4.0.5",
|
|
33
29
|
"highlight.js": "9.14.2",
|
|
34
30
|
"lodash": "^4.6.0",
|
|
35
31
|
"mkdirp": "^0.5.0",
|
|
36
32
|
"source-map-loader": "^0.1.5",
|
|
37
33
|
"ts-loader": "4.1.0",
|
|
38
|
-
"
|
|
34
|
+
"tslint": "^5.0.0",
|
|
35
|
+
"tslint-defocus": "^2.0.6",
|
|
36
|
+
"typedoc": "0.15.0"
|
|
39
37
|
},
|
|
40
38
|
"devDependencies": {
|
|
41
39
|
"gulp-jasmine": "^2.4.2",
|
|
42
|
-
"typescript": "~
|
|
40
|
+
"typescript": "~3.4.5"
|
|
43
41
|
},
|
|
44
42
|
"repository": {
|
|
45
43
|
"type": "git",
|
|
@@ -48,5 +46,5 @@
|
|
|
48
46
|
"publishConfig": {
|
|
49
47
|
"access": "public"
|
|
50
48
|
},
|
|
51
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "28182b56d4b5969becc7e346d5fc13ac995b0426"
|
|
52
50
|
}
|
package/spec-bundle.js
CHANGED
|
@@ -31,5 +31,5 @@ function requireAll(requireContext) {
|
|
|
31
31
|
return requireContext.keys().map(requireContext);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
let modules = requireAll(testContext); // eslint-disable-line no-unused-vars
|
|
35
35
|
// requires and returns all modules that match
|
package/src/api/enum-page.js
CHANGED
package/src/api/generator.js
CHANGED
|
@@ -71,7 +71,7 @@ const associateTypes = (elements, knownTypes) => {
|
|
|
71
71
|
traverseElements(elements, element => {
|
|
72
72
|
addTypeSlug(element, knownTypes);
|
|
73
73
|
});
|
|
74
|
-
}
|
|
74
|
+
};
|
|
75
75
|
|
|
76
76
|
const normalizeUnionReferences = (element, members) => {
|
|
77
77
|
if (element.kind === 'union') {
|
|
@@ -79,19 +79,17 @@ const normalizeUnionReferences = (element, members) => {
|
|
|
79
79
|
for (let idx = types.length - 1; idx >= 0; idx--) {
|
|
80
80
|
const type = types[idx];
|
|
81
81
|
if (type.type === 'reference') {
|
|
82
|
-
const unionReference = members.find((child) =>
|
|
83
|
-
return child.name === type.name;
|
|
84
|
-
});
|
|
82
|
+
const unionReference = members.find((child) => child.name === type.name);
|
|
85
83
|
|
|
86
84
|
if (unionReference && unionReference.kind === 'union') {
|
|
87
85
|
normalizeUnionReferences(unionReference, members);
|
|
88
86
|
const toReplace = unionReference.type.types;
|
|
89
|
-
types.splice.apply(types, [idx, 1].concat(toReplace));
|
|
87
|
+
types.splice.apply(types, [ idx, 1 ].concat(toReplace));
|
|
90
88
|
}
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
|
-
}
|
|
92
|
+
};
|
|
95
93
|
|
|
96
94
|
const normalizeMembers = (members) => {
|
|
97
95
|
traverseElements(members, (element) => {
|
|
@@ -99,9 +97,7 @@ const normalizeMembers = (members) => {
|
|
|
99
97
|
|
|
100
98
|
if (!element.comment && element.implementationOf) {
|
|
101
99
|
const interfaceName = element.implementationOf.name.split('.')[0];
|
|
102
|
-
const interfaceOptions = members.find((child) =>
|
|
103
|
-
return child.name === interfaceName;
|
|
104
|
-
});
|
|
100
|
+
const interfaceOptions = members.find((child) => child.name === interfaceName);
|
|
105
101
|
|
|
106
102
|
if (interfaceOptions) {
|
|
107
103
|
const baseOption = interfaceOptions.children.find(child => child.name === element.name);
|
|
@@ -110,13 +106,8 @@ const normalizeMembers = (members) => {
|
|
|
110
106
|
}
|
|
111
107
|
}
|
|
112
108
|
}
|
|
113
|
-
|
|
114
|
-
if (!element.comment && element.kindString === 'Accessor') {
|
|
115
|
-
const accessor = element.getSignature || element.setSignature || [];
|
|
116
|
-
element.comment = accessor[0].comment;
|
|
117
|
-
}
|
|
118
109
|
});
|
|
119
|
-
}
|
|
110
|
+
};
|
|
120
111
|
|
|
121
112
|
const mergeComments = (root, src) => {
|
|
122
113
|
if (!root.comment && src.comment) {
|
|
@@ -128,23 +119,20 @@ const mergeComments = (root, src) => {
|
|
|
128
119
|
mergeComments(root[key], src[key]);
|
|
129
120
|
}
|
|
130
121
|
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const moduleRoot = (moduleName, rootModules) => {
|
|
134
|
-
return rootModules.includes(moduleName) ? moduleName :
|
|
135
|
-
rootModules.find(rootModule => moduleName.indexOf(rootModule) > -1);
|
|
136
122
|
};
|
|
137
123
|
|
|
124
|
+
const moduleRoot = (moduleName, rootModules) => (rootModules.includes(moduleName) ? moduleName :
|
|
125
|
+
rootModules.find(rootModule => moduleName.indexOf(rootModule) > -1));
|
|
126
|
+
|
|
138
127
|
const moduleFullName = (moduleName, packageName, rootModules) => {
|
|
139
128
|
const rootModule = moduleRoot(moduleName, rootModules);
|
|
140
129
|
let fullName = packageName;
|
|
141
|
-
if (rootModule)
|
|
142
|
-
{
|
|
130
|
+
if (rootModule) {
|
|
143
131
|
fullName += '_' + rootModule;
|
|
144
132
|
}
|
|
145
133
|
|
|
146
134
|
return fullName;
|
|
147
|
-
}
|
|
135
|
+
};
|
|
148
136
|
|
|
149
137
|
const extractMembers = (packageName, modules, config) => {
|
|
150
138
|
const knownTypes = {};
|
|
@@ -153,7 +141,7 @@ const extractMembers = (packageName, modules, config) => {
|
|
|
153
141
|
|
|
154
142
|
const models = nonEmptyModules.map(module => module
|
|
155
143
|
.children
|
|
156
|
-
.filter(child => child.
|
|
144
|
+
.filter(child => child.flags.isExported)
|
|
157
145
|
.filter(child => child.name !== 'core')
|
|
158
146
|
.map(child => {
|
|
159
147
|
const fullName = moduleFullName(module.name, packageName, rootModules);
|
|
@@ -187,7 +175,7 @@ const extractMembers = (packageName, modules, config) => {
|
|
|
187
175
|
const members = utils.flatten(models)
|
|
188
176
|
.sort(utils.nameComparer)
|
|
189
177
|
.map(model => {
|
|
190
|
-
associateTypes([model], knownTypes);
|
|
178
|
+
associateTypes([ model ], knownTypes);
|
|
191
179
|
return model;
|
|
192
180
|
});
|
|
193
181
|
|
|
@@ -200,6 +188,7 @@ const namespacesAsModules = data => {
|
|
|
200
188
|
const modules = [];
|
|
201
189
|
data.filter(moduleFilter).forEach(module => module
|
|
202
190
|
.children
|
|
191
|
+
.filter(child => child.flags.isExported)
|
|
203
192
|
.filter(child => child.name !== 'core')
|
|
204
193
|
.forEach(child => {
|
|
205
194
|
if (child.kindString === 'Module' && child.children) {
|
|
@@ -231,6 +220,18 @@ const groupMembers = (members) => {
|
|
|
231
220
|
return membersByModule;
|
|
232
221
|
};
|
|
233
222
|
|
|
223
|
+
const packagePlatform = (packageInfo) => {
|
|
224
|
+
let platform = '';
|
|
225
|
+
|
|
226
|
+
if (/-angular-/.test(packageInfo.name)) {
|
|
227
|
+
platform = 'Angular';
|
|
228
|
+
} else if (/-react-/.test(packageInfo.name)) {
|
|
229
|
+
platform = 'React';
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return platform;
|
|
233
|
+
};
|
|
234
|
+
|
|
234
235
|
const generate = (done, config, packageInfo) => {
|
|
235
236
|
const meta = require(config.jsonPath);
|
|
236
237
|
const namespaces = namespacesAsModules(meta.children);
|
|
@@ -238,8 +239,7 @@ const generate = (done, config, packageInfo) => {
|
|
|
238
239
|
const membersByModule = config.reorderModules ?
|
|
239
240
|
config.reorderModules(groupMembers(members)) : groupMembers(members);
|
|
240
241
|
const outPath = config.outPath;
|
|
241
|
-
const platform =
|
|
242
|
-
/-react-/.test(packageInfo.name) ? 'React' : '';
|
|
242
|
+
const platform = packagePlatform(packageInfo);
|
|
243
243
|
const info = Object.assign({ platform }, packageInfo['@progress']);
|
|
244
244
|
|
|
245
245
|
writeFile(`${outPath}/index.md`, indexPage(packageInfo.name, membersByModule, info));
|
|
@@ -2,21 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
const comment = require('./comment');
|
|
4
4
|
const isPublic = require('./is-public');
|
|
5
|
-
const isInput = require('./is-input');
|
|
6
5
|
const types = require('./type-utils');
|
|
7
6
|
const utils = require('./utils');
|
|
8
7
|
|
|
9
8
|
const isConstructor = (prop) =>
|
|
10
9
|
prop.kindString && prop.kindString === 'Constructor' && isPublic(prop);
|
|
11
10
|
|
|
12
|
-
const mapConstructors = (member) =>
|
|
13
|
-
|
|
14
|
-
// Ignore NgModule constructors
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return utils.flatten(member.children.filter(isConstructor).map(ctr => {
|
|
19
|
-
const name = ctr.name;
|
|
11
|
+
const mapConstructors = (member) =>
|
|
12
|
+
utils.flatten(member.children.filter(isConstructor).map(ctr => {
|
|
20
13
|
const source = `${member.name}.constructor`;
|
|
21
14
|
|
|
22
15
|
return ctr.signatures.map((signature) => ({
|
|
@@ -26,7 +19,6 @@ const mapConstructors = (member) => {
|
|
|
26
19
|
params: types.params(signature, source)
|
|
27
20
|
}));
|
|
28
21
|
}));
|
|
29
|
-
};
|
|
30
22
|
|
|
31
23
|
module.exports = mapConstructors;
|
|
32
24
|
|
package/src/api/map-props.js
CHANGED
|
@@ -15,7 +15,7 @@ const defaultValue = prop => {
|
|
|
15
15
|
return text && ` (default: ${text.trim()})`;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const accessor = signature => Array.isArray(signature) ? signature[0] : signature;
|
|
18
|
+
const accessor = signature => (Array.isArray(signature) ? signature[0] : signature);
|
|
19
19
|
|
|
20
20
|
const isProp = (prop) => isPublic(prop) && !isConstructor(prop) && !isMethod(prop);
|
|
21
21
|
const mapProps = (children, parentName) =>
|
package/src/api/member-page.js
CHANGED
package/src/api/return-type.js
CHANGED
|
@@ -16,7 +16,7 @@ const returnType = (definition, parentName) => {
|
|
|
16
16
|
if (!comment && definition.type.name !== 'void') {
|
|
17
17
|
let source = `${definition.name}`;
|
|
18
18
|
if (parentName) {
|
|
19
|
-
|
|
19
|
+
source = `${parentName } - ${source}`;
|
|
20
20
|
}
|
|
21
21
|
utils.warn('Undocumented return type', source);
|
|
22
22
|
}
|
|
@@ -8,7 +8,7 @@ hbs.registerHelper('capitalize',
|
|
|
8
8
|
s => s.slice(0,1).toUpperCase() + s.slice(1));
|
|
9
9
|
|
|
10
10
|
hbs.registerHelper('contains',
|
|
11
|
-
(s, chars, options) => s.includes(chars) ? options.fn(s) : options.inverse(s));
|
|
11
|
+
(s, chars, options) => (s.includes(chars) ? options.fn(s) : options.inverse(s)));
|
|
12
12
|
|
|
13
13
|
const readLocal = (src) =>
|
|
14
14
|
fs.readFileSync(path.join(__dirname, src), { encoding: 'utf-8' });
|
package/src/api/type-utils.js
CHANGED
|
@@ -5,7 +5,7 @@ const comment = require('./comment');
|
|
|
5
5
|
const unionTypes = (member) =>
|
|
6
6
|
member.type.types.map(type => {
|
|
7
7
|
switch (type.type) {
|
|
8
|
-
case '
|
|
8
|
+
case 'stringLiteral':
|
|
9
9
|
return `"${type.value}"`;
|
|
10
10
|
default:
|
|
11
11
|
return typeString({ type });
|
|
@@ -118,7 +118,7 @@ const singleTypeString = (type) => {
|
|
|
118
118
|
if (type.typeArguments) {
|
|
119
119
|
suffix = `<${singleTypeString(type.typeArguments[0])}>`;
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
if (type.type === 'array') {
|
|
123
123
|
suffix += '[]';
|
|
124
124
|
}
|
|
@@ -153,7 +153,7 @@ const fullName = (member) => {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
return member.name + suffix;
|
|
156
|
-
}
|
|
156
|
+
};
|
|
157
157
|
|
|
158
158
|
module.exports = {
|
|
159
159
|
callSignature: callSignature,
|
package/src/api/utils.js
CHANGED
|
@@ -9,15 +9,15 @@ const not = predicate => member => !predicate(member);
|
|
|
9
9
|
|
|
10
10
|
const ignore = predicate => props => (props || []).filter(predicate);
|
|
11
11
|
|
|
12
|
-
const hasProp = prop => obj =>
|
|
12
|
+
const hasProp = prop => obj => Boolean(obj[prop]);
|
|
13
13
|
|
|
14
14
|
const groupBy = (predicate, list) =>
|
|
15
15
|
list.reduce((acc, item) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, {})
|
|
16
|
+
const field = predicate(item);
|
|
17
|
+
acc[field] = acc[field] || [];
|
|
18
|
+
acc[field].push(item);
|
|
19
|
+
return acc;
|
|
20
|
+
}, {});
|
|
21
21
|
|
|
22
22
|
const WARNINGS = [];
|
|
23
23
|
const warn = (type, text) => {
|
package/stub-loader.js
CHANGED
package/test/api.js
CHANGED
|
@@ -51,7 +51,7 @@ describe('API generation', () => {
|
|
|
51
51
|
|
|
52
52
|
describe('for modules', () => {
|
|
53
53
|
const pkg = require('./package.json');
|
|
54
|
-
const members = generator.extractMembers(pkg.name, pkg.children, { modules: ['module1'] });
|
|
54
|
+
const members = generator.extractMembers(pkg.name, pkg.children, { modules: [ 'module1' ] });
|
|
55
55
|
|
|
56
56
|
it('adds module to slug', () => {
|
|
57
57
|
expect(members[0].slug).toEqual('api_package-name_module1_foo');
|
|
@@ -162,13 +162,13 @@ describe('API generation', () => {
|
|
|
162
162
|
it('formats anonymous interfaces', () => {
|
|
163
163
|
const unionData = require('./type-union.json');
|
|
164
164
|
const page = unionPage(unionData);
|
|
165
|
-
expect(page).toContain(
|
|
165
|
+
expect(page).toContain('{ allowUnsort?: boolean; mode?: "single" | "multiple"; }');
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
it('formats intersection interfaces', () => {
|
|
169
169
|
const intersectionData = require('./intersection.json');
|
|
170
170
|
const page = unionPage(intersectionData);
|
|
171
|
-
expect(page).toContain(
|
|
171
|
+
expect(page).toContain('ColumnSortSettings [intersected](https://www.typescriptlang.org/docs/handbook/advanced-types.html#intersection-types) with { mode?: "single" | "multiple"; }');
|
|
172
172
|
});
|
|
173
173
|
});
|
|
174
174
|
|
|
@@ -325,22 +325,22 @@ describe('API generation', () => {
|
|
|
325
325
|
describe('index', () => {
|
|
326
326
|
const page = indexPage('foo/bar', {
|
|
327
327
|
'': {
|
|
328
|
-
'Function': [{
|
|
328
|
+
'Function': [ {
|
|
329
329
|
'slug': 'root-f',
|
|
330
330
|
'name': 'root-f'
|
|
331
|
-
}]
|
|
331
|
+
} ]
|
|
332
332
|
},
|
|
333
333
|
'a': {
|
|
334
|
-
'Function': [{
|
|
334
|
+
'Function': [ {
|
|
335
335
|
'slug': 'a-f',
|
|
336
336
|
'name': 'a-f'
|
|
337
|
-
}]
|
|
337
|
+
} ]
|
|
338
338
|
},
|
|
339
339
|
'b': {
|
|
340
|
-
'Function': [{
|
|
340
|
+
'Function': [ {
|
|
341
341
|
'slug': 'b-f',
|
|
342
342
|
'name': 'b-f'
|
|
343
|
-
}]
|
|
343
|
+
} ]
|
|
344
344
|
}
|
|
345
345
|
}, {
|
|
346
346
|
friendlyName: 'Foo',
|
|
@@ -348,7 +348,7 @@ describe('API generation', () => {
|
|
|
348
348
|
});
|
|
349
349
|
|
|
350
350
|
const assertModule = name => {
|
|
351
|
-
expect(new RegExp(`<h2 class
|
|
351
|
+
expect(new RegExp(`<h2 class="module-name">\\s*${name}\\s*<\\/h2>`).test(page)).toBeTruthy();
|
|
352
352
|
};
|
|
353
353
|
|
|
354
354
|
it('renders default group', () => {
|
package/src/linter.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const { ESLint } = require('eslint');
|
|
2
|
-
|
|
3
|
-
const linter = (files, options = {}) => async function lint(done) {
|
|
4
|
-
const eslint = new ESLint(options);
|
|
5
|
-
const results = await eslint.lintFiles(files);
|
|
6
|
-
const formatter = await eslint.loadFormatter('stylish');
|
|
7
|
-
const errors = ESLint.getErrorResults(results)
|
|
8
|
-
const resultText = formatter.format(results);
|
|
9
|
-
console.log(resultText);
|
|
10
|
-
|
|
11
|
-
if (errors.length > 0) {
|
|
12
|
-
done(new Error('Lint failed.'));
|
|
13
|
-
} else {
|
|
14
|
-
done();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = linter;
|