New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grunt-jsdoc

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-jsdoc - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

.eslintrc

46

Gruntfile.js
module.exports = function(grunt) {
'use strict';
require('load-grunt-tasks')(grunt);

@@ -9,3 +8,10 @@

grunt.initConfig({
clean: ['doc'],
clean: {
options: {
force : true
},
test: ['doc']
},
jsdoc: {

@@ -38,19 +44,24 @@ basic: {

destination: 'doc/docstrap',
template: "node_modules/ink-docstrap/template",
configure: "node_modules/ink-docstrap/template/jsdoc.conf.json"
template: 'node_modules/ink-docstrap/template',
configure: 'node_modules/ink-docstrap/template/jsdoc.conf.json'
}
},
nosrc : {
options: {
configure : 'test/nosrc.json'
}
}
},
nodeunit: {
unit: ['test/jsdoc-plugin_test.js'],
basic: ['test/jsdoc-basic_test.js'],
unit: ['test/jsdoc-plugin_test.js'],
basic: ['test/jsdoc-basic_test.js'],
alternate: ['test/jsdoc-alternate_test.js'],
docstrap: ['test/jsdoc-docstrap_test.js'],
spacepack: ['test/jsdoc-spacepack_test.js']
docstrap: ['test/jsdoc-docstrap_test.js'],
spacepack: ['test/jsdoc-spacepack_test.js'],
nosrc: ['test/jsdoc-nosrc_test.js']
},
jshint: {
files: ['Gruntfile.js', 'tasks/*.js', 'tasks/lib/*.js', 'test/*.js'],
options: {
node: true,
smarttabs: true
eslint: {
all: {
src: ['Gruntfile.js', 'tasks/**/*.js', 'test/**/*.js']
}

@@ -65,10 +76,11 @@ }

//testing tasks
grunt.registerTask('default', 'Default tas will lint and test', ['jshint', 'test']);
grunt.registerTask('test-basic', 'Test basic jsdoc', ['jsdoc:basic', 'nodeunit:basic']);
grunt.registerTask('test-basic', 'Test basic jsdoc', ['jsdoc:basic', 'nodeunit:basic']);
grunt.registerTask('test-alternate', 'Test jsdoc with alternate options', ['jsdoc:alternate', 'nodeunit:alternate']);
grunt.registerTask('test-docstrap', 'Test jsdoc with a template', ['jsdoc:docstrap', 'nodeunit:docstrap']);
grunt.registerTask('test-docstrap', 'Test jsdoc with a template', ['jsdoc:docstrap', 'nodeunit:docstrap']);
grunt.registerTask('test-spacepack', 'Test jsdoc with a package and spaces in the paths', ['jsdoc:spacepack', 'nodeunit:spacepack']);
grunt.registerTask('test', 'Full test suite', ['clean', 'nodeunit:unit', 'test-basic', 'test-alternate', 'test-docstrap', 'test-spacepack']);
grunt.registerTask('test-nosrc', 'Test jsdoc without src and dest, only a config', ['jsdoc:nosrc', 'nodeunit:nosrc']);
grunt.registerTask('test', 'Full test suite', ['clean:test', 'nodeunit:unit', 'test-basic', 'test-alternate', 'test-docstrap', 'test-spacepack', 'test-nosrc']);
grunt.registerTask('default', 'Default task will lint and test', ['eslint:all', 'test']);
};
{
"name": "grunt-jsdoc",
"description": "Integrates jsdoc3 generation into your Grunt build",
"version": "1.1.0",
"version": "2.0.0",
"homepage": "https://github.com/krampstudio/grunt-jsdoc",

@@ -35,14 +35,15 @@ "author": {

"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-nodeunit": "~0.4.0",
"load-grunt-tasks": "^3.2.0",
"ink-docstrap": "^0.5.2"
"grunt": "^1.0.0",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-nodeunit": "^1.0.0",
"grunt-eslint": "^18.1.0",
"ink-docstrap": "^1.1.4",
"load-grunt-tasks": "^3.5.0"
},
"dependencies": {
"cross-spawn-async": "^2.2.2",
"jsdoc": "^3.4.0"
},
"peerDependencies": {
"grunt": "*"
"grunt": ">=0.4.5"
},

@@ -49,0 +50,0 @@ "keywords": [

@@ -7,9 +7,4 @@ # grunt-jsdoc [![Build Status](https://travis-ci.org/krampstudio/grunt-jsdoc.png)](https://travis-ci.org/krampstudio/grunt-jsdoc) [![NPM version](https://badge.fury.io/js/grunt-jsdoc.png)](http://badge.fury.io/js/grunt-jsdoc) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)

## Compatibility
### :warning: Migrate from `0.x.x` to `1.x.x` branch :
I have removed the direct dependency to [ink-docstrap](https://www.npmjs.com/package/ink-docstrap). If you still want it, grab the dependency by yourself (`npm install --save-dev ink-docstrap`)
## Generate your documentation

@@ -101,2 +96,12 @@

## Compatibility
### :warning: Migrate from `0.x.x` to `1.x.x` branch :
I have removed the direct dependency to [ink-docstrap](https://www.npmjs.com/package/ink-docstrap). If you still want it, grab the dependency by yourself (`npm install --save-dev ink-docstrap`)
### :warning: Migrate from `1.x.x` to `2.x.x` branch :
The `private` option follows now the default jsdoc behavior : `false` by default.
## Contributions

@@ -120,2 +125,3 @@

## Release History
* _2.0.0_ `private` behavior, `cross-spawn-async` instead of manual windows management
* _1.1.0_ update to jsdoc 3.4.0 and make dest optional if a config file is set.

@@ -122,0 +128,0 @@ * _1.0.0_ remove direct dependency to docstrap

@@ -33,7 +33,7 @@ /**

var jsdoc;
var jsdoc,
child;
var params = {};
var done = this.async();
var options = this.options({
'private': true,
'ignoreWarnings': false,

@@ -43,7 +43,6 @@ 'timeout': 60

var sources = this.filesSrc;
var jsdocPath = this.data.jsdoc;
if (!options.destination) {
if (!options.destination && this.files.length) {
// Support for old syntax where destination was provided through 'dest' key

@@ -82,3 +81,3 @@ options.destination = this.files[0].dest || 'doc';

grunt.log.debug("Using jsdoc from : " + jsdoc);
grunt.log.debug('Using jsdoc from : ' + jsdoc);

@@ -91,2 +90,3 @@ //check if there is sources to generate the doc for

//check if jsdoc config file path is provided and does exist

@@ -98,3 +98,3 @@ if (params.configure && !grunt.file.exists(params.configure)) {

if (!grunt.file.exists(params.destination) && !params.configure) {
if (params.destination && !grunt.file.exists(params.destination) && !params.configure) {
grunt.file.mkdir(options.destination);

@@ -109,6 +109,7 @@ grunt.log.debug('create destination : ' + options.destination);

//execution of the jsdoc command
var child = exec.buildSpawned(grunt, jsdoc, sources, params);
child = exec.buildSpawned(grunt, jsdoc, sources, params);
child.stdout.on('data', grunt.log.debug);
child.stderr.on('data', function(data) {
grunt.log.debug(data);
if (!options.ignoreWarnings) {

@@ -120,3 +121,7 @@ grunt.log.error(data);

if (code === 0) {
grunt.log.write('Documentation generated to ' + path.resolve(options.destination));
if(options.destination){
grunt.log.write('Documentation generated to ' + path.resolve(options.destination));
} else {
grunt.log.write('Documentation generated');
}
done(true);

@@ -123,0 +128,0 @@ } else {

@@ -1,5 +0,3 @@

var path = require('path');
var spawn = require('child_process').spawn;
var isWin = process.platform === 'win32';
var path = require('path');
var spawn = require('cross-spawn-async');
/**

@@ -11,60 +9,50 @@ * Provides utility methods to execute a command

/**
* Build and execute a child process using the spawn function
* @param {Object} grunt - the grunt context
* @param {String} script - the script to run
* @param {Array} sources - the list of sources files
* @param {Object} params - the list of cli flags
* @return {ChildProcess} from the spawn
*/
buildSpawned : function(grunt, script, sources, params){
/**
* Build and execute a child process using the spawn function
* @param {Object} grunt - the grunt context
* @param {String} script - the script to run
* @param {Array} sources - the list of sources files
* @param {Object} params - the list of cli flags
* @return {ChildProcess} from the spawn
*/
buildSpawned: function(grunt, script, sources, params) {
var flag;
var cmd = (isWin) ? 'cmd' : script;
var args = (isWin) ? ['/c', script.slice(-2) === 'js' ? 'node ' + script : script] : [];
var cmd = script;
var args =[];
// handle paths that contain spaces
var quote = function quote(path){
if(isWin && path.indexOf(' ') !== -1){
return '"' + path + '"';
}
return path;
};
// Compute JSDoc options
for (flag in params) {
if (params.hasOwnProperty(flag)) {
if (params[flag] !== false){
args.push('--' + flag);
// Compute JSDoc options
for (flag in params) {
if (params.hasOwnProperty(flag)) {
if (params[flag] !== false) {
args.push('--' + flag);
}
if (typeof params[flag] === 'string') {
args.push(quote(params[flag]));
args.push(params[flag]);
}
}
}
}
if(!Array.isArray(sources)){
sources = [sources];
}
args = args.concat(sources.map(quote));
if (!Array.isArray(sources)) {
sources = [sources];
}
args = args.concat(sources);
grunt.log.debug("Running : "+ cmd + " " + args.join(' '));
grunt.log.debug('Running : ' + cmd + ' ' + args.join(' '));
return spawn(cmd, args, {
windowsVerbatimArguments: isWin // documentation PR is pending: https://github.com/joyent/node/pull/4259
});
},
return spawn(cmd, args);
},
/**
* Lookup file or path into node modules
* @param {Object} grunt - the grunt context
* @returns {String} the first matching resolved path or nothing if not found
*/
lookup : function(grunt){
var i, binPath, paths;
var nodePath = process.env.NODE_PATH || '';
/**
* Lookup file or path into node modules
* @param {Object} grunt - the grunt context
* @returns {String} the first matching resolved path or nothing if not found
*/
lookup: function(grunt) {
var i, binPath, paths;
var nodePath = process.env.NODE_PATH || '';
//check first the base path into the cwd
paths = [
//check first the base path into the cwd
paths = [
__dirname + '/../../node_modules/.bin/jsdoc',

@@ -76,18 +64,19 @@ __dirname + '/../../node_modules/jsdoc/jsdoc.js',

//fall back on global if not found at the usual location
nodePath.split(path.delimiter).forEach(function(p){
if(!/\/$/.test(p)){
p += '/';
}
paths.push(p + '/jsdoc/jsdoc.js');
});
nodePath.split(path.delimiter).forEach(function(p) {
if (!/\/$/.test(p)) {
p += '/';
}
paths.push(p + '/jsdoc/jsdoc.js');
});
for(i in paths){
for (i in paths) {
binPath = path.resolve(paths[i]);
if(grunt.file.exists(binPath) && grunt.file.isFile(binPath)){
return binPath;
}
}
if (grunt.file.exists(binPath) && grunt.file.isFile(binPath)) {
return binPath;
}
}
return;
}
return;
}
};

@@ -10,10 +10,3 @@ /**

/**
* @requires grunt
*/
var grunt = require('grunt');
/**
* This function enables you to extract

@@ -25,9 +18,9 @@ * the declared arguments from a function.

*/
var extractArgs = function(fn){
'use strict';
var extractArgs = function(fn) {
'use strict';
if(typeof fn !== 'function'){
throw new Error('TypeError : The extractArgs function requires the fn argument to be a function!');
}
return fn.toString ().match (/function\s+\w*\s*\((.*?)\)/)[1].split (/\s*,\s*/);
if (typeof fn !== 'function') {
throw new Error('TypeError : The extractArgs function requires the fn argument to be a function!');
}
return fn.toString().match(/function\s+\w*\s*\((.*?)\)/)[1].split(/\s*,\s*/);
};

@@ -44,49 +37,50 @@

/**
* Set up the test by load the tasks/jsdoc-plugin module
* @memberOf JsdocTest
* @param {Function} done - to call once the setup is done.
*/
setUp: function(done) {
'use strict';
/**
* Set up the test by load the tasks/jsdoc-plugin module
* @memberOf JsdocTest
* @param {Function} done - to call once the setup is done.
*/
setUp: function(done) {
'use strict';
this.jsdocTask = require('../tasks/jsdoc-plugin');
done();
},
this.jsdocTask = require('../tasks/jsdoc-plugin');
done();
},
/**
* Check the task is loaded and complies with the grunt requirements.
* @memberOf JsdocTest
* @param {Object} test - the node unit test context
*/
'taskCheck' : function(test){
'use strict';
/**
* Check the task is loaded and complies with the grunt requirements.
* @memberOf JsdocTest
* @param {Object} test - the node unit test context
*/
'taskCheck': function(test) {
'use strict';
test.notStrictEqual(this.jsdocTask, undefined, 'the jsdoc task should be set up');
test.equal(typeof this.jsdocTask, 'function', 'the task must be a function');
test.notStrictEqual(this.jsdocTask, undefined, 'the jsdoc task should be set up');
test.equal(typeof this.jsdocTask, 'function', 'the task must be a function');
var taskArgs = extractArgs(this.jsdocTask);
test.ok(taskArgs.length > 0 && taskArgs[0] === 'grunt', 'the task must declare the grunt context as 1st parameter');
var taskArgs = extractArgs(this.jsdocTask);
test.ok(taskArgs.length > 0 && taskArgs[0] === 'grunt', 'the task must declare the grunt context as 1st parameter');
test.done();
},
test.done();
},
/**
* Do some check on the exec library
* @memberOf JsdocTest
* @param {Object} test - the node unit test context
*/
'execCheck' : function(test){
'use strict';
/**
* Do some check on the exec library
* @memberOf JsdocTest
* @param {Object} test - the node unit test context
*/
'execCheck': function(test) {
'use strict';
var exec = require('../tasks/lib/exec');
var exec = require('../tasks/lib/exec');
test.notStrictEqual(exec, undefined, 'the exec lib should be required');
test.equal(typeof exec, 'object', 'exec is an object');
test.notStrictEqual(exec, undefined, 'the exec lib should be required');
test.equal(typeof exec, 'object', 'exec is an object');
test.equal(typeof exec.buildSpawned, 'function', 'exec must have a buildSpawned method');
test.equal(typeof exec.lookup, 'function', 'exec must have a lookup method');
test.equal(typeof exec.buildSpawned, 'function', 'exec must have a buildSpawned method');
test.equal(typeof exec.lookup, 'function', 'exec must have a lookup method');
test.done();
}
test.done();
}
};
var testCase = require('./task');
var package = require('../package.json');
var pkg = require('../package.json');
testCase.setUp = function(done){
this.destination = 'doc/pack age/' + package.name + '/' + package.version;
this.destination = 'doc/pack age/' + pkg.name + '/' + pkg.version;
this.expectedFiles = [

@@ -6,0 +6,0 @@ 'index.html',

@@ -22,24 +22,24 @@ /**

/**
* Check the destination directory exists
* @memberOf JsdociTaskTest
* @param {Object} test - the node unit test context
*/
'destination check' : function(test){
'use strict';
/**
* Check the destination directory exists
* @memberOf JsdociTaskTest
* @param {Object} test - the node unit test context
*/
'destination check': function(test) {
'use strict';
test.expect(1);
fs.exists(this.destination, function(result){
fs.exists(this.destination, function(result) {
test.ok(result === true, 'The documentation destination should exists');
test.done();
});
},
},
/**
* Check the documentation content
* @memberOf JsdociTaskTest
* @param {Object} test - the node unit test context
*/
'content check' : function(test){
* @memberOf JsdociTaskTest
* @param {Object} test - the node unit test context
*/
'content check': function(test) {

@@ -50,3 +50,3 @@ var base = this.destination + '/';

this.expectedFiles.forEach(function(file){
this.expectedFiles.forEach(function(file) {
test.ok(fs.existsSync(base + file), 'The file ' + base + file + ' should exists');

@@ -60,1 +60,2 @@ });

module.exports = exports = JsdocTaskTest;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc