-
Notifications
You must be signed in to change notification settings - Fork 10
/
buildDocs.js
39 lines (36 loc) · 1.44 KB
/
buildDocs.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
const documentation = require('documentation')
const fs = require('fs')
const path = require('path')
const Chalk = require('chalk')
async function build() {
let files = fs.readdirSync(path.join(__dirname, './src'))
for (let file of files) {
if (file !== `util.js` && file !== `util`) {
console.log(Chalk.yellow(`Building docs for ${file}...`))
let doc = await documentation.build([`${path.join(__dirname, `./src/${file}`)}`], {
extension: 'js',
// gotta remove the util cause those somehow end up in every fucking md
inferPrivate: '^get|set|sleep|log',
})
doc = await documentation.formats.md(doc, {
markdownToc: true,
})
await fs.writeFileSync(`./docs/${file.replace('.js', '.md')}`, doc)
console.log(Chalk.green(`Docs for ${file} built.`))
}
}
// now rebuild the util, except this time dont ignore the util functions
let file = `utility.js`
console.log(Chalk.yellow(`Building docs for ${file}...`))
let doc = await documentation.build([`${path.join(__dirname, `./src/${file}`)}`], {
extension: 'js',
})
doc = await documentation.formats.md(doc, {
markdownToc: true,
})
await fs.writeFileSync(`./docs/${file.replace('.js', '')}.md`, doc)
console.log(Chalk.green(`Docs for ${file} built.`))
}
build().catch((e) => {
console.error(e.stack)
})