forked from pstadler/flightplan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
43 lines (35 loc) · 1.11 KB
/
gulpfile.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
var fs = require('fs')
, gulp = require('gulp')
, stylish = require('jshint-stylish')
, jshint = require('gulp-jshint')
, markdox = require('markdox');
var sourceFiles = ['*.js', 'lib/**/*.js', 'bin/**/*.js'];
gulp.task('lint', function() {
var jshintOptions = {
laxcomma: true
};
return gulp.src(sourceFiles)
.pipe(jshint(jshintOptions))
.pipe(jshint.reporter(stylish));
});
gulp.task('docs', function(taskFinished) {
var sources = ['lib/flightplan.js', 'lib/transport/transport.js']
, readme = 'README.md'
, tmpFile = 'docs/API.md';
var options = {
template: 'docs/template.md.ejs',
output: tmpFile
};
markdox.process(sources, options, function() {
var docsStr = fs.readFileSync(tmpFile, 'utf8')
, readmeStr = fs.readFileSync(readme, 'utf8');
docsStr = docsStr.replace(/'/g, "'").replace(/"/g, '"');
readmeStr = readmeStr.replace(/(<!-- DOCS -->)(?:\r|\n|.)+(<!-- ENDDOCS -->)/gm
, "$1" + docsStr + "$2");
fs.writeFileSync(readme, readmeStr);
fs.unlinkSync(tmpFile);
console.log('Documentation generated.');
taskFinished();
});
});
gulp.task('default', ['lint']);