Remove Rhino support

This commit is contained in:
Tim Schaub 2015-10-30 13:11:43 -06:00
parent d18c08001f
commit 621f012211
50 changed files with 165 additions and 3480 deletions

View File

@ -1,5 +1,3 @@
node_modules/*
rhino/*
templates/default/static/scripts/*
test/fixtures/*
test/lib/*

View File

@ -4,11 +4,4 @@
.gitignore
.travis.yml
gulpfile.js
# scripts for launching JSDoc with Mozilla Rhino
/jsdoc*
!/jsdoc.js
# Rhino and test directories
rhino/
test/

View File

@ -145,19 +145,6 @@ Copyright (c) 2011-2015 by the Espree contributors.
The source code for Esprima is available at:
https://github.com/eslint/espree
## events ##
Portions of the events source code are incorporated into the following files:
+ `rhino/events.js`
events is distributed under the MIT license, which is reproduced above.
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
The source code for events is available at:
https://github.com/Gozala/events
## github-flavored-markdown ##
github-flavored-markdown is distributed under the BSD 3-clause license:
@ -234,36 +221,6 @@ Copyright (c) 2012 Michael Kourlas.
The source code for js2xmlparser is available at:
https://github.com/michaelkourlas/node-js2xmlparser
## Node.js ##
Portions of the Node.js source code are incorporated into the following files:
- `rhino/fs.js`
- `rhino/path.js`
- `rhino/querystring.js`
- `rhino/util.js`
Node.js is distributed under the MIT license, which is reproduced above.
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
The source code for Node.js is available at:
https://github.com/joyent/node
## node-browser-builtins ##
Portions of the node-browser-builtins source code are incorporated into the
following files:
- `rhino/assert.js`
- `rhino/rhino-shim.js`
node-browser-builtins is distributed under the MIT license, which is reproduced
above.
The source code for node-browser-builtins is available at:
https://github.com/alexgorbatchev/node-browser-builtins
## Open Sans ##
Open Sans is distributed under the Apache License 2.0, which is
@ -284,46 +241,6 @@ Copyright (c) 2012-2013 Johannes Ewald.
The source code for Requizzle is available at:
https://github.com/hegemonic/requizzle
## Rhino ##
Rhino is distributed under the following licenses:
### MPL 2.0 License ###
The majority of the source code for Rhino is available under the Mozilla Public
License (MPL) 2.0, which is included in this distribution.
### License for portions of the Rhino debugger ###
Additionally, some files are available under the BSD 3-clause license:
> Copyright 1997, 1998 Sun Microsystems, Inc. All Rights Reserved.
>
> Redistribution and use in source and binary forms, with or without
> modification, are permitted provided that the following conditions are met:
>
> - Redistributions of source code must retain the above copyright notice,
> this list of conditions and the following disclaimer.
> - Redistributions in binary form must reproduce the above copyright
> notice, this list of conditions and the following disclaimer in the
> documentation and/or other materials provided with the distribution.
> - Neither the name of Sun Microsystems nor the names of its contributors
> may be used to endorse or promote products derived from this software
> without specific prior written permission.
>
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
> SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
### Source Code ###
The source code for Rhino is available at:
https://github.com/jsdoc3/rhino
## TaffyDB ##
TaffyDB is distributed under a modified BSD license:

View File

@ -9,17 +9,8 @@ Want to contribute to JSDoc? Please read `CONTRIBUTING.md`.
Installation and Usage
----------------------
You can run JSDoc on either Node.js or Mozilla Rhino.
### Node.js
Native support for Node.js is available in JSDoc 3.3.0 and later. JSDoc
supports Node.js 0.10 and later.
#### Installing JSDoc for Node.js
You can install JSDoc in your project's `node_modules` folder, or you can
install it globally.
JSDoc supports Node.js 0.10 and later. You can install JSDoc in your project's
`node_modules` folder, or you can install it globally.
To install the latest version available on NPM:
@ -29,8 +20,6 @@ To install the latest development version:
npm install git+https://github.com/jsdoc3/jsdoc.git
#### Running JSDoc with Node.js
If you installed JSDoc locally, the JSDoc command-line tool is available in
`./node_modules/.bin`. To generate documentation for the file
`yourJavaScriptFile.js`:
@ -46,47 +35,6 @@ can use the `--destination` (`-d`) option to specify another directory.
Run `jsdoc --help` for a complete list of command-line options.
### Mozilla Rhino
All versions of JSDoc 3 run on a customized version of Mozilla Rhino, which
requires Java. You can run JSDoc 3 on Java 1.6 and later.
#### Installing JSDoc for Mozilla Rhino
To install JSDoc, download a .zip file for the
[latest development version](https://github.com/jsdoc3/jsdoc/archive/master.zip)
or a [previous release](https://github.com/jsdoc3/jsdoc/tags).
You can also use git to clone the
[JSDoc repository](https://github.com/jsdoc3/jsdoc):
git clone git+https://github.com/jsdoc3/jsdoc.git
The JSDoc repository includes a
[customized version of Mozilla Rhino](https://github.com/jsdoc3/rhino). Make
sure your Java classpath does not include any other versions of Rhino. (On OS X,
you may need to remove the file `~/Library/Java/Extensions/js.jar`.)
**Note**: In JSDoc 3.3.0 and later, if you need to run JSDoc on Mozilla Rhino,
do not install JSDoc with npm. Use one of the methods described above.
#### Running JSDoc with Mozilla Rhino
On OS X, Linux, and other POSIX systems, to generate documentation for the file
`yourJavaScriptFile.js`:
./jsdoc yourJavaScriptFile.js
Or on Windows:
jsdoc yourJavaScriptFile.js
By default, the generated documentation is saved in a directory named `out`. You
can use the `--destination` (`-d`) option to specify another directory.
Run `jsdoc --help` for a complete list of command-line options.
Templates and Build Tools
-------------------------

5
cli.js
View File

@ -6,10 +6,7 @@
* A few critical notes for anyone who works on this module:
*
* + The module should really export an instance of `cli`, and `props` should be properties of a
* `cli` instance. However, Rhino interpreted `this` as a reference to `global` within the
* prototype's methods, so we couldn't do that.
* + On Rhino, for unknown reasons, the `jsdoc/fs` and `jsdoc/path` modules can fail in some cases
* when they are required by this module. You may need to use `fs` and `path` instead.
* `cli` instance.
*
* @private
*/

View File

