grunt-jsdoc
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -9,3 +9,5 @@ module.exports = function(grunt) { | ||
src: ['tasks/*.js', 'test/*_test.js'], | ||
dest: 'doc' | ||
options: { | ||
destination: 'doc' | ||
} | ||
} | ||
@@ -12,0 +14,0 @@ }, |
{ | ||
"name": "grunt-jsdoc", | ||
"description": "Integrates jsdoc3 generation into your Grunt build", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"homepage": "https://github.com/krampstudio/grunt-jsdoc-plugin", | ||
@@ -38,4 +38,7 @@ "author": { | ||
"dependencies": { | ||
"jsdoc3": "git+https://github.com/jsdoc3/jsdoc.git" | ||
"jsdoc3": "git+https://github.com/jsdoc3/jsdoc.git#v3.1.1" | ||
}, | ||
"peerDependencies" : { | ||
"grunt" : "0.4.x" | ||
}, | ||
"keywords": [ | ||
@@ -42,0 +45,0 @@ "gruntplugin", |
@@ -42,3 +42,5 @@ # grunt-jsdoc-plugin [](https://travis-ci.org/krampstudio/grunt-jsdoc-plugin) | ||
src: ['src/*.js', 'test/*.js'], | ||
dest: 'doc' | ||
options{ | ||
destination: 'doc' | ||
} | ||
} | ||
@@ -49,7 +51,13 @@ } | ||
The only supported options are | ||
The supported options are | ||
* `src` : an array of pattern that matches the files to extract the documentation from. You can also add the pattern to a README.md file to include it in your doc as described [there](http://usejsdoc.org/about-including-readme.html). | ||
* `dest`: the directory where the documentation will be generated (it will be created if needed). | ||
* `config` : (optional) a path to a jsdoc config file (refer the [usejsdoc] documentation below for more information). | ||
* `src` : (required) an array of pattern that matches the files to extract the documentation from. You can also add the pattern to a README.md file to include it in your doc as described [there](http://usejsdoc.org/about-including-readme.html). | ||
* `dest` : (deprecated) to support the previous way to set up destination folder | ||
* `jsdoc`: (optional) the path to the jsdoc bin (needed only for some boreder line cases) | ||
* `options` : options used by jsdoc | ||
* `destination`: (required) the folder where the doc is generated | ||
* `congif` : (optionnal) path to a config file | ||
* `template` : (optionnal)path or name to a different template | ||
* `private` : (optionnal) include the private functions to the doc (`true` by default). | ||
* ... refer the [usejsdocCli] documentation for all the available options. | ||
@@ -97,2 +105,3 @@ Then, load the plugin | ||
* _0.2.3_ Fix [bug #14](https://github.com/krampstudio/grunt-jsdoc-plugin/pull/14) and [bug #15](https://github.com/krampstudio/grunt-jsdoc-plugin/issues/15) | ||
* _0.2.4_ Fix Jsdoc 3 dependency to 3.1.1 tag, enables jsdoc options [issue #19](https://github.com/krampstudio/grunt-jsdoc-plugin/issues/19), enable to add jsdoc path [issue #13](https://github.com/krampstudio/grunt-jsdoc-plugin/issues/13) and add peerDependencies | ||
@@ -111,1 +120,2 @@ [jsdoc3]: https://github.com/jsdoc3/jsdoc | ||
[usejsdoc]: http://usejsdoc.org | ||
[usejsdocCli]: http://usejsdoc.org/about-commandline.html |
@@ -30,23 +30,27 @@ /** | ||
function registerJsdocTask() { | ||
var fs = require('fs'), | ||
path = require('path'), | ||
options = grunt.task.current.options(), | ||
done = grunt.task.current.async(), | ||
srcs = grunt.task.current.filesSrc, | ||
dest = grunt.task.current.files[0].dest || 'doc', | ||
config = options.config, | ||
javaHome = process.env.JAVA_HOME, | ||
timeout = 60000, //todo implement and move in options | ||
var fs = require('fs'), | ||
path = require('path'), | ||
options = grunt.task.current.options({'private': true}), | ||
done = grunt.task.current.async(), | ||
srcs = grunt.task.current.filesSrc, | ||
javaHome = process.env.JAVA_HOME, | ||
jsDocPath = grunt.task.current.data.jsdoc, | ||
jsDocNpmPath = 'node_modules/jsdoc/jsdoc', | ||
timeout = 60000, //todo implement and move in options | ||
jsDoc; | ||
if (!options.destination) { | ||
// Support for old syntax where destination was provided through 'dest' key | ||
options.destination = grunt.task.current.files[0].dest || 'doc'; | ||
} | ||
/** | ||
* Build and execute a child process using the spawn function | ||
* @memberOf module:tasks/jsdoc-plugin#registerJsdocTask | ||
* @param {String} script the script to run | ||
* @param {Array} sources the list of sources files | ||
* @param {String} destination the destination directory | ||
* @param {String} [config] the path to a jsdoc config file | ||
* @return {ChildProcess} from the spawn | ||
* @memberOf module:tasks/jsdoc-plugin | ||
* @param {String} script - the script to run | ||
* @param {Array} sources - the list of sources files | ||
* @param {Object} options - the list of JSDoc options | ||
* @return {ChildProcess} from the spawn | ||
*/ | ||
var buildSpawned = function(script, sources, destination, config){ | ||
var buildSpawned = function(script, sources, options){ | ||
var isWin = process.platform === 'win32', | ||
@@ -57,8 +61,12 @@ cmd = (isWin) ? 'cmd' : script, | ||
if (config !== undefined) { | ||
args.push('-c'); | ||
args.push(config); | ||
// Compute JSDoc options | ||
for (var optionName in options) { | ||
grunt.log.debug("Reading option: " + optionName); | ||
args.push('--' + optionName); | ||
if (options.hasOwnProperty(optionName) && typeof(options[optionName]) === 'string') { | ||
grunt.log.debug(" > " + options[optionName]); | ||
args.push(options[optionName]); | ||
} | ||
} | ||
args.push('-d'); | ||
args.push(destination); | ||
if(!util.isArray(sources)){ | ||
@@ -77,12 +85,19 @@ sources = [sources]; | ||
* @todo find a more elegant way to do that... | ||
* @memberOf module:tasks/jsdoc-plugin#registerJsdocTask | ||
* @memberOf module:tasks/jsdoc-plugin | ||
* @param {String} base - the base path of jsdoc to look up in the different directories | ||
* @param {String} [path] - a defined path to the jsdoc bin, in case of a non standard location | ||
* @returns {String} the command absolute path | ||
*/ | ||
var jsDocLookup = function(){ | ||
var jsDocLookup = function(base, extPath){ | ||
var base = 'node_modules/jsdoc/jsdoc', | ||
paths = [ base, 'node_modules/grunt-jsdoc/' + base ], | ||
var paths = [], | ||
nodePath = process.env.NODE_PATH || '', | ||
_ = grunt.util._; | ||
if(extPath && typeof extPath === 'string'){ | ||
paths.push(extPath); | ||
} | ||
paths.push(base); | ||
paths.push('node_modules/grunt-jsdoc/' + base); | ||
_.map(nodePath.split(':'), function(p){ | ||
@@ -103,3 +118,3 @@ if(!/\/$/.test(p)){ | ||
}; | ||
jsDoc = jsDocLookup(); | ||
jsDoc = jsDocLookup(jsDocNpmPath, jsDocPath); | ||
@@ -129,3 +144,3 @@ //check if java is set | ||
//check if jsdoc config file path is provided and does exist | ||
if (config !== undefined && !fs.existsSync(config)){ | ||
if (options.config && !fs.existsSync(options.config)){ | ||
grunt.log.error('jsdoc config file path does not exist'); | ||
@@ -135,10 +150,10 @@ grunt.fail.warn('Wrong configuration', errorCode.generic); | ||
fs.exists(dest, function(exists){ | ||
fs.exists(options.destination, function(exists){ | ||
//if the destination don't exists, we create it | ||
if(!exists){ | ||
grunt.file.mkdir(dest); | ||
grunt.file.mkdir(options.destination); | ||
} | ||
//execution of the jsdoc command | ||
var child = buildSpawned(jsDoc, srcs, dest, config); | ||
var child = buildSpawned(jsDoc, srcs, options); | ||
child.stdout.on('data', function (data) { | ||
@@ -153,3 +168,3 @@ grunt.log.debug('jsdoc output : ' + data); | ||
if(code === 0){ | ||
grunt.log.write('Documentation generated to ' + path.resolve(dest)); | ||
grunt.log.write('Documentation generated to ' + path.resolve(options.destination)); | ||
done(true); | ||
@@ -156,0 +171,0 @@ } else { |
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
105403
1138
118
2
+ Addedabbrev@1.1.1(transitive)
+ Addedargparse@0.1.16(transitive)
+ Addedasync@0.1.22(transitive)
+ Addedcoffee-script@1.3.3(transitive)
+ Addedcolors@0.6.2(transitive)
+ Addeddateformat@1.0.2-1.2.3(transitive)
+ Addedesprima@1.0.4(transitive)
+ Addedeventemitter2@0.4.14(transitive)
+ Addedexit@0.1.2(transitive)
+ Addedfindup-sync@0.1.3(transitive)
+ Addedgetobject@0.1.0(transitive)
+ Addedglob@3.1.213.2.11(transitive)
+ Addedgraceful-fs@1.2.3(transitive)
+ Addedgrunt@0.4.5(transitive)
+ Addedgrunt-legacy-log@0.1.3(transitive)
+ Addedgrunt-legacy-log-utils@0.1.1(transitive)
+ Addedgrunt-legacy-util@0.2.0(transitive)
+ Addedhooker@0.2.3(transitive)
+ Addediconv-lite@0.2.11(transitive)
+ Addedinherits@1.0.22.0.4(transitive)
+ Addedjs-yaml@2.0.5(transitive)
+ Addedlodash@0.9.22.4.2(transitive)
+ Addedlru-cache@2.7.3(transitive)
+ Addedminimatch@0.2.140.3.0(transitive)
+ Addednopt@1.0.10(transitive)
+ Addedrimraf@2.2.8(transitive)
+ Addedsigmund@1.0.1(transitive)
+ Addedunderscore@1.7.0(transitive)
+ Addedunderscore.string@2.2.12.3.32.4.0(transitive)
+ Addedwhich@1.0.9(transitive)
Updatedjsdoc3@git+https://github.com/jsdoc3/jsdoc.git#v3.1.1