This repository was archived by the owner on Aug 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathdoc.js
executable file
·55 lines (51 loc) · 1.43 KB
/
doc.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
const exec = require("child_process").exec;
const FILES_TO_DOC = [
"dataframe",
"group",
"row",
"modules/sql/index",
"modules/stat",
"modules/matrix"
];
clean()
.then(buildMD)
.then(() => process.exit(0))
.catch((err) => {
console.error(err);
process.exit(1);
});
function clean() {
return new Promise((resolve) => {
console.log("Cleaning the doc folder.");
exec(
"shx rm -rf doc/md && shx mkdir doc/md && mkdir doc/md/modules",
(err, stdout, stderr) => {
if (stderr) {
console.error(stderr);
}
console.log("doc/ cleaned.\n");
resolve();
}
);
});
}
function buildMD() {
return new Promise(() => {
console.log("Building markdown doc:");
FILES_TO_DOC.forEach((file) => {
const output = file.endsWith("/index")
? file.replace("/index", "")
: file;
exec(
`documentation build src/${file}.js --github --shallow --format 'md' --output doc/api/${output}.md`,
(err, stdout, stderr) => {
if (stderr) {
console.error(stderr);
} else {
console.log(`src/${file}.js ---> doc/md/${file}.md`);
}
}
);
});
});
}