@ -31,16 +31,7 @@ var options = {
'test/specs/**/*.js'
],
nodeBin: path.resolve(__dirname, './jsdoc.js'),
nodePath: process.execPath,
rhinoBin: (function() {
var filepath = path.resolve(__dirname, './jsdoc');
if (os.platform().indexOf('win') === 0) {
filepath += '.cmd';
}
return filepath;
})()
nodePath: process.execPath
};
gulp.task('bump', function() {
@ -63,20 +54,9 @@ gulp.task('lint', function() {
.pipe(eslint.failOnError());
});
gulp.task('test-node', function(cb) {
gulp.task('test', function(cb) {
var cmd = util.format('%s "%s" -T', options.nodePath, options.nodeBin);
exec(cmd, execCb.bind(null, cb));
});
gulp.task('test-rhino', function(cb) {
var cmd = util.format('"%s" -T -q "parser=rhino"', options.rhinoBin);
exec(cmd, execCb.bind(null, cb));
});
gulp.task('test-rhino-jsparser', function(cb) {
var cmd = util.format('"%s" -T -q "parser=js"', options.rhinoBin);
exec(cmd, execCb.bind(null, cb));
});
gulp.task('test', ['test-node', 'test-rhino', 'test-rhino-jsparser']);
gulp.task('default', ['lint', 'test']);

33
jsdoc
View File

@ -1,33 +0,0 @@
#!/bin/sh
SOURCE="$0"
while [ -h "$SOURCE" ] ; do
NEXTSOURCE="$(readlink "$SOURCE")"
echo $NEXTSOURCE | grep -q -e "^/"
if [ $? = 0 ]; then
SOURCE="$NEXTSOURCE"
else
SOURCE="$(dirname $SOURCE)/$NEXTSOURCE"
fi
done
# Get a Windows path under MinGW or Cygwin
BASEPATH="$( cd -P "$( dirname "$SOURCE" )" && (pwd -W 2>/dev/null || cygpath -w $(pwd) 2>/dev/null || pwd))"
if [ "${BASEPATH%${BASEPATH#?}}" != "/" ] ; then
BASEPATH="$( echo "$BASEPATH" | sed -e 's@\\@/@g' )"
fi
if test "$1" = "--debug"
then
CMD="org.mozilla.javascript.tools.debugger.Main -debug -opt -1"
else
CMD="org.mozilla.javascript.tools.shell.Main"
fi
if test "$1" = "-T"
then
cd -P "$(dirname "$SOURCE")"
java -classpath "${BASEPATH}/rhino/js.jar" ${CMD} -opt -1 -modules "${BASEPATH}/lib" -modules "${BASEPATH}/node_modules" -modules "${BASEPATH}/rhino" -modules "${BASEPATH}" "${BASEPATH}/jsdoc.js" "$@"
else
java -classpath "${BASEPATH}/rhino/js.jar" ${CMD} -modules "${BASEPATH}/lib" -modules "${BASEPATH}/node_modules" -modules "${BASEPATH}/rhino" -modules "${BASEPATH}" "${BASEPATH}/jsdoc.js" "$@"
fi

View File

@ -1,26 +0,0 @@
@ECHO OFF
SETLOCAL
REM jsdoc.js expects paths without a trailing slash
SET _BASEPATH=%~dp0
SET _BASEPATH=%_BASEPATH:~0,-1%
REM we need the ability to resolve paths relative to the user's working
REM directory prior to launching JSDoc
SET PWD=%cd%
IF [%1]==[--debug] (
SET CMD=org.mozilla.javascript.tools.debugger.Main -debug -opt -1
) ELSE (
SET CMD=org.mozilla.javascript.tools.shell.Main
)
SET ARGS=%*
IF [%1]==[-T] (
java -classpath "%_BASEPATH%/rhino/js.jar" %CMD% -opt -1 -modules "%_BASEPATH%/lib" -modules "%_BASEPATH%/node_modules" -modules "%_BASEPATH%/rhino" -modules "%_BASEPATH%" "%_BASEPATH%/jsdoc.js" %ARGS% --nocolor
) ELSE (
java -classpath "%_BASEPATH%/rhino/js.jar" %CMD% -modules "%_BASEPATH%/lib" -modules "%_BASEPATH%/node_modules" -modules "%_BASEPATH%/rhino" -modules "%_BASEPATH%" "%_BASEPATH%/jsdoc.js" %ARGS%
)
ENDLOCAL

View File

@ -45,16 +45,7 @@
*/
global.env = (function() {
'use strict';
// This bit of joy is here because Rhino treats `./lib/jsdoc/env` and `jsdoc/env` as separate
// modules. In contrast, Node.js errors out on `jsdoc/env` because we don't patch `require()`
// until after this file is loaded.
if (require('./lib/jsdoc/util/runtime').isRhino()) {
return require('jsdoc/env');
}
else {
return require('./lib/jsdoc/env');
}
return require('./lib/jsdoc/env');
})();
/**
@ -67,14 +58,7 @@ global.env = (function() {
*/
global.app = (function() {
'use strict';
// See comment in `global.env` to find out why we jump through this hoop.
if (require('./lib/jsdoc/util/runtime').isRhino()) {
return require('jsdoc/app');
}
else {
return require('./lib/jsdoc/app');
}
return require('./lib/jsdoc/app');
})();
(function() {
@ -102,8 +86,7 @@ global.app = (function() {
if (env.opts.debug) {
/**
* 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.
* objects that contain circular references.
*
* This method is available only when JSDoc is run with the `--debug` option.
*
@ -117,21 +100,5 @@ global.app = (function() {
};
}
// On Rhino, we use a try/catch block so we can log the Java exception (if available)
if ( runtime.isRhino() ) {
try {
cli.runCommand(cb);
}
catch (e) {
if (e.rhinoException) {
logger.fatal( e.rhinoException.printStackTrace() );
} else {
console.trace(e);
cli.exit(1);
}
}
}
else {
cli.runCommand(cb);
}
cli.runCommand(cb);
})();

View File

@ -24,7 +24,7 @@ function parseQuery(str) {
argParser.addOption('a', 'access', true, 'Only display symbols with the given access: "public", "protected", "private" or "undefined", or "all" for all access levels. Default: all except "private"', true);
argParser.addOption('c', 'configure', true, 'The path to the configuration file. Default: path/to/jsdoc/conf.json');
argParser.addOption('d', 'destination', true, 'The path to the output folder. Use "console" to dump data to the console. Default: ./out/');
argParser.addOption('', 'debug', false, 'Log information for debugging JSDoc. On Rhino, launches the debugger when passed as the first option.');
argParser.addOption('', 'debug', false, 'Log information for debugging JSDoc.');
argParser.addOption('e', 'encoding', true, 'Assume this encoding when reading all source files. Default: utf8');
argParser.addOption('h', 'help', false, 'Print this message and quit.');
argParser.addOption('', 'match', true, 'When running tests, only use specs whose names contain <value>.', true);

View File

@ -95,7 +95,7 @@ exports.commonPrefix = function(paths) {
* @param {string} filepath - The path to the requested resource. May be an absolute path; a path
* relative to the JSDoc directory; or a path relative to the current working directory.
* @param {string} [filename] - The filename of the requested resource.
* @return {string} The fully qualified path (or, on Rhino, a URI) to the requested resource.
* @return {string} The fully qualified path to the requested resource.
* Includes the filename if one was provided.
*/
exports.getResourcePath = function(filepath, filename) {

View File

@ -33,17 +33,6 @@ exports.installPlugins = function(plugins, parser) {
plugin.defineTags(dictionary);
}
// ...add a Rhino node visitor (deprecated in JSDoc 3.3)
if (plugin.nodeVisitor) {
if ( !parser.addNodeVisitor ) {
logger.error('Unable to add the Rhino node visitor from %s, because JSDoc ' +
'is not using the Rhino JavaScript parser.', plugins[i]);
}
else {
parser.addNodeVisitor(plugin.nodeVisitor);
}
}
// ...add a Mozilla Parser API node visitor
if (plugin.astNodeVisitor) {
parser.addAstNodeVisitor(plugin.astNodeVisitor);

View File

@ -12,7 +12,6 @@ var jsdoc = {
};
var Syntax = jsdoc.src.syntax.Syntax;
// TODO: should set e.stopPropagation == true for consistency with Rhino, right?
var VISITOR_CONTINUE = true;
var VISITOR_STOP = false;

View File

@ -27,8 +27,7 @@ var Syntax = jsdoc.src.syntax.Syntax;
// TODO: docs
var PARSERS = exports.PARSERS = {
js: 'jsdoc/src/parser',
rhino: 'rhino/jsdoc/src/parser'
js: 'jsdoc/src/parser'
};
/* eslint-disable no-script-url */
// Prefix for JavaScript strings that were provided in lieu of a filename.
@ -62,7 +61,7 @@ exports.createParser = function(type) {
if (!type) {
/* istanbul ignore next */
type = jsdoc.util.runtime.isRhino() ? 'rhino' : 'js';
type = 'js';
}
if (hasOwnProp.call(PARSERS, type)) {

View File

@ -52,7 +52,7 @@ exports.Syntax = {
JSXSpreadAttribute: 'JSXSpreadAttribute',
JSXText: 'JSXText',
LabeledStatement: 'LabeledStatement',
LetStatement: 'LetStatement', // TODO: update Rhino to use VariableDeclaration
LetStatement: 'LetStatement',
Literal: 'Literal',
LogicalExpression: 'LogicalExpression',
MemberExpression: 'MemberExpression',

View File

@ -582,7 +582,6 @@ Walker.prototype._recurse = function(filename, ast) {
};
// TODO: docs
// TODO: skip the AST root node to be consistent with Rhino?
Walker.prototype.recurse = function(ast, visitor, filename) {
var shouldContinue;
var state = this._recurse(filename, ast);

View File

@ -10,25 +10,19 @@
var env = require('jsdoc/env');
var os = require('os');
// These strings represent directory names; do not modify them!
/** @private */
var RHINO = exports.RHINO = 'rhino';
// This string represents a directory name; do not modify it!
/** @private */
var NODE = exports.NODE = 'node';
/**
* The JavaScript runtime that is executing JSDoc:
*
* + `module:jsdoc/util/runtime~RHINO`: Mozilla Rhino.
* + `module:jsdoc/util/runtime~NODE`: Node.js.
*
* @private
*/
var runtime = (function() {
if (global.Packages && typeof global.Packages === 'object' &&
Object.prototype.toString.call(global.Packages) === '[object JavaPackage]') {
return RHINO;
} else if (require && require.main && module) {
if (require && require.main && module) {
return NODE;
} else {
// unknown runtime
@ -36,14 +30,6 @@ var runtime = (function() {
}
})();
/**
* Check whether Mozilla Rhino is running JSDoc.
* @return {boolean} Set to `true` if the current runtime is Mozilla Rhino.
*/
exports.isRhino = function() {
return runtime === RHINO;
};
/**
* Check whether Node.js is running JSDoc.
* @return {boolean} Set to `true` if the current runtime is Node.js.
@ -52,18 +38,6 @@ exports.isNode = function() {
return runtime === NODE;
};
function initializeRhino(args) {
// the JSDoc dirname is the main module URI, minus the filename, converted to a path
var uriParts = require.main.uri.split('/');
uriParts.pop();
env.dirname = String( new java.io.File(new java.net.URI(uriParts.join('/'))) );
env.pwd = String( java.lang.System.getenv().get('PWD') );
env.args = args;
require(env.dirname + '/rhino/rhino-shim.js');
}
function initializeNode(args) {
var fs = require('fs');
var path = require('path');
@ -83,9 +57,6 @@ function initializeNode(args) {
exports.initialize = function(args) {
switch (runtime) {
case RHINO:
initializeRhino(args);
break;
case NODE:
initializeNode(args);
break;

View File

@ -11,7 +11,6 @@ var env = require('jsdoc/env');
var util = require('util');
var conf = env.conf.eventDumper || {};
var isRhino = require('jsdoc/util/runtime').isRhino();
// Dump the included parser events (defaults to all events)
var events = conf.include || [
@ -30,20 +29,6 @@ if (conf.exclude) {
events = _.difference(events, conf.exclude);
}
/**
* Check whether a variable appears to be a Java native object.
*
* @param {*} o - The variable to check.
* @return {boolean} Set to `true` for Java native objects and `false` in all other cases.
*/
function isJavaNativeObject(o) {
if (!isRhino) {
return false;
}
return o && typeof o === 'object' && typeof o.getClass === 'function';
}
/**
* Replace AST node objects in events with a placeholder.
*
@ -91,8 +76,7 @@ function cleanse(e) {
}
// never include functions that belong to the object
else if (typeof e[prop] !== 'function') {
// don't call JSON.stringify() on Java native objects--Rhino will throw an exception
result[prop] = isJavaNativeObject(e[prop]) ? String(e[prop]) : e[prop];
result[prop] = e[prop];
}
});

View File

@ -1,373 +0,0 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View File

@ -1,315 +0,0 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// UTILITY
var util = require('util');
var pSlice = Array.prototype.slice;
// 1. The assert module provides functions that throw
// AssertionError's when particular conditions are not met. The
// assert module must conform to the following interface.
var assert = module.exports = ok;
// 2. The AssertionError is defined in assert.
// new assert.AssertionError({ message: message,
// actual: actual,
// expected: expected })
assert.AssertionError = function AssertionError(options) {
this.name = 'AssertionError';
this.actual = options.actual;
this.expected = options.expected;
this.operator = options.operator;
this.message = options.message || getMessage(this);
};
// assert.AssertionError instanceof Error
util.inherits(assert.AssertionError, Error);
function replacer(key, value) {
if (util.isUndefined(value)) {
return '' + value;
}
if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
return value.toString();
}
if (util.isFunction(value) || util.isRegExp(value)) {
return value.toString();
}
return value;
}
function truncate(s, n) {
if (util.isString(s)) {
return s.length < n ? s : s.slice(0, n);
} else {
return s;
}
}
function getMessage(self) {
return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
self.operator + ' ' +
truncate(JSON.stringify(self.expected, replacer), 128);
}
// At present only the three keys mentioned above are used and
// understood by the spec. Implementations or sub modules can pass
// other keys to the AssertionError's constructor - they will be
// ignored.
// 3. All of the following functions must throw an AssertionError
// when a corresponding condition is not met, with a message that
// may be undefined if not provided. All assertion methods provide
// both the actual and expected values to the assertion error for
// display purposes.
function fail(actual, expected, message, operator, stackStartFunction) {
throw new assert.AssertionError({
message: message,
actual: actual,
expected: expected,
operator: operator,
stackStartFunction: stackStartFunction
});
}
// EXTENSION! allows for well behaved errors defined elsewhere.
assert.fail = fail;
// 4. Pure assertion tests whether a value is truthy, as determined
// by !!guard.
// assert.ok(guard, message_opt);
// This statement is equivalent to assert.equal(true, !!guard,
// message_opt);. To test strictly for the value true, use
// assert.strictEqual(true, guard, message_opt);.
function ok(value, message) {
if (!value) fail(value, true, message, '==', assert.ok);
}
assert.ok = ok;
// 5. The equality assertion tests shallow, coercive equality with
// ==.
// assert.equal(actual, expected, message_opt);
assert.equal = function equal(actual, expected, message) {
if (actual != expected) fail(actual, expected, message, '==', assert.equal);
};
// 6. The non-equality assertion tests for whether two objects are not equal
// with != assert.notEqual(actual, expected, message_opt);
assert.notEqual = function notEqual(actual, expected, message) {
if (actual == expected) {
fail(actual, expected, message, '!=', assert.notEqual);
}
};
// 7. The equivalence assertion tests a deep equality relation.
// assert.deepEqual(actual, expected, message_opt);
assert.deepEqual = function deepEqual(actual, expected, message) {
if (!_deepEqual(actual, expected)) {
fail(actual, expected, message, 'deepEqual', assert.deepEqual);
}
};
function _deepEqual(actual, expected) {
// 7.1. All identical values are equivalent, as determined by ===.
if (actual === expected) {
return true;
} else if (util.isBuffer(actual) && util.isBuffer(expected)) {
if (actual.length != expected.length) return false;
for (var i = 0; i < actual.length; i++) {
if (actual[i] !== expected[i]) return false;
}
return true;
// 7.2. If the expected value is a Date object, the actual value is
// equivalent if it is also a Date object that refers to the same time.
} else if (util.isDate(actual) && util.isDate(expected)) {
return actual.getTime() === expected.getTime();
// 7.3 If the expected value is a RegExp object, the actual value is
// equivalent if it is also a RegExp object with the same source and
// properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
} else if (util.isRegExp(actual) && util.isRegExp(expected)) {
return actual.source === expected.source &&
actual.global === expected.global &&
actual.multiline === expected.multiline &&
actual.lastIndex === expected.lastIndex &&
actual.ignoreCase === expected.ignoreCase;
// 7.4. Other pairs that do not both pass typeof value == 'object',
// equivalence is determined by ==.
} else if (!util.isObject(actual) && !util.isObject(expected)) {
return actual == expected;
// 7.5 For all other Object pairs, including Array objects, equivalence is
// determined by having the same number of owned properties (as verified
// with Object.prototype.hasOwnProperty.call), the same set of keys
// (although not necessarily the same order), equivalent values for every
// corresponding key, and an identical 'prototype' property. Note: this
// accounts for both named and indexed properties on Arrays.
} else {
return objEquiv(actual, expected);
}
}
function isArguments(object) {
return Object.prototype.toString.call(object) == '[object Arguments]';
}
function objEquiv(a, b) {
if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
return false;
// an identical 'prototype' property.
if (a.prototype !== b.prototype) return false;
//~~~I've managed to break Object.keys through screwy arguments passing.
// Converting to array solves the problem.
if (isArguments(a)) {
if (!isArguments(b)) {
return false;
}
a = pSlice.call(a);
b = pSlice.call(b);
return _deepEqual(a, b);
}
try {
var ka = Object.keys(a),
kb = Object.keys(b),
key, i;
} catch (e) {//happens when one is a string literal and the other isn't
return false;
}
// having the same number of owned properties (keys incorporates
// hasOwnProperty)
if (ka.length != kb.length)
return false;
//the same set of keys (although not necessarily the same order),
ka.sort();
kb.sort();
//~~~cheap key test
for (i = ka.length - 1; i >= 0; i--) {
if (ka[i] != kb[i])
return false;
}
//equivalent values for every corresponding key, and
//~~~possibly expensive deep test
for (i = ka.length - 1; i >= 0; i--) {
key = ka[i];
if (!_deepEqual(a[key], b[key])) return false;
}
return true;
}
// 8. The non-equivalence assertion tests for any deep inequality.
// assert.notDeepEqual(actual, expected, message_opt);
assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
if (_deepEqual(actual, expected)) {
fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
}
};
// 9. The strict equality assertion tests strict equality, as determined by ===.
// assert.strictEqual(actual, expected, message_opt);
assert.strictEqual = function strictEqual(actual, expected, message) {
if (actual !== expected) {
fail(actual, expected, message, '===', assert.strictEqual);
}
};
// 10. The strict non-equality assertion tests for strict inequality, as
// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
if (actual === expected) {
fail(actual, expected, message, '!==', assert.notStrictEqual);
}
};
function expectedException(actual, expected) {
if (!actual || !expected) {
return false;
}
if (Object.prototype.toString.call(expected) == '[object RegExp]') {
return expected.test(actual);
} else if (actual instanceof expected) {
return true;
} else if (expected.call({}, actual) === true) {
return true;
}
return false;
}
function _throws(shouldThrow, block, expected, message) {
var actual;
if (util.isString(expected)) {
message = expected;
expected = null;
}
try {
block();
} catch (e) {
actual = e;
}
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
(message ? ' ' + message : '.');
if (shouldThrow && !actual) {
fail(actual, expected, 'Missing expected exception' + message);
}
if (!shouldThrow && expectedException(actual, expected)) {
fail(actual, expected, 'Got unwanted exception' + message);
}
if ((shouldThrow && actual && expected &&
!expectedException(actual, expected)) || (!shouldThrow && actual)) {
throw actual;
}
}
// 11. Expected to throw an error:
// assert.throws(block, Error_opt, message_opt);
assert.throws = function(block, /*optional*/error, /*optional*/message) {
_throws.apply(this, [true].concat(pSlice.call(arguments)));
};
// EXTENSION! This is annoying to write outside this module.
assert.doesNotThrow = function(block, /*optional*/message) {
_throws.apply(this, [false].concat(pSlice.call(arguments)));
};
assert.ifError = function(err) { if (err) {throw err;}};

View File

@ -1,3 +0,0 @@
'use strict';
module.exports = require('buffer-browserify');

View File

@ -1,3 +0,0 @@
'use strict';
module.exports = require('crypto-browserify');

View File

@ -1,292 +0,0 @@
/**
* Shim for Node.js `events` module.
* @see https://github.com/Gozala/events
* @license MIT
*/
'use strict';
function EventEmitter() {
this._events = this._events || {};
this._maxListeners = this._maxListeners || undefined;
}
module.exports = EventEmitter;
if (!process.EventEmitter) {
process.EventEmitter = EventEmitter;
}
// Backwards-compat with node 0.10.x
EventEmitter.EventEmitter = EventEmitter;
EventEmitter.prototype._events = undefined;
EventEmitter.prototype._maxListeners = undefined;
// By default EventEmitters will print a warning if more than 10 listeners are
// added to it. This is a useful default which helps finding memory leaks.
EventEmitter.defaultMaxListeners = 10;
// Obviously not all Emitters should be limited to 10. This function allows
// that to be increased. Set to zero for unlimited.
EventEmitter.prototype.setMaxListeners = function(n) {
if (!isNumber(n) || n < 0 || isNaN(n))
throw TypeError('n must be a positive number');
this._maxListeners = n;
return this;
};
EventEmitter.prototype.emit = function(type) {
var er, handler, len, args, i, listeners;
if (!this._events)
this._events = {};
// If there is no 'error' event listener then throw.
if (type === 'error') {
if (!this._events.error ||
(isObject(this._events.error) && !this._events.error.length)) {
er = arguments[1];
if (er instanceof Error) {
throw er; // Unhandled 'error' event
} else {
throw TypeError('Uncaught, unspecified "error" event.');
}
return false;
}
}
handler = this._events[type];
if (isUndefined(handler))
return false;
if (isFunction(handler)) {
switch (arguments.length) {
// fast cases
case 1:
handler.call(this);
break;
case 2:
handler.call(this, arguments[1]);
break;
case 3:
handler.call(this, arguments[1], arguments[2]);
break;
// slower
default:
len = arguments.length;
args = new Array(len - 1);
for (i = 1; i < len; i++)
args[i - 1] = arguments[i];
handler.apply(this, args);
}
} else if (isObject(handler)) {
len = arguments.length;
args = new Array(len - 1);
for (i = 1; i < len; i++)
args[i - 1] = arguments[i];
listeners = handler.slice();
len = listeners.length;
for (i = 0; i < len; i++)
listeners[i].apply(this, args);
}
return true;
};
EventEmitter.prototype.addListener = function(type, listener) {
var m;
if (!isFunction(listener))
throw TypeError('listener must be a function');
if (!this._events)
this._events = {};
// To avoid recursion in the case that type === "newListener"! Before
// adding it to the listeners, first emit "newListener".
if (this._events.newListener)
this.emit('newListener', type,
isFunction(listener.listener) ?
listener.listener : listener);
if (!this._events[type])
// Optimize the case of one listener. Don't need the extra array object.
this._events[type] = listener;
else if (isObject(this._events[type]))
// If we've already got an array, just append.
this._events[type].push(listener);
else
// Adding the second element, need to change to array.
this._events[type] = [this._events[type], listener];
// Check for listener leak
if (isObject(this._events[type]) && !this._events[type].warned) {
var m;
if (!isUndefined(this._maxListeners)) {
m = this._maxListeners;
} else {
m = EventEmitter.defaultMaxListeners;
}
if (m && m > 0 && this._events[type].length > m) {
this._events[type].warned = true;
console.error('(node) warning: possible EventEmitter memory ' +
'leak detected. %d listeners added. ' +
'Use emitter.setMaxListeners() to increase limit.',
this._events[type].length);
if (typeof console.trace === 'function') {
// not supported in IE 10
console.trace();
}
}
}
return this;
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.once = function(type, listener) {
if (!isFunction(listener))
throw TypeError('listener must be a function');
var fired = false;
function g() {
this.removeListener(type, g);
if (!fired) {
fired = true;
listener.apply(this, arguments);
}
}
g.listener = listener;
this.on(type, g);
return this;
};
// emits a 'removeListener' event iff the listener was removed
EventEmitter.prototype.removeListener = function(type, listener) {
var list, position, length, i;
if (!isFunction(listener))
throw TypeError('listener must be a function');
if (!this._events || !this._events[type])
return this;
list = this._events[type];
length = list.length;
position = -1;
if (list === listener ||
(isFunction(list.listener) && list.listener === listener)) {
delete this._events[type];
if (this._events.removeListener)
this.emit('removeListener', type, listener);
} else if (isObject(list)) {
for (i = length; i-- > 0;) {
if (list[i] === listener ||
(list[i].listener && list[i].listener === listener)) {
position = i;
break;
}
}
if (position < 0)
return this;
if (list.length === 1) {
list.length = 0;
delete this._events[type];
} else {
list.splice(position, 1);
}
if (this._events.removeListener)
this.emit('removeListener', type, listener);
}
return this;
};
EventEmitter.prototype.removeAllListeners = function(type) {
var key, listeners;
if (!this._events)
return this;
// not listening for removeListener, no need to emit
if (!this._events.removeListener) {
if (arguments.length === 0)
this._events = {};
else if (this._events[type])
delete this._events[type];
return this;
}
// emit removeListener for all listeners on all events
if (arguments.length === 0) {
for (key in this._events) {
if (key === 'removeListener') continue;
this.removeAllListeners(key);
}
this.removeAllListeners('removeListener');
this._events = {};
return this;
}
listeners = this._events[type];
if (isFunction(listeners)) {
this.removeListener(type, listeners);
} else {
// LIFO order
while (listeners.length)
this.removeListener(type, listeners[listeners.length - 1]);
}
delete this._events[type];
return this;
};
EventEmitter.prototype.listeners = function(type) {
var ret;
if (!this._events || !this._events[type])
ret = [];
else if (isFunction(this._events[type]))
ret = [this._events[type]];
else
ret = this._events[type].slice();
return ret;
};
EventEmitter.listenerCount = function(emitter, type) {
var ret;
if (!emitter._events || !emitter._events[type])
ret = 0;
else if (isFunction(emitter._events[type]))
ret = 1;
else
ret = emitter._events[type].length;
return ret;
};
function isFunction(arg) {
return typeof arg === 'function';
}
function isNumber(arg) {
return typeof arg === 'number';
}
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
}
function isUndefined(arg) {
return arg === void 0;
}

View File

@ -1,168 +0,0 @@
/**
* Partial Rhino shim for Node.js' `fs` module.
* @see http://nodejs.org/api/fs.html
*/
'use strict';
var env = require('jsdoc/env');
var path = require('path');
var util = require('util');
var asyncify = path._asyncify;
function checkEncoding(enc, name) {
// we require the `encoding` parameter for Node.js compatibility; on Node.js, if you omit the
// encoding, you get a stream instead of a string
if (!enc || typeof enc === 'function') {
throw new Error(name + ' requires an encoding on Rhino!');
}
// Node.js wants 'utf8', but Java wants 'utf-8'
if (enc === 'utf8') {
enc = 'utf-8';
}
return enc;
}
// provide an error that's consistent with Node.js
function errorFactory(filepath) {
return new Error( util.format("ENOENT, no such file or directory '%s'", filepath) );
}
exports.readFileSync = function readFileSync(filename, encoding) {
encoding = checkEncoding(encoding, 'fs.readFile[Sync]');
return readFile(filename, encoding);
};
exports.readFile = asyncify(exports.readFileSync);
// in node 0.8, path.exists() and path.existsSync() moved to the "fs" module
exports.existsSync = path.existsSync;
exports.exists = path.exists;
var statSync = exports.statSync = function statSync(_path) {
var f = new java.io.File(_path);
if (!f) {
throw errorFactory(_path);
}
return {
isFile: function isFile() {
return f.isFile();
},
isDirectory: function isDirectory() {
return f.isDirectory();
},
isSymlink: function isSymlink() {
// java.io.File resolves symlinks
return false;
}
};
};
exports.stat = asyncify(statSync);
// java.io.File resolves symlinks, so we can alias `lstat` to `stat`
var lstatSync = exports.lstatSync = statSync;
exports.lstat = asyncify(lstatSync);
var readdirSync = exports.readdirSync = function readdirSync(_path) {
var dir;
var files;
dir = new java.io.File(_path);
if (!dir.directory) {
throw errorFactory(_path);
}
files = dir.list()
.map(function(fileName) {
return String(fileName);
});
return files;
};
exports.readdir = asyncify(readdirSync);
// JSDoc extension to `fs` module
var toDir = exports.toDir = function toDir(_path) {
var f;
_path = path.normalize(_path);
f = new java.io.File( path.resolve(env.pwd, _path) );
if ( f.isDirectory() ){
return _path;
} else {
return path.dirname(_path);
}
};
var mkdirSync = exports.mkdirSync = function mkdirSync(_path) {
var dir_path = toDir(_path);
( new java.io.File(dir_path) ).mkdir();
};
exports.mkdir = asyncify(mkdirSync);
// JSDoc extension to `fs` module
exports.mkPath = function mkPath(_path) {
if ( Array.isArray(_path) ) {
_path = _path.join('');
}
( new java.io.File(path.resolve(env.pwd, _path)) ).mkdirs();
};
// JSDoc extension to `fs` module
exports.copyFileSync = function copyFileSync(inFile, outDir, fileName) {
if (fileName === undefined || fileName === null) {
fileName = path.basename(inFile);
}
outDir = toDir(outDir);
inFile = new java.io.File(inFile);
var outFile = new java.io.File(outDir + '/' + fileName);
var bis = new java.io.BufferedInputStream(new java.io.FileInputStream(inFile), 4096);
var bos = new java.io.BufferedOutputStream(new java.io.FileOutputStream(outFile), 4096);
var theChar = bis.read();
while (theChar !== -1) {
bos.write(theChar);
theChar = bis.read();
}
bos.close();
bis.close();
};
exports.copyFile = asyncify(exports.copyFileSync);
exports.writeFileSync = function writeFileSync(filename, data, encoding) {
encoding = checkEncoding(encoding, 'fs.writeFile[Sync]');
var out = new java.io.PrintWriter(
new java.io.OutputStreamWriter(
new java.io.FileOutputStream(filename),
encoding
)
);
try {
out.write(data);
}
finally {
out.flush();
out.close();
}
};
exports.writeFile = asyncify(exports.writeFileSync);
exports.rmdirSync = function rmdirSync(_path) {
throw new Error('not implemented');
};
exports.rmdir = asyncify(exports.rmdirSync);
exports.unlinkSync = function unlinkSync(_path) {
throw new Error('not implemented');
};
exports.unlink = asyncify(exports.unlinkSync);

Binary file not shown.

View File

@ -1,18 +0,0 @@
/*global Packages: true */
/**
* Creates an Esprima-compatible AST using Rhino's JavaScript parser.
* @module rhino/jsdoc/src/astbuilder
*/
'use strict';
var AstBuilder = exports.AstBuilder = function() {
this._builder = new Packages.org.jsdoc.AstBuilder();
};
AstBuilder.prototype.build = function(sourceCode, sourceName) {
return this._builder.build(sourceCode, sourceName);
};
AstBuilder.prototype.getRhinoNodes = function() {
return this._builder.getRhinoNodes();
};

View File

@ -1,48 +0,0 @@
// TODO: module docs
'use strict';
// TODO: docs
exports.createParser = require('jsdoc/src/parser').createParser;
// TODO: docs
var Parser = exports.Parser = function() {
var astBuilder;
var visitor;
var runtime = require('jsdoc/util/runtime');
if ( !runtime.isRhino() ) {
throw new Error('You must run JSDoc on Mozilla Rhino to use the Rhino parser.');
}
astBuilder = new ( require(runtime.getModulePath('jsdoc/src/astbuilder')) ).AstBuilder();
visitor = new ( require(runtime.getModulePath('jsdoc/src/visitor')) ).Visitor(this);
Parser.super_.call(this, astBuilder, visitor);
};
require('util').inherits(Parser, require('jsdoc/src/parser').Parser);
// TODO: update docs
/**
* Adds a node visitor to use in parsing
*/
Parser.prototype.addNodeVisitor = function(visitor) {
this._visitor.addRhinoNodeVisitor(visitor);
};
// TODO: docs
/**
* Get the node visitors used in parsing
*/
Parser.prototype.getNodeVisitors = function() {
return this._visitor.getRhinoNodeVisitors();
};
// TODO: docs
Parser.prototype._walkAst = function(ast, visitor, sourceName) {
// On Rhino, we visit the comments all at once before we walk the AST
this._visitor.visitNodeComments({
leadingComments: ast.comments
}, this, sourceName);
Parser.super_.prototype._walkAst.call(this, ast, visitor, sourceName);
};

View File

@ -1,69 +0,0 @@
// TODO: module docs
'use strict';
// TODO: docs
var Visitor = exports.Visitor = function() {
var runtime = require('jsdoc/util/runtime');
if ( !runtime.isRhino() ) {
throw new Error('You must run JSDoc on Mozilla Rhino to use the Rhino node visitor.');
}
Visitor.super_.call(this);
// Rhino node visitors added by plugins (deprecated in JSDoc 3.3)
this._rhinoNodeVisitors = [];
// Rhino nodes retrieved from the org.jsdoc.AstBuilder instance
this._rhinoNodes = null;
// only visit nodes, not their comments--the parser visits all the comments at once
this._visitors = [
this.visitNode
];
this.addAstNodeVisitor({
visitNode: this._visitRhinoNode.bind(this)
});
};
require('util').inherits(Visitor, require('jsdoc/src/visitor').Visitor);
// TODO: docs (deprecated)
Visitor.prototype.addRhinoNodeVisitor = function(visitor) {
this._rhinoNodeVisitors.push(visitor);
};
// TODO: docs (deprecated)
Visitor.prototype.removeRhinoNodeVisitor = function(visitor) {
var idx = this._rhinoNodeVisitors.indexOf(visitor);
if (idx !== -1) {
this._rhinoNodeVisitors.splice(idx, 1);
}
};
// TODO: docs (deprecated)
Visitor.prototype.getRhinoNodeVisitors = function() {
return this._rhinoNodeVisitors;
};
// TODO: docs (deprecated)
Visitor.prototype._visitRhinoNode = function(astNode, e, parser, filename) {
var rhinoNode;
var visitors = this._rhinoNodeVisitors;
if (!visitors.length) {
return;
}
if (!this._rhinoNodes) {
this._rhinoNodes = parser.astBuilder.getRhinoNodes();
}
rhinoNode = this._rhinoNodes ? this._rhinoNodes.get(astNode.nodeId) : null;
if (rhinoNode) {
for (var i = 0, l = visitors.length; i < l; i++) {
visitors[i].visitNode(rhinoNode, e, parser, filename);
if (e.stopPropagation) {
break;
}
}
}
};

View File

@ -1,14 +0,0 @@
/*global java */
/**
* Partial Rhino implementation of Node.js' `os` module.
* @module os
* @author Jeff Williams <jeffrey.l.williams@gmail.com>
* @see http://nodejs.org/api/os.html
*/
'use strict';
exports.EOL = String( java.lang.System.getProperty('line.separator') );
exports.platform = function() {
return process.platform;
};

View File

@ -1,432 +0,0 @@
'use strict';
var isWindows = java.lang.System.getProperty("os.name").toLowerCase().contains("windows");
var fileSeparator = exports.sep = String( java.lang.System.getProperty("file.separator") );
function noOp() {}
// exported for the benefit of our `fs` shim
var asyncify = exports._asyncify = function(func) {
return function() {
var args = Array.prototype.slice.call(arguments);
var callback = args.pop();
var data;
callback = typeof callback === 'function' ? callback : noOp;
try {
data = func.apply(this, args);
process.nextTick(function() {
callback(null, data);
});
}
catch (e) {
process.nextTick(function() {
callback(e);
});
}
};
};
/**
* Returns everything on a path except for the last item
* e.g. if the path was 'path/to/something', the return value would be 'path/to'
*/
exports.dirname = function(_path) {
var f = new java.io.File(_path);
return String(f.getParent());
};
/**
* Returns the last item on a path
*/
exports.basename = function(_path, ext) {
var f = new java.io.File(_path);
var p = f.getParentFile();
var base = String(f.getName());
if (p != null) {
var idx = ext ? base.indexOf(ext) : -1;
if (idx !== -1) {
base = base.substring(0, base.length - ext.length);
}
}
return base;
};
exports.existsSync = function(_path) {
var f = new java.io.File(_path);
if (f.isDirectory()){
return true;
}
if (!f.exists()){
return false;
}
if (!f.canRead()){
return false;
}
return true;
};
exports.exists = asyncify(exports.existsSync);
//Code below taken from node
//resolves . and .. elements in a path array with directory names there
//must be no slashes, empty elements, or device names (c:\) in the array
//(so also no leading and trailing slashes - it does not distinguish
//relative and absolute paths)
function normalizeArray(parts, allowAboveRoot) {
// if the path tries to go above the root, `up` ends up > 0
var up = 0;
for ( var i = parts.length - 1; i >= 0; i--) {
var last = parts[i];
if (last == '.') {
parts.splice(i, 1);
} else if (last === '..') {
parts.splice(i, 1);
up++;
} else if (up) {
parts.splice(i, 1);
up--;
}
}
// if the path is allowed to go above the root, restore leading ..s
if (allowAboveRoot) {
for (; up--; up) {
parts.unshift('..');
}
}
return parts;
}
exports.extname = function(path) {
return splitPath(path)[3];
};
if (isWindows) {
// Regex to split a windows path into three parts: [*, device, slash,
// tail] windows-only
var splitDeviceRe =
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?([\s\S]*?)$/;
// Regex to split the tail part of the above into [*, dir, basename, ext]
var splitTailRe =
/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
// Function to split a filename into [root, dir, basename, ext]
// windows version
var splitPath = function(filename) {
// Separate device+slash from tail
var result = splitDeviceRe.exec(filename),
device = (result[1] || '') + (result[2] || ''),
tail = result[3] || '';
// Split the tail into dir, basename and extension
var result2 = splitTailRe.exec(tail),
dir = result2[1],
basename = result2[2],
ext = result2[3];
return [device, dir, basename, ext];
};
// path.resolve([from ...], to)
// windows version
exports.resolve = function() {
var resolvedDevice = '',
resolvedTail = '',
resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1; i--) {
var path;
if (i >= 0) {
path = arguments[i];
} else if (!resolvedDevice) {
path = process.cwd();
} else {
// Windows has the concept of drive-specific current working
// directories. If we've resolved a drive letter but not yet an
// absolute path, get cwd for that drive. We're sure the device is not
// an unc path at this points, because unc paths are always absolute.
path = process.env['=' + resolvedDevice];
// Verify that a drive-local cwd was found and that it actually points
// to our drive. If not, default to the drive's root.
if (!path || path.substr(0, 3).toLowerCase() !==
resolvedDevice.toLowerCase() + '\\') {
path = resolvedDevice + '\\';
}
}
// Skip empty and invalid entries
if (typeof path !== 'string' || !path) {
continue;
}
var result = splitDeviceRe.exec(path),
device = result[1] || '',
isUnc = device && device.charAt(1) !== ':',
isAbsolute = !!result[2] || isUnc, // UNC paths are always absolute
tail = result[3];
if (device &&
resolvedDevice &&
device.toLowerCase() !== resolvedDevice.toLowerCase()) {
// This path points to another device so it is not applicable
continue;
}
if (!resolvedDevice) {
resolvedDevice = device;
}
if (!resolvedAbsolute) {
resolvedTail = tail + '\\' + resolvedTail;
resolvedAbsolute = isAbsolute;
}
if (resolvedDevice && resolvedAbsolute) {
break;
}
}
// Replace slashes (in UNC share name) by backslashes
resolvedDevice = resolvedDevice.replace(/\//g, '\\');
// At this point the path should be resolved to a full absolute path,
// but handle relative paths to be safe (might happen when process.cwd()
// fails)
// Normalize the tail path
function f(p) {
return !!p;
}
resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/).filter(f),
!resolvedAbsolute).join('\\');
return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
'.';
};
// windows version
exports.normalize = function(_path) {
var result = splitDeviceRe.exec(_path),
device = result[1] || '',
isUnc = device && device.charAt(1) !== ':',
isAbsolute = !!result[2] || isUnc, // UNC paths are always absolute
tail = result[3],
trailingSlash = /[\\\/]$/.test(tail);
// Normalize the tail path
tail = normalizeArray(tail.split(/[\\\/]+/).filter(function(p) {
return !!p;
}), !isAbsolute).join('\\');
if (!tail && !isAbsolute) {
tail = '.';
}
if (tail && trailingSlash) {
tail += '\\';
}
return device + (isAbsolute ? '\\' : '') + tail;
};
//windows version
exports.join = function() {
function f(p) {
return p && typeof p === 'string';
}
var _paths = Array.prototype.slice.call(arguments, 0).filter(f);
var joined = _paths.join('\\');
// Make sure that the joined path doesn't start with two slashes
// - it will be mistaken for an unc path by normalize() -
// unless the _paths[0] also starts with two slashes
if (/^[\\\/]{2}/.test(joined) && !/^[\\\/]{2}/.test(_paths[0])) {
joined = joined.slice(1);
}
return exports.normalize(joined);
};
// path.relative(from, to)
// it will solve the relative path from 'from' to 'to', for instance:
// from = 'C:\\orandea\\test\\aaa'
// to = 'C:\\orandea\\impl\\bbb'
// The output of the function should be: '..\\..\\impl\\bbb'
// windows version
exports.relative = function(from, to) {
from = exports.resolve(from);
to = exports.resolve(to);
// windows is not case sensitive
var lowerFrom = from.toLowerCase();
var lowerTo = to.toLowerCase();
function trim(arr) {
var start = 0;
for (; start < arr.length; start++) {
if (arr[start] !== '') {
break;
}
}
var end = arr.length - 1;
for (; end >= 0; end--) {
if (arr[end] !== '') {
break;
}
}
if (start > end) {
return [];
}
return arr.slice(start, end - start + 1);
}
var toParts = trim(to.split('\\'));
var lowerFromParts = trim(lowerFrom.split('\\'));
var lowerToParts = trim(lowerTo.split('\\'));
var length = Math.min(lowerFromParts.length, lowerToParts.length);
var samePartsLength = length;
for (var i = 0; i < length; i++) {
if (lowerFromParts[i] !== lowerToParts[i]) {
samePartsLength = i;
break;
}
}
if (samePartsLength === 0) {
return to;
}
var outputParts = [];
for (i = samePartsLength; i < lowerFromParts.length; i++) {
outputParts.push('..');
}
outputParts = outputParts.concat(toParts.slice(samePartsLength));
return outputParts.join('\\');
};
} else {
// Split a filename into [root, dir, basename, ext], unix version
// 'root' is just a slash, or nothing.
var splitPathRe =
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
var splitPath = function(filename) {
return splitPathRe.exec(filename).slice(1);
};
// path.resolve([from ...], to)
// posix version
exports.resolve = function() {
var resolvedPath = '',
resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
var path = (i >= 0) ? arguments[i] : process.cwd();
// Skip empty and invalid entries
if (typeof path !== 'string' || !path) {
continue;
}
resolvedPath = path + '/' + resolvedPath;
resolvedAbsolute = path.charAt(0) === '/';
}
// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
// Normalize the path
resolvedPath = normalizeArray(resolvedPath.split('/').filter(function(p) {
return !!p;
}), !resolvedAbsolute).join('/');
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
};
// path.normalize(_path)
// posix version
exports.normalize = function(_path) {
var isAbsolute = _path.charAt(0) === '/',
trailingSlash = _path.slice(-1) === '/';
// Normalize the path
_path = normalizeArray(_path.split('/').filter(function(p) {
return !!p;
}), !isAbsolute).join('/');
if (!_path && !isAbsolute) {
_path = '.';
}
if (_path && trailingSlash) {
_path += '/';
}
return (isAbsolute ? '/' : '') + _path;
};
// posix version
exports.join = function() {
var _paths = Array.prototype.slice.call(arguments, 0);
return exports.normalize(_paths.filter(function(p, index) {
return p && typeof p === 'string';
}).join('/'));
};
// path.relative(from, to)
// posix version
exports.relative = function(from, to) {
from = exports.resolve(from).substr(1);
to = exports.resolve(to).substr(1);
function trim(arr) {
var start = 0;
for (; start < arr.length; start++) {
if (arr[start] !== '') {
break;
}
}
var end = arr.length - 1;
for (; end >= 0; end--) {
if (arr[end] !== '') {
break;
}
}
if (start > end) {
return [];
}
return arr.slice(start, end - start + 1);
}
var fromParts = trim(from.split('/'));
var toParts = trim(to.split('/'));
var length = Math.min(fromParts.length, toParts.length);
var samePartsLength = length;
for (var i = 0; i < length; i++) {
if (fromParts[i] !== toParts[i]) {
samePartsLength = i;
break;
}
}
var outputParts = [];
for (i = samePartsLength; i < fromParts.length; i++) {
outputParts.push('..');
}
outputParts = outputParts.concat(toParts.slice(samePartsLength));
return outputParts.join('/');
};
}

View File

@ -1,121 +0,0 @@
/**
* Adapted version of Node.js' `querystring` module.
* @module querystring
* @see http://nodejs.org/api/querystring.html
* @see https://github.com/joyent/node/blob/f105f2f2/lib/querystring.js
* @license MIT
*/
'use strict';
var QueryString = exports;
// If obj.hasOwnProperty has been overridden, then calling
// obj.hasOwnProperty(prop) will break.
// See: https://github.com/joyent/node/issues/1707
function hasOwnProp(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
QueryString.unescape = function(s) {
return decodeURIComponent(s);
};
QueryString.escape = function(str) {
return encodeURIComponent(str);
};
var stringifyPrimitive = function(v) {
switch (typeof v) {
case 'string':
return v;
case 'boolean':
return v ? 'true' : 'false';
case 'number':
return isFinite(v) ? v : '';
default:
return '';
}
};
QueryString.stringify = QueryString.encode = function(obj, sep, eq, name) {
sep = sep || '&';
eq = eq || '=';
if (obj === null) {
obj = undefined;
}
if (typeof obj === 'object') {
return Object.keys(obj).map(function(k) {
var ks = QueryString.escape(stringifyPrimitive(k)) + eq;
if (Array.isArray(obj[k])) {
return obj[k].map(function(v) {
return ks + QueryString.escape(stringifyPrimitive(v));
}).join(sep);
} else {
return ks + QueryString.escape(stringifyPrimitive(obj[k]));
}
}).join(sep);
}
if (!name) {
return '';
}
return QueryString.escape(stringifyPrimitive(name)) + eq +
QueryString.escape(stringifyPrimitive(obj));
};
// Parse a key=val string.
QueryString.parse = QueryString.decode = function(qs, sep, eq, options) {
sep = sep || '&';
eq = eq || '=';
var obj = {};
if (typeof qs !== 'string' || qs.length === 0) {
return obj;
}
var regexp = /\+/g;
qs = qs.split(sep);
var maxKeys = 1000;
if (options && typeof options.maxKeys === 'number') {
maxKeys = options.maxKeys;
}
var len = qs.length;
// maxKeys <= 0 means that we should not limit keys count
if (maxKeys > 0 && len > maxKeys) {
len = maxKeys;
}
for (var i = 0; i < len; ++i) {
var x = qs[i].replace(regexp, '%20'),
idx = x.indexOf(eq),
kstr, vstr, k, v;
if (idx >= 0) {
kstr = x.substr(0, idx);
vstr = x.substr(idx + 1);
} else {
kstr = x;
vstr = '';
}
k = QueryString.unescape(kstr);
v = QueryString.unescape(vstr);
if (!hasOwnProp(obj, k)) {
obj[k] = v;
} else if (Array.isArray(obj[k])) {
obj[k].push(v);
} else {
obj[k] = [obj[k], v];
}
}
return obj;
};

View File

@ -1,191 +0,0 @@
/*global java, Packages, version */
/*eslint-disable strict */
/**
* @overview A minimal emulation of the standard features of Node.js necessary
* to get JSDoc to run.
*/
// Set the JS version that the Rhino interpreter will use.
version(180);
/**
* Emulate DOM timeout/interval functions.
* @see https://developer.mozilla.org/en-US/docs/DOM/window#Methods
*/
(function() {
'use strict';
var timerPool = new java.util.concurrent.ScheduledThreadPoolExecutor(1);
var timers = {};
var timerCount = 1;
var timerUnits = java.util.concurrent.TimeUnit.MILLISECONDS;
var queue = {};
var queueActive = false;
function getCallback(fn) {
return new java.lang.Runnable({
run: Packages.org.mozilla.javascript.Context.call(fn)
});
}
global.setTimeout = function setTimeout(fn, delay) {
var timerId = timerCount++;
var callback = getCallback(fn);
timers[timerId] = timerPool.schedule(callback, delay, timerUnits);
return timerId;
};
global.clearTimeout = function clearTimeout(timerId) {
if (timers[timerId]) {
timerPool.remove(timers[timerId]);
delete timers[timerId];
}
};
global.setInterval = function setInterval(fn, delay) {
var timerId = timerCount++;
var callback = getCallback(fn);
timers[timerId] = timerPool.scheduleAtFixedRate(callback, delay, delay, timerUnits);
return timerId;
};
global.clearInterval = global.clearTimeout;
// adapted from https://github.com/alexgorbatchev/node-browser-builtins
// MIT license
global.setImmediate = (function() {
function drain() {
var key;
var keys = Object.keys(queue);
queueActive = false;
for (var i = 0, l = keys.length; i < l; i++) {
key = keys[i];
var fn = queue[key];
delete queue[key];
fn();
}
}
return function setImmediate(fn) {
var timerId = timerCount++;
queue[timerId] = fn;
if (!queueActive) {
queueActive = true;
global.setTimeout(drain, 0);
}
return timerId;
};
})();
global.clearImmediate = function clearImmediate(id) {
delete queue[id];
};
})();
/**
* Emulate Node.js console functions.
* @see http://nodejs.org/api/stdio.html
*/
global.console = (function() {
function println(stream, args) {
java.lang.System[stream].println( require('util').format.apply(this, args) );
}
return {
error: function error() {
println('err', arguments);
},
info: function info() {
println('out', arguments);
},
log: function log() {
println('out', arguments);
},
trace: function trace(label) {
// this puts some extra junk at the top of the stack trace, but it's close enough
var e = new java.lang.Exception(label || 'Trace');
e.printStackTrace();
},
warn: function warn() {
println('err', arguments);
}
};
})();
/**
* Emulate Node.js process functions.
* @see http://nodejs.org/api/process.html
*/
global.process = {
// not quite right, but close enough
argv: ['java', 'jsdoc.js']
.concat( Array.prototype.slice.call(arguments, 0) ),
// this depends on a hack in our version of Rhino
cwd: function cwd() {
var f = new java.io.File( java.lang.System.getProperty('user.dir') );
return String( f.getAbsolutePath() );
},
env: (function() {
var javaEnv = java.lang.System.getenv();
var key;
var keys = javaEnv.keySet().toArray();
var result = {};
for (var i = 0, l = keys.length; i < l; i++) {
key = keys[i];
result[key + ''] = javaEnv.get(key) + '';
}
return result;
})(),
exit: function exit(n) {
n = n || 0;
java.lang.System.exit(n);
},
nextTick: function nextTick(callback) {
setTimeout(callback, 0);
},
platform: (function() {
if ( String(java.lang.System.getProperty('os.name')).match(/^[Ww]in/) ) {
return 'win32';
}
else {
// not necessarily accurate, but good enough
return 'linux';
}
})(),
stderr: {
// Java can't reliably find the terminal width across platforms, so we hard-code a
// reasonable value
columns: 80,
write: function write(str) {
java.lang.System.err.print(str);
}
},
stdout: {
// Java can't reliably find the terminal width across platforms, so we hard-code a
// reasonable value
columns: 80,
write: function write(str) {
java.lang.System.out.print(str);
}
}
};
/**
* Emulate other Node.js globals.
* @see http://nodejs.org/docs/latest/api/globals.html
*/
Object.defineProperties(global, {
'__dirname': {
get: function() {
return global.process.cwd();
},
enumerable: true
}
});

View File

@ -1,532 +0,0 @@
/**
* Adapted version of Node.js' `util` module.
* @module util
* @see http://nodejs.org/api/util.html
* @see https://github.com/joyent/node/blob/85090734/lib/util.js
* @license MIT
*/
function hasOwnProp(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
// placate JSHint
var stylizeNoColor, stylizeWithColor, formatValue, formatPrimitive;
/**
* Echoes the value of a value. Trys to print the value out
* in the best way possible given the different types.
*
* @param {Object} obj The object to print out.
* @param {Object} opts Optional options object that alters the output.
*/
/* legacy: obj, showHidden, depth, colors*/
function inspect(obj, opts) {
// default options
var ctx = {
seen: [],
stylize: stylizeNoColor
};
// legacy...
if (arguments.length >= 3) {
ctx.depth = arguments[2];
}
if (arguments.length >= 4) {
ctx.colors = arguments[3];
}
if (typeof opts === 'boolean') {
// legacy...
ctx.showHidden = opts;
} else if (opts) {
// got an "options" object
exports._extend(ctx, opts);
}
// set default options
if (typeof ctx.showHidden === 'undefined') {
ctx.showHidden = false;
}
if (typeof ctx.depth === 'undefined') {
ctx.depth = 2;
}
if (typeof ctx.colors === 'undefined') {
ctx.colors = false;
}
if (typeof ctx.customInspect === 'undefined') {
ctx.customInspect = true;
}
if (ctx.colors) {
ctx.stylize = stylizeWithColor;
}
return formatValue(ctx, obj, ctx.depth);
}
exports.inspect = inspect;
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
inspect.colors = {
'bold' : [1, 22],
'italic' : [3, 23],
'underline' : [4, 24],
'inverse' : [7, 27],
'white' : [37, 39],
'grey' : [90, 39],
'black' : [30, 39],
'blue' : [34, 39],
'cyan' : [36, 39],
'green' : [32, 39],
'magenta' : [35, 39],
'red' : [31, 39],
'yellow' : [33, 39]
};
// Don't use 'blue' not visible on cmd.exe
inspect.styles = {
'special': 'cyan',
'number': 'yellow',
'boolean': 'yellow',
'undefined': 'grey',
'null': 'bold',
'string': 'green',
'date': 'magenta',
// "name": intentionally not styling
'regexp': 'red'
};
stylizeWithColor = function(str, styleType) {
var style = inspect.styles[styleType];
if (style) {
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
'\u001b[' + inspect.colors[style][1] + 'm';
} else {
return str;
}
};
stylizeNoColor = function(str, styleType) {
return str;
};
var formatRegExp = /%[sdj%]/g;
exports.format = function(f) {
var i, len;
if (typeof f !== 'string') {
var objects = [];
for (i = 0, len = arguments.length; i < len; i++) {
objects.push(inspect(arguments[i]));
}
return objects.join(' ');
}
i = 1;
var args = arguments;
len = args.length;
var str = String(f).replace(formatRegExp, function(x) {
if (x === '%%') {
return '%';
}
if (i >= len) {
return x;
}
switch (x) {
case '%s': return String(args[i++]);
case '%d': return Number(args[i++]);
case '%j': return require('jsdoc/util/dumper').dump(args[i++]);
default:
return x;
}
});
for (var x = args[i]; i < len; x = args[++i]) {
if (x === null || typeof x !== 'object') {
str += ' ' + x;
} else {
str += ' ' + inspect(x);
}
}
return str;
};
// Mark that a method should not be used.
// Returns a modified function which warns once by default.
// If --no-deprecation is set, then it is a no-op.
exports.deprecate = function(fn, msg) {
if (process.noDeprecation === true) {
return fn;
}
var warned = false;
function deprecated() {
if (!warned) {
if (process.traceDeprecation) {
console.trace(msg);
} else {
console.error(msg);
}
warned = true;
}
return fn.apply(this, arguments);
}
return deprecated;
};
exports.print = function() {
var args = Array.prototype.slice.call(arguments, 0);
for (var i = 0, len = args.length; i < len; ++i) {
process.stdout.write(String(args[i]));
}
};
exports.puts = function() {
var args = Array.prototype.slice.call(arguments, 0);
for (var i = 0, len = args.length; i < len; ++i) {
process.stdout.write(args[i] + '\n');
}
};
exports.debug = function(x) {
process.stderr.write('DEBUG: ' + x + '\n');
};
var error = exports.error = function(x) {
var args = Array.prototype.slice.call(arguments, 0);
for (var i = 0, len = args.length; i < len; ++i) {
process.stderr.write(args[i] + '\n');
}
};
function arrayToHash(array) {
var hash = {};
array.forEach(function(val, idx) {
hash[val] = true;
});
return hash;
}
function formatError(value) {
return '[' + Error.prototype.toString.call(value) + ']';
}
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
var name, str, desc;
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
if (desc.get) {
if (desc.set) {
str = ctx.stylize('[Getter/Setter]', 'special');
} else {
str = ctx.stylize('[Getter]', 'special');
}
} else {
if (desc.set) {
str = ctx.stylize('[Setter]', 'special');
}
}
if (!hasOwnProp(visibleKeys, key)) {
name = '[' + key + ']';
}
if (!str) {
if (ctx.seen.indexOf(desc.value) < 0) {
if (recurseTimes === null) {
str = formatValue(ctx, desc.value, null);
} else {
str = formatValue(ctx, desc.value, recurseTimes - 1);
}
if (str.indexOf('\n') > -1) {
if (array) {
str = str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n').substr(2);
} else {
str = '\n' + str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n');
}
}
} else {
str = ctx.stylize('[Circular]', 'special');
}
}
if (typeof name === 'undefined') {
if (array && key.match(/^\d+$/)) {
return str;
}
name = JSON.stringify('' + key);
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
name = name.substr(1, name.length - 2);
name = ctx.stylize(name, 'name');
} else {
name = name.replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'");
name = ctx.stylize(name, 'string');
}
}
return name + ': ' + str;
}
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
var output = [];
for (var i = 0, l = value.length; i < l; ++i) {
if (hasOwnProp(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
} else {
output.push('');
}
}
keys.forEach(function(key) {
if (!key.match(/^\d+$/)) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, true));
}
});
return output;
}
function reduceToSingleString(output, base, braces) {
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if (cur.indexOf('\n') >= 0) {
numLinesEst++;
}
return prev + cur.length + 1;
}, 0);
if (length > 60) {
return braces[0] +
(base === '' ? '' : base + '\n ') +
' ' +
output.join(',\n ') +
' ' +
braces[1];
}
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
}
function objectToString(o) {
return Object.prototype.toString.call(o);
}
// NOTE: These type checking functions intentionally don't use `instanceof`
// because it is fragile and can be easily faked with `Object.create()`.
function isArray(ar) {
return Array.isArray(ar) ||
(typeof ar === 'object' && objectToString(ar) === '[object Array]');
}
exports.isArray = isArray;
function isRegExp(re) {
return typeof re === 'object' && objectToString(re) === '[object RegExp]';
}
exports.isRegExp = isRegExp;
function isDate(d) {
return typeof d === 'object' && objectToString(d) === '[object Date]';
}
exports.isDate = isDate;
function isError(e) {
return typeof e === 'object' && objectToString(e) === '[object Error]';
}
exports.isError = isError;
formatValue = function(ctx, value, recurseTimes) {
// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it
if (ctx.customInspect && value && typeof value.inspect === 'function' &&
// Filter out the util module, it's inspect function is special
value.inspect !== exports.inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
return String(value.inspect(recurseTimes));
}
// Primitive types cannot have properties
var primitive = formatPrimitive(ctx, value);
if (primitive) {
return primitive;
}
// Look up the keys of the object.
var keys = Object.keys(value);
var visibleKeys = arrayToHash(keys);
if (ctx.showHidden) {
keys = Object.getOwnPropertyNames(value);
}
// Some type of object without properties can be shortcutted.
if (keys.length === 0) {
if (typeof value === 'function') {
var name = value.name ? ': ' + value.name : '';
return ctx.stylize('[Function' + name + ']', 'special');
}
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
}
if (isDate(value)) {
return ctx.stylize(Date.prototype.toString.call(value), 'date');
}
if (isError(value)) {
return formatError(value);
}
}
var base = '', array = false, braces = ['{', '}'];
// Make Array say that they are Array
if (isArray(value)) {
array = true;
braces = ['[', ']'];
}
// Make functions say that they are functions
if (typeof value === 'function') {
var n = value.name ? ': ' + value.name : '';
base = ' [Function' + n + ']';
}
// Make RegExps say that they are RegExps
if (isRegExp(value)) {
base = ' ' + RegExp.prototype.toString.call(value);
}
// Make dates with properties first say the date
if (isDate(value)) {
base = ' ' + Date.prototype.toUTCString.call(value);
}
// Make error with message first say the error
if (isError(value)) {
base = ' ' + formatError(value);
}
if (keys.length === 0 && (!array || value.length === 0)) {
return braces[0] + base + braces[1];
}
if (recurseTimes < 0) {
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
} else {
return ctx.stylize('[Object]', 'special');
}
}
ctx.seen.push(value);
var output;
if (array) {
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
} else {
output = keys.map(function(key) {
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
});
}
ctx.seen.pop();
return reduceToSingleString(output, base, braces);
};
formatPrimitive = function(ctx, value) {
switch (typeof value) {
case 'undefined':
return ctx.stylize('undefined', 'undefined');
case 'string':
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
.replace(/'/g, "\\'")
.replace(/\\"/g, '"') + '\'';
return ctx.stylize(simple, 'string');
case 'number':
return ctx.stylize('' + value, 'number');
case 'boolean':
return ctx.stylize('' + value, 'boolean');
}
// For some reason typeof null is "object", so special case here.
if (value === null) {
return ctx.stylize('null', 'null');
}
};
exports.p = exports.deprecate(function() {
var args = Array.prototype.slice.call(arguments, 0);
for (var i = 0, len = args.length; i < len; ++i) {
error(exports.inspect(args[i]));
}
}, 'util.p: Use console.error() instead.');
function pad(n) {
return n < 10 ? '0' + n.toString(10) : n.toString(10);
}
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec'];
// 26 Feb 16:19:34
function timestamp() {
var d = new Date();
var time = [pad(d.getHours()),
pad(d.getMinutes()),
pad(d.getSeconds())].join(':');
return [d.getDate(), months[d.getMonth()], time].join(' ');
}
exports.log = function(msg) {
exports.puts(timestamp() + ' - ' + msg.toString());
};
exports.exec = function() {
throw new Error('util.exec() is not implemented on Rhino (and was deprecated in Node.js 0.2)');
};
exports.pump = function() {
throw new Error('util.pump() is not implemented on Rhino (and was deprecated in Node.js 0.8');
};
/**
* Inherit the prototype methods from one constructor into another.
*
* The Function.prototype.inherits from lang.js rewritten as a standalone
* function (not on Function.prototype). NOTE: If this file is to be loaded
* during bootstrapping this function needs to be rewritten using some native
* functions as prototype setup using normal JavaScript does not work as
* expected during bootstrapping (see mirror.js in r114903).
*
* @param {function} ctor Constructor function which needs to inherit the
* prototype.
* @param {function} superCtor Constructor function to inherit prototype from.
*/
exports.inherits = function(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
exports._extend = function(origin, add) {
// Don't do anything if add isn't an object
if (!add || typeof add !== 'object') {
return origin;
}
var keys = Object.keys(add);
var i = keys.length;
while (i--) {
origin[keys[i]] = add[keys[i]];
}
return origin;
};

View File

@ -13,12 +13,6 @@ Or on OS X, Linux, and other POSIX-compliant platforms:
./jsdoc -T
If you can't get the short-form commands to work, try invoking Java directly:
java -cp lib/js.jar org.mozilla.javascript.tools.shell.Main \
-modules node_modules -modules rhino -modules lib -modules . \
jsdoc.js -T
Writing Tests
-------------

View File

@ -40,9 +40,9 @@ jasmine.getParseResults = function() {
return parseResults;
};
// use the requested parser, or default to the pure JS parser (on Node.js) or Rhino (on Rhino)
// use the requested parser, or default to the pure JS parser (on Node.js)
jasmine.jsParser = (function() {
var parser = jsdoc.util.runtime.isRhino() ? 'rhino' : 'js';
var parser = 'js';
if (jsdoc.env.opts.query && jsdoc.env.opts.query.parser) {
parser = jsdoc.env.opts.query.parser;

View File

@ -43,7 +43,7 @@ function addSpec(file, target) {
function isValidSpec(file, matcher) {
var result;
var skipPath = runtime.isRhino() ? runtime.NODE : runtime.RHINO;
var skipPath = runtime.NODE;
// valid specs must...
try {

View File

@ -1,24 +1,22 @@
'use strict';
if (jasmine.jsParser !== 'rhino') {
describe('arrow functions', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/arrowfunction.js');
var increment = docSet.getByLongname('increment')[0];
var print = docSet.getByLongname('print')[0];
describe('arrow functions', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/arrowfunction.js');
var increment = docSet.getByLongname('increment')[0];
var print = docSet.getByLongname('print')[0];
it('should use the correct name and longname', function() {
expect(increment).toBeDefined();
expect(increment.name).toBe('increment');
});
it('should allow function parameters to be documented', function() {
expect(increment.params.length).toBe(1);
expect(increment.params[0].name).toBe('n');
});
it('should support inline comments on parameters', function() {
expect(print.params.length).toBe(1);
expect(print.params[0].type.names[0]).toBe('*');
});
it('should use the correct name and longname', function() {
expect(increment).toBeDefined();
expect(increment.name).toBe('increment');
});
}
it('should allow function parameters to be documented', function() {
expect(increment.params.length).toBe(1);
expect(increment.params[0].name).toBe('n');
});
it('should support inline comments on parameters', function() {
expect(print.params.length).toBe(1);
expect(print.params[0].type.names[0]).toBe('*');
});
});

View File

@ -8,14 +8,12 @@ describe('const declarations', function() {
expect(myPocket.kind).toBe('constant');
});
if (jasmine.jsParser !== 'rhino') {
describe('ES 2015 only', function() {
it('should not override kind="class" when a const is autodetected', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/constanttag2.js');
var foo = docSet.getByLongname('Foo')[0];
describe('ES 2015 only', function() {
it('should not override kind="class" when a const is autodetected', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/constanttag2.js');
var foo = docSet.getByLongname('Foo')[0];
expect(foo.kind).toBe('class');
});
expect(foo.kind).toBe('class');
});
}
});
});

View File

@ -1,55 +1,52 @@
'use strict';
// Rhino can't handle default parameters
if (jasmine.jsParser !== 'rhino') {
describe('default parameters', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/defaultparams.js');
describe('default parameters', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/defaultparams.js');
var setActive = docSet.getByLongname('setActive')[0];
var setBirthYear = docSet.getByLongname('setBirthYear')[0];
var setDogName = docSet.getByLongname('setDogName')[0];
var setFirstName = docSet.getByLongname('setFirstName')[0];
var setLastName = docSet.getByLongname('setLastName')[0];
var setManager = docSet.getByLongname('setManager')[0];
var setName = docSet.getByLongname('setName')[0];
var setPizzaToppings = docSet.getByLongname('setPizzaToppings')[0];
var setActive = docSet.getByLongname('setActive')[0];
var setBirthYear = docSet.getByLongname('setBirthYear')[0];
var setDogName = docSet.getByLongname('setDogName')[0];
var setFirstName = docSet.getByLongname('setFirstName')[0];
var setLastName = docSet.getByLongname('setLastName')[0];
var setManager = docSet.getByLongname('setManager')[0];
var setName = docSet.getByLongname('setName')[0];
var setPizzaToppings = docSet.getByLongname('setPizzaToppings')[0];
it('should automatically add string-literal values as defaults when no default value is documented', function() {
expect(setFirstName.params[0].defaultvalue).toBe('Buster');
});
it('should not automatically mark parameters with default values as optional', function() {
expect(setFirstName.params[0].optional).toBeUndefined();
});
it('should not automatically mark parameters with default values as nullable', function() {
expect(setFirstName.params[0].nullable).toBeUndefined();
});
it('should not override documented default values', function() {
expect(setLastName.params[0].defaultvalue).toBe('Braun');
});
it('should work when some parameters have default values and others do not', function() {
expect(setName.params[0].defaultvalue).toBeUndefined();
expect(setName.params[1].defaultvalue).toBe('Bluster');
expect(setName.params[2].defaultvalue).toBe('Brown');
});
it('should ignore empty strings', function() {
expect(setDogName.params[0].defaultvalue).toBeUndefined();
});
it('should work with boolean literals', function() {
expect(setActive.params[0].defaultvalue).toBe(true);
});
it('should work with numeric literals', function() {
expect(setBirthYear.params[0].defaultvalue).toBe(3000);
});
it('should ignore non-literal default values, such as variable identifiers', function() {
expect(setPizzaToppings.params[0].defaultvalue).toBeUndefined();
});
it('should automatically add string-literal values as defaults when no default value is documented', function() {
expect(setFirstName.params[0].defaultvalue).toBe('Buster');
});
}
it('should not automatically mark parameters with default values as optional', function() {
expect(setFirstName.params[0].optional).toBeUndefined();
});
it('should not automatically mark parameters with default values as nullable', function() {
expect(setFirstName.params[0].nullable).toBeUndefined();
});
it('should not override documented default values', function() {
expect(setLastName.params[0].defaultvalue).toBe('Braun');
});
it('should work when some parameters have default values and others do not', function() {
expect(setName.params[0].defaultvalue).toBeUndefined();
expect(setName.params[1].defaultvalue).toBe('Bluster');
expect(setName.params[2].defaultvalue).toBe('Brown');
});
it('should ignore empty strings', function() {
expect(setDogName.params[0].defaultvalue).toBeUndefined();
});
it('should work with boolean literals', function() {
expect(setActive.params[0].defaultvalue).toBe(true);
});
it('should work with numeric literals', function() {
expect(setBirthYear.params[0].defaultvalue).toBe(3000);
});
it('should ignore non-literal default values, such as variable identifiers', function() {
expect(setPizzaToppings.params[0].defaultvalue).toBeUndefined();
});
});

View File

@ -31,29 +31,27 @@ describe('When a getter or setter is part of a class', function() {
});
});
if (jasmine.jsParser !== 'rhino') {
describe('in an ES 2015 class', function() {
var docSet2 = jasmine.getDocSetFromFile('test/fixtures/getset2.js');
var location = docSet2.getByLongname('Employee#location');
describe('in an ES 2015 class', function() {
var docSet2 = jasmine.getDocSetFromFile('test/fixtures/getset2.js');
var location = docSet2.getByLongname('Employee#location');
it('should have a doclet with the correct longname', function() {
expect(location.length).toBe(2);
});
it('should have a doclet with the correct name', function() {
expect(location[0].name).toBe('location');
expect(location[1].name).toBe('location');
});
it('should have a doclet with the correct kind', function() {
expect(location[0].kind).toBe('member');
expect(location[1].kind).toBe('member');
});
it('should have a doclet with the correct memberof', function() {
expect(location[0].memberof).toBe('Employee');
expect(location[1].memberof).toBe('Employee');
});
it('should have a doclet with the correct longname', function() {
expect(location.length).toBe(2);
});
}
it('should have a doclet with the correct name', function() {
expect(location[0].name).toBe('location');
expect(location[1].name).toBe('location');
});
it('should have a doclet with the correct kind', function() {
expect(location[0].kind).toBe('member');
expect(location[1].kind).toBe('member');
});
it('should have a doclet with the correct memberof', function() {
expect(location[0].memberof).toBe('Employee');
expect(location[1].memberof).toBe('Employee');
});
});
});

View File

@ -1,17 +1,15 @@
'use strict';
if (jasmine.jsParser !== 'rhino') {
describe('JSX support', function() {
it('should parse JSX files without errors', function() {
var logger = require('jsdoc/util/logger');
describe('JSX support', function() {
it('should parse JSX files without errors', function() {
var logger = require('jsdoc/util/logger');
function parseJsx() {
return jasmine.getDocSetFromFile('test/fixtures/jsx.js');
}
function parseJsx() {
return jasmine.getDocSetFromFile('test/fixtures/jsx.js');
}
spyOn(logger, 'error');
expect(parseJsx).not.toThrow();
expect(logger.error).not.toHaveBeenCalled();
});
spyOn(logger, 'error');
expect(parseJsx).not.toThrow();
expect(logger.error).not.toHaveBeenCalled();
});
}
});

View File

@ -1,19 +1,17 @@
'use strict';
if (jasmine.jsParser !== 'rhino') {
describe('method definition inside a class declaration', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/methoddefinition.js');
var runMethod = docSet.getByLongname('Test#run')[0];
var staticRunMethod = docSet.getByLongname('Test.run')[0];
describe('method definition inside a class declaration', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/methoddefinition.js');
var runMethod = docSet.getByLongname('Test#run')[0];
var staticRunMethod = docSet.getByLongname('Test.run')[0];
it('methods should have documentation comments', function() {
expect(runMethod).toBeDefined();
expect(runMethod.description).toBe('Document me.');
expect(runMethod.kind).toBe('function');
it('methods should have documentation comments', function() {
expect(runMethod).toBeDefined();
expect(runMethod.description).toBe('Document me.');
expect(runMethod.kind).toBe('function');
expect(staticRunMethod).toBeDefined();
expect(staticRunMethod.description).toBe('Static document me.');
expect(staticRunMethod.kind).toBe('function');
});
expect(staticRunMethod).toBeDefined();
expect(staticRunMethod.description).toBe('Static document me.');
expect(staticRunMethod.kind).toBe('function');
});
}
});

View File

@ -1,24 +1,21 @@
'use strict';
// Rhino can't handle rest parameters
if (jasmine.jsParser !== 'rhino') {
describe('rest parameters', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/restparams.js');
var setAdmins = docSet.getByLongname('setAdmins')[0];
var setWidgetAccess = docSet.getByLongname('setWidgetAccess')[0];
describe('rest parameters', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/restparams.js');
var setAdmins = docSet.getByLongname('setAdmins')[0];
var setWidgetAccess = docSet.getByLongname('setWidgetAccess')[0];
it('should automatically mark standalone rest parameters as repeatable', function() {
var restParam = setAdmins.params[0];
it('should automatically mark standalone rest parameters as repeatable', function() {
var restParam = setAdmins.params[0];
expect(restParam.name).toBe('users');
expect(restParam.variable).toBe(true);
});
it('should automatically mark rest parameters as repeatable when they are mixed with other params', function() {
var restParam = setWidgetAccess.params[1];
expect(restParam.name).toBe('users');
expect(restParam.variable).toBe(true);
});
expect(restParam.name).toBe('users');
expect(restParam.variable).toBe(true);
});
}
it('should automatically mark rest parameters as repeatable when they are mixed with other params', function() {
var restParam = setWidgetAccess.params[1];
expect(restParam.name).toBe('users');
expect(restParam.variable).toBe(true);
});
});

View File

@ -31,7 +31,6 @@ describe('jsdoc/src/parser', function() {
describe('createParser', function() {
it('should return a Parser when called without arguments', function() {
// we don't check instanceof because we get different objects on Node.js and Rhino
expect(typeof jsdoc.src.parser.createParser()).toBe('object');
});
@ -41,15 +40,6 @@ describe('jsdoc/src/parser', function() {
expect(parser instanceof jsdoc.src.parser.Parser).toBe(true);
});
if (jsdoc.util.runtime.isRhino()) {
it('should create a Rhino parser with the argument "rhino"', function() {
var RhinoParser = require('rhino/jsdoc/src/parser').Parser;
var parser = jsdoc.src.parser.createParser('rhino');
expect(parser instanceof RhinoParser).toBe(true);
});
}
it('should log a fatal error on bad input', function() {
var parser;
@ -303,18 +293,15 @@ describe('jsdoc/src/parser', function() {
expect(spy.mostRecentCall.args[0].doclets).toBe(doclets);
});
// Rhino can't parse ES6
if (jasmine.jsParser !== 'rhino') {
it('should not throw errors when parsing files with ES6 syntax', function() {
function parse() {
var parserSrc = 'javascript:' + fs.readFileSync(
path.join(jsdoc.env.dirname, 'test/fixtures/es6.js'), 'utf8');
parser.parse(parserSrc);
}
it('should not throw errors when parsing files with ES6 syntax', function() {
function parse() {
var parserSrc = 'javascript:' + fs.readFileSync(
path.join(jsdoc.env.dirname, 'test/fixtures/es6.js'), 'utf8');
parser.parse(parserSrc);
}
expect(parse).not.toThrow();
});
}
expect(parse).not.toThrow();
});
it('should be able to parse its own source file', function() {
var parserSrc = 'javascript:' + fs.readFileSync(path.join(jsdoc.env.dirname,
@ -408,43 +395,14 @@ describe('jsdoc/src/parser', function() {
}
}
// Rhino fires events in a different order
if (jasmine.jsParser === 'rhino') {
it('should fire all jsdocCommentFound events, in source order, ' +
'then all symbolFound events, in source order', function() {
parser.on('jsdocCommentFound', pushEvent);
parser.on('symbolFound', pushEvent);
jsdoc.src.handlers.attachTo(parser);
parser.parse('javascript:' + source);
// make sure jsdocCommentFound events are in the correct order
events.jsdocCommentFound.slice(0).sort(sourceOrderSort)
.forEach(function(e, i) {
expect(e).toBe(events.jsdocCommentFound[i]);
});
// make sure symbolFound events are in the correct order
events.symbolFound.slice(0).sort(sourceOrderSort).forEach(function(e, i) {
expect(e).toBe(events.symbolFound[i]);
});
// make sure jsdocCommentFound events are all first
events.all.slice(0, events.jsdocCommentFound.length)
.forEach(function(e, i) {
expect(e).toBe(events.all[i]);
});
it('should fire interleaved jsdocCommentFound and symbolFound events, ' +
'in source order', function() {
jsdoc.src.handlers.attachTo(parser);
parser.parse(source);
events.all.slice(0).sort(sourceOrderSort).forEach(function(e, i) {
expect(e).toBe(events.all[i]);
});
}
else {
it('should fire interleaved jsdocCommentFound and symbolFound events, ' +
'in source order', function() {
jsdoc.src.handlers.attachTo(parser);
parser.parse(source);
events.all.slice(0).sort(sourceOrderSort).forEach(function(e, i) {
expect(e).toBe(events.all[i]);
});
});
}
});
});
});

View File

@ -2,7 +2,6 @@
describe('jsdoc/util/runtime', function() {
var runtime = require('jsdoc/util/runtime');
var isRhino;
var isNode;
it('should exist', function() {
@ -10,54 +9,21 @@ describe('jsdoc/util/runtime', function() {
expect(typeof runtime).toEqual('object');
});
it("should export a 'RHINO' constant", function() {
expect(runtime.RHINO).toBeDefined();
expect(typeof runtime.RHINO).toEqual('string');
});
it("should export a 'NODE' constant", function() {
expect(runtime.NODE).toBeDefined();
expect(typeof runtime.NODE).toEqual('string');
});
it("should export an 'isRhino' function", function() {
expect(runtime.isRhino).toBeDefined();
expect(typeof runtime.isRhino).toEqual('function');
});
it("should export an 'isNode' function", function() {
expect(runtime.isNode).toBeDefined();
expect(typeof runtime.isNode).toEqual('function');
});
describe('isRhino', function() {
isRhino = runtime.isRhino();
it('should return a boolean', function() {
expect(typeof isRhino).toEqual('boolean');
});
it('should return the opposite value from isNode()', function() {
if (isNode === undefined) {
isNode = runtime.isNode();
}
expect(!isRhino).toBe(isNode);
});
});
describe('isNode', function() {
isNode = runtime.isNode();
it('should return a boolean', function() {
expect(typeof isNode).toEqual('boolean');
});
it('should return the opposite value from isRhino()', function() {
if (isRhino === undefined) {
isRhino = runtime.isRhino();
}
expect(!isNode).toBe(isRhino);
});
});
});

View File

@ -1,5 +0,0 @@
'use strict';
xdescribe('rhino/fs', function() {
// TODO
});

View File

@ -1,5 +0,0 @@
'use strict';
xdescribe('rhino/os', function() {
// TODO
});

View File

@ -1,36 +0,0 @@
'use strict';
describe('rhino/path', function() {
// TODO: more tests
var path = require('path');
var pathChunks = [
'foo',
'bar',
'baz',
'qux.html'
];
var joinedPath = path.join.apply(this, pathChunks);
describe('basename', function() {
it('should exist', function() {
expect(path.basename).toBeDefined();
});
it('should be a function', function() {
expect(typeof path.basename).toBe('function');
});
it('should work correctly without an "ext" parameter', function() {
expect( path.basename(joinedPath) ).toBe( pathChunks[pathChunks.length - 1] );
});
it('should work correctly with an "ext" parameter', function() {
var fn = pathChunks[pathChunks.length - 1];
var ext = Array.prototype.slice.call( fn, fn.indexOf('.') ).join('');
var bn = Array.prototype.slice.call( fn, 0, fn.indexOf('.') ).join('');
expect( path.basename(joinedPath, ext) ).toBe(bn);
});
});
});

View File

@ -1,185 +0,0 @@
'use strict';
describe('rhino/jsdoc/src/parser', function() {
var jsdoc = {
src: {
parser: (function() {
var runtime = require('jsdoc/util/runtime');
return require( runtime.getModulePath('jsdoc/src/parser') );
})()
}
};
// don't run this spec if we're currently testing another parser
if (jasmine.jsParser !== 'rhino') {
return;
}
it('should exist', function() {
expect(jsdoc.src.parser).toBeDefined();
expect(typeof jsdoc.src.parser).toBe('object');
});
it('should export a "Parser" constructor', function() {
expect(jsdoc.src.parser.Parser).toBeDefined();
expect(typeof jsdoc.src.parser.Parser).toBe('function');
});
describe('Parser', function() {
var parser;
function newParser() {
parser = jsdoc.src.parser.createParser('rhino');
}
newParser();
it('should inherit from jsdoc/src/parser', function() {
var parent = require('jsdoc/src/parser').Parser;
expect(parser instanceof parent).toBe(true);
});
it('should have an "addNodeVisitor" method', function() {
expect(parser.addNodeVisitor).toBeDefined();
expect(typeof parser.addNodeVisitor).toBe('function');
});
it('should have a "getNodeVisitors" method', function() {
expect(parser.getNodeVisitors).toBeDefined();
expect(typeof parser.getNodeVisitors).toBe('function');
});
describe('addNodeVisitor', function() {
function visitorA() {}
function visitorB() {}
var visitors;
beforeEach(newParser);
it('should work with a single Rhino node visitor', function() {
parser.addNodeVisitor(visitorA);
visitors = parser.getNodeVisitors();
expect(visitors.length).toBe(1);
expect(visitors[0]).toBe(visitorA);
});
it('should work with multiple Rhino node visitors', function() {
parser.addNodeVisitor(visitorA);
parser.addNodeVisitor(visitorB);
visitors = parser.getNodeVisitors();
expect(visitors.length).toBe(2);
expect(visitors[0]).toBe(visitorA);
expect(visitors[1]).toBe(visitorB);
});
});
describe('getNodeVisitors', function() {
beforeEach(newParser);
it('should return an empty array by default', function() {
var visitors = parser.getNodeVisitors();
expect( Array.isArray(visitors) ).toBe(true);
expect(visitors.length).toBe(0);
});
// other functionality is covered by the addNodeVisitors tests
});
describe('parse', function() {
/*eslint no-script-url: 0 */
beforeEach(newParser);
var sourceCode = ['javascript:/** foo */var foo;'];
it('should call Rhino node visitors', function() {
var args;
var visitor = {
visitNode: function(rhinoNode, e, visitParser, sourceName) {
if (e && e.code && !args) {
args = Array.prototype.slice.call(arguments);
}
}
};
require('jsdoc/src/handlers').attachTo(parser);
parser.addNodeVisitor(visitor);
parser.parse(sourceCode);
expect(args).toBeDefined();
expect( Array.isArray(args) ).toBe(true);
expect(args.length).toBe(4);
// args[0]: Rhino node
expect(args[0].toSource).toBeDefined();
expect( String(args[0].toSource()) ).toBe('foo');
// args[1]: JSDoc event
expect(typeof args[1]).toBe('object');
expect(args[1].code).toBeDefined();
expect(args[1].code.name).toBeDefined();
expect( String(args[1].code.name) ).toBe('foo');
// args[2]: parser
expect(typeof args[2]).toBe('object');
// args[3]: current source name
expect( String(args[3]) ).toBe('[[string0]]');
});
it('should reflect changes made by Rhino node visitors', function() {
var doclet;
var visitor = {
visitNode: function(rhinoNode, e, visitParser, sourceName) {
if (e && e.code && e.code.name === 'foo') {
e.code.name = 'bar';
}
}
};
require('jsdoc/src/handlers').attachTo(parser);
parser.addNodeVisitor(visitor);
parser.parse(sourceCode);
doclet = parser.results()[0];
expect(doclet).toBeDefined();
expect(typeof doclet).toBe('object');
expect(doclet.name).toBeDefined();
expect(doclet.name).toBe('bar');
});
it('should not call a second Rhino node visitor if the first visitor stopped ' +
'propagation', function() {
var doclet;
var visitor1 = {
visitNode: function(rhinoNode, e, visitParser, sourceName) {
e.stopPropagation = true;
}
};
var visitor2 = {
visitNode: function(rhinoNode, e, visitParser, sourceName) {
e.propertyThatWillNeverBeSet = ':(';
}
};
require('jsdoc/src/handlers').attachTo(parser);
parser.addNodeVisitor(visitor1);
parser.addNodeVisitor(visitor2);
parser.parse(sourceCode);
doclet = parser.results()[0];
expect(doclet.propertyThatWillNeverBeSet).not.toBeDefined();
});
});
});
});

View File

@ -1,89 +0,0 @@
'use strict';
describe('rhino/jsdoc/src/visitor', function() {
var runtime = require('jsdoc/util/runtime');
var jsdoc = {
src: {
visitor: require( runtime.getModulePath('jsdoc/src/visitor') )
}
};
it('should exist', function() {
expect(jsdoc.src.visitor).toBeDefined();
expect(typeof jsdoc.src.visitor).toBe('object');
});
it('should export a "Visitor" constructor', function() {
expect(jsdoc.src.visitor.Visitor).toBeDefined();
expect(typeof jsdoc.src.visitor.Visitor).toBe('function');
});
describe('Visitor', function() {
var parser;
var visitor;
function newVisitor() {
parser = require('jsdoc/src/parser').createParser('rhino');
visitor = new jsdoc.src.visitor.Visitor(parser);
}
newVisitor();
it('should inherit from jsdoc/src/visitor', function() {
var parent = require('jsdoc/src/visitor').Visitor;
expect(visitor instanceof parent).toBe(true);
});
it('should have an "addRhinoNodeVisitor" method', function() {
expect(visitor.addRhinoNodeVisitor).toBeDefined();
expect(typeof visitor.addRhinoNodeVisitor).toBe('function');
});
it('should have a "getRhinoNodeVisitors" method', function() {
expect(visitor.getRhinoNodeVisitors).toBeDefined();
expect(typeof visitor.getRhinoNodeVisitors).toBe('function');
});
describe('addRhinoNodeVisitor', function() {
function visitorA() {}
function visitorB() {}
var visitors;
beforeEach(newVisitor);
it('should work with a single Rhino node visitor', function() {
visitor.addRhinoNodeVisitor(visitorA);
visitors = visitor.getRhinoNodeVisitors();
expect(visitors.length).toBe(1);
expect(visitors[0]).toBe(visitorA);
});
it('should work with multiple Rhino node visitors', function() {
visitor.addRhinoNodeVisitor(visitorA);
visitor.addRhinoNodeVisitor(visitorB);
visitors = visitor.getRhinoNodeVisitors();
expect(visitors.length).toBe(2);
expect(visitors[0]).toBe(visitorA);
expect(visitors[1]).toBe(visitorB);
});
});
describe('getRhinoNodeVisitors', function() {
beforeEach(newVisitor);
it('should return an empty array by default', function() {
var visitors = visitor.getRhinoNodeVisitors();
expect( Array.isArray(visitors) ).toBe(true);
expect(visitors.length).toBe(0);
});
// other functionality is covered by the addNodeVisitors tests
});
});
});