-
Notifications
You must be signed in to change notification settings - Fork 7
/
generate-eos-docs.js
37 lines (29 loc) · 1.5 KB
/
generate-eos-docs.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
require("download-git-repo")("bancorprotocol/contracts_eos", "node_modules/bancor-contracts_eos", function (error) {
if (error)
throw error;
const fs = require("fs");
const spawnSync = require("child_process").spawnSync;
const nodeArgs = ["node_modules/doxygen/bin/nodeDoxygen.js", "--docs", "--configPath=config/eos-smart-contracts/Doxyfile"];
const pythonArgs = ["-m", "doxybook", "-i=tmp/xml", "-o=eos-contracts/eos-api-reference", "-t=gitbook"];
const nodeResult = spawnSync("node", nodeArgs, {stdio: ["inherit", "inherit", "pipe"]});
if (nodeResult.stderr.length > 0)
throw new Error(nodeResult.stderr);
const pythonResult = spawnSync("python", pythonArgs, {stdio: ["inherit", "inherit", "pipe"]});
if (pythonResult.stderr.length > 0)
throw new Error(pythonResult.stderr);
for (const fileName of fs.readdirSync("eos-contracts/eos-api-reference"))
if (!/^(modules|structmemo__x__transfer|group__.*).md$/.test(fileName))
fs.unlinkSync("eos-contracts/eos-api-reference/" + fileName);
function remove(pathName) {
if (fs.lstatSync(pathName).isDirectory()) {
for (const fileName of fs.readdirSync(pathName))
remove(pathName + "/" + fileName);
fs.rmdirSync(pathName);
}
else {
fs.unlinkSync(pathName);
}
}
remove("tmp");
fs.copyFileSync("node_modules/bancor-contracts_eos/README.md", "eos-contracts/eos-api-reference/README.md");
});