-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgulpfile.js
27 lines (23 loc) · 1017 Bytes
/
gulpfile.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
const gulp = require('gulp')
const jsdoc2md = require('jsdoc-to-markdown')
const fs = require('fs')
const path = require('path')
gulp.task('docs', () => {
/* input and output paths */
const inputFile = 'src/**/*.js'
const outputDir = `${__dirname}/docs`
/* get template data */
const templateData = jsdoc2md.getTemplateDataSync({ files: inputFile })
/* reduce templateData to an array of class names */
const classNames = templateData.reduce((classNames, identifier) => {
if (identifier.kind === 'class') classNames.push(identifier.name)
return classNames
}, [])
/* create a documentation file for each class */
for (const className of classNames) {
const template = `{{#class name="${className}"}}{{>docs}}{{/class}}`
console.log(`rendering ${className}, template: ${template}`)
const output = jsdoc2md.renderSync({ data: templateData, template: template })
fs.writeFileSync(path.resolve(outputDir, `${className}.md`), output)
}
})