-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (40 loc) · 1.28 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
const Dgeni = require('dgeni'),
copy = require('copy');
function DocsGeneratorPlugin (options) {
this.options = Object.assign({
enable : true,
staticContent: './docs',
sources : [
{
include : 'src/app/**/**/*.js',
basePath: 'src/app'
}
],
output : 'dist-docs'
}, options);
if (!Array.isArray(this.options.sources)) {
this.options.sources = [].concat(this.options.sources);
}
this.options.sources.push({
include : `${this.options.staticContent}/**/*.ngdoc`,
basePath : this.options.staticContent,
fileReader: 'ngdocFileReader'
});
this.dgeni = new Dgeni([require('./config')(this.options.output, this.options.sources)])
}
DocsGeneratorPlugin.prototype.apply = function (compiler) {
let options = this.options;
let dgeni = this.dgeni;
compiler.plugin("compile", function () {
if (options.enable) {
dgeni.generate();
copy(__dirname + '/app/**/*.{js,html,css}', options.output, (err) => {
if (err) throw err;
});
}
});
compiler.plugin("emit", (compilation, callback) => {
callback();
});
};
module.exports = DocsGeneratorPlugin;