Added rhino-require as a remote.

This commit is contained in:
Michael Mathews 2011-05-07 15:14:14 +01:00
parent a43ca23c24
commit d3b0da4b06
196 changed files with 0 additions and 11692 deletions

View File

@ -1,202 +0,0 @@
License
=======
JSDoc 3 is free software, licensed under the Apache License,
Version 2.0 (the "License"); you MAY NOT use this software except in
compliance with the License. You have permission to use it for commercial,
non-commercial, or any other purpose you like, according to the
License below.
Copyright (c) 2011 Michael Mathews <micmath@gmail.com>
All rights reserved.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.
You may obtain the source code for JSDoc 3 at
https://github.com/micmath/JSDoc
In Addition
===========
Third party software is included, used-by or distributed along
with JSDoc 3. Each is provided under its own license and has source
available from other locations.
Rhino (build/java/classes/js.jar)
----
Rhino is open source and licensed by Mozilla under the MPL 1.1 or
later/GPL 2.0 or later licenses.
https://developer.mozilla.org/en/Rhino_License
You may obtain the source code for Rhino from the Mozilla web site at
http://www.mozilla.org/rhino/download.html
json2xml (modules/goessner/json2xml)
----
Copyright (c) Stefan Goessner 2006
json2xml is licensed under Creative Commons GNU LGPL License,
http://creativecommons.org/licenses/LGPL/2.1/
You may obtain the source code for json2xml at
http://goessner.net/download/prj/jsonxml/
Node (modules/common/assert, modules/common/util)
----
Copyright 2009, 2010 Ryan Lienhart Dahl. All rights reserved.
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.
You may obtain the source code for Node at
https://github.com/ry/node
JSONSchema Validator (modules/sitepen/jsonschema)
----
Copyright (c) 2007 Kris Zyp SitePen (www.sitepen.com)
Licensed under the MIT license. You may obtain a copy of the
License at http://www.opensource.org/licenses/mit-license.php
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.
You may obtain the source code for JSONSchema Validator at
http://github.com/kriszyp/commonjs-utils/blob/master/lib/json-schema.js
http://www.sitepen.com/blog/2010/03/02/commonjs-utilities/
markdown-js (modules/evilstreak/markdown)
----
markdown-js is released under the MIT license. You may obtain a copy of the
License at http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2009-2010 Dominic Baggott
Copyright (c) 2009-2010 Ash Berlin
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.
You may obtain the source code for markdown-js at
https://github.com/evilstreak/markdown-js
sqlitejdbc (build/java/classes/sqlitejdbc-v054.jar)
----
Copyright (c) 2007 David Crawshaw <david@zentus.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
You may obtain the source code for sqlitejdbc at
https://github.com/crawshaw/sqlitejdbc
Underscore Template (templates/lib/underscore/template.js)
----
Underscore.js 1.1.4
Copyright (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
Underscore is freely distributable under the MIT license.
Portions of Underscore are inspired or borrowed from Prototype,
Oliver Steele's Functional, and John Resig's Micro-Templating.
For all details and documentation:
http://documentcloud.github.com/underscore/#template
TaffyDB (modules/typicaljoe/taffy.js)
----
Copyright (c) 2008 All rights reserved.
Software License Agreement (BSD License)
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following condition is met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
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.
You may obtain the source code for TaffyDB at
https://github.com/typicaljoe/taffydb

View File

@ -1,95 +0,0 @@
JSDoc 3
=======
An inline API documentation processor for JavaScript. JSDoc 3 is intended to be
an upgrade to JsDoc Toolkit (JSDoc 2).
Notice
------
This is *pre-release software*! It is under active development, not complete
and is not suitable for reqular use yet.
Installation
------------
Download a copy of JSDoc 3 from the official Git Hub repository here:
<https://github.com/micmath/jsdoc>
To build the jar file that runs JSDoc 3, use the Apache ant build tool:
cd jsdoc
ant
This will create a file named `jsdoc.jar` in the project base directory.
To test that the newly installed app is working, execute the following:
java -jar jsdoc.jar --test
Usage
-----
This example assumes that your working directory is the jsdoc application base
directory:
java -jar jsdoc.jar yourSourceCodeFile.js
For help regarding the supported commandline options use the --help option.
java -jar jsdoc.jar --help
Included with JSDoc 3 is a bash shell script that can simplify the command line
usage slightly. For example:
./jsdoc --help
./jsdoc yourSourceCodeFile.js
Dependencies
------------
JSDoc 3 utilises the Mozilla Rhino engine, which requires Java. JSDoc 3 is known
to work with version 1.6.0_24 of Java.
JSDoc 3 uses advanced features in the Rhino application which are only
available in or after Rhino 1.7 release 3. A copy of this version of Rhino is
included in JSDoc so this is not normally an issue that the user needs to be
concerned with. However, in rare cases, users may have their Java CLASSPATH
configured to override that included Rhino and point to some older version of
Rhino instead. If this is the case, simply correct the CLASSPATH to remove the
older Rhino.
The build script for JSDoc 3 requires Apache ant. It is know to work with
version 1.8.2 of ant.
Debugging
---------
Rhino is not always very friendly when it comes to reporting errors in
JavaScript. Luckily it comes with a full-on debugger included that can be much
more useful than a simple stack trace. To invoke JSDoc with the debugger try the
following command:
$ java -classpath build-files/java/classes/js.jar \
org.mozilla.javascript.tools.debugger.Main main.js `pwd` \
your/script.js
This will open a debugging window. Choose "Break on Exceptions" from the "Debug"
menu, then press the "Run" button. If there is an error, you should see exactly
where it is in the source code.
See Also
--------
Project Documentation: <http://usejsdoc.org/> (under development)
JSDoc User's Group: <http://groups.google.com/group/jsdoc-users>
Subversion Mirror: <http://code.google.com/p/jsdoc/source>
Project Annoncements: <http://twitter.com/jsdoc3>
License
-------
JSDoc 3 is copyright (c) 2011 Michael Mathews <micmath@gmail.com>
See file "LICENSE.md" in this distribution for more details about
terms of use.

View File

@ -1,2 +0,0 @@
app.name=jsdoc
app.version=3.0.0beta1

Binary file not shown.

View File

@ -1,56 +0,0 @@
/*
OVERVIEW:
A bootstrap tool for running main.js. Assumes main.js is in
the same directory as the run.jar file.
Its duty is simply to add the absolute path for main.js as
the first argument to the main.js script itself. This enables
the script to know it's own directory, useful for accessing
resources via relative filepaths.
AUTHOR: Michael Mathews <micmath@gmail.com>
LICENSE: Apache License 2.0 - See file 'LICENSE.md' in this project.
USAGE: java -jar run.jar <args>
*/
import java.io.File;
import java.net.URL;
import java.util.*;
public class Run {
// requires java.io.File, java.net.URL
public static void main(String[] args) throws java.io.IOException {
// get the absolute file path to the jar file containing this class
ClassLoader loader = Run.class.getClassLoader();
// url is like "file:/Users/michael/WorkArea/jsdoc/run.jar!/Run.class"
String jarUrl = loader.getResource("Run.class").getPath();
// parse the filepath out of the URL
String delims = "[:!]";
String[] tokens = jarUrl.split(delims);
String jarPath = tokens[1];
// the base directory, assumed to contain main.js
String jarDir = new File(jarPath).getParent();
String mainPath = jarDir + "/main.js";
// Rhino eats the first arg (the path to the script file it is running)
// so we add it twice: one for Rhino the next for us
String[] mainArgs = {mainPath, mainPath};
String[] allArgs = concat(mainArgs, args);
// main.js will now get arguments like:
// ["/abs/path/to/main.js", "-a", "aval", "-b", "bval"]
org.mozilla.javascript.tools.shell.Main.main(allArgs);
}
// requires java.util
public static String[] concat(String[] a, String[] b) {
List<String> ab = new ArrayList<String>(a.length + b.length);
Collections.addAll(ab, a);
Collections.addAll(ab, b);
return ab.toArray(new String[] {});
}
}

View File

@ -1,36 +0,0 @@
{
"name": "@app.name@",
"version": "@app.version@",
"revision": "@timestamp@",
"description": "An automatic documentation generator for javascript.",
"keywords": [ "documentation", "javascript" ],
"licenses": [
{
"type": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
],
"repositories": [
{
"type": "git",
"url": "git://github.com/micmath/jsdoc.git"
},
{
"type": "svn",
"url": "https://jsdoc.googlecode.com/svn/trunk"
}
],
"bugs": "http://code.google.com/p/jsdoc/issues/list",
"contributors" : [
{
"name": "Michael Mathews",
"email": "micmath@gmail.com"
}
],
"maintainers": [
{
"name": "Michael Mathews",
"email": "micmath@gmail.com"
}
]
}

View File

@ -1,71 +0,0 @@
<?xml version="1.0"?>
<project name="jsdoc" default="jar-install">
<property file="build-files/build.properties" />
<property name="build.templates" location="build-files/templates" />
<tstamp>
<format property="NOW" pattern="yyyy-MM-dd-HHmm" locale="en,UK"/>
</tstamp>
<!-- build the package.json file -->
<target name="about">
<delete file="package.json" quiet="true"/>
<copy file="${build.templates}/package.json" tofile="package.json" >
<filterchain>
<replacetokens>
<token key="app.name" value="${app.name}" />
<token key="app.version" value="${app.version}" />
<token key="timestamp" value="${NOW}" />
</replacetokens>
</filterchain>
</copy>
</target>
<!-- commit a copy of master to subversion -->
<target name="mirror">
<exec executable="/usr/local/git/bin/git">
<arg value="svn" />
<arg value="dcommit" />
</exec>
</target>
<!-- steps to build and install the jsdoc.jar file: clean, compile, build -->
<target name="jar-clean">
<delete dir="build-files/java/build" />
<delete file="jsdoc.jar" />
</target>
<target name="jar-compile">
<path id="local-classes">
<fileset dir="build-files/java/classes/">
<include name="*.jar" />
</fileset>
</path>
<mkdir dir="build-files/java/build/classes" />
<javac srcdir="build-files/java/src"
destdir="build-files/java/build/classes"
includeAntRuntime="false">
<classpath refid="local-classes" />
</javac>
</target>
<target name="jar-build" depends="jar-compile">
<mkdir dir="build-files/java/build/jar" />
<jar destfile="build-files/java/build/jar/jsdoc.jar" basedir="build-files/java/build/classes">
<manifest>
<attribute name="Main-Class" value="Run" />
<attribute name="Class-Path" value="build-files/java/classes/js.jar build-files/java/classes/sqlitejdbc-v054.jar" />
</manifest>
</jar>
</target>
<!-- do all the steps to build and install the jsdoc.jar file -->
<target name="jar-install" depends="jar-clean, jar-build">
<copy file="build-files/java/build/jar/jsdoc.jar" tofile="jsdoc.jar" overwrite="true" />
</target>
</project>

View File

View File

@ -1,14 +0,0 @@
{
"tags": {
"allowUnknownTags": true
},
"source": {
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/)_"
},
"plugins": [
]
}

7
jsdoc
View File

@ -1,7 +0,0 @@
#!/bin/sh
BASEDIR=`dirname $0`
java -classpath ${BASEDIR}/build-files/java/classes/js.jar -jar ${BASEDIR}/jsdoc.jar $@
# or possibly?
# java -classpath build-files/java/classes/js.jar org.mozilla.javascript.tools.shell.Main main.js `pwd`

273
main.js
View File

@ -1,273 +0,0 @@
/**
* @project jsdoc
* @author Michael Mathews <micmath@gmail.com>
* @license See LICENSE.md file included in this distribution.
*/
// try: $ java -classpath build-files/java/classes/js.jar org.mozilla.javascript.tools.shell.Main main.js `pwd` script/to/parse.js
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
/** The absolute path to the base directory of the jsdoc application.
@type string
@global
*/
const BASEDIR = (arguments[0].replace(/([\/\\])main\.js$/, '$1') + '/').replace('//', '/'); // expects argument[0] to the abspath to main.js
/** Include a JavaScript module, defined in the CommonJS way.
@param {string} id The identifier of the module you require.
@returns {mixed} The module's "exports" value.
@see <http://wiki.commonjs.org/wiki/Modules/1.1>
*/
function require(id) { // like commonjs
var moduleContent = '',
moduleUri;
for (var i = 0, len = require.paths.length; i < len; i++) {
moduleUri = require.paths[i] + '/' + id + '.js';
moduleContent = '';
var file = new java.io.File(moduleUri);
if ( file.exists() && file.canRead() && !file.isDirectory() ) {
try {
var scanner = new java.util.Scanner(file).useDelimiter("\\Z");
moduleContent = String( scanner.next() );
}
catch(ignored) { }
if (moduleContent) { break; }
}
}
if (moduleContent) {
try {
var f = new Function('require', 'exports', 'module', moduleContent),
exports = require.cache[moduleUri] || {},
module = { id: id, uri: moduleUri };
f.call({}, require, exports, module);
}
catch(e) {
throw 'Unable to require source code from "' + moduleUri + '": ' + e.toSource();
}
exports = module.exports || exports;
require.cache[id] = exports;
}
else {
throw 'The requested module cannot be returned: no content for id: "' + id + '" in paths: ' + require.paths.join(', ');
}
return exports;
}
require.root = BASEDIR;
require.paths = [ require.root + 'modules', require.root + 'modules/common' ];
require.cache = {}; // cache module exports. Like: {id: exported}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
/** Data representing the environment in which this app is running.
@namespace
*/
env = {
/** Running start and finish times. */
run: {
start: new Date(),
finish: null
},
/**
The command line arguments passed into jsdoc.
@type Array
*/
args: Array.prototype.slice.call(arguments, 1), // jsdoc.jar adds argument[0], the abspath to main.js, user args follow
/**
The parsed JSON data from the configuration file.
@type Object
*/
conf: {},
/**
The command line arguments, parsed into a key/value hash.
@type Object
@example if (env.opts.help) { print 'Helpful message.'; }
*/
opts: {}
};
/**
Data that must be shared across the entire application.
@namespace
*/
app = {
jsdoc: {
scanner: new (require('jsdoc/src/scanner').Scanner)(),
parser: new (require('jsdoc/src/parser').Parser)(),
name: require('jsdoc/name')
}
}
try { main(); }
catch(e) {
if (e.rhinoException != null) {
e.rhinoException.printStackTrace();
}
else throw e;
}
finally { env.run.finish = new Date(); }
/** Print string/s out to the console.
@param {string} ... String/s to print out to console.
*/
function print() {
for (var i = 0, leni = arguments.length; i < leni; i++) {
java.lang.System.out.println('' + arguments[i]);
}
}
/**
Try to recursively print out all key/values in an object.
@global
@param {Object} ... Object/s to dump out to console.
*/
function dump() {
for (var i = 0, leni = arguments.length; i < leni; i++) {
print( require('common/dumper').dump(arguments[i]) );
}
}
/** @global
@param {string} filepath The path to the script file to include (read and execute).
*/
function include(filepath) {
try {
load(BASEDIR + filepath);
}
catch (e) {
print('Cannot include "' + BASEDIR + filepath + '": '+e);
}
}
/**
Cause the VM running jsdoc to exit running.
@param {number} [n = 0] The exit status.
*/
function exit(n) {
n = n || 0;
java.lang.System.exit(n);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
/**
Run the jsoc application.
*/
function main() {
var sourceFiles,
packageJson,
docs,
jsdoc = {
opts: {
parser: require('jsdoc/opts/parser'),
}
};
env.opts = jsdoc.opts.parser.parse(env.args);
try {
env.conf = JSON.parse(
require('fs').read( env.opts.configure || BASEDIR+'conf.json' )
);
}
catch (e) {
throw('Configuration file cannot be evaluated. '+e);
}
if (env.opts.query) {
env.opts.query = require('query').toObject(env.opts.query);
}
if (env.opts.help) {
print( jsdoc.opts.parser.help() );
exit(0);
}
else if (env.opts.test) {
include('test/runner.js');
exit(0);
}
// allow user-defined plugins to register listeners
if (env.conf.plugins) {
for (var i = 0, leni = env.conf.plugins.length; i < leni; i++) {
include(env.conf.plugins[i]);
}
}
// any source file named package.json is treated special
for (var i = 0, l = env.opts._.length; i < l; i++ ) {
if (/\bpackage\.json$/i.test(env.opts._[i])) {
packageJson = require('fs').read( env.opts._[i] );
env.opts._.splice(i--, 1);
}
}
if (env.opts._.length > 0) { // are there any files to scan and parse?
var includeMatch = (env.conf.source && env.conf.source.includePattern)? new RegExp(env.conf.source.includePattern) : null,
excludeMatch = (env.conf.source && env.conf.source.excludePattern)? new RegExp(env.conf.source.excludePattern) : null;
sourceFiles = app.jsdoc.scanner.scan(env.opts._, (env.opts.recurse? 10 : undefined), includeMatch, excludeMatch);
require('jsdoc/src/handlers').attachTo(app.jsdoc.parser);
docs = app.jsdoc.parser.parse(sourceFiles, env.opts.encoding);
if (packageJson) {
var packageDocs = new (require('jsdoc/package').Package)(packageJson);
packageDocs.files = sourceFiles || [];
docs.push(packageDocs);
}
function indexAll(docs) {
var lookupTable = {};
docs.forEach(function(doc) {
if ( !lookupTable.hasOwnProperty(doc.longname) ) {
lookupTable[doc.longname] = [];
}
lookupTable[doc.longname].push(doc);
});
docs.index = lookupTable;
}
indexAll(docs);
require('jsdoc/borrow').resolveBorrows(docs);
if (env.opts.expel) {
dump(docs);
exit(0);
}
env.opts.template = env.opts.template || 'default';
// should define a global "publish" function
include('templates/' + env.opts.template + '/publish.js');
if (typeof publish === 'function') {
publish(
new (require('typicaljoe/taffy'))(docs),
env.opts
);
}
else { // TODO throw no publish warning?
}
}
}

View File

@ -1,140 +0,0 @@
/**
Parse the command line arguments.
@module common/args
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
/**
Create an instance of the parser.
@classdesc A parser to interpret the key value pairs entered on the command
line.
@constructor
*/
exports.ArgParser = function() {
this._options = [];
}
exports.ArgParser.prototype._getOptionByShortName = function(name) {
for (var i = this._options.length; i--;) {
if (this._options[i].shortName === name) { return this._options[i]; }
}
return null;
}
exports.ArgParser.prototype._getOptionByLongName = function(name) {
for (var i = this._options.length; i--;) {
if (this._options[i].longName === name) { return this._options[i]; }
}
return null;
}
/**
* Provide information about a legal option.
* @param {character} shortName The short name of the option, entered like: -T.
* @param {string} longName The equivalent long name of the option, entered like: --test.
* @param {boolean} hasValue Does this option require a value? Like: -t templatename
* @param {string} helpText
* @example
* myParser.addOption('t', 'template', true, 'The path to the template.');
* myParser.addOption('h', 'help', false, 'Show the help message.');
*/
exports.ArgParser.prototype.addOption = function(shortName, longName, hasValue, helpText) {
this._options.push({shortName: shortName, longName: longName, hasValue: hasValue, helpText: helpText});
};
/**
Generate a summary of all the options with corresponding help text.
@returns {string}
*/
exports.ArgParser.prototype.help = function() {
var help = 'OPTIONS:\n',
option;
for (var i = 0, leni = this._options.length; i < leni; i++) {
option = this._options[i];
if (option.shortName) {
help += '-' + option.shortName + (option.longName? ' or ' : '');
}
if (option.longName) {
help += '--' + option.longName;
}
if (option.hasValue) {
help += ' <value>';
}
help += ' ' + option.helpText + '\n';
}
return help;
};
/**
Get the options.
@param {Array.<string>} args An array, like ['-x', 'hello']
@param {Object} [defaults={}] An optional collection of default values.
@returns {Object} The keys will be the longNames, or the shortName if
no longName is defined for that option. The values will be the values
provided, or `true` if the option accepts no value.
*/
exports.ArgParser.prototype.parse = function(args, defaults) {
var result = defaults || {};
result._ = [];
for (var i = 0, leni = args.length; i < leni; i++) {
var arg = '' + args[i],
next = (i < leni-1)? '' + args[i+1] : null,
option,
shortName,
longName,
name,
value = null;
// like -t
if (arg.charAt(0) === '-') {
// like: --template
if (arg.charAt(1) === '-') {
name = longName = arg.slice(2);
option = this._getOptionByLongName(longName);
}
else {
name = shortName = arg.slice(1);
option = this._getOptionByShortName(shortName);
}
if (option === null) {
throw new Error( 'Unknown command line option found: ' + name );
}
if (option.hasValue) {
value = next;
i++;
if (value === null || value.charAt(0) === '-') {
throw new Error( 'Command line option requires a value: ' + name );
}
}
else {
value = true;
}
if (option.longName && shortName) {
name = option.longName;
}
result[name] = value;
}
else {
result._.push(arg);
}
}
return result;
}
})();

View File

@ -1,302 +0,0 @@
// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
//
// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
//
// Originally from narwhal.js (http://narwhaljs.org)
// Copyright (c) 2009 Thomas Robinson <280north.com>
//
// 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 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 common = { util: require('common/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 = exports;
// 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.message = options.message;
this.actual = options.actual;
this.expected = options.expected;
this.operator = options.operator;
var stackStartFunction = options.stackStartFunction || fail;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, stackStartFunction);
}
};
common.util.inherits(assert.AssertionError, Error);
assert.AssertionError.prototype.toString = function() {
if (this.message) {
return [this.name + ':', this.message].join(' ');
} else {
return [this.name + ':',
JSON.stringify(this.expected),
this.operator,
JSON.stringify(this.actual)].join(' ');
}
};
// assert.AssertionError instanceof Error
assert.AssertionError.__proto__ = Error.prototype;
// 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);.
assert.ok = function ok(value, message) {
if (!!!value) fail(value, true, message, '==', assert.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 (this.Buffer && Buffer.isBuffer(actual) && Buffer.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 (actual instanceof Date && expected instanceof Date) {
return actual.getTime() === expected.getTime();
// 7.3. Other pairs that do not both pass typeof value == 'object',
// equivalence is determined by ==.
} else if (typeof actual != 'object' && typeof expected != 'object') {
return actual == expected;
// 7.4. 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 isUndefinedOrNull(value) {
return value === null || value === undefined;
}
function isArguments(object) {
return Object.prototype.toString.call(object) == '[object Arguments]';
}
function objEquiv(a, b) {
if (isUndefinedOrNull(a) || isUndefinedOrNull(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 (expected instanceof 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 (typeof expected === 'string') {
message = expected;
expected = null;
}
try {
block();
} catch (e) {
actual = e;
}
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
(message ? ' ' + message : '.');
if (shouldThrow && !actual) {
fail('Missing expected exception' + message);
}
if (!shouldThrow && expectedException(actual, expected)) {
fail('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*/error, /*optional*/message) {
_throws.apply(this, [false].concat(pSlice.call(arguments)));
};
assert.ifError = function(err) { if (err) {throw err;}};

View File

@ -1,158 +0,0 @@
/**
Recursively print out all names and values in a data structure.
@module common/dumper
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
/**
@param {any} object
*/
exports.dump = function(object) {
indentBy = 0;
output = '';
walk(object);
outdent(false);
return output;
}
const INDENTATION = ' '; // 4 spaces
var indentBy,
output;
function pad(depth) {
var padding = '';
while (depth--) {
padding += INDENTATION;
}
return padding;
}
/**
@param {string} openingBrace - The opening brace to add, like "{".
@private
@inner
@memberof module:common/dumper
*/
function indent(openingBrace) {
indentBy++;
if (openingBrace) output += openingBrace + '\n';
}
/**
@param {string|boolean} closingBrace - The closing brace to add, like "}" or if boolean
`false` no closing brace or trailing newline.
@private
@inner
@memberof module:common/dumper
*/
function outdent(closingBrace) {
indentBy--;
output = output.replace(/,\n$/, '\n'); // trim trailing comma
if (closingBrace === false) { output = output.replace(/\n$/, ''); }
else if (closingBrace) output += pad(indentBy) + closingBrace + ',\n';
}
var seen = [];
seen.has = function(object) {
for (var i = 0, l = seen.length; i < l; i++) {
if (seen[i] === object) { return true; }
}
return false;
}
function walk(object) {
var value;
if ( value = getValue(object) ) {
output += value + ',\n';
}
else if ( isUnwalkable(object) ) {
output += '<Object>,\n'
}
else if ( isRegExp(object) ) {
output += '<RegExp ' + object + '>,\n'
}
else if ( isDate(object) ) {
output += '<Date ' + object.toUTCString() + '>,\n'
}
else if ( isFunction(object) ) {
output += '<Function' + (object.name? ' '+ object.name : '') + '>,\n';
}
else if ( isArray(object) ) {
if ( seen.has(object) ) {
output += '<CircularRef>,\n';
return;
}
else {
seen.push(object);
}
indent('[');
for (var i = 0, leni = object.length; i < leni; i++) {
output += pad(indentBy); // + i + ': ';
walk( object[i] );
}
outdent(']');
}
else if ( isObject(object) ) {
if ( seen.has(object) ) {
output += '<CircularRef>,\n';
return;
}
else {
seen.push(object);
}
indent('{');
for (var p in object) {
if ( object.hasOwnProperty(p) ) {
output += pad(indentBy) + stringify(p) + ': ';
walk( object[p] );
}
}
outdent('}');
}
}
function getValue(o) { // see: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special/typeof
if (o === null) { return 'null'; }
if ( /^(string|boolean|number|undefined)$/.test(typeof o) ) {
return ''+stringify(o);
}
}
function stringify(o) {
return JSON.stringify(o);
}
function isUnwalkable(o) { // some objects are unwalkable, like Java native objects
return (typeof o === 'object' && typeof o.constructor === 'undefined');
}
function isArray(o) {
return o && (o instanceof Array) || o.constructor === Array;
}
function isRegExp(o) {
return (o instanceof RegExp) ||
(typeof o.constructor !== 'undefined' && o.constructor.name === 'RegExp');
}
function isDate(o) {
return o && (o instanceof Date) ||
(typeof o.constructor !== 'undefined' && o.constructor.name === 'Date');
}
function isFunction(o) {
return o && (typeof o === 'function' || o instanceof Function);// ||
//(typeof o.constructor !== 'undefined' && (o.constructor||{}).name === 'Function');
}
function isObject(o) {
return o && o instanceof Object ||
(typeof o.constructor !== 'undefined' && o.constructor.name === 'Object');
}
})();

View File

@ -1,71 +0,0 @@
/**
Functions related to events. Designed to be mixed into other classes.
@exports common/events
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
module.exports = {
/**
@param {string} type
@param {function} handler
@returns {this}
*/
on: function(type, handler, context) {
if ( !type || !handler ) {
return;
}
if ( !context ) { context = this; }
if ( !this.__bindings ) { this.__bindings = {}; }
// TODO check here for hasOwnProperty?
if ( !this.__bindings[type] ) { this.__bindings[type] = []; }
var call = function(e) {
return handler.call(context, e);
};
this.__bindings[type].push( {handler: handler, call: call} );
return this; // chainable
},
/**
@param {string} type
@param {object} [eventData]
@returns {this}
*/
fire: function(eventType, eventData) {
if ( !eventType || !this.__bindings || !this.__bindings[eventType] ) {
return;
}
// run handlers in first-in-first-run order
for (var i = 0, leni = this.__bindings[eventType].length; i < leni; i++) {
if ( false === this.__bindings[eventType][i].call(eventData) ) {
if (eventData) { eventData.defaultPrevented = true; }
}
}
return this; // chainable
},
/**
@param {string} type
@param {function} handler
*/
removeListener: function(type, handler) {
if ( !type || !handler || !this.__bindings || !this.__bindings[type] ) {
return;
}
var i = this.__bindings[type].length;
while ( i-- ) {
if ( this.__bindings[type][i].handler === handler ) {
this.__bindings[type].splice(i, 1);
}
}
if (this.__bindings[type].length === 0) {
delete this.__bindings[type];
}
}
};

View File

@ -1,180 +0,0 @@
/**
Functions related to interaction with the filesystem.
@module common/fs
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
var slash = java.lang.System.getProperty('file.separator') || '/',
File = java.io.File,
defaultEncoding = java.lang.System.getProperty('file.encoding');
/**
Read the contents of a file.
@param {string} path
@param {string} encoding
@returns {string} The contents of the file.
*/
exports.read = function(path, encoding) {
var options = options || {},
encoding = encoding || defaultEncoding,
input;
input = new java.util.Scanner(
new File(path),
encoding
).useDelimiter("\\Z");
return String( input.next() );
}
/**
Write the content to a file.
@param {string} path
@param {string} content
@param {string} encoding
*/
exports.write = function(path, content, encoding) {
var options = options || {},
encoding = encoding || defaultEncoding,
output;
output = new java.io.PrintWriter(
new java.io.OutputStreamWriter(
new java.io.FileOutputStream(path),
encoding
)
);
output.write(content);
output.flush();
output.close();
}
/**
* Check if a file exists.
* @param {string} path The file to check.
* @returns {boolean}
*/
exports.exists = function(path) {
var file = new File(path);
if (file.isDirectory()){
return true;
}
if (!file.exists()){
return false;
}
if (!file.canRead()){
return false;
}
return true;
}
/**
* Get a list of all files in a given directory. Will not include files that
* start with a dot.
* @type string[]
* @param {string} dir The starting directory to look in.
* @param {number} [recurse=1] How many levels deep to scan.
* @returns {string[]} An array of {string} paths to the files in the given directory.
*/
exports.ls = function(dir, recurse, _allFiles, _path) {
var files,
file;
if (typeof _path === 'undefined') { // initially
_allFiles = [];
_path = [dir];
}
if (_path.length === 0) { return _allFiles; }
if (typeof recurse === 'undefined') { recurse = 1; }
dir = new File(dir);
if (!dir.directory) { return [String(dir)]; }
files = dir.list();
for (var f = 0, lenf = files.length; f < lenf; f++) {
file = String(files[f]);
if (file.match(/^\.[^\.\/\\]/)) { continue; } // skip dot files
if ((new File(_path.join(slash) + slash + file)).list()) { // it's a directory
_path.push(file);
if (_path.length - 1 < recurse) {
exports.ls(_path.join(slash), recurse, _allFiles, _path);
}
_path.pop();
}
else { // it's a file
_allFiles.push(
fixSlash( (_path.join(slash) + slash + file) )
);
}
}
return _allFiles;
}
exports.copyFile = function(inFile, outDir, fileName) {
if (fileName == null) fileName = exports.toFile(inFile);
outDir = exports.toDir(outDir);
var inFile = new File(inFile);
var outFile = new File(outDir+slash+fileName);
var bis = new Packages.java.io.BufferedInputStream(new Packages.java.io.FileInputStream(inFile), 4096);
var bos = new Packages.java.io.BufferedOutputStream(new Packages.java.io.FileOutputStream(outFile), 4096);
var theChar;
while ((theChar = bis.read()) != -1) {
bos.write(theChar);
}
bos.close();
bis.close();
}
exports.toDir = function(path) {
var file = new File(path);
if (file.isDirectory()){
return path;
}
var parts = path.split(/[\\\/]/);
parts.pop();
return parts.join(slash);
}
exports.toFile = function(path) {
var parts = path.split(/[\\\/]/);
return parts.pop();
}
exports.mkPath = function(/**Array*/ path) {
if (path.constructor != Array) path = path.split(/[\\\/]/);
var make = "";
for (var i = 0, l = path.length; i < l; i++) {
make += path[i] + slash;
if (! exports.exists(make)) {
exports.makeDir(make);
}
}
}
exports.makeDir = function(/**string*/ path) {
var dirPath = (exports.toDir(path));
(new File(dirPath)).mkdir();
}
// fix multiple slashes, like one//two
function fixSlash(path) {
return path.replace(/[\/\\]+/g, slash);
}
})();

View File

@ -1,42 +0,0 @@
/**
@description Support parsing of command line querystrings into JS objects.
@module common/query
@example
-q 'format=xml&root+node=documentation&publish='
> becomes
{
"format": "xml",
"root node": "documentation",
"publish": true
}
*/
(function() {
var query = module.exports = {
/**
@name module:common/query.toObject
@param {string} querystring
@returns {object}
*/
toObject: function(querystring) {
var object = {};
querystring.replace(
new RegExp('([^?=&]+)(?:=([^&]*))?', 'g'),
function($0, key, val) {
object[query._decode(key)] =
(typeof val !== 'undefined')? query._decode(val) : true;
}
);
return object;
},
/** @private */
_decode: function(string) {
return decodeURIComponent( string.replace(/\+/g, ' ') );
}
};
})();

View File

@ -1,55 +0,0 @@
importPackage(java.sql);
java.lang.Class.forName('org.sqlite.JDBC');
var DB = exports.DB = function(dbname) {
this.dbname = dbname;
}
DB.prototype.connect = function() {
this.conn = DriverManager.getConnection('jdbc:sqlite:' + this.dbname);
return this;
}
DB.prototype.prepare = function(statement) { // like "insert into symbols values (?, ?, ?);"
this.prep = this.conn.prepareStatement(statement);
return this;
}
DB.prototype.values = function() { // replaces "?" placeholders in prepared statement
for (var i = 0, leni = arguments.length; i < leni; i++) {
this.prep.setString(i+1, arguments[i]);
}
this.prep.addBatch();
return this;
}
DB.prototype.commit = function() {
this.conn.setAutoCommit(false);
this.prep.executeBatch();
this.conn.setAutoCommit(true);
return this;
}
DB.prototype.query = function(statement) { // like "select * from symbols;"
this.stat = this.conn.createStatement();
this.resultSet = this.stat.executeQuery(statement);
return this.resultSet;
}
DB.prototype.update = function(statement) { // like "create table symbols (id, longname, kind);"
this.stat = this.conn.createStatement();
this.resultSet = this.stat.executeUpdate(statement);
return this;
}
DB.prototype.close = function() {
if (this.resultSet) this.resultSet.close();
if (this.stat) this.stat.close();
if (this.conn) this.conn.close();
return this;
}

View File

@ -1,119 +0,0 @@
/**
@module common/util
*/
exports.print = function() {
for (var i = 0, len = arguments.length; i < len; ++i) {
java.lang.System.out.print(String(arguments[i]));
}
};
exports.puts = function() {
for (var i = 0, len = arguments.length; i < len; ++i) {
java.lang.System.out.println(arguments[i] + '\n');
}
};
exports.debug = function(x) {
exports.puts('DEBUG: ' + x + '\n');
};
var error = exports.error = function(x) {
for (var i = 0, len = arguments.length; i < len; ++i) {
exports.puts(arguments[i] + '\n');
}
};
exports.format = {
stylize: function(str, styleType) {
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
var styles =
{ '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] };
var style =
{ 'special': 'cyan',
'number': 'blue',
'boolean': 'yellow',
'undefined': 'grey',
'null': 'bold',
'string': 'green',
'date': 'magenta',
// "name": intentionally not styling
'regexp': 'red' }[styleType];
if (style) {
return '\033[' + styles[style][0] + 'm' + str +
'\033[' + styles[style][1] + 'm';
} else {
return str;
}
},
pad: function (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'];
/**
* Create a timestamp string.
* @returns {string} Like 26 Feb 2011 16:19:34
*/
exports.timestamp = function() {
var d = new Date();
var time = [pad(d.getHours()),
pad(d.getMinutes()),
pad(d.getSeconds())].join(':');
return [d.getDate(), months[d.getMonth()], d.getFullYear(), time].join(' ');
}
exports.log = function(msg) {
exports.puts(exports.timestamp() + ' - ' + msg.toString());
};
/**
* Inherit the prototype methods from one constructor into another.
* @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 }
});
};
/**
* Mix in the members of a source object over a target object.
* @param {object} target
* @param {object} source
*/
exports.mixin = function(target, source /*...*/){
var sourceProperty;
for (var i = 1, len = arguments.length; i < len; i++) {
source = arguments[i];
for (sourceProperty in source) {
if( source.hasOwnProperty(sourceProperty) ) {
target[sourceProperty] = source[sourceProperty]; // overwrites target property
}
}
}
return target;
};

File diff suppressed because it is too large Load Diff

View File

@ -1,70 +0,0 @@
/* This work is licensed under Creative Commons GNU LGPL License.
License: http://creativecommons.org/licenses/LGPL/2.1/
Version: 0.9/modified to conform to commonjs modules pattern
Author: Stefan Goessner/2006
Web: http://goessner.net/
*/
var json2xml = (typeof exports === 'undefined')? {} : exports; // like commonjs
(function() {
json2xml.convert = function(o) {
var toXml = function(v, name, ind) {
var xml = "";
if (v instanceof Array) {
for (var i=0, n=v.length; i<n; i++)
xml += toXml(v[i], name, ind+"");
}
else if (typeof(v) == "object") {
var hasChild = false;
xml += ind + "<" + name;
for (var m in v) {
if (m.charAt(0) == "@")
xml += " " + m.substr(1) + "=\"" + v[m].toString() + "\"";
else
hasChild = true;
}
xml += hasChild ? ">\n" : "/>";
if (hasChild) {
for (var m in v) {
if (m == "#text")
xml += makeSafe(v[m]);
else if (m == "#cdata")
xml += "<![CDATA[" + lines(v[m]) + "]]>";
else if (m.charAt(0) != "@")
xml += toXml(v[m], m, ind+"\t");
}
xml += (xml.charAt(xml.length-1)=="\n"?ind:"") + "</" + name + ">\n";
}
}
else { // added special-character transform, but this needs to be better handled [micmath]
xml += ind + "<" + name + ">" + makeSafe(v.toString()) + "</" + name + ">\n";
}
return xml;
},
xml="";
for (var m in o) {
xml += toXml(o[m], m, "");
}
return xml;
}
function lines(str) {
// normalise line endings, all in file will be unixy
str = str.replace(/\r\n/g, '\n');
return str;
}
function makeSafe(str) {
// xml special charaters
str = str.replace(/</g, '&lt;').replace(/&/g, '&amp;');
return lines(str);
}
})();

View File

@ -1,70 +0,0 @@
/**
A collection of functions relating to resolving @borrows tags in JSDoc symbols.
@module jsdoc/borrow
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
// requires docs to have been indexed: docs.index must be defined here
/**
Take a copy of the docs for borrowed symbols and attach them to the
docs for the borrowing symbol. This process changes the symbols involved,
moving docs from the "borrowed" array and into the general docs, then
deleting the "borrowed" array.
*/
exports.resolveBorrows = function(docs) {
if (!docs.index) {
throw 'Docs has not been indexed: docs.index must be defined here.';
}
docs.forEach(function(doc) {
if (doc.borrowed) {
doc.borrowed.forEach(function(b, i) {
var lent = docs.index[b.from], // lent is an array
asName = b['as'] || b.from;
if (lent) {
var cloned = doop(lent);
cloned.forEach(function(clone) {
asName = asName.replace(/^prototype\./, '#');
var parts = asName.split('#');
if (parts.length === 2) clone.scope = 'instance';
else clone.scope = 'static';
asName = parts.pop();
clone.name = asName;
clone.memberof = doc.longname;
clone.longname = clone.memberof + (clone.scope === 'instance'? '#': '.') + clone.name;
docs.push(clone);
});
}
});
delete doc.borrowed;
}
});
}
/**
Deep clone a simple object.
@private
*/
function doop(o) {
if (o instanceof Object && o.constructor != Function) {
var clone = o instanceof Array ? [] : {}, prop;
for (prop in o){
if ( o.hasOwnProperty(prop) ) {
clone[prop] = (o[prop] instanceof Object)? doop(o[prop]) : o[prop];
}
}
return clone;
}
return o;
};
})();

View File

@ -1,296 +0,0 @@
/**
@overview
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
/**
@module jsdoc/doclet
@requires jsdoc/tag
@requires jsdoc/name
@requires jsdoc/tag/dictionary
*/
(function() {
var jsdoc = {
tag: {
Tag: require('jsdoc/tag').Tag,
dictionary: require('jsdoc/tag/dictionary')
},
name: require('jsdoc/name')
};
/**
@class
@classdesc Represents a single JSDoc comment.
@param {string} docletSrc - The raw source code of the jsdoc comment.
@param {object=} meta - Properties describing the code related to this comment.
*/
exports.Doclet = function(docletSrc, meta) {
var newTags = [];
/** The original text of the comment from the source code. */
this.comment = docletSrc;
this.setMeta(meta);
docletSrc = unwrap(docletSrc);
docletSrc = fixDescription(docletSrc);
newTags = toTags.call(this, docletSrc);
for (var i = 0, leni = newTags.length; i < leni; i++) {
this.addTag(newTags[i].title, newTags[i].text);
}
this.postProcess();
}
/** Called once after all tags have been added. */
exports.Doclet.prototype.postProcess = function() {
if (!this.preserveName) { jsdoc.name.resolve(this); }
if (this.name && !this.longname) {
this.setLongname(this.name);
}
if (this.memberof === '') {
delete(this.memberof);
}
if (!this.kind && this.meta && this.meta.code) {
this.addTag( 'kind', codetypeToKind(this.meta.code.type) );
}
}
/** Add a tag to this doclet.
@param {string} title - The title of the tag being added.
@param {string} [text] - The text of the tag being added.
*/
exports.Doclet.prototype.addTag = function(title, text) {
var tagDef = jsdoc.tag.dictionary.lookUp(title),
newTag = new jsdoc.tag.Tag(title, text, this.meta);
if (tagDef && tagDef.onTagged) {
tagDef.onTagged(this, newTag)
}
if (!tagDef) {
this.tags = this.tags || [];
this.tags.push(newTag);
}
applyTag.call(this, newTag);
}
/** Set the `memberof` property of this doclet.
@param {string} sid - The longname of the symbol that this doclet is a member of.
*/
exports.Doclet.prototype.setMemberof = function(sid) {
if (/^<global>\.?/.test(sid)) { sid = sid.replace(/^<global>.?/, ''); }
/**
The longname of the symbol that contains this one, if any.
@type string
*/
this.memberof = sid.replace(/\.prototype/g, '#');
}
/** Set the `longname` property of this doclet.
@param {string} name
*/
exports.Doclet.prototype.setLongname = function(name) {
if (/^<global>\.?/.test(name)) { name = name.replace(/^<global>\.?/, ''); }
/**
The fully resolved symbol name.
@type string
*/
this.longname = name;
if (jsdoc.tag.dictionary.isNamespace(this.kind)) {
this.longname = jsdoc.name.applyNamespace(this.longname, this.kind);
}
}
/** Add a symbol to this doclet's `borrowed` array.
@param {string} source - The longname of the symbol that is the source.
@param {string} target - The name the symbol is being assigned to.
*/
exports.Doclet.prototype.borrow = function(source, target) {
var about = {from: source};
if (target) about.as = target;
if (!this.borrowed) {
/**
A list of symbols that are borrowed by this one, if any.
@type Array.<string>
*/
this.borrowed = [];
}
this.borrowed.push(about);
}
/** Add a symbol to this doclet's `augments` array.
@param {string} base - The longname of the base symbol.
*/
exports.Doclet.prototype.augment = function(base) {
if (!this.augments) {
/**
A list of symbols that are augmented by this one, if any.
@type Array.<string>
*/
this.augments = [];
}
this.augments.push(base);
}
/**
Set the `meta` property of this doclet.
@param {object} meta
*/
exports.Doclet.prototype.setMeta = function(meta) {
if (!this.meta) {
/**
Information about the source code associated with this doclet.
@namespace
*/
this.meta = {};
}
if (meta.lineno) {
/**
The line number of the code associated with this doclet.
@type number
*/
this.meta.lineno = meta.lineno;
}
if (meta.lineno) {
/**
The name of the file containing the code associated with this doclet.
@type string
*/
this.meta.filename = meta.filename;
}
/**
Information about the code symbol.
@namespace
*/
this.meta.code = (this.meta.code || {});
if (meta.id) this.meta.code.id = meta.id;
if (meta.code) {
if (meta.code.name) {
/** The name of the symbol in the source code. */
this.meta.code.name = meta.code.name;
}
if (meta.code.type) {
/** The type of the symbol in the source code. */
this.meta.code.type = meta.code.type;
}
if (meta.code.node) {
this.meta.code.node = meta.code.node;
}
if (meta.code.funcscope) {
this.meta.code.funcscope = meta.code.funcscope;
}
if (meta.code.value) {
/** The value of the symbol in the source code. */
this.meta.code.value = meta.code.value;
}
}
}
function applyTag(tag) {
if (tag.title === 'name') {
this.name = tag.value;
}
if (tag.title === 'kind') {
this.kind = tag.value;
}
if (tag.title === 'description') {
this.description = tag.value;
}
if (tag.title === 'scope') {
this.scope = tag.value;
}
}
// use the meta info about the source code to guess what the doclet kind should be
function codetypeToKind(type) {
var kind = (type || '').toLowerCase();
if (kind !== 'function') {
return 'property';
}
return kind;
}
/**
Convert the raw source of the doclet comment into an array of Tag objects.
@private
*/
function toTags(docletSrc) {
var tagSrcs,
tags = [];
docletSrc = unwrap(docletSrc);
tagSrcs = split(docletSrc);
for each(tagSrc in tagSrcs) {
tags.push( {title: tagSrc.title, text: tagSrc.text} );
}
return tags;
}
function unwrap(docletSrc) {
if (!docletSrc) { return ''; }
// note: keep trailing whitespace for @examples
// extra opening/closing stars are ignored
// left margin is considered a star and a space
// use the /m flag on regex to avoid having to guess what this platform's newline is
docletSrc =
docletSrc.replace(/^\/\*\*+/, '') // remove opening slash+stars
.replace(/\**\*\/$/, "\\Z") // replace closing star slash with end-marker
.replace(/^\s*(\* ?|\\Z)/gm, '') // remove left margin like: spaces+star or spaces+end-marker
.replace(/\s*\\Z$/g, ''); // remove end-marker
return docletSrc;
}
function fixDescription(docletSrc) {
if (!/^\s*@/.test(docletSrc)) {
docletSrc = '@description ' + docletSrc;
}
return docletSrc;
}
function split(docletSrc) {
var tagSrcs = [];
// split out the basic tags, keep surrounding whitespace
// like: @tagTitle tagBody
docletSrc
.replace(/^(\s*)@(\S)/gm, '$1\\@$2') // replace splitter ats with an arbitrary sequence
.split('\\@') // then split on that arbitrary sequence
.forEach(function($) {
if ($) {
var parsedTag = $.match(/^(\S+)(:?\s+(\S[\s\S]*))?/);
if (parsedTag) {
var [, tagTitle, tagText] = parsedTag;
if (tagTitle) {
tagSrcs.push({
title: tagTitle,
text: tagText
});
}
}
}
});
return tagSrcs;
}
})();

View File

@ -1,180 +0,0 @@
/**
A collection of functions relating to JSDoc symbol name manipulation.
@module jsdoc/name
@requires jsdoc/tag/dictionary
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
var jsdoc = {
tagDictionary: require('jsdoc/tag/dictionary')
};
var puncToScope = { '.': 'static', '~': 'inner', '#': 'instance' },
scopeToPunc = { 'static': '.', 'inner': '~', 'instance': '#' },
Token = Packages.org.mozilla.javascript.Token;
/**
Resolves the longname, memberof, variation and name values of the given doclet.
@param {module:jsdoc/doclet.Doclet} doclet
*/
exports.resolve = function(doclet) {
var name = doclet.name,
memberof = doclet.memberof || '',
about = {},
parentDoc;
name = name? (''+name).replace(/\.prototype\.?/g, '#') : '';
// member of a var in an outer scope?
if (name && !memberof && doclet.meta.code && doclet.meta.code.funcscope) {
name = doclet.longname = doclet.meta.code.funcscope + '~' + name;
}
if (memberof) { // @memberof tag given
memberof = memberof.replace(/\.prototype\.?/g, '#');
// the name is a fullname, like @name foo.bar, @memberof foo
if (name && name.indexOf(memberof) === 0) {
about = exports.shorten(name);
}
else if (name && /([#.~])$/.test(memberof) ) { // like @memberof foo# or @memberof foo~
about = exports.shorten(memberof + name);
}
else if (name && doclet.scope ) { // like @memberof foo# or @memberof foo~
about = exports.shorten(memberof + scopeToPunc[doclet.scope] + name);
}
}
else { // no @memberof
about = exports.shorten(name);
}
if (about.name) {
doclet.name = about.name;
}
if (about.memberof) {
doclet.setMemberof(about.memberof);
}
if (about.longname && !doclet.longname) {
doclet.setLongname(about.longname);
}
if (doclet.scope === 'global') { // via @global tag?
doclet.setLongname(doclet.name);
delete doclet.memberof;
}
else if (about.scope) {
doclet.scope = puncToScope[about.scope];
}
else {
if (doclet.name && doclet.memberof && !doclet.longname) {
doclet.scope = 'static'; // default scope when none is provided
doclet.setLongname(doclet.memberof + scopeToPunc[doclet.scope] + doclet.name);
}
}
if (about.variation) {
doclet.variation = about.variation;
}
//dump('doclet', doclet);
}
/**
@inner
@memberof module:jsdoc/name
@param {string} name
@param {string} kind
@returns {string} The name with unsafe names enclosed in quotes.
*/
function quoteUnsafe(name, kind) { // docspaced names may have unsafe characters which need to be quoted by us
if ( (jsdoc.tagDictionary.lookUp(kind).setsDocletDocspace) && /[^$_a-zA-Z0-9\/]/.test(name) ) {
if (!/^[a-z_$-\/]+:\"/i.test(name)) {
return '"' + name.replace(/\"/g, '"') + '"';
}
}
return name;
}
RegExp.escape = RegExp.escape || function(str) {
var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\
return str.replace(specials, "\\$&");
}
/**
@method module:jsdoc/name.applyNamespace
@param {string} longname The full longname of the symbol.
@param {string} ns The namespace to be applied.
@returns {string} The longname with the namespace applied.
*/
exports.applyNamespace = function(longname, ns) {
var nameParts = exports.shorten(longname),
name = nameParts.name,
longname = nameParts.longname;
if ( !/^[a-zA-Z]+?:.+$/i.test(name) ) {
longname = longname.replace( new RegExp(RegExp.escape(name)+'$'), ns + ':' + name );
}
return longname;
}
/**
Given a longname like "a.b#c(2)", slice it up into ["a.b", "#", 'c', '2'],
representing the memberof, the scope, the name, and variation.
@param {string} longname
@returns {object} Representing the properties of the given name.
*/
exports.shorten = function(longname) {
// quoted strings in a longname are atomic, convert to tokens
var atoms = [], token;
// handle quoted names like foo["bar"]
longname = longname.replace(/(\[?".+?"\]?)/g, function($) {
var dot = '';
if ( /^\[/.test($) ) {
dot = '.';
$ = $.replace( /^\[/g, '' ).replace( /\]$/g, '' );
}
token = '@{' + atoms.length + '}@';
atoms.push($);
return dot + token; // foo["bar"] => foo.@{1}@
});
longname = longname.replace( /\.prototype\.?/g, '#' );
var parts = longname?
(longname.match( /^(:?(.+)([#.~]))?(.+?)$/ ) || []).reverse()
: [''];
var name = parts[0],
scope = parts[1] || '', // ., ~, or #
memberof = parts[2] || '',
variation;
// like /** @name foo.bar(2) */
if ( /(.+)\(([^)]+)\)$/.test(name) ) {
name = RegExp.$1, variation = RegExp.$2;
}
//// restore quoted strings back again
var i = atoms.length;
while (i--) {
longname = longname.replace('@{'+i+'}@', atoms[i]);
memberof = memberof.replace('@{'+i+'}@', atoms[i]);
scope = scope.replace('@{'+i+'}@', atoms[i]);
name = name.replace('@{'+i+'}@', atoms[i]);
}
////
return {longname: longname, memberof: memberof, scope: scope, name: name, variation: variation};
}
})();

View File

@ -1,75 +0,0 @@
/**
@module jsdoc/opts/parser
@requires common/args
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
var common = {
args: require('common/args')
};
var argParser = new common.args.ArgParser(),
ourOptions,
defaults = {
template: 'default',
destination: BASEDIR + 'out/'
};
argParser.addOption('t', 'template', true, 'The name of the template to use. Default: the "default" template');
argParser.addOption('c', 'configure', true, 'The path to the configuration file. Default: jsdoc basedir + conf.json');
argParser.addOption('e', 'encoding', true, 'Assume this encoding when reading all source files. Default: your system default encoding');
argParser.addOption('n', 'nocode', false, 'Ignore doclets that don\'t explicitly provide a symbol name.');
argParser.addOption('T', 'test', false, 'Run all tests and quit.');
argParser.addOption('d', 'destination', true, 'The path to the output folder. Use "console" to dump data to the console. Default: console');
argParser.addOption('V', 'validate', false, 'Validate the results produced by parsing the source code.');
argParser.addOption('r', 'recurse', false, 'Recurse into subdirectories when scanning for source code files.');
argParser.addOption('h', 'help', false, 'Print this message and quit.');
argParser.addOption('X', 'expel', false, 'Dump all found doclet internals to console and quit.');
argParser.addOption('q', 'query', true, 'Provide a querystring to define custom variable names/values to add to the options hash.');
// TODO [-R, recurseonly] = a number representing the depth to recurse
// TODO [-f, filter] = a regex to filter on <-- this can be better defined in the configs?
/**
Set the options for this app.
@throws {Error} Illegal arguments will throw errors.
@param {string|String[]} args The command line arguments for this app.
*/
exports.parse = function(args) {
args = args || [];
if (typeof args === 'string' || args.constructor === String) {
args = (''+args).split(/\s+/g);
}
ourOptions = argParser.parse(args, defaults);
return ourOptions;
}
/**
Display help message for options.
*/
exports.help = function() {
return argParser.help();
}
/**
Get a named option.
@param {string} name The name of the option.
@return {string} The value associated with the given name.
*//**
Get all the options for this app.
@return {Object} A collection of key/values representing all the options.
*/
exports.get = function(name) {
if (typeof name === 'undefined') {
return ourOptions;
}
else {
return ourOptions[name];
}
}
})();

View File

@ -1,69 +0,0 @@
/**
@overview
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
/**
@module jsdoc/package
@see http://wiki.commonjs.org/wiki/Packages/1.0
*/
(function() {
/**
@class
@classdesc Represents a JavaScript package.
@param {string} json - The contents of package.json.
*/
exports.Package = function(json) {
/** The source files associated with this package.
@type {Array<String>}
*/
this.files = [];
/** The kind of this package.
@readonly
@default
@type {string}
*/
this.kind = 'package';
json = JSON.parse(json);
/** The name of this package.
This value is found in the package.json file passed in as a command line option.
@type {string}
*/
this.name = json.name;
/** The longname of this package.
@type {string}
*/
this.longname = this.kind + ':' + this.name;
/** The description of this package.
@type {string}
*/
this.description = json.description;
/**
The hash summary of the source file.
@type {string}
@since 3.2.0
*/
this.version = json.version;
/**
* The licenses of this package.
* @type {Array<Object>}
* @example
* "licenses": [
* {
* "type": "GPLv2",
* "url": "http://www.example.com/licenses/gpl.html"
* }
* ]
*/
this.licenses = json.licenses;
}
})();

View File

@ -1,296 +0,0 @@
/**
@overview Schema for validating JSON produced by JSDoc Toolkit.
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
@see <http://tools.ietf.org/html/draft-zyp-json-schema-02>
*/
exports.jsdocSchema = {
"properties": {
"doc": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"author": {
"type": ["string", "array"],
"optional": true,
"items": {
"type": "string"
}
},
"path": { // unique identifier for each doc
"type": "string",
"maxItems": 1
},
"description": { // a description
"type": "string",
"optional": true,
"maxItems": 1
},
"classdesc": { // a description of the class that this constructor belongs to
"type": "string",
"optional": true,
"maxItems": 1
},
"name": { // probably a trailing substring of the path
"type": "string",
"maxItems": 1
},
"version": { // what is the version of this doc
"type": "string",
"optional": true,
"maxItems": 1
},
"since": { // at what previous version was this doc added?
"type": "string",
"optional": true,
"maxItems": 1
},
"see": { // some thing else to consider
"type": ["string", "array"],
"optional": true,
"items": {
"type": "string"
}
},
"deprecated": { // is usage of this symbol deprecated?
"type": ["string", "boolean"],
"optional": true
},
"scope": { // how is this symbol attached to it's enclosing scope?
"type": "string",
"maxItems": 1,
"enum": ["global", "static", "instance", "inner"]
},
"memberof": { // probably a leading substring of the path
"type": "string",
"optional": true,
"maxItems": 1
},
"extends": { // the path to another constructor
"type": ["string", "array"],
"optional": true,
"items": {
"type": "string"
}
},
"fires": { // the path to another doc object
"type": ["string", "array"],
"optional": true,
"items": {
"type": "string"
}
},
"requires": { // the symbol being documented requires another symbol
"type": ["string", "array"],
"optional": true,
"items": {
"type": "string"
}
},
"implements": {
"type": ["string", "array"],
"optional": true,
"items": {
"type": "string"
}
},
"kind": { // what kind of symbol is this?
"type": "string",
"maxItems": 1,
"enum": ["constructor", "module", "event", "namespace", "method", "property", "enum", "class", "interface", "constant", "mixin", "file", "version"]
},
"refersto": { // the path to another doc: this doc is simply a renamed alias to that
"type": "string",
"optional": true,
"maxItems": 1
},
"access": { // what access priviledges are allowed
"type": "string",
"optional": true,
"maxItems": 1,
"enum": ["private", "protected", "public"]
},
"attrib": { // other attributes, like "readonly"
"type": "string",
"optional": true
},
"type": { // what type is the value that this doc is associated with, like "number"
"type": ["string", "array"],
"optional": true,
"items": {
"type": "string"
}
},
"exception" : {
"optional": true,
"type": "object",
"properties": {
"type": { // what is the type of the value thrown?
"type": "array",
"optional": true,
"items": {
"type": "string"
}
},
"description": { // a description of the thrown value
"type": "string",
"optional": true
}
},
"additionalProperties": false
},
"returns" : {
"optional": true,
"type": "object",
"properties": {
"type": { // what is the type of the value returned?
"type": ["string", "array"],
"optional": true,
"items": {
"type": "string"
}
},
"description": { // a description of the returned value
"type": "string",
"optional": true
}
},
"additionalProperties": false
},
"param" : { // are there function parameters associated with this doc?
"type": "array",
"optional": true,
"items": {
"type": "object",
"properties": {
"type": { // what are the types of value expected for this parameter?
"type": ["string", "array"],
"optional": true,
"items": {
"type": "string"
}
},
"optional": { // is a value for this parameter optional?
"type": "boolean",
"optional": true,
"default": true
},
"nullable": { // can the value for this parameter be null?
"type": "boolean",
"optional": true,
"default": true
},
"defaultvalue": { // what is the default value for this parameter?
"type": "string",
"optional": true
},
"name": { // what name does this parameter have within the function?
"type": "string"
},
"description": { // a description of the parameter
"type": "string",
"optional": true
}
},
"additionalProperties": false
}
},
"thisobj": {
"type": ["string", "array"],
"optional": true,
"items": {
"type": "string"
}
},
"example": { // some thing else to consider
"type": ["string", "array"],
"optional": true,
"items": {
"type": "string"
}
},
"tags": { // arbitrary tags associated with this doc
"type": "array",
"optional": true,
"additionalProperties": false,
"items": {
"type": "string"
}
},
"meta": { // information about this doc
"type": "object",
"optional": true,
"maxItems": 1,
"properties": {
"file": { // what is the name of the file this doc appears in?
"type": "string",
"optional": true,
"maxItems": 1
},
"line": { // on what line of the file does this doc appear?
"type": "number",
"optional": true,
"maxItems": 1
}
},
"additionalProperties": false
}
}
}
},
"meta": { // information about the generation for all the docs
"type": "object",
"optional": true,
"maxItems": 1,
"properties": {
"project": { // to what project does this doc belong?
"type": "object",
"optional": true,
"maxItems": 1,
"properties": {
"name": { // the name of the project
"type": "string",
"maxItems": 1
},
"uri": { // the URI of the project
"type": "string",
"maxItems": 1,
"format": "uri"
},
"version": { // the version of the project
"type": "string",
"maxItems": 1
},
"lang": { // the programming language used in the project
"type": "string",
"maxItems": 1
}
},
"additionalProperties": false
},
"generated": { // some information about the running of the doc generator
"type": "object",
"optional": true,
"maxItems": 1,
"properties": {
"date": { // on what date and time was the doc generated?
"type": "string",
"maxItems": 1,
"optional": true,
"format": "date-time"
},
"parser": { // what tool was used to generate the doc?
"type": "string",
"maxItems": 1,
"optional": true
}
},
"additionalProperties": false
}
}
}
}
};

View File

@ -1,137 +0,0 @@
/**
@module jsdoc/src/handlers
*/
(function() {
var currentModule = null;
/**
Attach these event handlers to a particular instance of a parser.
@param parser
*/
exports.attachTo = function(parser) {
var jsdoc = {doclet: require('jsdoc/doclet')};
// handles JSDoc comments that include a @name tag -- the code is ignored in such a case
parser.on('jsdocCommentFound', function(e) {
var newDoclet = new jsdoc.doclet.Doclet(e.comment, e);
if (!newDoclet.name) {
return false; // only interested in virtual comments (with a @name) here
}
addDoclet.call(this, newDoclet);
if (newDoclet.kind === 'module') {
currentModule = newDoclet.longname;
}
e.doclet = newDoclet;
});
// handles named symbols in the code, may or may not have a JSDoc comment attached
parser.on('symbolFound', function(e) {
var subDoclets = e.comment.split(/@also\b/g);
for (var i = 0, l = subDoclets.length; i < l; i++) {
newSymbolDoclet.call(this, subDoclets[i], e);
}
});
function newSymbolDoclet(docletSrc, e) {
var newDoclet = new jsdoc.doclet.Doclet(docletSrc, e);
// an undocumented symbol right after a virtual comment? rhino mistakenly connected the two
if (newDoclet.name) { // there was a @name in comment
// try again, without the comment
e.comment = '@undocumented';
newDoclet = new jsdoc.doclet.Doclet(e.comment, e);
}
if (newDoclet.alias) {
newDoclet.addTag('name', newDoclet.alias);
newDoclet.postProcess();
}
else if (e.code && e.code.name) { // we need to get the symbol name from code
newDoclet.addTag('name', e.code.name);
if (!newDoclet.memberof && e.astnode) {
var memberofName,
scope;
if ( /^((module.)?exports|this)(\.|$)/.test(newDoclet.name) ) {
var nameStartsWith = RegExp.$1;
newDoclet.name = newDoclet.name.replace(/^(exports|this)(\.|$)/, '');
// like /** @module foo */ exports.bar = 1;
if (nameStartsWith === 'exports' && currentModule) {
memberofName = currentModule;
scope = 'static';
}
else if (newDoclet.name === 'module.exports' && currentModule) {
newDoclet.addTag('name', currentModule);
newDoclet.postProcess();
}
else {
// like /** @module foo */ exports = {bar: 1};
// or /** blah */ this.foo = 1;
memberofName = this.resolveThis(e.astnode);
scope = nameStartsWith === 'exports'? 'static' : 'instance';
// like /** @module foo */ this.bar = 1;
if (nameStartsWith === 'this' && currentModule && !memberofName) {
memberofName = currentModule;
scope = 'static';
}
}
if (memberofName) {
if (newDoclet.name) {
newDoclet.name = memberofName + (scope === 'instance'? '#' : '.') + newDoclet.name;
}
else { newDoclet.name = memberofName; }
}
}
else {
memberofName = this.astnodeToMemberof(e.astnode);
}
if (memberofName) { newDoclet.addTag( 'memberof', memberofName); }
}
newDoclet.postProcess();
}
else {
return false;
}
addDoclet.call(this, newDoclet);
e.doclet = newDoclet;
}
//parser.on('fileBegin', function(e) { });
parser.on('fileComplete', function(e) {
currentModule = null;
});
function addDoclet(newDoclet) {
if (newDoclet) {
e = { doclet: newDoclet };
this.fire('newDoclet', e);
if (!e.defaultPrevented) {
if ( !filter(newDoclet) ) {
this.addResult(newDoclet);
}
}
}
}
function filter(doclet) {
// you can't document prototypes
if ( /#$/.test(doclet.longname) ) return true;
// you can't document symbols added by the parser with a dummy name
if (doclet.meta.code && doclet.meta.code.name === '____') return true;
return false;
}
}
})();

View File

@ -1,495 +0,0 @@
/**
* @module jsdoc/src/parser
* @requires common/util
* @requires common/fs
* @requires common/events
*/
(function() {
var Token = Packages.org.mozilla.javascript.Token,
currentParser = null,
currentSourceName = '';
/**
* @class
* @mixes module:common/events
*
* @example <caption>Create a new parser.</caption>
* var jsdocParser = new (require('jsdoc/src/parser').Parser)();
*/
exports.Parser = function() {
this._resultBuffer = [];
this.refs = {};
}
require('common/util').mixin(exports.Parser.prototype, require('common/events'));
/**
* Parse the given source files for JSDoc comments.
* @param {Array.<string>} sourceFiles An array of filepaths to the JavaScript sources.
* @param {string} [encoding=utf8]
*
* @fires jsdocCommentFound
* @fires symbolFound
* @fires newDoclet
* @fires fileBegin
* @fires fileComplete
*
* @example <caption>Parse two source files.</caption>
* var myFiles = ['file1.js', 'file2.js'];
* var docs = jsdocParser.parse(myFiles);
*/
exports.Parser.prototype.parse = function(sourceFiles, encoding) {
const SCHEMA = 'javascript:';
var sourceCode = '',
filename = '';
if (typeof sourceFiles === 'string') { sourceFiles = [sourceFiles]; }
for (i = 0, leni = sourceFiles.length; i < leni; i++) {
if (sourceFiles[i].indexOf(SCHEMA) === 0) {
sourceCode = sourceFiles[i].substr(SCHEMA.length);
filename = '[[string' + i + ']]';
}
else {
filename = sourceFiles[i];
try {
sourceCode = require('common/fs').read(filename, encoding);
}
catch(e) {
print('FILE READ ERROR: in module:jsdoc/parser.parseFiles: "' + filename + '" ' + e);
continue;
}
}
currentParser = this;
this._parseSourceCode(sourceCode, filename);
currentParser = null;
}
return this._resultBuffer;
}
/**
* @returns {Array<Doclet>} The accumulated results of any calls to parse.
*/
exports.Parser.prototype.results = function() {
return this._resultBuffer;
}
/**
* @param {Object} o The parse result to add to the result buffer.
*/
exports.Parser.prototype.addResult = function(o) {
this._resultBuffer.push(o);
}
/**
* Empty any accumulated results of calls to parse.
*/
exports.Parser.prototype.clear = function() {
currentParser = null;
currentSourceName = '';
this._resultBuffer = [];
}
/** @private */
exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) {
currentSourceName = sourceName;
sourceCode = pretreat(sourceCode);
var ast = parserFactory().parse(sourceCode, sourceName, 1);
var e = {filename: currentSourceName};
this.fire('fileBegin', e);
if (!e.defaultPrevented) {
ast.visit(
new Packages.org.mozilla.javascript.ast.NodeVisitor({
visit: visitNode
})
);
}
this.fire('fileComplete', e);
currentSourceName = '';
}
function pretreat(code) {
return code
// merge adjacent doclets
.replace(/\*\/\/\*\*+/g, '@also')
// make lent objectliterals documentable by giving them a dummy name
.replace(/(\/\*\*[\s\S]*@lends\b[\s\S]*\*\/\s*)\{/g, '$1____ = {');
}
/**
* Given a node, determine what the node is a member of.
* @param {astnode} node
* @returns {string} The long name of the node that this is a member of.
*/
exports.Parser.prototype.astnodeToMemberof = function(node) {
var memberof = {};
if (node.type === Token.VAR || node.type === Token.FUNCTION) {
if (node.enclosingFunction) { // an inner var or func
memberof.id = 'astnode'+node.enclosingFunction.hashCode();
memberof.doclet = this.refs[memberof.id];
if (!memberof.doclet) {
return '<anonymous>~';
}
return (memberof.doclet.longname||memberof.doclet.name) + '~';
}
}
else {
memberof.id = 'astnode'+node.parent.hashCode();
memberof.doclet = this.refs[memberof.id];
if (!memberof.doclet) return ''; // global?
return memberof.doclet.longname||memberof.doclet.name;
}
}
/**
* Resolve what "this" refers too, relative to a node.
* @param {astnode} node - The "this" node
* @returns {string} The longname of the enclosing node.
*/
exports.Parser.prototype.resolveThis = function(node) {
var memberof = {};
if (node.enclosingFunction) {
memberof.id = 'astnode'+node.enclosingFunction.hashCode();
memberof.doclet = this.refs[memberof.id];
if (!memberof.doclet) {
return '<anonymous>'; // TODO handle global this?
}
if (memberof.doclet['this']) {
return memberof.doclet['this'];
}
// like: Foo.constructor = function(n) { /** blah */ this.name = n; }
else if (memberof.doclet.kind === 'function' && memberof.doclet.memberof) {
return memberof.doclet.memberof;
}
// walk up to the closest class we can find
else if (memberof.doclet.kind === 'class' || memberof.doclet.kind === 'module') {
return memberof.doclet.longname||memberof.doclet.name;
}
else {
if (node.enclosingFunction){
return this.resolveThis(node.enclosingFunction/*memberof.doclet.meta.code.val*/);
}
else return ''; // TODO handle global this?
}
}
else if (node.parent) {
var parent = node.parent;
if (parent.type === Token.COLON) parent = parent.parent; // go up one more
memberof.id = 'astnode'+parent.hashCode();
memberof.doclet = this.refs[memberof.id];
if (!memberof.doclet) return ''; // global?
return memberof.doclet.longname||memberof.doclet.name;
}
else {
return ''; // global?
}
}
/**
* Resolve what function a var is limited to.
* @param {astnode} node
* @param {string} basename The leftmost name in the long name: in foo.bar.zip the basename is foo.
*/
exports.Parser.prototype.resolveVar = function(node, basename) {
var doclet,
enclosingFunction = node.enclosingFunction;
if (!enclosingFunction) { return ''; } // global
doclet = this.refs['astnode'+enclosingFunction.hashCode()];
if ( doclet && doclet.meta.vars && ~doclet.meta.vars.indexOf(basename) ) {
return doclet.longname;
}
return this.resolveVar(enclosingFunction, basename);
}
/** @private */
function visitNode(node) {
var e,
commentSrc;
// look for stand-alone doc comments
if (node.type === Token.SCRIPT && node.comments) {
// note: ALL comments are seen in this block...
for each(var comment in node.comments.toArray()) {
if (comment.commentType !== Token.CommentType.JSDOC) {
continue;
}
if (commentSrc = ''+comment.toSource()) {
e = {
comment: commentSrc,
lineno: comment.getLineno(),
filename: currentSourceName
};
if ( isValidJsdoc(commentSrc) ) {
currentParser.fire('jsdocCommentFound', e, currentParser);
}
}
}
}
else if (node.type === Token.ASSIGN) {
e = {
id: 'astnode'+node.hashCode(), // the id of the ASSIGN node
comment: String(node.jsDoc||'@undocumented'),
lineno: node.getLineno(),
filename: currentSourceName,
astnode: node,
code: aboutNode(node)
};
var basename = e.code.name.replace(/^([$a-z_][$a-z_0-9]*).*?$/i, '$1');
if (basename !== 'this') e.code.funcscope = currentParser.resolveVar(node, basename);
if ( isValidJsdoc(e.comment) ) {
currentParser.fire('symbolFound', e, currentParser);
}
if (e.doclet) {
currentParser.refs['astnode'+e.code.node.hashCode()] = e.doclet; // allow lookup from value => doclet
}
}
else if (node.type === Token.COLON) { // assignment within an object literal
e = {
id: 'astnode'+node.hashCode(), // the id of the COLON node
comment: String(node.left.jsDoc||'@undocumented'),
lineno: node.getLineno(),
filename: currentSourceName,
astnode: node,
code: aboutNode(node)
};
if ( isValidJsdoc(e.comment) ) {
currentParser.fire('symbolFound', e, currentParser);
}
if (e.doclet) {
currentParser.refs['astnode'+e.code.node.hashCode()] = e.doclet; // allow lookup from value => doclet
}
}
else if (node.type == Token.VAR || node.type == Token.LET || node.type == Token.CONST) {
if (node.variables) {
return true; // we'll get each var separately on future visits
}
if (node.parent.variables.toArray()[0] === node) { // like /** blah */ var a=1, b=2, c=3;
// the first var assignment gets any jsDoc before the whole var series
node.jsDoc = node.parent.jsDoc;
}
e = {
id: 'astnode'+node.hashCode(), // the id of the VARIABLE node
comment: String(node.jsDoc||'@undocumented'),
lineno: node.getLineno(),
filename: currentSourceName,
astnode: node,
code: aboutNode(node)
};
// keep track of vars in a function scope
if (node.enclosingFunction) {
var func = 'astnode'+node.enclosingFunction.hashCode(),
funcDoc = currentParser.refs[func];
if (funcDoc) {
funcDoc.meta.vars = funcDoc.meta.vars || [];
funcDoc.meta.vars.push(e.code.name);
}
}
if ( isValidJsdoc(e.comment) ) {
currentParser.fire('symbolFound', e, currentParser);
}
if (e.doclet) {
currentParser.refs['astnode'+e.code.node.hashCode()] = e.doclet; // allow lookup from value => doclet
}
}
else if (node.type == Token.FUNCTION) {
e = {
id: 'astnode'+node.hashCode(), // the id of the COLON node
comment: String(node.jsDoc||'@undocumented'),
lineno: node.getLineno(),
filename: currentSourceName,
astnode: node,
code: aboutNode(node)
};
e.code.name = String(node.name) || '';
if ( isValidJsdoc(e.comment) ) {
currentParser.fire('symbolFound', e, currentParser);
}
if (e.doclet) {
currentParser.refs['astnode'+e.code.node.hashCode()] = e.doclet; // allow lookup from value => doclet
}
else if (!currentParser.refs['astnode'+e.code.node.hashCode()]) { // keep references to undocumented anonymous functions too as they might have scoped vars
currentParser.refs['astnode'+e.code.node.hashCode()] = {
longname: '<anonymous>',
meta: { code: e.code }
};
}
}
return true;
}
/** @private */
function parserFactory() {
var cx = Packages.org.mozilla.javascript.Context.getCurrentContext();
var ce = new Packages.org.mozilla.javascript.CompilerEnvirons();
ce.setRecordingComments(true);
ce.setRecordingLocalJsDocComments(true);
ce.setLanguageVersion(180);
ce.initFromContext(cx);
return new Packages.org.mozilla.javascript.Parser(ce, ce.getErrorReporter());
}
/**
* Attempts to find the name and type of the given node.
* @private
* @memberof module:src/parser.Parser
*/
function aboutNode(node) {
about = {};
if (node.type == Token.FUNCTION) {
about.name = '' + node.name;
about.type = 'function';
about.node = node;
return about;
}
if (node.type == Token.VAR || node.type == Token.LET || node.type == Token.CONST) {
about.name = nodeToString(node.target);
if (node.initializer) { // like var i = 0;
about.node = node.initializer;
about.value = nodeToString(about.node);
about.type = getTypeName(node.initializer);
}
else { // like var i;
about.node = node.target;
about.value = nodeToString(about.node);
about.type = 'undefined';
}
return about;
}
if (node.type === Token.ASSIGN || node.type === Token.COLON) {
about.name = nodeToString(node.left);
if (node.type === Token.COLON) {
// objlit keys with unsafe variable-name characters must be quoted
if (!/^[$_a-z][$_a-z0-9]*$/i.test(about.name) ) {
about.name = '"'+about.name.replace(/"/g, '\\"')+'"';
}
}
about.node = node.right;
about.value = nodeToString(about.node);
about.type = getTypeName(node.right);
return about;
}
// type 39 (NAME)
var string = nodeToString(node);
if (string) {
about.name = string;
return about;
}
return about;
}
/** @private
@memberof module:src/parser.Parser
*/
function nodeToString(node) {
var str;
if (!node) return;
if (node.type === Token.GETPROP) {
str = [nodeToString(node.target), node.property.string].join('.');
}
else if (node.type === Token.VAR) {
str = nodeToString(node.target)
}
else if (node.type === Token.NAME) {
str = node.string;
}
else if (node.type === Token.STRING) {
str = node.value;
}
else if (node.type === Token.NUMBER) {
str = node.value;
}
else if (node.type === Token.THIS) {
str = 'this';
}
else if (node.type === Token.GETELEM) {
str = node.toSource(); // like: Foo['Bar']
}
else {
str = getTypeName(node);
}
return '' + str;
};
/** @private
@memberof module:src/parser.Parser
*/
function getTypeName(node) {
var type = '';
if (node) {
type = ''+ Packages.org.mozilla.javascript.Token.typeToName(node.getType());
}
return type;
}
/** @private
@memberof module:src/parser.Parser
*/
function isValidJsdoc(commentSrc) {
return commentSrc.indexOf('/***') !== 0; /*** ignore comments that start with many stars ***/
}
})();
/**
Fired whenever the parser encounters a JSDoc comment in the current source code.
@event jsdocCommentFound
@memberof module:jsdoc/src/parser.Parser
@param {event} e
@param {string} e.comment The text content of the JSDoc comment
@param {number} e.lineno The line number associated with the found comment.
@param {string} e.filename The file name associated with the found comment.
*/

View File

@ -1,63 +0,0 @@
/**
@module jsdoc/src/scanner
@requires module:common/fs
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
var common = {
fs: require('common/fs'),
mixin: require('common/util').mixin,
events: require('common/events')
};
/**
@constructor
@mixes module:common.events
*/
exports.Scanner = function() {
}
common.mixin(exports.Scanner.prototype, common.events);
/**
Recursively searches the given searchPaths for js files.
@param {Array.<string>} searchPaths
@param {number} [depth=1]
@fires sourceFileFound
*/
exports.Scanner.prototype.scan = function(searchPaths, depth, includeMatch, excludeMatch) {
var filePaths = [],
that = this;
searchPaths = searchPaths || [];
depth = depth || 1;
searchPaths.forEach(function($) {
filePaths = filePaths.concat(common.fs.ls($, depth));
});
filePaths = filePaths.filter(function($) {
if (includeMatch && !includeMatch.test($)) {
return false
}
if (excludeMatch && excludeMatch.test($)) {
return false
}
return true;
});
filePaths = filePaths.filter(function($) {
var e = { fileName: $ };
that.fire('sourceFileFound', e);
return !e.defaultPrevented;
});
return filePaths;
}
})();

View File

@ -1,135 +0,0 @@
/**
@overview
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
/**
Functionality related to JSDoc tags.
@module jsdoc/tag
@requires jsdoc/tag/dictionary
@requires jsdoc/tag/validator
@requires jsdoc/tag/type
*/
(function() {
var jsdoc = {
tag: {
dictionary: require('jsdoc/tag/dictionary'),
validator: require('jsdoc/tag/validator'),
type: require('jsdoc/tag/type')
}
};
/**
Constructs a new tag object. Calls the tag validator.
@class
@classdesc Represents a single doclet tag.
@param {string} tagTitle
@param {string=} tagBody
@param {object=} meta
*/
exports.Tag = function(tagTitle, tagBody, meta) {
var tagDef = jsdoc.tag.dictionary.lookUp(tagTitle),
meta = meta || {};
this.originalTitle = trim(tagTitle);
/** The title part of the tag: @title text */
this.title = jsdoc.tag.dictionary.normalise( this.originalTitle );
/** The text part of the tag: @title text */
this.text = trim(tagBody, tagDef.keepsWhitespace);
if (this.text) {
if (tagDef.onTagText) {
this.text = tagDef.onTagText(this.text);
}
if (tagDef.canHaveType) {
/** The value propertiy represents the result of parsing the tag text. */
this.value = {};
var [
/*Array.<string>*/ typeNames,
/*any*/ remainingText,
/*?boolean*/ optional,
/*?boolean*/ nullable,
/*?boolean*/ variable
] = jsdoc.tag.type.parse(this.text);
if (typeNames.length) {
this.value.type = {
names: typeNames,
optional: optional,
nullable: nullable,
variable: variable
};
}
if (remainingText) {
if (tagDef.canHaveName) {
var [paramName, paramDesc, paramOptional, paramDefault]
= parseParamText(remainingText);
// note the dash is a special case: as a param name it means "no name"
if (paramName && paramName !== '-') { this.value.name = paramName; }
if (paramDesc) { this.value.description = paramDesc; }
if (paramOptional) { this.value.optional = paramOptional; }
if (paramDefault) { this.value.defaultvalue = paramDefault; }
}
else {
this.value.description = remainingText;
}
}
}
else {
this.value = this.text;
}
}
jsdoc.tag.validator.validate(this, meta);
}
function trim(text, newlines) {
if (!text) { return ''; }
if (newlines) {
return text.replace(/^[\n\r\f]+|[\n\r\f]+$/g, '');
}
else {
return text.replace(/^\s+|\s+$/g, '');
}
}
/**
Parse the parameter name and parameter desc from the tag text.
@private
@method parseParamText
@param {string} tagText
@returns {Array.<string, string, boolean, boolean>} [pname, pdesc, poptional, pdefault].
*/
function parseParamText(tagText) {
var pname, pdesc, poptional, pdefault;
// like: pname, pname pdesc, or name - pdesc
tagText.match(/^(\[[^\]]+\]|\S+)((?:\s*\-\s*|\s+)(\S[\s\S]*))?$/);
pname = RegExp.$1;
pdesc = RegExp.$3;
if ( /^\[\s*(.+?)\s*\]$/.test(pname) ) {
pname = RegExp.$1;
poptional = true;
if ( /^(.+?)\s*=\s*(.+)$/.test(pname) ) {
pname = RegExp.$1;
pdefault = RegExp.$2;
}
}
return [pname, pdesc, poptional, pdefault];
}
})();

View File

@ -1,73 +0,0 @@
/**
@overview
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
var _synonyms = {},
_definitions = {},
_namespaces = [];
function _TagDefinition(title, etc) {
etc = etc || {};
this.title = dictionary.normalise(title);
for (var p in etc) {
if (etc.hasOwnProperty(p)) {
this[p] = etc[p];
}
}
}
_TagDefinition.prototype.synonym = function(synonymName) {
_synonyms[synonymName.toLowerCase()] = this.title;
return this; // chainable
}
/** @exports jsdoc/tag/dictionary */
var dictionary = {
/** @function */
defineTag: function(title, opts) {
_definitions[title] = new _TagDefinition(title, opts);
if (opts.isNamespace) {
_namespaces.push(title);
}
return _definitions[title];
},
/** @function */
lookUp: function(title) {
title = dictionary.normalise(title);
if ( _definitions.hasOwnProperty(title) ) {
return _definitions[title];
}
return false;
},
/** @function */
isNamespace: function(kind) {
return ( ~ _namespaces.indexOf(kind) );
},
/** @function */
normalise: function(title) {
canonicalName = title.toLowerCase();
if ( _synonyms.hasOwnProperty(canonicalName) ) {
return _synonyms[canonicalName];
}
return canonicalName;
}
};
require('jsdoc/tag/dictionary/definitions').defineTags(dictionary);
module.exports = dictionary;
})();

View File

@ -1,538 +0,0 @@
/**
Define tags that are known in JSDoc.
@module jsdoc/tag/dictionary/definitions
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
/** Populate the given dictionary with all known JSDoc tag definitions.
@param {module:jsdoc/tag/dictionary} dictionary
*/
exports.defineTags = function(dictionary) {
dictionary.defineTag('access', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
// only valid values are private and protected, public is default
if ( /^(private|protected)$/i.test(tag.value) ) {
doclet.access = tag.value.toLowerCase();
}
else {
delete doclet.access;
}
}
});
dictionary.defineTag('alias', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.alias = tag.value;
}
});
dictionary.defineTag('lends', {
// mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.alias = tag.value || '<global>';
doclet.addTag('undocumented');
}
});
dictionary.defineTag('author', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.author = tag.value;
}
});
// I add on to that
dictionary.defineTag('augments', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.augment( firstWordOf(tag.value) );
}
})
.synonym('extends');
// that adds on to me
dictionary.defineTag('borrows', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
var [target, source] = parseBorrows(doclet, tag);
doclet.borrow(target, source);
}
})
.synonym('mixes');
dictionary.defineTag('class', {
onTagged: function(doclet, tag) {
doclet.addTag('kind', 'class');
// handle special case where both @class and @constructor tags exist in same doclet
if (tag.originalTitle === 'class') {
var looksLikeDesc = (tag.value || '').match(/\S+\s+\S+/); // multiple words after @class?
if ( looksLikeDesc || /@construct(s|or)\b/i.test(doclet.comment) ) {
doclet.classdesc = tag.value; // treat the @class tag as a @classdesc tag instead
return;
}
}
setDocletNameToValue(doclet, tag);
}
})
.synonym('constructor');
dictionary.defineTag('classdesc', {
onTagged: function(doclet, tag) {
doclet.classdesc = tag.value;
}
});
dictionary.defineTag('constant', {
canHaveType: true,
onTagged: function(doclet, tag) {
setDocletKindToTitle(doclet, tag);
setDocletNameToValue(doclet, tag);
if (tag.value && tag.value.type) {
doclet.type = tag.value.type;
}
}
})
.synonym('const');
dictionary.defineTag('copyright', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.copyright = tag.value;
}
});
dictionary.defineTag('constructs', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
var ownerClassName = firstWordOf(tag.value);
doclet.addTag('alias', ownerClassName);
doclet.addTag('kind', 'class');
}
});
dictionary.defineTag('defaultvalue', {
onTagged: function(doclet, tag) {
if (tag.value) {
doclet.defaultvalue = tag.value;
}
else if (doclet.meta && doclet.meta.code && typeof doclet.meta.code.value !== 'undefined') {
if (doclet.meta.code.type && /STRING|NUMBER|NAME|TRUE|FALSE/.test(doclet.meta.code.type)) {
doclet.defaultvalue = doclet.meta.code.value;
if (doclet.meta.code.type === 'STRING') {
// TODO: handle escaped quotes in values
doclet.defaultvalue = '"'+doclet.defaultvalue.replace(/"/g, '\\"')+'"'
}
if (doclet.defaultvalue === 'TRUE' || doclet.defaultvalue == 'FALSE') {
doclet.defaultvalue = doclet.defaultvalue.toLowerCase();
}
}
else if (doclet.meta.code.type === 'NULL') {
// TODO: handle escaped quotes in values
doclet.defaultvalue = 'null'
}
}
}
})
.synonym('default');
dictionary.defineTag('deprecated', {
// value is optional
onTagged: function(doclet, tag) {
doclet.deprecated = tag.value || true;
}
});
dictionary.defineTag('description', {
mustHaveValue: true
})
.synonym('desc');
dictionary.defineTag('event', {
onTagged: function(doclet, tag) {
setDocletKindToTitle(doclet, tag);
setDocletNameToValue(doclet, tag);
applyNamespace(doclet, tag);
}
});
dictionary.defineTag('example', {
keepsWhitespace: true,
mustHaveValue: true,
onTagged: function(doclet, tag) {
if (!doclet.examples) { doclet.examples = []; }
doclet.examples.push(tag.value);
}
});
dictionary.defineTag('exception', {
mustHaveValue: true,
canHaveType: true,
onTagged: function(doclet, tag) {
if (!doclet.exceptions) { doclet.exceptions = []; }
doclet.exceptions.push(tag.value);
if (tag.value && tag.value.type) {
doclet.type = tag.value.type;
}
}
})
.synonym('throws');
dictionary.defineTag('exports', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
var modName = firstWordOf(tag.value);
doclet.addTag('alias', modName);
doclet.addTag('kind', 'module');
}
});
dictionary.defineTag('file', {
onTagged: function(doclet, tag) {
setNameToFile(doclet, tag);
setDocletKindToTitle(doclet, tag);
setDocletDescriptionToValue(doclet, tag);
doclet.preserveName = true;
}
})
.synonym('fileoverview')
.synonym('overview');
dictionary.defineTag('fires', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
if (!doclet.fires) { doclet.fires = []; }
doclet.fires.push(tag.value);
}
});
dictionary.defineTag('function', {
onTagged: function(doclet, tag) {
setDocletKindToTitle(doclet, tag);
setDocletNameToValue(doclet, tag);
}
})
.synonym('method');
dictionary.defineTag('global', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.scope = 'global';
delete doclet.memberof;
}
});
dictionary.defineTag('ignore', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.ignore = true;
}
});
dictionary.defineTag('inner', {
onTagged: function(doclet, tag) {
setDocletScopeToTitle(doclet, tag);
}
});
dictionary.defineTag('instance', {
onTagged: function(doclet, tag) {
setDocletScopeToTitle(doclet, tag);
}
});
dictionary.defineTag('kind', {
mustHaveValue: true
});
dictionary.defineTag('license', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.license = tag.value;
}
});
dictionary.defineTag('memberof', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
setDocletMemberof(doclet, tag);
}
})
.synonym('member');
dictionary.defineTag('mixin', {
onTagged: function(doclet, tag) {
setDocletKindToTitle(doclet, tag);
setDocletNameToValue(doclet, tag);
}
});
dictionary.defineTag('module', {
canHaveType: true,
isNamespace: true,
onTagged: function(doclet, tag) {
setDocletKindToTitle(doclet, tag);
setDocletNameToValue(doclet, tag);
doclet.name || setDocletNameToFilename(doclet, tag);
if (tag.value && tag.value.type) {
doclet.type = tag.value.type;
}
}
});
dictionary.defineTag('name', {
mustHaveValue: true
});
dictionary.defineTag('namespace', {
canHaveType: true,
onTagged: function(doclet, tag) {
setDocletKindToTitle(doclet, tag);
setDocletNameToValue(doclet, tag);
if (tag.value && tag.value.type) {
doclet.type = tag.value.type;
}
}
});
dictionary.defineTag('param', {
mustHaveValue: true,
canHaveType: true,
canHaveName: true,
onTagged: function(doclet, tag) {
if (!doclet.params) { doclet.params = []; }
doclet.params.push(tag.value);
}
})
.synonym('argument')
.synonym('arg');
dictionary.defineTag('private', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.access = 'private';
}
});
dictionary.defineTag('property', {
canHaveType: true,
onTagged: function(doclet, tag) {
setDocletKindToTitle(doclet, tag);
setDocletNameToValue(doclet, tag);
if (tag.value && tag.value.type) {
doclet.type = tag.value.type;
}
}
});
dictionary.defineTag('protected', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.access = 'protected';
}
});
dictionary.defineTag('public', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
delete doclet.access; // public is default
}
});
// use this instead of old deprecated @final tag
dictionary.defineTag('readonly', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.readonly = true;
}
});
dictionary.defineTag('requires', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
var modName = firstWordOf(tag.value);
if (modName.indexOf('module:') !== 0) {
modName = 'module:'+modName;
}
if (!doclet.requires) { doclet.requires = []; }
doclet.requires.push(modName);
}
});
dictionary.defineTag('returns', {
mustHaveValue: true,
canHaveType: true,
onTagged: function(doclet, tag) {
if (!doclet.returns) { doclet.returns = []; }
doclet.returns.push(tag.value);
}
})
.synonym('return');
dictionary.defineTag('see', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
if (!doclet.see) { doclet.see = []; }
doclet.see.push(tag.value);
}
});
dictionary.defineTag('since', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.since = tag.value;
}
});
dictionary.defineTag('summary', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.summary = tag.value;
}
});
dictionary.defineTag('this', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
if (!doclet.see) { doclet.see = []; }
doclet['this'] = firstWordOf(tag.value);
}
});
dictionary.defineTag('type', {
mustHaveValue: true,
canHaveType: true,
onTagText: function(text) {
// any text must be formatted as a type, but for back compat braces are optional
if ( ! /^\{.+\}$/.test(text) ) {
text = '{ '+text+' }';
}
return text;
},
onTagged: function(doclet, tag) {
if (tag.value && tag.value.type) {
doclet.type = tag.value.type;
if (doclet.kind === 'function') doclet.addTag('returns', tag.text); // for backwards compatibility we allow @type for functions to imply return type
}
}
});
dictionary.defineTag('typedef', {
canHaveType: true,
canHaveName: true,
onTagged: function(doclet, tag) {
setDocletKindToTitle(doclet, tag);
if (tag.value) {
if (tag.value.name) {
doclet.addTag('name', tag.value.name);
}
if (tag.value.type) {
doclet.type = tag.value.type;
}
}
}
});
dictionary.defineTag('undocumented', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.undocumented = true;
doclet.comment = '';
}
});
dictionary.defineTag('variation', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.variation = tag.value;
}
});
dictionary.defineTag('version', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.version = tag.value;
}
});
}
/** @private */
function setDocletKindToTitle(doclet, tag) {
doclet.addTag( 'kind', tag.title );
}
function setDocletScopeToTitle(doclet, tag) {
doclet.addTag( 'scope', tag.title );
}
function setDocletNameToValue(doclet, tag) {
if (tag.value && tag.value.description) { // as in a long tag
doclet.addTag( 'name', tag.value.description);
}
else if (tag.text) { // or a short tag
doclet.addTag('name', tag.text);
}
}
function setDocletDescriptionToValue(doclet, tag) {
if (tag.value) {
doclet.addTag( 'description', tag.value );
}
}
function setNameToFile(doclet, tag) {
if (doclet.meta.filename) { doclet.addTag( 'name', 'file:'+doclet.meta.filename ); }
}
function setDocletMemberof(doclet, tag) {
doclet.setMemberof(tag.value);
}
function applyNamespace(doclet, tag) {
if (!doclet.name) return; // error?
//doclet.displayname = doclet.name;
doclet.longname = app.jsdoc.name.applyNamespace(doclet.name, tag.title)
}
function setDocletNameToFilename(doclet, tag) {
var name = doclet.meta.filename;
name = name.replace(/\.js$/i, '');
for (var i = 0, len = env.opts._.length; i < len; i++) {
if (name.indexOf(env.opts._[i]) === 0) {
name = name.replace(env.opts._[0], '');
break
}
}
doclet.name = name;
}
function parseBorrows(doclet, tag) {
var m = /^(\S+)(?:\s+as\s+(\S+))?$/.exec(tag.text);
if (m) {
if (m[1] && m[2]) {
return [ m[1], m[2] ];
}
else if (m[1]) {
return [ m[1] ];
}
}
}
function firstWordOf(string) {
var m = /^(\S+)/.exec(string);
if (m) { return m[1]; }
else { return ''; }
}
})();

View File

@ -1,113 +0,0 @@
/**
@module jsdoc/tag/type
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
/**
@param {string} tagValue
@returns {Array.<string>}
*/
exports.parse = function(tagValue) {
if (typeof tagValue !== 'string') { tagValue = ''; }
var type = '',
text = '',
count = 0,
optional,
nullable,
variable;
// type expressions start with '{'
if (tagValue[0] === '{') {
count++;
// find matching closer '}'
for (var i = 1, leni = tagValue.length; i < leni; i++) {
if (tagValue[i] === '\\') { i++; continue; } // backslash escapes the next character
if (tagValue[i] === '{') { count++; }
else if (tagValue[i] === '}') { count--; }
if (count === 0) {
type = trim(tagValue.slice(1, i))
.replace(/\\\{/g, '{') // unescape escaped curly braces
.replace(/\\\}/g, '}');
text = trim(tagValue.slice(i+1));
break;
}
}
}
if (type === '') { text = tagValue; }
[type, optional] = parseOptional(type);
[type, nullable] = parseNullable(type);
[type, variable] = parseVariable(type);
type = parseTypes(type); // make it into an array
return [type, text, optional, nullable, variable];
}
function parseOptional(type) {
var optional = null;
// {sometype=} means optional
if ( /(.+)=$/.test(type) ) {
type = RegExp.$1;
optional = true;
}
return [type, optional];
}
function parseNullable(type) {
var nullable = null;
// {?sometype} means nullable, {!sometype} means not-nullable
if ( /^([\?\!])(.+)$/.test(type) ) {
type = RegExp.$2;
nullable = (RegExp.$1 === '?')? true : false;
}
return [type, nullable];
}
function parseVariable(type) {
var variable = null;
// {...sometype} means variable number of that type
if ( /^(\.\.\.)(.+)$/.test(type) ) {
type = RegExp.$2;
variable = true;
}
return [type, variable];
}
function parseTypes(type) {
var types = [];
if ( ~type.indexOf('|') ) {
// remove optional parens, like: { ( string | number ) }
// see: http://code.google.com/closure/compiler/docs/js-for-compiler.html#types
if ( /^\s*\(\s*(.+)\s*\)\s*$/.test(type) ) {
type = RegExp.$1;
}
types = type.split(/\s*\|\s*/g);
}
else if (type) {
types = [type];
}
return types;
}
/** @private */
function trim(text) {
return text.replace(/^\s+|\s+$/g, '');
}
})();

View File

@ -1,52 +0,0 @@
/**
@module jsdoc/tag/validator
@requires jsdoc/tag/dictionary
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
var dictionary = require('jsdoc/tag/dictionary');
/**
Validate the given tag.
*/
exports.validate = function(tag, meta) {
var tagDef = dictionary.lookUp(tag.title);
if (!tagDef && !env.conf.tags.allowUnknownTags) {
throw new UnknownTagError(tag.title, meta);
}
if (!tag.text) {
if (tagDef.mustHaveValue) {
throw new TagValueRequiredError(tag.title, meta);
}
}
else {
if (tagDef.mustNotHaveValue) {
throw new TagValueNotPermittedError(tag.title, meta);
}
}
}
function UnknownTagError(tagName, meta) {
this.name = 'UnknownTagError';
this.message = 'The @' + tagName + ' tag is not a known tag. File: ' + meta.filename + ', Line: ' + meta.lineno + '\n' + meta.comment;
}
UnknownTagError.prototype = Error.prototype;
function TagValueRequiredError(tagName, meta) {
this.name = 'TagValueRequiredError';
this.message = 'The @' + tagName + ' tag requires a value. File: ' + meta.filename + ', Line: ' + meta.lineno + '\n' + meta.comment;
}
TagValueRequiredError.prototype = Error.prototype;
function TagValueNotPermittedError(tagName, message, meta) {
this.name = 'TagValueNotPermittedError';
this.message = 'The @' + tagName + ' tag does not permit a value: "' + message + '". File: ' + meta.filename + ', Line: ' + meta.lineno + '\n' + meta.comment;
}
TagValueNotPermittedError.prototype = Error.prototype;
})();

