-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (22 loc) · 948 Bytes
/
index.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
const path = require('path');
const { readFile, writeFile } = require('fs');
const glob = require('glob');
const jsdoc2md = require('jsdoc-to-markdown');
glob('../ensemble*/{lib,src}/**/*.js', (err, files) => {
if (err) throw err;
for (const file of files) {
readFile(file, (err, data) => {
if (err) throw err;
jsdoc2md.render({ source: data, 'no-cache': true }).then(docs => {
const filename = 'module-ensemble-' + path.parse(file).name + '.md';
const head = '---\ntitle: ensemble.' + path.parse(file).name + '\nslug: /' + filename.substr(0, filename.length - 3) + '\n---\n';
//FIX empty <code/> breaks docusaurus markdown parser
docs = docs.replace('<code></code>', '<code>null</code>');
console.log(file, docs.length, filename);
writeFile(path.resolve('./docs/docs', filename), head + docs, (err) => {
if (err) throw err;
});
});
});
}
});