node-query/node_modules/jsdoc/jsdoc.js

185 lines
4.2 KiB
JavaScript
Raw Normal View History

2014-10-22 10:11:40 -04:00
#!/usr/bin/env node
/*global arguments, require: true */
2014-10-20 16:56:45 -04:00
/**
* @project jsdoc
* @author Michael Mathews <micmath@gmail.com>
* @license See LICENSE.md file included in this distribution.
*/
/**
* Data representing the environment in which this app is running.
*
* @namespace
* @name env
*/
2014-10-22 10:11:40 -04:00
global.env = {
2014-10-20 16:56:45 -04:00
/**
* Running start and finish times.
2014-10-22 10:11:40 -04:00
*
2014-10-20 16:56:45 -04:00
* @memberof env
*/
run: {
start: new Date(),
finish: null
},
/**
* The command-line arguments passed into JSDoc.
*
* @type Array
* @memberof env
*/
args: [],
/**
* The parsed JSON data from the configuration file.
2014-10-22 10:11:40 -04:00
*
2014-10-20 16:56:45 -04:00
* @type Object
* @memberof env
*/
conf: {},
/**
* The absolute path to the base directory of the JSDoc application.
2014-10-22 10:11:40 -04:00
*
2014-10-20 16:56:45 -04:00
* @private
* @type string
* @memberof env
*/
dirname: '.',
/**
2014-10-22 10:11:40 -04:00
* The user's working directory at the time that JSDoc was started.
*
* @private
* @type string
* @memberof env
*/
pwd: null,
/**
* The command-line options, parsed into a key/value hash.
*
2014-10-20 16:56:45 -04:00
* @type Object
* @memberof env
2014-10-22 10:11:40 -04:00
* @example if (global.env.opts.help) { console.log('Helpful message.'); }
2014-10-20 16:56:45 -04:00
*/
opts: {},
/**
* The source files that JSDoc will parse.
* @type Array
* @memberof env
*/
sourceFiles: [],
2014-10-22 10:11:40 -04:00
2014-10-20 16:56:45 -04:00
/**
* The JSDoc version number and revision date.
2014-10-22 10:11:40 -04:00
*
2014-10-20 16:56:45 -04:00
* @type Object
* @memberof env
*/
version: {}
};
// initialize the environment for the current JavaScript VM
(function(args) {
2014-10-22 10:11:40 -04:00
'use strict';
var path;
if (args[0] && typeof args[0] === 'object') {
// we should be on Node.js
args = [__dirname, process.cwd()];
path = require('path');
// Create a custom require method that adds `lib/jsdoc` and `node_modules` to the module
// lookup path. This makes it possible to `require('jsdoc/foo')` from external templates and
// plugins, and within JSDoc itself. It also allows external templates and plugins to
// require JSDoc's module dependencies without installing them locally.
require = require('requizzle')({
requirePaths: {
before: [path.join(__dirname, 'lib')],
after: [path.join(__dirname, 'node_modules')]
},
infect: true
});
}
2014-10-20 16:56:45 -04:00
2014-10-22 10:11:40 -04:00
require('./lib/jsdoc/util/runtime').initialize(args);
})( Array.prototype.slice.call(arguments, 0) );
2014-10-20 16:56:45 -04:00
/**
* Data that must be shared across the entire application.
2014-10-22 10:11:40 -04:00
*
2014-10-20 16:56:45 -04:00
* @namespace
* @name app
*/
2014-10-22 10:11:40 -04:00
global.app = {
2014-10-20 16:56:45 -04:00
jsdoc: {
2014-10-22 10:11:40 -04:00
name: require('./lib/jsdoc/name'),
parser: null,
scanner: new (require('./lib/jsdoc/src/scanner').Scanner)()
2014-10-20 16:56:45 -04:00
}
};
/**
2014-10-22 10:11:40 -04:00
* Recursively print an object's properties to stdout. This method is safe to use with objects that
* contain circular references. In addition, on Mozilla Rhino, this method is safe to use with
* native Java objects.
*
* @global
* @name dump
* @private
* @param {Object} obj - Object(s) to print to stdout.
2014-10-20 16:56:45 -04:00
*/
2014-10-22 10:11:40 -04:00
global.dump = function() {
'use strict';
var doop = require('./lib/jsdoc/util/doop').doop;
var _dump = require('./lib/jsdoc/util/dumper').dump;
2014-10-20 16:56:45 -04:00
for (var i = 0, l = arguments.length; i < l; i++) {
console.log( _dump(doop(arguments[i])) );
}
2014-10-22 10:11:40 -04:00
};
2014-10-20 16:56:45 -04:00
2014-10-22 10:11:40 -04:00
(function() {
'use strict';
2014-10-20 16:56:45 -04:00
2014-10-22 10:11:40 -04:00
var logger = require('./lib/jsdoc/util/logger');
var runtime = require('./lib/jsdoc/util/runtime');
var cli = require('./cli');
2014-10-20 16:56:45 -04:00
2014-10-22 10:11:40 -04:00
function cb(errorCode) {
cli.logFinish();
cli.exit(errorCode || 0);
2014-10-20 16:56:45 -04:00
}
2014-10-22 10:11:40 -04:00
cli.setVersionInfo()
.loadConfig();
2014-10-20 16:56:45 -04:00
2014-10-22 10:11:40 -04:00
if (!global.env.opts.test) {
cli.configureLogger();
2014-10-20 16:56:45 -04:00
}
2014-10-22 10:11:40 -04:00
cli.logStart();
2014-10-20 16:56:45 -04:00
2014-10-22 10:11:40 -04:00
// On Rhino, we use a try/catch block so we can log the Java exception (if available)
if ( runtime.isRhino() ) {
2014-10-20 16:56:45 -04:00
try {
2014-10-22 10:11:40 -04:00
cli.runCommand(cb);
2014-10-20 16:56:45 -04:00
}
catch(e) {
2014-10-22 10:11:40 -04:00
if (e.rhinoException) {
logger.fatal( e.rhinoException.printStackTrace() );
} else {
console.trace(e);
cli.exit(1);
2014-10-20 16:56:45 -04:00
}
}
}
2014-10-22 10:11:40 -04:00
else {
cli.runCommand(cb);
2014-10-20 16:56:45 -04:00
}
2014-10-22 10:11:40 -04:00
})();