-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.jsdoc.js
24 lines (20 loc) · 917 Bytes
/
.jsdoc.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
const jsdoc2md = require('jsdoc-to-markdown');
const fs = require('fs');
const path = require('path');
/* input and output paths */
const inputFile = ['0/*', '1/*', 'cli/*', 'util.js'];
const outputDir = '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)
}