Skip to content

Instantly share code, notes, and snippets.

@cleverness
Last active October 29, 2015 02:27
Show Gist options
  • Save cleverness/861b7991a8d86c017caf to your computer and use it in GitHub Desktop.
Save cleverness/861b7991a8d86c017caf to your computer and use it in GitHub Desktop.
/*
* grunt-phpdocumentor
* https://github.com/gomoob/grunt-phpdocumentor
*
* Copyright (c) 2013 Baptiste Gaillard
* Licensed under the MIT license.
*/
'use strict';
module.exports = function ( grunt ) {
var ChildProcess = require( 'child_process' ),
Util = require( 'util' ),
Path = require( 'path' ),
_ = require( 'lodash' )._;
// Please see the Grunt documentation for more information regarding task
// creation: http://gruntjs.com/creating-tasks
grunt.registerMultiTask( 'phpdocumentor', 'Runs the PHPDocumentor documentation generator tool.', function () {
var options = this.options( {
target: 'docs',
filename: '',
directory: './',
encoding: '',
extensions: '',
ignore: [],
hidden: '',
'ignore-symlinks': '',
markers: '',
title: '',
force: '',
validate: '',
visibility: '',
defaultpackagename: '',
sourcecode: '',
progressbar: '',
template: '',
parseprivate: '',
config: '',
bin: ''
} );
var done = this.async();
// Checks if the provided Phpdocumentor command name is valid
if ( options.command !== undefined &&
options.command !== 'help' &&
options.command !== 'list' &&
options.command !== 'parse' &&
options.command !== 'run' &&
options.command !== 'transform' &&
options.command !== 'project:parse' &&
options.command !== 'project:run' &&
options.command !== 'project:transform' &&
options.command !== 'template:generate' &&
options.command !== 'template:list' &&
options.command !== 'template:package' ) {
grunt.log.error( Util.format( 'Phpdocumentor does not provide any command named \'%s\' !', this.data.command ) );
done( false );
}
// Path to the phar file
var phpDocumentorCommand = options.bin;
phpDocumentorCommand += ' --target=' + options.target;
phpDocumentorCommand += ' --directory=' + options.directory;
phpDocumentorCommand += ' --template=' + options.template;
if ( options.ignore !== false ) {
phpDocumentorCommand += ' --ignore=' + options.ignore.join( ',' );
}
grunt.log.writeln( phpDocumentorCommand );
var childProcess = ChildProcess.exec( phpDocumentorCommand, function ( error, stdout, stderr ) {
grunt.log.writeln( error );
grunt.log.writeln( stdout );
grunt.log.writeln( stderr );
} );
childProcess.on( 'exit', function ( code ) {
if ( code > 0 ) {
grunt.log.error( Util.format( 'Exited with code: %d.', code ) );
return done( false );
}
grunt.verbose.ok( Util.format( 'Exited with code: %d.', code ) );
done();
} );
} );
};
@cleverness
Copy link
Author

grunt-phpdocumentor
replace /node_modules/grunt-phpdocumentor/tasks/phpdocumentor.js with this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment