Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@

module.exports = {
name: 'ember-cli-jsdoc',

included: function(app) {
this.jsdocOptions = app.options.jsdoc || {};
},
includedCommands: function() {
return {
'ember-cli-jsdoc': require( './lib/commands/ember-cli-jsdoc' )
}
},
postBuild: function(){
if(this.jsdocOptions.generateOnBuild) {
return require('./lib/generate-docs')(this.jsdocOptions.configFile);
}
}
};
40 changes: 4 additions & 36 deletions lib/commands/ember-cli-jsdoc.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,8 @@
'use strict';

module.exports = {
name: 'ember-cli-jsdoc',

run: function() {
var exec = require( 'child_process' ).exec;
var rsvp = require( 'rsvp' );
var path = require( 'path' );
var chalk = require( 'chalk' );
var cmdPath = ( Number( process.version.match( /^v(\d+)/ )[1] ) >= 5 ) ?
path.join( 'node_modules', '.bin', 'jsdoc' ) :
path.join( 'node_modules', 'ember-cli-jsdoc', 'node_modules', '.bin', 'jsdoc' );

return new rsvp.Promise( function( resolve, reject ) {
exec( cmdPath + ' -c jsdoc.json', { cwd: process.cwd() }, function( error, stdout, stderr ) {
console.log( stderr );

var shouldReject = false;

if ( error ) {
console.log( chalk.red( 'EMBER-CLI-JSDOC: ERRORS have occurred during documentation generation' ) );
shouldReject = true;
}

if ( /WARNING/.test( stderr ) ) {
console.log( chalk.yellow( 'EMBER-CLI-JSDOC: WARNINGS have occurred during documentation generation' ) );
}

if ( shouldReject ) {
reject();

} else {
console.log( chalk.green( 'EMBER-CLI-JSDOC: Documentation was successfully generated' ) );
resolve();
}
});
});
}
name: 'ember-cli-jsdoc',
run: function() {
return require('../generate-docs')()
}
}
31 changes: 31 additions & 0 deletions lib/generate-docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = function(configFile){
var exec = require( 'child_process' ).exec;
var rsvp = require( 'rsvp' );
var chalk = require( 'chalk' );
var cmdPath = require.resolve('jsdoc/jsdoc.js');
var configFile = configFile || 'jsdoc.json'
return new rsvp.Promise( function( resolve, reject ) {
exec( cmdPath + ' -c '+ configFile, { cwd: process.cwd() }, function( error, stdout, stderr ) {
console.log( stderr );

var shouldReject = false;

if ( error ) {
console.log( chalk.red( 'EMBER-CLI-JSDOC: ERRORS have occurred during documentation generation' ) );
shouldReject = true;
}

if ( /WARNING/.test( stderr ) ) {
console.log( chalk.yellow( 'EMBER-CLI-JSDOC: WARNINGS have occurred during documentation generation' ) );
}

if ( shouldReject ) {
reject();

} else {
console.log( chalk.green( 'EMBER-CLI-JSDOC: Documentation was successfully generated' ) );
resolve();
}
});
});
}