|
@@ -2,15 +2,16 @@ const jsdoc2md = require('jsdoc-to-markdown');
|
2
|
2
|
const fs = require('fs');
|
3
|
3
|
const path = require('path');
|
4
|
4
|
|
5
|
|
-const paramsDir = './lib/src/params/';
|
6
|
|
-const optionsDir = './lib/src/params/options/';
|
|
5
|
+const PARAMS_DIR = './lib/src/params/';
|
|
6
|
+const OPTIONS_DIR = './lib/src/params/options/';
|
7
|
7
|
const OUTPUT_DIR = './docs/docs/';
|
8
|
|
-const partial = ['./docs/templates/scope.hbs', './docs/templates/docs.hbs'];
|
|
8
|
+const OPTION_PARTIALS = ['./docs/templates/header.hbs', './docs/templates/sig-name.hbs'];
|
|
9
|
+const PARTIALS = ['./docs/templates/scope.hbs', './docs/templates/docs.hbs'];
|
9
|
10
|
|
10
|
|
-const generateMarkdownForFile = ({ file, outputDir }) => {
|
|
11
|
+const generateMarkdownForFile = ({ file, outputDir, partial }) => {
|
11
|
12
|
const templateData = jsdoc2md.getTemplateDataSync({ files: file });
|
12
|
13
|
const classNames = getClassesInFile(templateData);
|
13
|
|
- classNames.forEach((className) => createDocFileForClass(className, templateData, outputDir));
|
|
14
|
+ classNames.forEach((className) => createDocFileForClass({ className, templateData, outputDir, partial }));
|
14
|
15
|
};
|
15
|
16
|
|
16
|
17
|
function getClassesInFile(templateData) {
|
|
@@ -23,15 +24,15 @@ function getClassesInFile(templateData) {
|
23
|
24
|
return classNames;
|
24
|
25
|
}
|
25
|
26
|
|
26
|
|
-function createDocFileForClass(className, templateData, outputDir) {
|
|
27
|
+function createDocFileForClass({ className, templateData, outputDir, partial = [] }) {
|
27
|
28
|
const template = `{{#class name="${className}"}}{{>docs}}{{/class}}`;
|
28
|
29
|
const options = {
|
29
|
30
|
data: templateData,
|
30
|
31
|
template,
|
31
|
32
|
separators: true,
|
32
|
|
- partial
|
|
33
|
+ partial: [...PARTIALS, ...partial]
|
33
|
34
|
};
|
34
|
|
- console.log(`rendering ${className}, template: ${template} ${outputDir}`);
|
|
35
|
+ console.log(`rendering ${className}`);
|
35
|
36
|
const output = jsdoc2md.renderSync(options);
|
36
|
37
|
fs.writeFileSync(path.resolve(outputDir, `${className}.md`), output);
|
37
|
38
|
}
|
|
@@ -39,17 +40,18 @@ function createDocFileForClass(className, templateData, outputDir) {
|
39
|
40
|
function inputFiles() {
|
40
|
41
|
return [
|
41
|
42
|
{ file: './lib/src/Navigation.js', outputDir: OUTPUT_DIR },
|
42
|
|
- ...fs.readdirSync(optionsDir).map((file) => {
|
|
43
|
+ ...fs.readdirSync(OPTIONS_DIR).map((file) => {
|
43
|
44
|
return {
|
44
|
|
- file: optionsDir + file,
|
45
|
|
- outputDir: OUTPUT_DIR + 'options/'
|
|
45
|
+ file: OPTIONS_DIR + file,
|
|
46
|
+ outputDir: OUTPUT_DIR + 'options/',
|
|
47
|
+ partial: OPTION_PARTIALS
|
46
|
48
|
};
|
47
|
49
|
}),
|
48
|
|
- ...fs.readdirSync(paramsDir)
|
49
|
|
- .filter((file) => fs.statSync(paramsDir + file).isFile())
|
|
50
|
+ ...fs.readdirSync(PARAMS_DIR)
|
|
51
|
+ .filter((file) => fs.statSync(PARAMS_DIR + file).isFile())
|
50
|
52
|
.map((file) => {
|
51
|
53
|
return {
|
52
|
|
- file: paramsDir + file,
|
|
54
|
+ file: PARAMS_DIR + file,
|
53
|
55
|
outputDir: OUTPUT_DIR
|
54
|
56
|
};
|
55
|
57
|
})
|