-
Notifications
You must be signed in to change notification settings - Fork 580
/
Copy pathgenerateDocs.js
103 lines (90 loc) · 3.19 KB
/
generateDocs.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const jsdoc2md = require('jsdoc-to-markdown');
const fs = require('fs-extra');
const execSync = require('child_process').execSync;
function prependWarning(input, source) {
return `<!--
DO NOT EDIT THIS FILE DIRECTLY, THIS FILE IS GENERATED BY JSDOC!
EDIT ${source} OR JSDOC COMMENT INSTEAD!
-->
${input}`;
}
const DOCS_PATH = './docs/api.md';
const docs = jsdoc2md.renderSync({
files: ['index.js','lib/**/*.js'],
template: fs.readFileSync('scripts/handlebars/templates/api.hbs').toString(),
// 'no-gfm': true,
separators: true,
partial: ['scripts/handlebars/header.hbs','scripts/handlebars/sig-name.hbs', 'scripts/handlebars/body.hbs'],
configure: '.jsdoc.json'
});
fs.ensureFileSync( DOCS_PATH );
fs.writeFileSync(
DOCS_PATH,
prependWarning(docs, 'scripts/handlebars/templates/api.hbs')
);
execSync(`git add ${DOCS_PATH}`);
console.log(DOCS_PATH + ' generated.');
const TRANSFORMS_PATH = './docs/transforms.md'
const transforms = jsdoc2md.renderSync({
files: ['lib/common/transforms.js'],
template: fs.readFileSync('scripts/handlebars/templates/transforms.hbs').toString(),
'no-gfm': true,
separators: true,
partial: ['scripts/handlebars/header.hbs','scripts/handlebars/body.hbs'],
configure: '.jsdoc.json'
});
fs.ensureFileSync( TRANSFORMS_PATH );
fs.writeFileSync(
TRANSFORMS_PATH,
prependWarning(transforms, 'scripts/handlebars/templates/api.hbs')
);
execSync(`git add ${TRANSFORMS_PATH}`);
console.log(TRANSFORMS_PATH + ' generated.');
const TRANSFORM_GROUPS_PATH = './docs/transform_groups.md'
const transform_groups = jsdoc2md.renderSync({
files: ['lib/common/transformGroups.js'],
template: fs.readFileSync('scripts/handlebars/templates/transform_groups.hbs').toString(),
'no-gfm': true,
separators: true,
partial: ['scripts/handlebars/header.hbs','scripts/handlebars/body.hbs'],
configure: '.jsdoc.json'
});
fs.ensureFileSync( TRANSFORM_GROUPS_PATH );
fs.writeFileSync(
TRANSFORM_GROUPS_PATH,
prependWarning(transform_groups, 'scripts/handlebars/templates/api.hbs')
);
execSync(`git add ${TRANSFORM_GROUPS_PATH}`);
console.log(TRANSFORM_GROUPS_PATH + ' generated.');
const ACTIONS_PATH = './docs/actions.md'
const actions = jsdoc2md.renderSync({
files: ['lib/common/actions.js'],
template: fs.readFileSync('scripts/handlebars/templates/actions.hbs').toString(),
'no-gfm': true,
separators: true,
partial: ['scripts/handlebars/header.hbs','scripts/handlebars/body.hbs'],
configure: '.jsdoc.json'
});
fs.ensureFileSync( ACTIONS_PATH );
fs.writeFileSync(
ACTIONS_PATH,
prependWarning(actions, 'scripts/handlebars/templates/api.hbs')
);
execSync(`git add ${ACTIONS_PATH}`);
console.log(ACTIONS_PATH + ' generated.');
const FORMATS_PATH = './docs/formats.md'
const formats = jsdoc2md.renderSync({
files: ['lib/common/formats.js'],
template: fs.readFileSync('scripts/handlebars/templates/formats.hbs').toString(),
'no-gfm': true,
separators: true,
partial: ['scripts/handlebars/header.hbs','scripts/handlebars/body.hbs'],
configure: '.jsdoc.json'
});
fs.ensureFileSync( FORMATS_PATH );
fs.writeFileSync(
FORMATS_PATH,
prependWarning(formats, 'scripts/handlebars/templates/api.hbs')
);
execSync(`git add ${FORMATS_PATH}`);
console.log(FORMATS_PATH + ' generated.');