-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
52 lines (40 loc) · 1.26 KB
/
index.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
'use strict';
const merge = require('merge');
const yuidoc = require('yuidocjs');
const rsvp = require('rsvp');
const fs = require('fs');
const path = require('path');
const CachingWriter = require('broccoli-caching-writer');
const defaultOpts = {
destDir: 'docs',
yuidoc: {
linkNatives: true,
quiet: true,
parseOnly: false,
lint: false
}
};
module.exports = class BroccoliYuidoc extends CachingWriter {
constructor(inputNodes, options) {
options = options || {};
super(inputNodes, {
annotation: options.annotation
});
this.inputNodes = inputNodes;
this.options = merge(defaultOpts, options);
}
build() {
let destDir = this.options.destDir;
let yuiOptions = this.options.yuidoc;
yuiOptions.paths = this.inputPaths;
yuiOptions.outdir = path.join(this.outputPath, destDir);
let json = (new yuidoc.YUIDoc(yuiOptions)).run();
yuiOptions = yuidoc.Project.mix(json, yuiOptions);
if (yuiOptions.parseOnly) {
fs.writeFileSync(path.join(yuiOptions.outdir, 'data.json'), JSON.stringify(json, null, 4));
return;
}
let builder = new yuidoc.DocBuilder(yuiOptions, json);
return new rsvp.Promise(resolve => builder.compile(resolve));
}
};