forked from mozilla-b2g/gaia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
58 lines (51 loc) · 1.51 KB
/
Gruntfile.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
57
58
/* global module, require */
module.exports = function(grunt) {
'use strict';
var fs = require('fs'),
path = require('path');
var JSDOCJSON = 'jsdoc.json';
// Load the plugin that provides tasks.
require('load-grunt-tasks')(grunt);
grunt.loadTasks('tasks');
// merge source to destination dict
function extend(destination, source) {
for (var property in source) {
if (source.hasOwnProperty(property)) {
destination[property] = source[property];
}
}
return destination;
}
var jsdocConfig = {
// per app configurations are defined in each app's jsdoc.json file
options: {
configure: '.jsdocrc',
lenient: true //comment this out to debug jsdoc strictly
}
};
// processing jsdoc configurations
var files = fs.readdirSync('apps');
files.forEach(function(filePath, i) {
var appName = path.join('apps', filePath);
if (fs.statSync(appName).isDirectory()) {
// read jsdoc.json file in each app
var jsonFile = path.join('apps', filePath, JSDOCJSON);
if (fs.existsSync(jsonFile)) {
console.log('... ' + filePath + ' config file found');
var appcfg = JSON.parse(fs.readFileSync(jsonFile,
{ encoding: 'utf8' }));
extend(jsdocConfig, appcfg);
}
}
});
// Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
docs: ['docs/']
},
jsdoc: jsdocConfig
});
// Default task(s)
grunt.registerTask('docs', ['clean', 'jsdoc']);
};