|
| 1 | +/* global module, require */ |
1 | 2 | module.exports = function(grunt) {
|
2 | 3 | 'use strict';
|
3 | 4 |
|
| 5 | + var fs = require('fs'), |
| 6 | + path = require('path'); |
| 7 | + var JSDOCJSON = 'jsdoc.json'; |
| 8 | + |
| 9 | + // Load the plugin that provides tasks. |
| 10 | + require('load-grunt-tasks')(grunt); |
| 11 | + grunt.loadTasks('tasks'); |
| 12 | + |
| 13 | + // merge source to destination dict |
| 14 | + function extend(destination, source) { |
| 15 | + for (var property in source) { |
| 16 | + if (source.hasOwnProperty(property)) { |
| 17 | + destination[property] = source[property]; |
| 18 | + } |
| 19 | + } |
| 20 | + return destination; |
| 21 | + } |
| 22 | + |
| 23 | + var jsdocConfig = { |
| 24 | + // per app configurations are defined in each app's jsdoc.json file |
| 25 | + options: { |
| 26 | + configure: '.jsdocrc', |
| 27 | + lenient: true //comment this out to debug jsdoc strictly |
| 28 | + } |
| 29 | + }; |
| 30 | + |
| 31 | + // processing jsdoc configurations |
| 32 | + var files = fs.readdirSync('apps'); |
| 33 | + files.forEach(function(filePath, i) { |
| 34 | + var appName = path.join('apps', filePath); |
| 35 | + if (fs.statSync(appName).isDirectory()) { |
| 36 | + // read jsdoc.json file in each app |
| 37 | + var jsonFile = path.join('apps', filePath, JSDOCJSON); |
| 38 | + if (fs.existsSync(jsonFile)) { |
| 39 | + console.log('... ' + filePath + ' config file found'); |
| 40 | + var appcfg = JSON.parse(fs.readFileSync(jsonFile, |
| 41 | + { encoding: 'utf8' })); |
| 42 | + extend(jsdocConfig, appcfg); |
| 43 | + } |
| 44 | + } |
| 45 | + }); |
| 46 | + |
4 | 47 | // Project configuration
|
5 | 48 | grunt.initConfig({
|
6 | 49 | pkg: grunt.file.readJSON('package.json'),
|
7 | 50 | clean: {
|
8 | 51 | docs: ['docs/']
|
9 | 52 | },
|
10 |
| - jsdoc: { |
11 |
| - system: { |
12 |
| - src: ['apps/system/js/**/*.js', |
13 |
| - // XXX Remove the following exclusion after related javascript |
14 |
| - // features are supported by JSDocs parser. |
15 |
| - '!apps/system/js/airplane_mode.js', |
16 |
| - '!apps/system/js/sound_manager.js', |
17 |
| - '!apps/system/js/title.js', |
18 |
| - '!apps/system/js/value_selector/date_picker.js', |
19 |
| - '!apps/system/js/value_selector/spin_date_picker.js', |
20 |
| - '!apps/system/js/lockscreen.js', |
21 |
| - '!apps/system/js/edge_swipe_detector.js', |
22 |
| - '!apps/system/js/stack_manager.js',], |
23 |
| - options: { |
24 |
| - destination: 'docs/system' |
25 |
| - } |
26 |
| - }, |
27 |
| - keyboard: { |
28 |
| - src: ['apps/keyboard/js/**/*.js', |
29 |
| - '!apps/keyboard/js/render.js'], |
30 |
| - options: { |
31 |
| - destination: 'docs/keyboard' |
32 |
| - } |
33 |
| - }, |
34 |
| - options: { |
35 |
| - configure: '.jsdocrc', |
36 |
| - lenient: true |
37 |
| - } |
38 |
| - } |
| 53 | + jsdoc: jsdocConfig |
39 | 54 | });
|
40 | 55 |
|
41 |
| - // Load the plugin that provides tasks |
42 |
| - grunt.loadNpmTasks('grunt-contrib-clean'); |
43 |
| - grunt.loadNpmTasks('grunt-jsdoc'); |
44 |
| - |
45 | 56 | // Default task(s)
|
46 | 57 | grunt.registerTask('docs', ['clean', 'jsdoc']);
|
47 | 58 | };
|
0 commit comments