-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (34 loc) · 1.1 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
53
54
55
56
"use strict";
const through = require("through2");
const PluginError = require("plugin-error");
const File = require("vinyl");
const doxdox = require("doxdox");
const PLUGIN_NAME = "gulp-doxdox";
module.exports = function (config) {
config = config || {};
const files = [];
return through.obj(function (file, encoding, callback) {
if (file.isNull()) {
return callback(null, file);
} else if (file.isStream()) {
this.emit("error", new PluginError(PLUGIN_NAME, "Streams not supported!"));
} else if (file.isBuffer()) {
files.push(file.path);
callback();
}
}, function (callback) {
doxdox.parseInputs(files, {
"description": config.description || "",
"ignore": (config.ignore || "").split(/\s*,\s*/),
"layout": (config.layout || "markdown").toLowerCase(),
"parser": (config.parser || "dox").toLowerCase(),
"title": config.title || "Untitled Project"
}).then(function (content) {
this.push(new File({
path: "docs.md",
contents: new Buffer(content)
}));
callback();
}.bind(this));
});
};