-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocs.js
53 lines (44 loc) · 1.59 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* A script that uses the documentation.js npm package to generate Markdown
documentation from jsdoc comments in the code. */
import { build, formats } from 'documentation';
import fs from 'fs';
const postProcessLine = (line) => line
// Reduce heading level of Parameters to avoid it showing up in docusaurus
// table of content
.replace('### Parameters', '#### Parameters');
// build(process.argv.slice(2), {
// sortOrder: ['kind', 'alpha'],
// inferPrivate: '^_'
// shallow: true,
// }).then(formats.md)
// .then(output => {
// // post-process
// const processed = output.split('\n').map(postProcessLine).join('\n');
// let header = '';
// try {
// header = fs.readFileSync('./docs_header.md', {encoding: 'utf-8'});
// } catch (e) {
// console.log('No docs_header.md found, proceeding without');
// }
// fs.mkdirSync('docs', {recursive: true});
// fs.writeFileSync('./docs/index.md', header + processed);
// });
process.argv.slice(2).forEach(folder => {
build(folder, {
sortOrder: ['kind', 'alpha'],
inferPrivate: '^_',
shallow: true,
}).then(formats.md)
.then(output => {
// post-process
const processed = output.split('\n').map(postProcessLine).join('\n');
let header = '';
try {
header = fs.readFileSync(`./${folder}/docs_header.md`, {encoding: 'utf-8'});
} catch (e) {
console.log('No docs_header.md found, proceeding without');
}
fs.mkdirSync('docs', {recursive: true});
fs.writeFileSync(`./docs/${folder.replace(/\//g, '')}.md`, header + processed);
});
});