-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
61 lines (51 loc) · 1.37 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const gulp = require('gulp');
const typedoc = require('gulp-typedoc');
const path = require('path');
const fs = require('fs')
const hbs = require('./hbs');
const API_FOLDER = './source/api/';
const API_JSON_PATH = path.join(API_FOLDER, 'api.json');
const API_TEMPLATE = fs.readFileSync(path.join('./api.hbs'), 'utf8');
gulp.task('typedoc', () =>
gulp
.src(['./node_modules/ng2-qgrid/core/**/*.d.ts'])
.pipe(typedoc({
module: 'commonjs',
target: 'es5',
includeDeclarations: true,
json: API_JSON_PATH,
name: 'qgrid',
ignoreCompilerErrors: true,
excludeExternals: true
}))
);
gulp.task('markdown', done => {
const input = fs.readFileSync(API_JSON_PATH);
const project = JSON.parse(input);
project.children.forEach((unit, i) => {
if (!unit.children.some(x => x.comment && x.comment.shortText)) {
// omit files without documentaion
return;
}
unit.order = i;
const link = hbs.compile(API_TEMPLATE);
const output = link({ unit });
const name = path
.basename(unit.originalName)
.slice(0, -'.d.ts'.length)
.replace(/\./g, '-');
console.log(`process: ${name}`);
fs.writeFileSync(
path.join(API_FOLDER, `${name}.md`),
output,
{ flag: 'w' }
);
fs.writeFileSync(
path.join(API_FOLDER, `${name}.json`),
JSON.stringify(unit, null, 3),
{ flag: 'w' }
);
});
done();
});
gulp.task('api', gulp.series('typedoc', 'markdown'));