View File

@ -1,233 +0,0 @@
/**
* JSONSchema Validator - Validates JavaScript objects using JSON Schemas
* (http://www.json.com/json-schema-proposal/)
*
* Copyright (c) 2007 Kris Zyp SitePen (www.sitepen.com)
* Licensed under the MIT (MIT-LICENSE.txt) license.
To use the validator call JSONSchema.validate with an instance object and an optional schema object.
If a schema is provided, it will be used to validate. If the instance object refers to a schema (self-validating),
that schema will be used to validate and the schema parameter is not necessary (if both exist,
both validations will occur).
The validate method will return an array of validation errors. If there are no errors, then an
empty list will be returned. A validation error will have two properties:
"property" which indicates which property had the error
"message" which indicates what the error was
*/
// setup primitive classes to be JSON Schema types
String.type = "string";
Boolean.type = "boolean";
Number.type = "number";
exports.Integer = {type:"integer"};
Object.type = "object";
Array.type = "array";
Date.type = "string";
Date.format = "date-time";
exports.validate = function(/*Any*/instance,/*Object*/schema) {
// Summary:
// To use the validator call JSONSchema.validate with an instance object and an optional schema object.
// If a schema is provided, it will be used to validate. If the instance object refers to a schema (self-validating),
// that schema will be used to validate and the schema parameter is not necessary (if both exist,
// both validations will occur).
// The validate method will return an object with two properties:
// valid: A boolean indicating if the instance is valid by the schema
// errors: An array of validation errors. If there are no errors, then an
// empty list will be returned. A validation error will have two properties:
// property: which indicates which property had the error
// message: which indicates what the error was
//
return validate(instance,schema,false);
};
exports.checkPropertyChange = function(/*Any*/value,/*Object*/schema, /*String*/ property) {
// Summary:
// The checkPropertyChange method will check to see if an value can legally be in property with the given schema
// This is slightly different than the validate method in that it will fail if the schema is readonly and it will
// not check for self-validation, it is assumed that the passed in value is already internally valid.
// The checkPropertyChange method will return the same object type as validate, see JSONSchema.validate for
// information.
//
return validate(value,schema, property || "property");
};
var validate = exports._validate = function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) {
var errors = [];
// validate a value against a property definition
function checkProp(value, schema, path,i){
var l;
path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i;
function addError(message){
errors.push({property:path,message:message});
}
if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function') && !(schema && schema.type)){
if(typeof schema == 'function'){
if(!(value instanceof schema)){
addError("is not an instance of the class/constructor " + schema.name);
}
}else if(schema){
addError("Invalid schema/property definition " + schema);
}
return null;
}
if(_changing && schema.readonly){
addError("is a readonly field, it can not be changed");
}
if(schema['extends']){ // if it extends another schema, it must pass that schema as well
checkProp(value,schema['extends'],path,i);
}
// validate a value against a type definition
function checkType(type,value){
if(type){
if(typeof type == 'string' && type != 'any' &&
(type == 'null' ? value !== null : typeof value != type) &&
!(value instanceof Array && type == 'array') &&
!(type == 'integer' && value%1===0)){
return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}];
}
if(type instanceof Array){
var unionErrors=[];
for(var j = 0; j < type.length; j++){ // a union type
if(!(unionErrors=checkType(type[j],value)).length){
break;
}
}
if(unionErrors.length){
return unionErrors;
}
}else if(typeof type == 'object'){
var priorErrors = errors;
errors = [];
checkProp(value,type,path);
var theseErrors = errors;
errors = priorErrors;
return theseErrors;
}
}
return [];
}
if(value === undefined){
if(!schema.optional && !schema.get){
addError("is missing and it is not optional");
}
}else{
errors = errors.concat(checkType(schema.type,value));
if(schema.disallow && !checkType(schema.disallow,value).length){
addError(" disallowed value was matched");
}
if(value !== null){
if(value instanceof Array){
if(schema.items){
if(schema.items instanceof Array){
for(i=0,l=value.length; i<l; i++){
errors.concat(checkProp(value[i],schema.items[i],path,i));
}
}else{
for(i=0,l=value.length; i<l; i++){
errors.concat(checkProp(value[i],schema.items,path,i));
}
}
}
if(schema.minItems && value.length < schema.minItems){
addError("There must be a minimum of " + schema.minItems + " in the array");
}
if(schema.maxItems && value.length > schema.maxItems){
addError("There must be a maximum of " + schema.maxItems + " in the array");
}
}else if(schema.properties || schema.additionalProperties){
errors.concat(checkObj(value, schema.properties, path, schema.additionalProperties));
}
if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){
addError("does not match the regex pattern " + schema.pattern);
}
if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){
addError("may only be " + schema.maxLength + " characters long");
}
if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){
addError("must be at least " + schema.minLength + " characters long");
}
if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum &&
schema.minimum > value){
addError("must have a minimum value of " + schema.minimum);
}
if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum &&
schema.maximum < value){
addError("must have a maximum value of " + schema.maximum);
}
if(schema['enum']){
var enumer = schema['enum'];
l = enumer.length;
var found;
for(var j = 0; j < l; j++){
if(enumer[j]===value){
found=1;
break;
}
}
if(!found){
addError("does not have a value in the enumeration " + enumer.join(", "));
}
}
if(typeof schema.maxDecimal == 'number' &&
(value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){
addError("may only have " + schema.maxDecimal + " digits of decimal places");
}
}
}
return null;
}
// validate an object against a schema
function checkObj(instance,objTypeDef,path,additionalProp){
if(typeof objTypeDef =='object'){
if(typeof instance != 'object' || instance instanceof Array){
errors.push({property:path,message:"an object is required"});
}
for(var i in objTypeDef){
if(objTypeDef.hasOwnProperty(i) && !(i.charAt(0) == '_' && i.charAt(1) == '_')){
var value = instance[i];
var propDef = objTypeDef[i];
checkProp(value,propDef,path,i);
}
}
}
for(i in instance){
if(instance.hasOwnProperty(i) && !(i.charAt(0) == '_' && i.charAt(1) == '_') && objTypeDef && !objTypeDef[i] && additionalProp===false){
errors.push({property:path,message:(typeof value) + "The property " + i +
" is not defined in the schema and the schema does not allow additional properties"});
}
var requires = objTypeDef && objTypeDef[i] && objTypeDef[i].requires;
if(requires && !(requires in instance)){
errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"});
}
value = instance[i];
if(additionalProp && (!(objTypeDef && typeof objTypeDef == 'object') || !(i in objTypeDef))){
checkProp(value,additionalProp,path,i);
}
if(!_changing && value && value.$schema){
errors = errors.concat(checkProp(value,value.$schema,path,i));
}
}
return errors;
}
if(schema){
checkProp(instance,schema,'',_changing || '');
}
if(!_changing && instance && instance.$schema){
checkProp(instance,instance.$schema,'','');
}
return {valid:!errors.length,errors:errors};
};
exports.mustBeValid = function(result){
// summary:
// This checks to ensure that the result is valid and will throw an appropriate error message if it is not
// result: the result returned from checkPropertyChange or validate
if(!result.valid){
throw new TypeError(result.errors.map(function(error){return "for property " + error.property + ': ' + error.message;}).join(", \n"));
}
}
/* will add this later
newFromSchema : function() {
}
*/

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +0,0 @@
// By default, Underscore uses ERB-style template delimiters, change the
// following template settings to use alternative delimiters.
exports.settings = {
evaluate : /<%([\s\S]+?)%>/g,
interpolate : /<%=([\s\S]+?)%>/g
};
// JavaScript micro-templating, similar to John Resig's implementation.
// Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code.
exports.render = function(templateStr, data) {
var settings = exports.settings,
compiledTemplate,
renderFunction;
compiledTemplate = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
'with(data||{}){__p.push(\'' +
templateStr.replace(/\\/g, '\\\\')
.replace(/'/g, "\\'")
.replace(settings.interpolate, function(match, code) {
return "'," + code.replace(/\\'/g, "'") + ",'";
})
.replace(settings.evaluate || null, function(match, code) {
return "');" + code.replace(/\\'/g, "'")
.replace(/[\r\n\t]/g, ' ') + "__p.push('";
})
.replace(/\r/g, '\\r')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
+ "');}return __p.join('');";
renderFunction = new Function('data', compiledTemplate);
return data ? renderFunction(data) : renderFunction;
};

View File

@ -1,36 +0,0 @@
{
"name": "jsdoc",
"version": "3.0.0beta1",
"revision": "2011-04-13-0000",
"description": "An automatic documentation generator for javascript.",
"keywords": [ "documentation", "javascript" ],
"licenses": [
{
"type": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
],
"repositories": [
{
"type": "git",
"url": "git://github.com/micmath/jsdoc.git"
},
{
"type": "svn",
"url": "https://jsdoc.googlecode.com/svn/trunk"
}
],
"bugs": "http://code.google.com/p/jsdoc/issues/list",
"contributors" : [
{
"name": "Michael Mathews",
"email": "micmath@gmail.com"
}
],
"maintainers": [
{
"name": "Michael Mathews",
"email": "micmath@gmail.com"
}
]
}

View File

@ -1,18 +0,0 @@
/**
@overview Translate doclet descriptions from MarkDown into HTML.
*/
(function() {
var markdown = require('evilstreak/markdown');
app.jsdoc.parser.on('newDoclet', function(e) {
if (e.doclet.description) {
e.doclet.description = markdown.toHTML(e.doclet.description)
.replace( /&amp;/g, "&" ) // because markdown escapes these
.replace( /&lt;/g, "<" )
.replace( /&gt;/g, ">" );
}
});
})();

View File

@ -1,290 +0,0 @@
(function() {
var template = require('underscore/template'),
fs = require('fs');
template.settings.evaluate = /<\?js([\s\S]+?)\?>/g;
template.settings.interpolate = /<\?js=([\s\S]+?)\?>/g;
/**
@global
@param {TAFFY} data See <http://taffydb.com/>.
@param {object} opts
*/
publish = function(data, opts) {
var out = '',
containerTemplate = template.render(fs.read(BASEDIR + 'templates/default/tmpl/container.tmpl'));
function render(tmpl, partialData) {
var renderFunction = arguments.callee.cache[tmpl];
if (!renderFunction) {
renderFunction = arguments.callee.cache[tmpl] = template.render(fs.read(BASEDIR + 'templates/default/tmpl/'+tmpl));
}
partialData.render = arguments.callee;
partialData.find = find;
partialData.linkto = linkto;
partialData.htmlsafe = htmlsafe;
return renderFunction.call(partialData, partialData);
}
render.cache = {};
function find(spec) {
return data.get( data.find(spec) );
}
function htmlsafe(str) {
return str.replace(/</g, '&lt;');
}
function addSignatureParams(f) {
var pnames = [];
if (f.params) {
f.params.forEach(function(p) {
if (p.name && p.name.indexOf('.') === -1) {
if (p.optional) { pnames.push('['+p.name+']'); }
else { pnames.push(p.name); }
}
});
}
f.signature = (f.signature || '') + '('+pnames.join(', ')+')';
}
function generateAncestry(doc) {
var ancestors = [];
while (doc = doc.memberof) {
doc = data.get( data.find({longname: doc}) );
if (doc) { doc = doc[0]; }
if (!doc) break;
ancestors.unshift( linkto(doc.longname, doc.name) );
}
return ancestors;
}
function addSignatureReturns(f) {
var returnTypes = [];
if (f.returns) {
f.returns.forEach(function(r) {
if (r.type && r.type.names) {
returnTypes = r.type.names;
}
});
}
f.signature = (f.signature || '') + '<span class="type-signature">'+htmlsafe(returnTypes.length? ' &#8658; '+returnTypes.join('|') : '')+'</span>';
}
function addSignatureType(f) {
var types = [];
if (f.type && f.type.names) {
types = f.type.names;
}
f.signature = (f.signature || '') + '<span class="type-signature">'+htmlsafe(types.length? ' :'+types.join('|') : '')+'</span>';
}
function addAttribs(f) {
var attribs = [];
if (f.access && f.access !== 'public') {
attribs.push(f.access);
}
if (f.scope && f.scope !== 'instance') {
if (f.kind == 'function' || f.kind == 'property') attribs.push(f.scope);
}
if (f.readonly === true) {
if (f.kind == 'property') attribs.push('readonly');
}
f.attribs = '<span class="type-signature">'+htmlsafe(attribs.length? '<'+attribs.join(', ')+'> ' : '')+'</span>';
}
data.remove({undocumented: true});
var packageInfo = (data.get( data.find({kind: 'package'}) ) || []) [0];
function renderLinks(text) {
text = text.replace(/\{@link (\S+)\}/g, function(match, longname) {
var link = linkto(longname);
return link;
});
return text;
}
data.forEach(function(doclet) {
doclet.signature = '';
doclet.attribs = '';
if (doclet.kind === 'function' || doclet.kind === 'class') {
addSignatureParams(doclet);
addSignatureReturns(doclet);
addAttribs(doclet);
}
if (doclet.kind === 'property') {
addSignatureType(doclet);
addAttribs(doclet)
}
if (doclet.examples) {
doclet.examples = doclet.examples.map(function(example) {
var caption, code;
if (example.match(/^\s*<caption>([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) {
caption = RegExp.$1;
code = RegExp.$3;
}
return {
caption: caption || '',
code: code || example
};
});
}
});
data.orderBy(['longname', 'version', 'since']);
// kinds of containers
var globals = data.get( data.find({kind: ['property', 'function'], memberof: {isUndefined: true}}) ),
modules = data.get( data.find({kind: 'module'}) ),
namespaces = data.get( data.find({kind: 'namespace'}) );
var outdir = opts.destination;
if (packageInfo) {
outdir += '/' + packageInfo.name + '/' + packageInfo.version + '/';
}
fs.mkPath(outdir);
// copy static files to outdir
var fromDir = BASEDIR + 'templates/default/static',
staticFiles = fs.ls(fromDir, 3);
staticFiles.forEach(function(fileName) {
var toDir = fs.toDir(fileName.replace(fromDir, outdir));
fs.mkPath(toDir);
fs.copyFile(fileName, toDir);
});
function linkto(longname, linktext) {
var url = longnameToUrl[longname];
return url? '<a href="'+url+'">'+(linktext || longname)+'</a>' : (linktext || longname);
}
var containers= ['class', 'module', 'namespace'],
urlToLongname = {},
longnameToUrl = {};
data.forEach(function(doclet) {
if (containers.indexOf(doclet.kind) < 0) {
var longname = doclet.longname,
urlSafe = ('global' || doclet.memberof).replace(/[^$a-z0-9._-]/gi, '_'), // TODO handle name collisions
url = urlSafe + '.html#'+doclet.name;
}
else {
var longname = doclet.longname,
urlSafe = longname.replace(/[^$a-z0-9._-]/gi, '_'), // TODO handle name collisions
url = urlSafe + '.html';
}
// bidirectional lookups: url <=> longname
urlToLongname[urlSafe] = longname;
longnameToUrl[longname] = url;
});
// do this after the urls have all been generated
data.forEach(function(doclet) {
if (doclet.classdesc) doclet.classdesc = renderLinks(doclet.classdesc);
if (doclet.description) doclet.description = renderLinks(doclet.description);
doclet.ancestors = generateAncestry(doclet);
});
var nav = '',
seen = {};
var moduleNames = data.get( data.find({kind: 'module'}) );
if (moduleNames.length) {
nav = nav + '<h3>Modules</h3><ul>';
moduleNames.forEach(function(m) {
if ( !seen.hasOwnProperty(m.longname) ) nav += '<li>'+linkto(m.longname, m.name)+'</li>';
seen[m.longname] = true;
});
nav = nav + '</ul>';
}
var namespaceNames = data.get( data.find({kind: 'namespace'}) );
if (namespaceNames.length) {
nav = nav + '<h3>Namespaces</h3><ul>';
namespaceNames.forEach(function(n) {
if ( !seen.hasOwnProperty(n.longname) ) nav += '<li>'+linkto(n.longname, n.name)+'</li>';
seen[n.longname] = true;
});
nav = nav + '</ul>';
}
var classNames = data.get( data.find({kind: 'class'}) );
if (classNames.length) {
nav = nav + '<h3>Classes</h3><ul>';
classNames.forEach(function(c) {
if ( !seen.hasOwnProperty(c.longname) ) nav += '<li>'+linkto(c.longname, c.name)+'</li>';
seen[c.longname] = true;
});
nav = nav + '</ul>';
}
var globalNames = data.get( data.find({kind: ['property', 'function'], 'memberof': {'isUndefined': true}}) );
if (globalNames.length) {
nav = nav + '<h3>Global</h3><ul>';
globalNames.forEach(function(g) {
if ( !seen.hasOwnProperty(g.longname) ) nav += '<li>'+linkto(g.longname, g.name)+'</li>';
seen[g.longname] = true;
});
nav = nav + '</ul>';
}
for (var longname in longnameToUrl) {
var classes = data.get( data.find({kind: 'class', longname: longname}) );
if (classes.length) generate('Class: '+classes[0].name, classes, longnameToUrl[longname]);
var modules = data.get( data.find({kind: 'module', longname: longname}) );
if (modules.length) generate('Module: '+modules[0].name, modules, longnameToUrl[longname]);
var namespaces = data.get( data.find({kind: 'namespace', longname: longname}) );
if (namespaces.length) generate('Namespace: '+namespaces[0].name, namespaces, longnameToUrl[longname]);
}
if (globals.length) generate('Global', [{kind: 'globalobj'}], 'global.html');
function generate(title, docs, filename) {
var data = {
title: title,
docs: docs,
nav: nav,
// helpers
render: render,
find: find,
linkto: linkto,
htmlsafe: htmlsafe
};
var path = outdir + '/' + filename,
html = containerTemplate.call(data, data);
fs.write(path, html)
}
}
})();

View File

@ -1,231 +0,0 @@
body
{
font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Verdana, Tahoma, sans-serif;
font-size: 13px;
color: #000;
}
a {
color: #444;
}
a:visited {
color: #444;
}
a:active {
color: #444;
}
header
{
display: block;
/*border-bottom: 1px solid #ddd;*/
padding: 6px 4px;
}
.class-description {
font-style: italic;
font-family: Palatino, 'Palatino Linotype', serif;
font-size: 18px;
}
#main {
float: left;
width: 100%;
}
section
{
display: block;
background-color: #fff;
padding: 12px 24px;
border-bottom: 1px solid #ccc;
margin-right: 240px;
}
sup {
color: #aaa;
}
nav
{
display: block;
float: left;
margin-left: -230px;
margin-top: 28px;
width: 220px;
border-left: 1px solid #ccc;
padding-left: 9px;
}
nav ul {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
font-size: 13px;
line-height: 17px;
padding:0;
margin:0;
list-style-type:none;
}
nav h3 {
margin-top: 12px;
}
nav li {
margin-top: 6px;
}
nav a {
color: #5C5954;
}
nav a:visited {
color: #5C5954;
}
nav a:active {
color: #5C5954;
}
footer {
display: block;
padding: 6px;
margin-top: 12px;
font-style: italic;
font-size: 11px;
}
h1
{
font-size: 32px;
font-weight: bold;
letter-spacing: -0.03em;
margin: 6px 0 9px 0;
}
h2
{
font-size: 22px;
font-weight: bold;
letter-spacing: -0.03em;
margin: 6px 0 3px 0;
}
h3
{
font-size: 20px;
font-weight: bold;
letter-spacing: -0.03em;
margin-top: 16px;
margin: 6px 0 3px 0;
}
h4
{
font-size: 18px;
font-weight: bold;
letter-spacing: -0.03em;
margin-top: 16px;
margin: 18px 0 3px 0;
color: #A35A00;
}
h5
{
font-size: 16px;
font-weight: bold;
letter-spacing: -0.03em;
margin: 8px 0 3px -16px;
}
h6
{
font-size: 13px;
letter-spacing: -0.03em;
margin: 6px 0 3px 0;
font-style: italic;
}
.important
{
font-weight: bold;
color: #950B02;
}
.yes-def {
text-indent: -1000px;
}
.type-signature {
color: #aaa;
}
.details dt { width:100px; float:left;}
.details dd { margin-left: 100px; }
.description { margin-left: -16px; }
.code-caption
{
font-style: italic;
font-family: Palatino, 'Palatino Linotype', serif;
font-size: 14px;
margin: 0;
}
.sh_sourceCode
{
border: 1px solid #ddd;
width: 80%;
}
.sh_sourceCode code
{
font-family: Consolas, 'Lucida Console', Monaco, monospace;
font-size: 12px;
line-height: 18px;
display: block;
padding: 4px 12px;
margin: 0;
background-color: #fff;
color: #000;
border-left: 3px #ddd solid;
}
.params
{
border-spacing: 0;
border: 0;
border-collapse: collapse;
}
.params .name { color: #1C02A3; }
.params td, .params th
{
border: 1px solid #ddd;
margin: 0px;
text-align: left;
vertical-align: top;
padding: 4px 6px;
display: table-cell;
}
.params thead tr
{
background-color: #ddd;
font-weight: bold;
}
.params .params thead tr
{
background-color: #fff;
font-weight: bold;
}
.params th { border-right: 1px solid #aaa; }
.params thead .last { border-right: 1px solid #ddd; }

View File

@ -1,150 +0,0 @@
.sh_sourceCode {
background-color: #ffffff;
color: #000000;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_keyword {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_type {
color: #a52a2a;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_string {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_regexp {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_specialchar {
color: #2e8b57;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_comment {
color: #000000;
font-weight: normal;
font-style: italic;
}
.sh_sourceCode .sh_number {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_preproc {
color: #27408b;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_symbol {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_function {
color: #000000;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_cbracket {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_url {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_date {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_time {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_file {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_ip {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_name {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_variable {
color: #dda0dd;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_oldfile {
color: #2e8b57;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_newfile {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_difflines {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_selector {
color: #dda0dd;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_property {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_value {
color: #006400;
font-weight: normal;
font-style: normal;
}

View File

@ -1,202 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: <?js= title ?></title>
<script src="http://shjs.sourceforge.net/sh_main.min.js"> </script>
<script src="http://shjs.sourceforge.net/lang/sh_javascript.min.js"> </script>
<link type="text/css" rel="stylesheet" href="styles/node-dark.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title"><?js= title ?></h1>
<?js
docs.forEach(function(doc, i) {
?>
<section>
<header>
<?js
print('<h2>');
if (doc.ancestors && doc.ancestors.length) {
print('<span class="ancestors">'+doc.ancestors.join(' » ')+'</span>');
print(' » '+doc.name);
}
else {
print(doc.name)
}
if (doc.variation) {
print('<sup>'+doc.variation+'</sup>');
}
print('</h2>');
if (doc.classdesc) {
print('<p class="class-description">'+doc.classdesc+'</p>');
}
?>
</header>
<article>
<?js
if (doc.kind === 'class') {
print(render('method.tmpl', doc));
}
else {
if (doc.description) {
print('<p class="description">' + doc.description + '</p>');
}
print(render('details.tmpl', doc));
if (doc.examples && doc.examples.length) {
print('<h3>Example' + (doc.examples.length > 1? 's':'') + '</h3>');
print( render('examples.tmpl', doc.examples) );
}
}
?>
<?js
if (doc.augments && doc.augments.length) {
?>
<h3 class="subsection-title">Extends</h3>
<ul><?js
doc.augments.forEach(function(a) {
?>
<li><?js= linkto(a, a) ?></li>
<?js
});
?></ul>
<?js
}
?>
<?js
if (doc.requires && doc.requires.length) {
?>
<h3 class="subsection-title">Requires</h3>
<ul><?js
doc.requires.forEach(function(r) {
?>
<li><?js= linkto(r, r) ?></li>
<?js
});
?></ul>
<?js
}
?>
<?js
var classes = find({kind: 'class', memberof: doc.longname});
if (doc.kind !== 'globalobj' && classes && classes.length) {
?>
<h3 class="subsection-title">Classes</h3>
<dl><?js
classes.forEach(function(c) {
?>
<dt><?js= linkto(c.longname, c.name) ?></dt>
<dd><?js if (c.summary) print(c.summary); ?></dd>
<?js
});
?></dl>
<?js } ?>
<?js
var namespaces = find({kind: 'namespace', memberof: doc.longname});
if (doc.kind !== 'globalobj' && namespaces && namespaces.length) {
?>
<h3 class="subsection-title">Namespaces</h3>
<dl><?js
namespaces.forEach(function(n) {
?>
<dt><a href="namespaces.html#<?js= n.longname ?>"><?js= linkto(n.longname, n.name) ?></a></dt>
<dd><?js if (n.summary) print(n.summary); ?></dd>
<?js
});
?></dl>
<?js } ?>
<?js
var properties = find({kind: 'property', memberof: doc.longname});
if (title === 'Globals') {
properties = find({kind: 'property', memberof: {isUndefined: true}});
}
if (properties && properties.length && properties.forEach) {
?>
<h3 class="subsection-title">Properties</h3>
<dl><?js
properties.forEach(function(p) {
print(render('properties.tmpl', p));
});
?></dl>
<?js } ?>
<?js
var methods = find({kind: 'function', memberof: doc.longname});
if (title === 'Globals') {
methods = find({kind: 'function', memberof: {isUndefined: true}});
}
if (methods && methods.length && methods.forEach) {
?>
<h3 class="subsection-title">Methods</h3>
<dl><?js
methods.forEach(function(m) {
print(render('method.tmpl', m));
});
?></dl>
<?js } ?>
<?js
var events = find({kind: 'event', memberof: doc.longname});
if (events && events.length && events.forEach) {
?>
<h3 class="subsection-title">Events</h3>
<dl><?js
events.forEach(function(e) {
print(render('method.tmpl', e));
});
?></dl>
<?js } ?>
</article>
</section>
<?js }); ?>
</div>
<nav>
<?js= nav ?>
</nav>
<br clear="both">
<footer>
Documentation generated by JSDoc 3 on <?js= (new Date()) ?>
</footer>
<script> sh_highlightDocument(); </script>
</body>
</html>

View File

@ -1,55 +0,0 @@
<dl class="details">
<?js if (this.version) {?>
<dt>Version:</dt>
<dd><?js= version ?></dd>
<?js } ?>
<?js if (this.since) {?>
<dt>Since:</dt>
<dd><?js= since ?></dd>
<?js } ?>
<?js if (this.deprecated) { ?>
<dt class="important">Deprecated<?js
if (this.deprecated === true) print('</dt><dd class="yes-def">Yes</dd>');
else print(':</dt><dd>'+this.deprecated+'</dd>');
?>
<?js } ?>
<?js if (this.author) {?>
<dt>Author:</dt>
<dd><?js= author ?></dd>
<?js } ?>
<?js if (this.copyright) {?>
<dt>Copyright:</dt>
<dd><?js= copyright ?></dd>
<?js } ?>
<?js if (this.license) {?>
<dt>License:</dt>
<dd><?js= license ?></dd>
<?js } ?>
<?js if (this.defaultvalue) {?>
<dt>Default Value:</dt>
<dd><?js= this.defaultvalue ?></dd>
<?js } ?>
<?js if (this.meta) {?>
<dt>Source:</dt>
<dd><?js= meta.filename ?>, line <?js= meta.lineno ?></dd>
<?js } ?>
<?js if (this.see && see.length) {?>
<dt>See:</dt>
<dd>
<ul><?js
see.forEach(function(s) {
print('<li>'+linkto(s)+'</li>');
});
?></ul>
</dd>
<?js } ?>
</dl>

View File

@ -1,2 +0,0 @@
<pre><code><?js= this ?></code></pre>

View File

@ -1,10 +0,0 @@
<?js
this.forEach(function(example) {
if (example.caption) {
?>
<p class="code-caption"><?js= example.caption ?></p>
<?js } ?>
<pre class="sh_javascript"><code><?js= example.code ?></code></pre>
<?js
});
?>

View File

@ -1,28 +0,0 @@
<li>
<?js if (this.description) { ?>
<div class="param-desc">
<?js= description ?>
</div>
<?js } ?>
<?js
if (typeof this.names !== 'undefined') {
?>
<dl>
<dt>
Type
</dt>
<dd>
<?js
this.names.forEach(function(name, i) {
?>
<span class="param-type"><?js= name ?></span> <?js if (i < this.names.length-1) print('|'); ?>
<?js
});
?>
</dd>
</dl>
<?js
}
?>
</li>

View File

@ -1,3 +0,0 @@
<li>
<?js= this ?>
</li>

View File

@ -1,73 +0,0 @@
<dt id="<?js= longname ?>">
<h4 class="name" id="<?js= name ?>"><?js= this.attribs + (kind == 'class'? 'new ':'') + name + this.signature ?></h4>
<?js if (this.summary) { ?>
<p class="summary"><?js= summary ?></p>
<?js } ?>
</dt>
<dd>
<?js if (this.description) { ?>
<p class="description">
<?js= this.description ?>
</p>
<?js } ?>
<?js print(render('details.tmpl', this)); ?>
<?js
if (this['this']) {
print('<h5>This:</h5>');
print( '<ul><li>'+linkto(this['this'], this['this'])+'</li></ul>' );
}
?>
<?js
if (this.params && params.length) {
print('<h5>Parameters:</h5>');
print( render('params.tmpl', params) );
}
?>
<?js if (this.fires && fires.length) { ?>
<h5>Fires:</h5>
<ul><?js
fires.forEach(function(f) {
print( render('fires.tmpl', f) );
});
?></ul>
<?js } ?>
<?js if (this.exceptions && exceptions.length) { ?>
<h5>Throws:</h5>
<ul><?js
exceptions.forEach(function(e) {
print( render('exceptions.tmpl', e) );
});
?></ul>
<?js } ?>
<?js
if (this.returns && returns.length) {
var rdesc = [];
returns.forEach(function(r) {
if (r.description) rdesc.push(r.description);
});
if (rdesc.length) {
print('<h5>Returns:</h5>');
print('<p>'+rdesc.join('</p><p>')+'</p>');
}
}
?>
<?js
if (this.examples && examples.length) {
print('<h5>Example' + (examples.length > 1? 's':'') + '</h5>');
print( render('examples.tmpl', examples) );
}
?>
</dd>

View File

@ -1,115 +0,0 @@
<?js
var params = this;
/* sort subparams under their parent params (like opts.classname) */
var parentParam = null;
params.forEach(function(param, i) {
if (!param) { return; }
if ( parentParam && param.name.indexOf(parentParam.name + '.') === 0 ) {
param.name = param.name.substr(parentParam.name.length+1);
parentParam.subparams = parentParam.subparams || [];
parentParam.subparams.push(param);
params[i] = null;
}
else {
parentParam = param;
}
});
/* determine if we need extra columns, "attributes" and "default" */
params.hasAttributes = false;
params.hasDefault = false;
params.hasName = false;
params.forEach(function(param) {
if (!param) { return; }
if (param.optional || param.nullable) {
params.hasAttributes = true;
}
if (param.name) {
params.hasName = true;
}
if (typeof param.defaultvalue !== 'undefined') {
params.hasDefault = true;
}
});
?>
<table class="params">
<thead>
<tr>
<?js if (params.hasName) {?>
<th>Name</th>
<?js } ?>
<th>Type</th>
<?js if (params.hasAttributes) {?>
<th>Argument</th>
<?js } ?>
<?js if (params.hasDefault) {?>
<th>Default</th>
<?js } ?>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<?js
params.forEach(function(param) {
if (!param) { return; }
?>
<tr>
<?js if (params.hasName) {?>
<td class="name"><code><?js= param.name ?></code></td>
<?js } ?>
<td class="type">
<?js
if (param.type && param.type.names) {
param.type.names.forEach(function(name, i) {
print( linkto(name, htmlsafe(name)) );
if (i < param.type.names.length-1) { print(' | '); }
});
}
?>
</td>
<?js if (params.hasAttributes) {?>
<td class="attributes">
<?js
if (param.optional) {
print( '&lt;optional><br>' );
}
if (param.nullable) {
print( '&lt;nullable><br>' );
}
?>
</td>
<?js } ?>
<?js if (params.hasDefault) {?>
<td class="default">
<?js
if (typeof param.defaultvalue !== 'undefined') {
print( htmlsafe(param.defaultvalue) );
}
?>
</td>
<?js } ?>
<td class="description last"><?js= param.description ?><?js if (param.subparams) {
print( '<h6>Properties</h6>' + render('params.tmpl', param.subparams) );
}?></td>
</tr>
<?js }); ?>
</tbody>
</table>

View File

@ -1,24 +0,0 @@
<dt id="property:<?js= longname ?>">
<h4 class="name"><?js= this.attribs + name + this.signature ?></h4>
<?js if (this.summary) { ?>
<p class="summary"><?js= summary ?></p>
<?js } ?>
</dt>
<dd>
<?js if (this.description) { ?>
<p class="description">
<?js= this.description ?>
</p>
<?js } ?>
<?js print(render('details.tmpl', this)); ?>
<?js
if (this.examples && examples.length) {
print('<h5>Example' + (examples.length > 1? 's':'') + '</h5>');
print( render('examples.tmpl', examples) );
}
?>
</dd>

View File

@ -1,31 +0,0 @@
<li>
<?js if (this.description) { ?>
<div class="param-desc">
<?js= description ?>
</div>
<?js } ?>
<?js
if (this.type) {
with(type) {
?>
<dl>
<dt>
Type
</dt>
<dd>
<?js
names.forEach(function(name, i) {
?>
<span class="param-type"><?js= htmlsafe(name) ?></span> <?js if (i < names.length-1) print('|'); ?>
<?js
});
?>
</dd>
</dl>
<?js
}
}
?>
</li>

View File

@ -1,189 +0,0 @@
/**
@overview Builds a tree-like JSON string from the doclet data.
@version 0.0.1
*/
(function() {
/**
@global
@param {TAFFY} data
@param {object} opts
*/
publish = function(data, opts) {
var root = {},
docs;
data.remove({undocumented: true});
docs = data.get(); // <-- an array of Doclet objects
graft(root, docs);
if (opts.destination === 'console') {
if (opts.query && opts.query.format === 'xml') {
var xml = require('goessner/json2xml');
print( '<jsdoc>\n' + xml.convert(root) + '\n</jsdoc>' );
}
else {
dump(root);
}
}
else {
print('The only -d destination option currently supported is "console"!');
}
}
function graft(parentNode, childNodes, parentLongname, parentName) {
childNodes
.filter(function (element) {
return (element.memberof === parentLongname);
})
.forEach(function (element, i) {
//print((i+1)+': '+element.kind+' '+element.longname+' ('+element.name+')');
if (element.kind === 'namespace') {
if (! parentNode.namespaces) {
parentNode.namespaces = { };
}
var thisNamespace = parentNode.namespaces[element.name] = {
'name': element.name,
'description': element.description || '',
'access': element.access || ''
};
graft(thisNamespace, childNodes, element.longname, element.name);
}
else if (element.kind === 'mixin') {
if (! parentNode.mixins) {
parentNode.mixins = { };
}
var thisMixin = parentNode.mixins[element.name] = {
'name': element.name,
'description': element.description || '',
'access': element.access || ''
};
graft(thisMixin, childNodes, element.longname, element.name);
}
else if (element.kind === 'function') {
if (! parentNode.functions) {
parentNode.functions = { };
}
var thisFunction = parentNode.functions[element.name] = {
'name': element.name,
'access': element.access || '',
'description': element.description || '',
'parameters': [ ]
};
if (element.returns) {
parentNode.functions[element.name].returns = {
'type': element.returns.type? (element.returns.type.names.length === 1? element.returns.type.names[0] : element.returns.type.names) : '',
'description': element.returns.description || ''
};
}
if (element.params) {
for (var i = 0, len = element.params.length; i < len; i++) {
thisFunction.parameters.push({
'name': element.params[i].name,
'type': element.params[i].type? (element.params[i].type.names.length === 1? element.params[i].type.names[0] : element.params[i].type.names) : '',
'description': element.params[i].description || '',
'default': element.params[i].defaultvalue || '',
'optional': typeof element.params[i].optional === 'boolean'? element.params[i].optional : '',
'nullable': typeof element.params[i].nullable === 'boolean'? element.params[i].nullable : ''
});
}
}
}
else if (element.kind === 'property') {
if (! parentNode.properties) {
parentNode.properties = { };
}
parentNode.properties[element.name] = {
'name': element.name,
'access': element.access || '',
'description': element.description || '',
'type': element.type? (element.type.length === 1? element.type[0] : element.type) : ''
};
}
else if (element.kind === 'event') {
if (! parentNode.events) {
parentNode.events = { };
}
var thisEvent = parentNode.events[element.name] = {
'name': element.name,
'access': element.access || '',
'description': element.description || '',
'parameters': [
]
};
if (element.returns) {
parentNode.events[element.name].returns = {
'type': element.returns.type? (element.returns.type.names.length === 1? element.returns.type.names[0] : element.returns.type.names) : '',
'description': element.returns.description || ''
};
}
if (element.params) {
for (var i = 0, len = element.params.length; i < len; i++) {
thisEvent.parameters.push({
'name': element.params[i].name,
'type': element.params[i].type? (element.params[i].type.names.length === 1? element.params[i].type.names[0] : element.params[i].type.names) : '',
'description': element.params[i].description || '',
'default': element.params[i].defaultvalue || '',
'optional': typeof element.params[i].optional === 'boolean'? element.params[i].optional : '',
'nullable': typeof element.params[i].nullable === 'boolean'? element.params[i].nullable : ''
});
}
}
}
else if (element.kind === 'class') {
if (! parentNode.classes) {
parentNode.classes = { };
}
var thisClass = parentNode.classes[element.name] = {
'name': element.name,
'description': element.classdesc || '',
'extends': element.augments || [],
'access': element.access || '',
'fires': element.fires || '',
'constructor': {
'name': element.name,
'description': element.description || '',
'parameters': [
]
}
};
if (element.params) {
for (var i = 0, len = element.params.length; i < len; i++) {
thisClass.constructor.parameters.push({
'name': element.params[i].name,
'type': element.params[i].type? (element.params[i].type.names.length === 1? element.params[i].type.names[0] : element.params[i].type.names) : '',
'description': element.params[i].description || '',
'default': element.params[i].defaultvalue || '',
'optional': typeof element.params[i].optional === 'boolean'? element.params[i].optional : '',
'nullable': typeof element.params[i].nullable === 'boolean'? element.params[i].nullable : ''
});
}
}
graft(thisClass, childNodes, element.longname, element.name);
}
});
}
})();

View File

@ -1,29 +0,0 @@
/** @constructor */
function Thingy() {
/** @access private */
var foo = 0;
/** @access protected */
this._bar = 1;
/** @access public */
this.pez = 2;
}
// same as...
/** @constructor */
function OtherThingy() {
/** @private */
var foo = 0;
/** @protected */
this._bar = 1;
/** @public */
this.pez = 2;
}

View File

@ -1,13 +0,0 @@
var myObject = (function() {
/** Give x another name.
@alias myObject
@namespace
*/
var x = {
/** document me */
myProperty: 'foo'
}
return x;
})();

View File

@ -1,10 +0,0 @@
(function() {
/** @alias ns.Myclass# */
var x = {
/** document me */
myProperty: 'foo'
}
return x;
})();

View File

@ -1,12 +0,0 @@
Klass('trackr.CookieManager',
/** @class
@alias trackr.CookieManager
@param {object} kv
*/
function(kv) {
/** document me */
this.value = kv;
}
);

View File

@ -1,20 +0,0 @@
/** @class */
function Asset() {
this._name = '';
}
/**
*
* Set the value of the name property.
* @param {string} newName
*
*//**
*
* Get the value of the name property.
* @returns {string}
*
*/
Asset.prototype.name = function(newName) {
if (newName) { this._name = newName; }
else { return this._name; }
}

View File

@ -1,14 +0,0 @@
/**
* @constructor
*/
function Foo() {
}
/**
* @extends Foo
*/
function Bar() {
}

View File

@ -1,6 +0,0 @@
/** @constructor
@author Michael Mathews <micmath@gmail.com>
*/
function Thingy() {
}

View File

@ -1,14 +0,0 @@
/** @namespace
@borrows trstr as trim
*/
var util = {
"trim": trstr
};
/**
Remove whitespace from around a string.
@param {string} str
*/
function trstr(str) {
}

View File

@ -1,21 +0,0 @@
/** @namespace
@borrows rtrim
*/
var str = {
rtrim: util.rtrim
};
/** @namespace
@borrows rtrim
*/
var util = {
rtrim: rtrim
};
/**
Remove whitespace from the right side of a string.
@param {string} str
*/
function rtrim(str) {
}

View File

@ -1,12 +0,0 @@
/**
Describe the Ticker class here.
@class
*/
var Ticker = function() {
};
/**
Describe the NewsSource class here.
@class NewsSource
*/

View File

@ -1,15 +0,0 @@
/**
Describe your constructor function here.
@class Describe your class here.
@constructor
@param {string} url
@throws MalformedURL
*/
function Feed(url) {
}
/**
Document your method here.
*/
Feed.prototype.refresh = function() {
}

View File

@ -1,19 +0,0 @@
Classify('TextBlock', {
/**
Document your constructor function here.
@constructs TextBlock
@classdesc Describe your class here
@param {object} opts
@throws MissingNode
*/
construct: function(node, opts) {
},
/**
Document your method here.
@memberof TextBlock#
*/
align: function() {
}
});

View File

@ -1,16 +0,0 @@
Classify('Menu',
/**
@constructs Menu
@param items
*/
function (items) {
},
{
/**
@memberof Menu#
*/
show: function(){
}
}
);

View File

@ -1,26 +0,0 @@
/**
A class that represents a person.
@class
*/
var Person = Class.create({
/**
@constructs Person
@param {string} name
*/
initialize: function(name) {
/** The name of the person. */
this.name = name;
},
/**
@memberof Person#
@param {string} message
*/
say: function(message) {
/** The person's message. */
this.message = message;
}
});

View File

@ -1,6 +0,0 @@
/** @constructor
@copyright (c) 2011 Michael Mathews
*/
function Thingy() {
}

View File

@ -1,34 +0,0 @@
/**
@default
*/
var request = null;
/**
@default
*/
var response = 'ok';
/**
@default
*/
var rcode = 200;
/**
@default
*/
var rvalid = true;
/**
@default
*/
var rerrored = false;
/**
@default the parent window
*/
var win = getParentWindow();
/**
@default
*/
var header = getHeaders(request);

View File

@ -1,11 +0,0 @@
/** @deprecated
*/
function foo() {
}
/** @deprecated since version 2.0
*/
function bar() {
}

View File

@ -1,20 +0,0 @@
/**
@throws {InvalidArgumentException}
*/
function foo(x) {
}
/**
@exception Will throw an error if argument is null.
*/
function bar(x) {
}
/**
@exception {DivideByZero} Argument x must be non-zero.
*/
function pez(x) {
}

View File

@ -1,15 +0,0 @@
/**
* An example of a server-side JavaScript module.
* @module hello/world
* @example
* var g = require('hello/world').sayHello('Gracie');
*/
/**
* Generate a greeting.
* @param {string} [subject="world"] To whom we greet.
* @returns {string}
*/
exports.sayHello = function(subject) {
return 'Hello ' + (subject || 'World');
};

View File

@ -1,20 +0,0 @@
define(function () {
/**
A module representing a shirt.
@exports my/shirt
@version 1.0
*/
var shirt = {
/** A property of the module. */
color: "black",
/** @constructor */
Turtleneck: function(size) {
/** A property of the class. */
this.size = size;
}
};
return shirt;
});

View File

@ -1,18 +0,0 @@
define(
["my/buttons"],
function () {
/**
A module representing a coat.
@exports my/coat
@requires my/buttons
@version 1.0
*/
var myModule = function(wool) {
/** document me */
this.wool = wool;
}
return myModule;
}
);

View File

@ -1,22 +0,0 @@
define(
/**
Utility functions to ease working with DOM elements.
@exports html/utils
*/
function () {
var exports = {
/** Get the value of a property on an element. */
getStyleProperty: function(element, propertyName) {
// ...
}
};
/** Determine if an element is in the document head. */
exports.isInHead = function(element) {
// ...
}
return exports;
}
);

View File

@ -1,6 +0,0 @@
/**
* @overview This is a file doclet.
*/
function ignoreMe() {
}

View File

@ -1,16 +0,0 @@
/**
@global
@constructor
*/
window.Bar = new Function('', a, b, c);
(function() {
/** @global */
var foo;
foo = 'hello foo';
this.foo = foo;
}).apply(window);

View File

@ -1,6 +0,0 @@
/**
@ignore
*/
function foo(x) {
}

View File

@ -1,7 +0,0 @@
function sendMessage(text) {
/** document me */
var encoding = 'utf8';
/** document me */
function encrypt(){}
}

View File

@ -1,18 +0,0 @@
/** @constructor */
function Message(to) {
var headers = {},
response;
/** document me */
headers.to = to;
(function() {
/** document me */
response.code = '200';
/** document me */
headers.from = '';
})()
}

View File

@ -1,19 +0,0 @@
/** @constructor */
function Message(to) {
var headers = {};
/** document me */
headers.to = to;
(function() {
var headers = {
/** document me */
cache: {}
};
/** document me */
headers.from = '';
})()
}

View File

@ -1,24 +0,0 @@
/** @namespace */
var constructor = {
/** document me */
toString: function(){}
};
/** @namespace */
var prototye = {
/** document me */
valueOf: function(){}
}
/**
This is Object
@namespace Object
*/
/**
This is Object.hasOwnProperty
@method Object.hasOwnProperty
*/
// NOTE: you can't document a prototype of an object in JSDoc -- seriously, you just can't

View File

@ -1,16 +0,0 @@
/** @class */
var Person = makeClass(
/** @lends Person# */
{
/** Set up initial values. */
initialize: function(name) {
/** The name of the person. */
this.name = name;
},
/** Speak a message. */
say: function(message) {
return this.name + " says: " + message;
}
}
);

View File

@ -1,18 +0,0 @@
var Person = makeClass(
/** @lends Person# */
{
/** Construct a Person.
@constructs Person
*/
initialize: function(name) {
/** The name of the person. */
this.name = name;
},
/** Speak a message. */
say: function(message) {
return this.name + " says: " + message;
}
}
);

View File

@ -1,14 +0,0 @@
declare({
globals: /** @lends */ {
/** document me */
'test': function() { },
/** @namespace */
'test1': {
/** document me */
'test2': function() { }
}
}
});

View File

@ -1,11 +0,0 @@
/** @constructor
@member mathlib
*/
function Data() {
/** @property */
this.point = {};
}
/** @namespace */
mathlib = {Data: Data};

View File

@ -1,10 +0,0 @@
create(
'Observable',
{
/** @memberof Observable */
cache: [],
/** @memberof Observable.prototype */
publish: function(msg) {}
}
);

View File

@ -1,5 +0,0 @@
/** @module */
define({
property: "foo",
method: function() {}
});

View File

@ -1,5 +0,0 @@
/** @module my/module/name */
define({
property: "foo",
method: function() {}
});

View File

@ -1,21 +0,0 @@
/**
My test module.
@module my/module
*/
define(function() {
/**
@undocumented
@alias module:my/module
*/
var mod = {
/** Document a property. */
myProperty: "foo",
/** Document a method. */
myMethod: function() {}
};
return mod;
});

View File

@ -1,11 +0,0 @@
/**
* @module bookshelf
*/
/**
* @class
*/
this.Book = function(title) {
/** document me */
this.title = title;
}

View File

@ -1,9 +0,0 @@
/** @module color/mixer */
module.exports = {
/** Blend two colors together. */
blend: function(color1, color2) { }
}
/** Darken a color by the given shade. */
exports.darken = function(color, shade) { }

View File

@ -1,8 +0,0 @@
/** document me */
var tools = {
/** document me */
serialiser: {
/** document me */
value: ''
}
};

View File

@ -1,8 +0,0 @@
/** document me */
var position = {
axis: {
/** document me */
x: 0,
y: 0
}
};

View File

@ -1,41 +0,0 @@
/**
* @param { String | Array<String>} targetName The name (or names) of what to find.
*/
function find(targetName) {
}
/**
* @param {function} callback
*/
function bind(callback) {
}
/**
* @param {function}
*/
function unbind(callback) {
}
/**
* @param id The id of the element.
*/
function getElement(id) {
}
/**
* @param ... Two or more elements.
*/
function combine() {
}
/**
* @param delimiter - What to split on.
*/
function split(delimiter) {
}
/**
* @param - If true make the commit atomic.
*/
function commit(atomic) {
}

View File

@ -1,11 +0,0 @@
/**
* @constructor
* @private
*/
function Foo() {
/** document me */
this.bar = 1;
}

View File

@ -1,9 +0,0 @@
/**
An automated documentation generator for JavaScript.
@project JSDoc
@version 3.0.0
@copyright 2011 (c) Michael Mathews <micmath@gmail.com>
@license Apache Version 2 <http://www.apache.org/licenses/LICENSE-2.0>
*/
function blah(url) {
}

View File

@ -1,19 +0,0 @@
/** @namespace */
var chat = {};
/**
@namespace
*/
chat["#channel"] = {};
/**
@property
@type {boolean}
@defaultvalue
*/
chat["#channel"].open = true;
/**
@event chat."#channel"."op:announce-motd"
*/

Some files were not shown because too many files have changed in this diff Show More