forked from mozilla-b2g/gaia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (47 loc) · 1.56 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
44
45
46
47
48
49
50
51
52
53
54
55
56
/* jshint node: true */
'use strict';
var gulp = require('gulp');
var shell = require('gulp-shell');
var ghPages = require('gulp-gh-pages');
var del = require('del');
var fs = require('fs');
var path = require('path');
var JSDOC_JSON = 'jsdoc.json';
var JSDOC_TASK_PREFIX = 'jsdoc:';
var jsdocTasks = [];
var generatePerAppTasks = function(appFolder) {
var files = fs.readdirSync(appFolder);
// generate per app tasks and host those tasks name in jsdocTasks list
files.forEach(function(filePath, i) {
var appName = path.join(appFolder, filePath);
if (fs.statSync(appName).isDirectory()) {
// read jsdoc.json file in each app
var jsonFile = path.join(appFolder, filePath, JSDOC_JSON);
if (fs.existsSync(jsonFile)) {
console.log(filePath + ' config file found');
var appcfg = JSON.parse(fs.readFileSync(jsonFile,
{ encoding: 'utf8' }));
if('name' in appcfg) {
var property = appcfg['name'];
jsdocTasks.push(JSDOC_TASK_PREFIX + property);
gulp.task(JSDOC_TASK_PREFIX + property, shell.task([
'./node_modules/jsdoc/jsdoc.js -c ' + jsonFile + ' -d ' +
appcfg.opts.destination
]));
console.log('... ' + property + ' task registered');
}
}
}
});
};
['apps', 'tv_apps'].forEach(function(appFolder) {
generatePerAppTasks(appFolder);
});
gulp.task('clean', function(cb) {
del(['./docs'], cb);
});
gulp.task('docs', jsdocTasks);
gulp.task('github', ['docs'], function() {
return gulp.src('./docs/**/*')
.pipe(ghPages());
});