diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index ba2d2fb9..00000000 --- a/LICENSE.md +++ /dev/null @@ -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 -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 - -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 \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 8cb8c36c..00000000 --- a/README.md +++ /dev/null @@ -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: - - -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: (under development) -JSDoc User's Group: -Subversion Mirror: -Project Annoncements: - -License -------- - -JSDoc 3 is copyright (c) 2011 Michael Mathews - -See file "LICENSE.md" in this distribution for more details about -terms of use. \ No newline at end of file diff --git a/build-files/build.properties b/build-files/build.properties deleted file mode 100644 index ecaaae15..00000000 --- a/build-files/build.properties +++ /dev/null @@ -1,2 +0,0 @@ -app.name=jsdoc -app.version=3.0.0beta1 diff --git a/build-files/java/classes/js.jar b/build-files/java/classes/js.jar deleted file mode 100644 index 64d9e3af..00000000 Binary files a/build-files/java/classes/js.jar and /dev/null differ diff --git a/build-files/java/classes/sqlitejdbc-v054.jar b/build-files/java/classes/sqlitejdbc-v054.jar deleted file mode 100644 index 180de267..00000000 Binary files a/build-files/java/classes/sqlitejdbc-v054.jar and /dev/null differ diff --git a/build-files/java/src/Run.java b/build-files/java/src/Run.java deleted file mode 100644 index 37222cfb..00000000 --- a/build-files/java/src/Run.java +++ /dev/null @@ -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 - LICENSE: Apache License 2.0 - See file 'LICENSE.md' in this project. - USAGE: java -jar run.jar - */ - -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 ab = new ArrayList(a.length + b.length); - Collections.addAll(ab, a); - Collections.addAll(ab, b); - return ab.toArray(new String[] {}); - } -} diff --git a/build-files/templates/package.json b/build-files/templates/package.json deleted file mode 100644 index 3a39d8d9..00000000 --- a/build-files/templates/package.json +++ /dev/null @@ -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" - } - ] -} diff --git a/build.xml b/build.xml deleted file mode 100644 index 7e2edd03..00000000 --- a/build.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/changes.md b/changes.md deleted file mode 100644 index e69de29b..00000000 diff --git a/conf.json b/conf.json deleted file mode 100644 index 4978ae7f..00000000 --- a/conf.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "tags": { - "allowUnknownTags": true - }, - - "source": { - "includePattern": ".+\\.js(doc)?$", - "excludePattern": "(^|\\/)_" - }, - - "plugins": [ - ] - -} \ No newline at end of file diff --git a/jsdoc b/jsdoc deleted file mode 100755 index 0ccd48d0..00000000 --- a/jsdoc +++ /dev/null @@ -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` \ No newline at end of file diff --git a/main.js b/main.js deleted file mode 100644 index a837c8f3..00000000 --- a/main.js +++ /dev/null @@ -1,273 +0,0 @@ -/** - * @project jsdoc - * @author Michael Mathews - * @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 - */ -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? - } - } -} \ No newline at end of file diff --git a/modules/common/args.js b/modules/common/args.js deleted file mode 100644 index 6bb7a399..00000000 --- a/modules/common/args.js +++ /dev/null @@ -1,140 +0,0 @@ -/** - Parse the command line arguments. - @module common/args - @author Michael Mathews - @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 += ' '; - } - - help += ' ' + option.helpText + '\n'; - } - - return help; - }; - - /** - Get the options. - @param {Array.} 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; - } -})(); \ No newline at end of file diff --git a/modules/common/assert.js b/modules/common/assert.js deleted file mode 100644 index a693dfbc..00000000 --- a/modules/common/assert.js +++ /dev/null @@ -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;}}; \ No newline at end of file diff --git a/modules/common/dumper.js b/modules/common/dumper.js deleted file mode 100644 index b7a094d9..00000000 --- a/modules/common/dumper.js +++ /dev/null @@ -1,158 +0,0 @@ -/** - Recursively print out all names and values in a data structure. - @module common/dumper - @author Michael Mathews - @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 += ',\n' - } - else if ( isRegExp(object) ) { - output += ',\n' - } - else if ( isDate(object) ) { - output += ',\n' - } - else if ( isFunction(object) ) { - output += ',\n'; - } - else if ( isArray(object) ) { - if ( seen.has(object) ) { - output += ',\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 += ',\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'); - } - -})(); \ No newline at end of file diff --git a/modules/common/events.js b/modules/common/events.js deleted file mode 100644 index d2e9c500..00000000 --- a/modules/common/events.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - Functions related to events. Designed to be mixed into other classes. - @exports common/events - @author Michael Mathews - @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]; - } - } -}; \ No newline at end of file diff --git a/modules/common/fs.js b/modules/common/fs.js deleted file mode 100644 index 04f67182..00000000 --- a/modules/common/fs.js +++ /dev/null @@ -1,180 +0,0 @@ -/** - Functions related to interaction with the filesystem. - @module common/fs - @author Michael Mathews - @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); - } - -})(); - diff --git a/modules/common/query.js b/modules/common/query.js deleted file mode 100644 index 075f8985..00000000 --- a/modules/common/query.js +++ /dev/null @@ -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, ' ') ); - } - }; -})(); \ No newline at end of file diff --git a/modules/common/sqlite.js b/modules/common/sqlite.js deleted file mode 100644 index 7bc9f97a..00000000 --- a/modules/common/sqlite.js +++ /dev/null @@ -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; -} diff --git a/modules/common/util.js b/modules/common/util.js deleted file mode 100644 index 1b57ee34..00000000 --- a/modules/common/util.js +++ /dev/null @@ -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; -}; \ No newline at end of file diff --git a/modules/evilstreak/markdown.js b/modules/evilstreak/markdown.js deleted file mode 100644 index cdfbeb65..00000000 --- a/modules/evilstreak/markdown.js +++ /dev/null @@ -1,1446 +0,0 @@ -// Released under MIT license -// Copyright (c) 2009-2010 Dominic Baggott -// Copyright (c) 2009-2010 Ash Berlin - -(function( expose ) { - -/** - * class Markdown - * - * Markdown processing in Javascript done right. We have very particular views - * on what constitutes 'right' which include: - * - * - produces well-formed HTML (this means that em and strong nesting is - * important) - * - * - has an intermediate representation to allow processing of parsed data (We - * in fact have two, both as [JsonML]: a markdown tree and an HTML tree). - * - * - is easily extensible to add new dialects without having to rewrite the - * entire parsing mechanics - * - * - has a good test suite - * - * This implementation fulfills all of these (except that the test suite could - * do with expanding to automatically run all the fixtures from other Markdown - * implementations.) - * - * ##### Intermediate Representation - * - * *TODO* Talk about this :) Its JsonML, but document the node names we use. - * - * [JsonML]: http://jsonml.org/ "JSON Markup Language" - **/ -var Markdown = expose.Markdown = function Markdown(dialect) { - switch (typeof dialect) { - case "undefined": - this.dialect = Markdown.dialects.Gruber; - break; - case "object": - this.dialect = dialect; - break; - default: - if (dialect in Markdown.dialects) { - this.dialect = Markdown.dialects[dialect]; - } - else { - throw new Error("Unknown Markdown dialect '" + String(dialect) + "'"); - } - break; - } - this.em_state = []; - this.strong_state = []; - this.debug_indent = ""; -} - -/** - * parse( markdown, [dialect] ) -> JsonML - * - markdown (String): markdown string to parse - * - dialect (String | Dialect): the dialect to use, defaults to gruber - * - * Parse `markdown` and return a markdown document as a Markdown.JsonML tree. - **/ -expose.parse = function( source, dialect ) { - // dialect will default if undefined - var md = new Markdown( dialect ); - return md.toTree( source ); -} - -/** - * toHTML( markdown ) -> String - * toHTML( md_tree ) -> String - * - markdown (String): markdown string to parse - * - md_tree (Markdown.JsonML): parsed markdown tree - * - * Take markdown (either as a string or as a JsonML tree) and run it through - * [[toHTMLTree]] then turn it into a well-formated HTML fragment. - **/ -expose.toHTML = function toHTML( source ) { - var input = expose.toHTMLTree( source ); - - return expose.renderJsonML( input ); -} - -/** - * toHTMLTree( markdown, [dialect] ) -> JsonML - * toHTMLTree( md_tree ) -> JsonML - * - markdown (String): markdown string to parse - * - dialect (String | Dialect): the dialect to use, defaults to gruber - * - md_tree (Markdown.JsonML): parsed markdown tree - * - * Turn markdown into HTML, represented as a JsonML tree. If a string is given - * to this function, it is first parsed into a markdown tree by calling - * [[parse]]. - **/ -expose.toHTMLTree = function toHTMLTree( input, dialect ) { - // convert string input to an MD tree - if ( typeof input ==="string" ) input = this.parse( input, dialect ); - - // Now convert the MD tree to an HTML tree - - // remove references from the tree - var attrs = extract_attr( input ), - refs = {}; - - if ( attrs && attrs.references ) { - refs = attrs.references; - } - - var html = convert_tree_to_html( input, refs ); - merge_text_nodes( html ); - return html; -} - -var mk_block = Markdown.mk_block = function(block, trail, line) { - // Be helpful for default case in tests. - if ( arguments.length == 1 ) trail = "\n\n"; - - var s = new String(block); - s.trailing = trail; - // To make it clear its not just a string - s.toSource = function() { - return "Markdown.mk_block( " + - uneval(block) + - ", " + - uneval(trail) + - ", " + - uneval(line) + - " )" - } - - if (line != undefined) - s.lineNumber = line; - - return s; -} - -function count_lines( str ) { - var n = 0, i = -1;; - while ( ( i = str.indexOf('\n', i+1) ) != -1) n++; - return n; -} - -// Internal - split source into rough blocks -Markdown.prototype.split_blocks = function splitBlocks( input, startLine ) { - // [\s\S] matches _anything_ (newline or space) - var re = /([\s\S]+?)($|\n(?:\s*\n|$)+)/g, - blocks = [], - m; - - var line_no = 1; - - if ( ( m = (/^(\s*\n)/)(input) ) != null ) { - // skip (but count) leading blank lines - line_no += count_lines( m[0] ); - re.lastIndex = m[0].length; - } - - while ( ( m = re(input) ) != null ) { - blocks.push( mk_block( m[1], m[2], line_no ) ); - line_no += count_lines( m[0] ); - } - - return blocks; -} - -/** - * Markdown#processBlock( block, next ) -> undefined | [ JsonML, ... ] - * - block (String): the block to process - * - next (Array): the following blocks - * - * Process `block` and return an array of JsonML nodes representing `block`. - * - * It does this by asking each block level function in the dialect to process - * the block until one can. Succesful handling is indicated by returning an - * array (with zero or more JsonML nodes), failure by a false value. - * - * Blocks handlers are responsible for calling [[Markdown#processInline]] - * themselves as appropriate. - * - * If the blocks were split incorrectly or adjacent blocks need collapsing you - * can adjust `next` in place using shift/splice etc. - * - * If any of this default behaviour is not right for the dialect, you can - * define a `__call__` method on the dialect that will get invoked to handle - * the block processing. - */ -Markdown.prototype.processBlock = function processBlock( block, next ) { - var cbs = this.dialect.block, - ord = cbs.__order__; - - if ( "__call__" in cbs ) { - return cvs.__call__.call(this, block, next); - } - - for ( var i = 0; i < ord.length; i++ ) { - //D:this.debug( "Testing", ord[i] ); - var res = cbs[ ord[i] ].call( this, block, next ); - if ( res ) { - //D:this.debug(" matched"); - if ( !res instanceof Array || ( res.length > 0 && !( res[0] instanceof Array ) ) ) - this.debug(ord[i], "didn't return a proper array"); - //D:this.debug( "" ); - return res; - } - } - - // Uhoh! no match! Should we throw an error? - return []; -} - -Markdown.prototype.processInline = function processInline( block ) { - return this.dialect.inline.__call__.call( this, String( block ) ); -} - -/** - * Markdown#toTree( source ) -> JsonML - * - source (String): markdown source to parse - * - * Parse `source` into a JsonML tree representing the markdown document. - **/ -// custom_tree means set this.tree to `custom_tree` and restore old value on return -Markdown.prototype.toTree = function toTree( source, custom_root ) { - var blocks = source instanceof Array - ? source - : this.split_blocks( source ); - - // Make tree a member variable so its easier to mess with in extensions - var old_tree = this.tree; - try { - this.tree = custom_root || this.tree || [ "markdown" ]; - - blocks: - while ( blocks.length ) { - var b = this.processBlock( blocks.shift(), blocks ); - - // Reference blocks and the like won't return any content - if ( !b.length ) continue blocks; - - this.tree.push.apply( this.tree, b ); - } - return this.tree; - } - finally { - if ( custom_root ) - this.tree = old_tree; - } - -} - -// Noop by default -Markdown.prototype.debug = function () { - var args = Array.prototype.slice.call( arguments); - args.unshift(this.debug_indent); - print.apply( print, args ); -} - -Markdown.prototype.loop_re_over_block = function( re, block, cb ) { - // Dont use /g regexps with this - var m, - b = block.valueOf(); - - while ( b.length && (m = re(b) ) != null) { - b = b.substr( m[0].length ); - cb.call(this, m); - } - return b; -} - -/** - * Markdown.dialects - * - * Namespace of built-in dialects. - **/ -Markdown.dialects = {}; - -/** - * Markdown.dialects.Gruber - * - * The default dialect that follows the rules set out by John Gruber's - * markdown.pl as closely as possible. Well actually we follow the behaviour of - * that script which in some places is not exactly what the syntax web page - * says. - **/ -Markdown.dialects.Gruber = { - block: { - atxHeader: function atxHeader( block, next ) { - var m = block.match( /^(#{1,6})\s*(.*?)\s*#*\s*(?:\n|$)/ ); - - if ( !m ) return undefined; - - var header = [ "header", { level: m[ 1 ].length }, m[ 2 ] ]; - - if ( m[0].length < block.length ) - next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) ); - - return [ header ]; - }, - - setextHeader: function setextHeader( block, next ) { - var m = block.match( /^(.*)\n([-=])\2\2+(?:\n|$)/ ); - - if ( !m ) return undefined; - - var level = ( m[ 2 ] === "=" ) ? 1 : 2; - var header = [ "header", { level : level }, m[ 1 ] ]; - - if ( m[0].length < block.length ) - next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) ); - - return [ header ]; - }, - - code: function code( block, next ) { - // | Foo - // |bar - // should be a code block followed by a paragraph. Fun - // - // There might also be adjacent code block to merge. - - var ret = [], - re = /^(?: {0,3}\t| {4})(.*)\n?/, - lines; - - // 4 spaces + content - var m = block.match( re ); - - if ( !m ) return undefined; - - block_search: - do { - // Now pull out the rest of the lines - var b = this.loop_re_over_block( - re, block.valueOf(), function( m ) { ret.push( m[1] ) } ); - - if (b.length) { - // Case alluded to in first comment. push it back on as a new block - next.unshift( mk_block(b, block.trailing) ); - break block_search; - } - else if (next.length) { - // Check the next block - it might be code too - var m = next[0].match( re ); - - if ( !m ) break block_search; - - // Pull how how many blanks lines follow - minus two to account for .join - ret.push ( block.trailing.replace(/[^\n]/g, '').substring(2) ); - - block = next.shift(); - } - else - break block_search; - } while (true); - - return [ [ "code_block", ret.join("\n") ] ]; - }, - - horizRule: function horizRule( block, next ) { - // this needs to find any hr in the block to handle abutting blocks - var m = block.match( /^(?:([\s\S]*?)\n)?[ \t]*([-_*])(?:[ \t]*\2){2,}[ \t]*(?:\n([\s\S]*))?$/ ); - - if ( !m ) { - return undefined; - } - - var jsonml = [ [ "hr" ] ]; - - // if there's a leading abutting block, process it - if ( m[ 1 ] ) { - jsonml.unshift.apply( jsonml, this.processBlock( m[ 1 ], [] ) ); - } - - // if there's a trailing abutting block, stick it into next - if ( m[ 3 ] ) { - next.unshift( mk_block( m[ 3 ] ) ); - } - - return jsonml; - }, - - // There are two types of lists. Tight and loose. Tight lists have no whitespace - // between the items (and result in text just in the
  • ) and loose lists, - // which have an empty line between list items, resulting in (one or more) - // paragraphs inside the
  • . - // - // There are all sorts weird edge cases about the original markdown.pl's - // handling of lists: - // - // * Nested lists are supposed to be indented by four chars per level. But - // if they aren't, you can get a nested list by indenting by less than - // four so long as the indent doesn't match an indent of an existing list - // item in the 'nest stack'. - // - // * The type of the list (bullet or number) is controlled just by the - // first item at the indent. Subsequent changes are ignored unless they - // are for nested lists - // - lists: (function( ) { - // Use a closure to hide a few variables. - var any_list = "[*+-]|\\d\\.", - bullet_list = /[*+-]/, - number_list = /\d+\./, - // Capture leading indent as it matters for determining nested lists. - is_list_re = new RegExp( "^( {0,3})(" + any_list + ")[ \t]+" ), - indent_re = "(?: {0,3}\\t| {4})"; - - // TODO: Cache this regexp for certain depths. - // Create a regexp suitable for matching an li for a given stack depth - function regex_for_depth( depth ) { - - return new RegExp( - // m[1] = indent, m[2] = list_type - "(?:^(" + indent_re + "{0," + depth + "} {0,3})(" + any_list + ")\\s+)|" + - // m[3] = cont - "(^" + indent_re + "{0," + (depth-1) + "}[ ]{0,4})" - ); - } - function expand_tab( input ) { - return input.replace( / {0,3}\t/g, " " ); - } - - // Add inline content `inline` to `li`. inline comes from processInline - // so is an array of content - function add(li, loose, inline, nl) { - if (loose) { - li.push( [ "para" ].concat(inline) ); - return; - } - // Hmmm, should this be any block level element or just paras? - var add_to = li[li.length -1] instanceof Array && li[li.length - 1][0] == "para" - ? li[li.length -1] - : li; - - // If there is already some content in this list, add the new line in - if (nl && li.length > 1) inline.unshift(nl); - - for (var i=0; i < inline.length; i++) { - var what = inline[i], - is_str = typeof what == "string"; - if (is_str && add_to.length > 1 && typeof add_to[add_to.length-1] == "string" ) - { - add_to[ add_to.length-1 ] += what; - } - else { - add_to.push( what ); - } - } - } - - // contained means have an indent greater than the current one. On - // *every* line in the block - function get_contained_blocks( depth, blocks ) { - - var re = new RegExp( "^(" + indent_re + "{" + depth + "}.*?\\n?)*$" ), - replace = new RegExp("^" + indent_re + "{" + depth + "}", "gm"), - ret = []; - - while ( blocks.length > 0 ) { - if ( re( blocks[0] ) ) { - var b = blocks.shift(), - // Now remove that indent - x = b.replace( replace, ""); - - ret.push( mk_block( x, b.trailing, b.lineNumber ) ); - } - break; - } - return ret; - } - - // passed to stack.forEach to turn list items up the stack into paras - function paragraphify(s, i, stack) { - var list = s.list; - var last_li = list[list.length-1]; - - if (last_li[1] instanceof Array && last_li[1][0] == "para") { - return; - } - if (i+1 == stack.length) { - // Last stack frame - // Keep the same array, but replace the contents - last_li.push( ["para"].concat( last_li.splice(1) ) ); - } - else { - var sublist = last_li.pop(); - last_li.push( ["para"].concat( last_li.splice(1) ), sublist ); - } - } - - // The matcher function - return function( block, next ) { - var m = block.match( is_list_re ); - if ( !m ) return undefined; - - function make_list( m ) { - var list = bullet_list( m[2] ) - ? ["bulletlist"] - : ["numberlist"]; - - stack.push( { list: list, indent: m[1] } ); - return list; - } - - - var stack = [], // Stack of lists for nesting. - list = make_list( m ), - last_li, - loose = false, - ret = [ stack[0].list ]; - - // Loop to search over block looking for inner block elements and loose lists - loose_search: - while( true ) { - // Split into lines preserving new lines at end of line - var lines = block.split( /(?=\n)/ ); - - // We have to grab all lines for a li and call processInline on them - // once as there are some inline things that can span lines. - var li_accumulate = ""; - - // Loop over the lines in this block looking for tight lists. - tight_search: - for (var line_no=0; line_no < lines.length; line_no++) { - var nl = "", - l = lines[line_no].replace(/^\n/, function(n) { nl = n; return "" }); - - // TODO: really should cache this - var line_re = regex_for_depth( stack.length ); - - m = l.match( line_re ); - //print( "line:", uneval(l), "\nline match:", uneval(m) ); - - // We have a list item - if ( m[1] !== undefined ) { - // Process the previous list item, if any - if ( li_accumulate.length ) { - add( last_li, loose, this.processInline( li_accumulate ), nl ); - // Loose mode will have been dealt with. Reset it - loose = false; - li_accumulate = ""; - } - - m[1] = expand_tab( m[1] ); - var wanted_depth = Math.floor(m[1].length/4)+1; - //print( "want:", wanted_depth, "stack:", stack.length); - if ( wanted_depth > stack.length ) { - // Deep enough for a nested list outright - //print ( "new nested list" ); - list = make_list( m ); - last_li.push( list ); - last_li = list[1] = [ "listitem" ]; - } - else { - // We aren't deep enough to be strictly a new level. This is - // where Md.pl goes nuts. If the indent matches a level in the - // stack, put it there, else put it one deeper then the - // wanted_depth deserves. - var found = stack.some(function(s, i) { - if ( s.indent != m[1] ) return false; - list = s.list; // Found the level we want - stack.splice(i+1); // Remove the others - //print("found"); - return true; // And stop looping - }); - - if (!found) { - //print("not found. l:", uneval(l)); - wanted_depth++; - if (wanted_depth <= stack.length) { - stack.splice(wanted_depth); - //print("Desired depth now", wanted_depth, "stack:", stack.length); - list = stack[wanted_depth-1].list; - //print("list:", uneval(list) ); - } - else { - //print ("made new stack for messy indent"); - list = make_list(m); - last_li.push(list); - } - } - - //print( uneval(list), "last", list === stack[stack.length-1].list ); - last_li = [ "listitem" ]; - list.push(last_li); - } // end depth of shenegains - nl = ""; - } - - // Add content - if (l.length > m[0].length) { - li_accumulate += nl + l.substr( m[0].length ); - } - } // tight_search - - if ( li_accumulate.length ) { - add( last_li, loose, this.processInline( li_accumulate ), nl ); - // Loose mode will have been dealt with. Reset it - loose = false; - li_accumulate = ""; - } - - // Look at the next block - we might have a loose list. Or an extra - // paragraph for the current li - var contained = get_contained_blocks( stack.length, next ); - - // Deal with code blocks or properly nested lists - if (contained.length > 0) { - // Make sure all listitems up the stack are paragraphs - stack.forEach( paragraphify, this ); - - last_li.push.apply( last_li, this.toTree( contained, [] ) ); - } - - var next_block = next[0] && next[0].valueOf() || ""; - - if ( next_block.match(is_list_re) || next_block.match( /^ / ) ) { - block = next.shift(); - - // Check for an HR following a list: features/lists/hr_abutting - var hr = this.dialect.block.horizRule( block, next ); - - if (hr) { - ret.push.apply(ret, hr); - break; - } - - // Make sure all listitems up the stack are paragraphs - stack.forEach( paragraphify , this ); - - loose = true; - continue loose_search; - } - break; - } // loose_search - - return ret; - } - })(), - - blockquote: function blockquote( block, next ) { - if ( !block.match( /^>/m ) ) - return undefined; - - var jsonml = []; - - // separate out the leading abutting block, if any - if ( block[ 0 ] != ">" ) { - var lines = block.split( /\n/ ), - prev = []; - - // keep shifting lines until you find a crotchet - while ( lines.length && lines[ 0 ][ 0 ] != ">" ) { - prev.push( lines.shift() ); - } - - // reassemble! - block = lines.join( "\n" ); - jsonml.push.apply( jsonml, this.processBlock( prev.join( "\n" ), [] ) ); - } - - // if the next block is also a blockquote merge it in - while ( next.length && next[ 0 ][ 0 ] == ">" ) { - var b = next.shift(); - block += block.trailing + b; - block.trailing = b.trailing; - } - - // Strip off the leading "> " and re-process as a block. - var input = block.replace( /^> ?/gm, '' ), - old_tree = this.tree; - jsonml.push( this.toTree( input, [ "blockquote" ] ) ); - - return jsonml; - }, - - referenceDefn: function referenceDefn( block, next) { - var re = /^\s*\[(.*?)\]:\s*(\S+)(?:\s+(?:(['"])(.*?)\3|\((.*?)\)))?\n?/; - // interesting matches are [ , ref_id, url, , title, title ] - - if ( !block.match(re) ) - return undefined; - - // make an attribute node if it doesn't exist - if ( !extract_attr( this.tree ) ) { - this.tree.splice( 1, 0, {} ); - } - - var attrs = extract_attr( this.tree ); - - // make a references hash if it doesn't exist - if ( attrs.references === undefined ) { - attrs.references = {}; - } - - var b = this.loop_re_over_block(re, block, function( m ) { - - if ( m[2] && m[2][0] == '<' && m[2][m[2].length-1] == '>' ) - m[2] = m[2].substring( 1, m[2].length - 1 ); - - var ref = attrs.references[ m[1].toLowerCase() ] = { - href: m[2] - }; - - if (m[4] !== undefined) - ref.title = m[4]; - else if (m[5] !== undefined) - ref.title = m[5]; - - } ); - - if (b.length) - next.unshift( mk_block( b, block.trailing ) ); - - return []; - }, - - para: function para( block, next ) { - // everything's a para! - return [ ["para"].concat( this.processInline( block ) ) ]; - } - } -} - -Markdown.dialects.Gruber.inline = { - __call__: function inline( text, patterns ) { - // Hmmm - should this function be directly in Md#processInline, or - // conversely, should Md#processBlock be moved into block.__call__ too - var out = [ ], - m, - // Look for the next occurange of a special character/pattern - re = new RegExp( "([\\s\\S]*?)(" + (patterns.source || patterns) + ")", "g" ), - lastIndex = 0; - - //D:var self = this; - //D:self.debug("processInline:", uneval(text) ); - function add(x) { - //D:self.debug(" adding output", uneval(x)); - if (typeof x == "string" && typeof out[out.length-1] == "string") - out[ out.length-1 ] += x; - else - out.push(x); - } - - while ( ( m = re.exec(text) ) != null) { - if ( m[1] ) add( m[1] ); // Some un-interesting text matched - else m[1] = { length: 0 }; // Or there was none, but make m[1].length == 0 - - var res; - if ( m[2] in this.dialect.inline ) { - res = this.dialect.inline[ m[2] ].call( - this, - text.substr( m.index + m[1].length ), m, out ); - } - // Default for now to make dev easier. just slurp special and output it. - res = res || [ m[2].length, m[2] ]; - - var len = res.shift(); - // Update how much input was consumed - re.lastIndex += ( len - m[2].length ); - - // Add children - res.forEach(add); - - lastIndex = re.lastIndex; - } - - // Add last 'boring' chunk - if ( text.length > lastIndex ) - add( text.substr( lastIndex ) ); - - return out; - }, - - "\\": function escaped( text ) { - // [ length of input processed, node/children to add... ] - // Only esacape: \ ` * _ { } [ ] ( ) # * + - . ! - if ( text.match( /^\\[\\`\*_{}\[\]()#\+.!\-]/ ) ) - return [ 2, text[1] ]; - else - // Not an esacpe - return [ 1, "\\" ]; - }, - - "![": function image( text ) { - // ![Alt text](/path/to/img.jpg "Optional title") - // 1 2 3 4 <--- captures - var m = text.match( /^!\[(.*?)\][ \t]*\([ \t]*(\S*)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/ ); - - if ( m ) { - if ( m[2] && m[2][0] == '<' && m[2][m[2].length-1] == '>' ) - m[2] = m[2].substring( 1, m[2].length - 1 ); - - m[2] == this.dialect.inline.__call__.call( this, m[2], /\\/ )[0]; - - var attrs = { alt: m[1], href: m[2] || "" }; - if ( m[4] !== undefined) - attrs.title = m[4]; - - return [ m[0].length, [ "img", attrs ] ]; - } - - // ![Alt text][id] - m = text.match( /^!\[(.*?)\][ \t]*\[(.*?)\]/ ); - - if ( m ) { - // We can't check if the reference is known here as it likely wont be - // found till after. Check it in md tree->hmtl tree conversion - return [ m[0].length, [ "img_ref", { alt: m[1], ref: m[2].toLowerCase(), text: m[0] } ] ]; - } - - // Just consume the '![' - return [ 2, "![" ]; - }, - - "[": function link( text ) { - // [link text](/path/to/img.jpg "Optional title") - // 1 2 3 4 <--- captures - var m = text.match( /^\[([\s\S]*?)\][ \t]*\([ \t]*(\S+)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/ ); - - if ( m ) { - if ( m[2] && m[2][0] == '<' && m[2][m[2].length-1] == '>' ) - m[2] = m[2].substring( 1, m[2].length - 1 ); - - // Process escapes only - m[2] = this.dialect.inline.__call__.call( this, m[2], /\\/ )[0]; - - var attrs = { href: m[2] || "" }; - if ( m[4] !== undefined) - attrs.title = m[4]; - - return [ m[0].length, [ "link", attrs, m[1] ] ]; - } - - // [Alt text][id] - // [Alt text] [id] - // [id] - m = text.match( /^\[([\s\S]*?)\](?: ?\[(.*?)\])?/ ); - - if ( m ) { - // [id] case, text == id - if ( m[2] === undefined || m[2] === "" ) m[2] = m[1]; - - // We can't check if the reference is known here as it likely wont be - // found till after. Check it in md tree->hmtl tree conversion. - // Store the original so that conversion can revert if the ref isn't found. - return [ - m[ 0 ].length, - [ - "link_ref", - { - ref: m[ 2 ].toLowerCase(), - original: m[ 0 ] - }, - m[ 1 ] - ] - ]; - } - - // Just consume the '[' - return [ 1, "[" ]; - }, - - - "<": function autoLink( text ) { - var m; - - if ( ( m = text.match( /^<(?:((https?|ftp|mailto):[^>]+)|(.*?@.*?\.[a-zA-Z]+))>/ ) ) != null ) { - if ( m[3] ) { - return [ m[0].length, [ "link", { href: "mailto:" + m[3] }, m[3] ] ]; - - } - else if ( m[2] == "mailto" ) { - return [ m[0].length, [ "link", { href: m[1] }, m[1].substr("mailto:".length ) ] ]; - } - else - return [ m[0].length, [ "link", { href: m[1] }, m[1] ] ]; - } - - return [ 1, "<" ]; - }, - - "`": function inlineCode( text ) { - // Inline code block. as many backticks as you like to start it - // Always skip over the opening ticks. - var m = text.match( /(`+)(([\s\S]*?)\1)/ ); - - if ( m && m[2] ) - return [ m[1].length + m[2].length, [ "inlinecode", m[3] ] ]; - else { - // TODO: No matching end code found - warn! - return [ 1, "`" ]; - } - }, - - " \n": function lineBreak( text ) { - return [ 3, [ "linebreak" ] ]; - } - -} - -// Meta Helper/generator method for em and strong handling -function strong_em( tag, md ) { - - var state_slot = tag + "_state", - other_slot = tag == "strong" ? "em_state" : "strong_state"; - - function CloseTag(len) { - this.len_after = len; - this.name = "close_" + md; - } - - return function ( text, orig_match ) { - - if (this[state_slot][0] == md) { - // Most recent em is of this type - //D:this.debug("closing", md); - this[state_slot].shift(); - - // "Consume" everything to go back to the recrusion in the else-block below - return[ text.length, new CloseTag(text.length-md.length) ]; - } - else { - // Store a clone of the em/strong states - var other = this[other_slot].slice(), - state = this[state_slot].slice(); - - this[state_slot].unshift(md); - - //D:this.debug_indent += " "; - - // Recurse - var res = this.processInline( text.substr( md.length ) ); - //D:this.debug_indent = this.debug_indent.substr(2); - - var last = res[res.length - 1]; - - //D:this.debug("processInline from", tag + ": ", uneval( res ) ); - - var check = this[state_slot].shift(); - if (last instanceof CloseTag) { - res.pop(); - // We matched! Huzzah. - var consumed = text.length - last.len_after; - return [ consumed, [ tag ].concat(res) ]; - } - else { - // Restore the state of the other kind. We might have mistakenly closed it. - this[other_slot] = other; - this[state_slot] = state; - - // We can't reuse the processed result as it could have wrong parsing contexts in it. - return [ md.length, md ]; - } - } - } // End returned function -} - -Markdown.dialects.Gruber.inline["**"] = strong_em("strong", "**"); -Markdown.dialects.Gruber.inline["__"] = strong_em("strong", "__"); -Markdown.dialects.Gruber.inline["*"] = strong_em("em", "*"); -Markdown.dialects.Gruber.inline["_"] = strong_em("em", "_"); - - -// Build default order from insertion order. -Markdown.buildBlockOrder = function(d) { - var ord = []; - for ( var i in d ) { - if ( i == "__order__" || i == "__call__" ) continue; - ord.push( i ); - } - d.__order__ = ord; -} - -// Build patterns for inline matcher -Markdown.buildInlinePatterns = function(d) { - var patterns = []; - - for ( var i in d ) { - if (i == "__call__") continue; - var l = i.replace( /([\\.*+?|()\[\]{}])/g, "\\$1" ) - .replace( /\n/, "\\n" ); - patterns.push( i.length == 1 ? l : "(?:" + l + ")" ); - } - - patterns = patterns.join("|"); - //print("patterns:", uneval( patterns ) ); - - var fn = d.__call__; - d.__call__ = function(text, pattern) { - if (pattern != undefined) - return fn.call(this, text, pattern); - else - return fn.call(this, text, patterns); - } -} - -// Helper function to make sub-classing a dialect easier -Markdown.subclassDialect = function( d ) { - function Block() {}; - Block.prototype = d.block; - function Inline() {}; - Inline.prototype = d.inline; - - return { block: new Block(), inline: new Inline() }; -} - -Markdown.buildBlockOrder ( Markdown.dialects.Gruber.block ); -Markdown.buildInlinePatterns( Markdown.dialects.Gruber.inline ); - -Markdown.dialects.Maruku = Markdown.subclassDialect( Markdown.dialects.Gruber ); - -Markdown.dialects.Maruku.block.document_meta = function document_meta( block, next ) { - // we're only interested in the first block - if ( block.lineNumber > 1 ) return undefined; - - // document_meta blocks consist of one or more lines of `Key: Value\n` - if ( ! block.match( /^(?:\w+:.*\n)*\w+:.*$/ ) ) return undefined; - - // make an attribute node if it doesn't exist - if ( !extract_attr( this.tree ) ) { - this.tree.splice( 1, 0, {} ); - } - - var pairs = block.split( /\n/ ); - for ( p in pairs ) { - var m = pairs[ p ].match( /(\w+):\s*(.*)$/ ), - key = m[ 1 ].toLowerCase(), - value = m[ 2 ]; - - this.tree[ 1 ][ key ] = value; - } - - // document_meta produces no content! - return []; -} - -Markdown.dialects.Maruku.block.block_meta = function block_meta( block, next ) { - // check if the last line of the block is an meta hash - var m = block.match( /(^|\n) {0,3}\{:\s*((?:\\\}|[^\}])*)\s*\}$/ ); - if ( !m ) return undefined; - - // process the meta hash - var attr = process_meta_hash( m[ 2 ] ); - - // if we matched ^ then we need to apply meta to the previous block - if ( m[ 1 ] === "" ) { - var node = this.tree[ this.tree.length - 1 ], - hash = extract_attr( node ); - - // if the node is a string (rather than JsonML), bail - if ( typeof node === "string" ) return undefined; - - // create the attribute hash if it doesn't exist - if ( !hash ) { - hash = {}; - node.splice( 1, 0, hash ); - } - - // add the attributes in - for ( a in attr ) { - hash[ a ] = attr[ a ]; - } - - // return nothing so the meta hash is removed - return []; - } - - // pull the meta hash off the block and process what's left - var b = block.replace( /\n.*$/, "" ), - result = this.processBlock( b, [] ); - - // get or make the attributes hash - var hash = extract_attr( result[ 0 ] ); - if ( !hash ) { - hash = {}; - result[ 0 ].splice( 1, 0, hash ); - } - - // attach the attributes to the block - for ( a in attr ) { - hash[ a ] = attr[ a ]; - } - - return result; -} - -Markdown.dialects.Maruku.block.definition_list = function definition_list( block, next ) { - // one or more terms followed by one or more definitions, in a single block - var tight = /^((?:[^\s:].*\n)+):\s+([^]+)$/, - list = [ "dl" ]; - - // see if we're dealing with a tight or loose block - if ( ( m = block.match( tight ) ) ) { - // pull subsequent tight DL blocks out of `next` - var blocks = [ block ]; - while ( next.length && tight.exec( next[ 0 ] ) ) { - blocks.push( next.shift() ); - } - - for ( var b = 0; b < blocks.length; ++b ) { - var m = blocks[ b ].match( tight ), - terms = m[ 1 ].replace( /\n$/, "" ).split( /\n/ ), - defns = m[ 2 ].split( /\n:\s+/ ); - - // print( uneval( m ) ); - - for ( var i = 0; i < terms.length; ++i ) { - list.push( [ "dt", terms[ i ] ] ); - } - - for ( var i = 0; i < defns.length; ++i ) { - // run inline processing over the definition - list.push( [ "dd" ].concat( this.processInline( defns[ i ].replace( /(\n)\s+/, "$1" ) ) ) ); - } - } - } - else { - return undefined; - } - - return [ list ]; -} - -Markdown.dialects.Maruku.inline[ "{:" ] = function inline_meta( text, matches, out ) { - if ( !out.length ) { - return [ 2, "{:" ]; - } - - // get the preceeding element - var before = out[ out.length - 1 ]; - - if ( typeof before === "string" ) { - return [ 2, "{:" ]; - } - - // match a meta hash - var m = text.match( /^\{:\s*((?:\\\}|[^\}])*)\s*\}/ ); - - // no match, false alarm - if ( !m ) { - return [ 2, "{:" ]; - } - - // attach the attributes to the preceeding element - var meta = process_meta_hash( m[ 1 ] ), - attr = extract_attr( before ); - - if ( !attr ) { - attr = {}; - before.splice( 1, 0, attr ); - } - - for ( var k in meta ) { - attr[ k ] = meta[ k ]; - } - - // cut out the string and replace it with nothing - return [ m[ 0 ].length, "" ]; -} - -Markdown.buildBlockOrder ( Markdown.dialects.Maruku.block ); -Markdown.buildInlinePatterns( Markdown.dialects.Maruku.inline ); - -function extract_attr( jsonml ) { - return jsonml instanceof Array - && jsonml.length > 1 - && typeof jsonml[ 1 ] === "object" - && !( jsonml[ 1 ] instanceof Array ) - ? jsonml[ 1 ] - : undefined; -} - -function process_meta_hash( meta_string ) { - var meta = split_meta_hash( meta_string ), - attr = {}; - - for ( var i = 0; i < meta.length; ++i ) { - // id: #foo - if ( /^#/.test( meta[ i ] ) ) { - attr.id = meta[ i ].substring( 1 ); - } - // class: .foo - else if ( /^\./.test( meta[ i ] ) ) { - // if class already exists, append the new one - if ( attr['class'] ) { - attr['class'] = attr['class'] + meta[ i ].replace( /./, " " ); - } - else { - attr['class'] = meta[ i ].substring( 1 ); - } - } - // attribute: foo=bar - else if ( /=/.test( meta[ i ] ) ) { - var s = meta[ i ].split( /=/ ); - attr[ s[ 0 ] ] = s[ 1 ]; - } - } - - return attr; -} - -function split_meta_hash( meta_string ) { - var meta = meta_string.split( "" ), - parts = [ "" ], - in_quotes = false; - - while ( meta.length ) { - var letter = meta.shift(); - switch ( letter ) { - case " " : - // if we're in a quoted section, keep it - if ( in_quotes ) { - parts[ parts.length - 1 ] += letter; - } - // otherwise make a new part - else { - parts.push( "" ); - } - break; - case "'" : - case '"' : - // reverse the quotes and move straight on - in_quotes = !in_quotes; - break; - case "\\" : - // shift off the next letter to be used straight away. - // it was escaped so we'll keep it whatever it is - letter = meta.shift(); - default : - parts[ parts.length - 1 ] += letter; - break; - } - } - - return parts; -} - -/** - * renderJsonML( jsonml[, options] ) -> String - * - jsonml (Array): JsonML array to render to XML - * - options (Object): options - * - * Converts the given JsonML into well-formed XML. - * - * The options currently understood are: - * - * - root (Boolean): wether or not the root node should be included in the - * output, or just its children. The default `false` is to not include the - * root itself. - */ -expose.renderJsonML = function( jsonml, options ) { - options = options || {}; - // include the root element in the rendered output? - options.root = options.root || false; - - var content = []; - - if ( options.root ) { - content.push( render_tree( jsonml ) ); - } - else { - jsonml.shift(); // get rid of the tag - if ( jsonml.length && typeof jsonml[ 0 ] === "object" && !( jsonml[ 0 ] instanceof Array ) ) { - jsonml.shift(); // get rid of the attributes - } - - while ( jsonml.length ) { - content.push( render_tree( jsonml.shift() ) ); - } - } - - return content.join( "\n\n" ); -} - -function render_tree( jsonml ) { - // basic case - if ( typeof jsonml === "string" ) { - return jsonml.replace( /&/g, "&" ) - .replace( //g, ">" ); - } - - var tag = jsonml.shift(), - attributes = {}, - content = []; - - if ( jsonml.length && typeof jsonml[ 0 ] === "object" && !( jsonml[ 0 ] instanceof Array ) ) { - attributes = jsonml.shift(); - } - - while ( jsonml.length ) { - content.push( arguments.callee( jsonml.shift() ) ); - } - - var tag_attrs = ""; - for ( var a in attributes ) { - tag_attrs += " " + a + '="' + attributes[ a ] + '"'; - } - - // be careful about adding whitespace here for inline elements - return "<"+ tag + tag_attrs + ">" + content.join( "" ) + ""; -} - -function convert_tree_to_html( tree, references ) { - // shallow clone - var jsonml = tree.slice( 0 ); - - // Clone attributes if the exist - var attrs = extract_attr( jsonml ); - if ( attrs ) { - jsonml[ 1 ] = {}; - for ( var i in attrs ) { - jsonml[ 1 ][ i ] = attrs[ i ]; - } - attrs = jsonml[ 1 ]; - } - - // basic case - if ( typeof jsonml === "string" ) { - return jsonml; - } - - // convert this node - switch ( jsonml[ 0 ] ) { - case "header": - jsonml[ 0 ] = "h" + jsonml[ 1 ].level; - delete jsonml[ 1 ].level; - break; - case "bulletlist": - jsonml[ 0 ] = "ul"; - break; - case "numberlist": - jsonml[ 0 ] = "ol"; - break; - case "listitem": - jsonml[ 0 ] = "li"; - break; - case "para": - jsonml[ 0 ] = "p"; - break; - case "markdown": - jsonml[ 0 ] = "html"; - if ( attrs ) delete attrs.references; - break; - case "code_block": - jsonml[ 0 ] = "pre"; - var i = attrs ? 2 : 1; - var code = [ "code" ]; - code.push.apply( code, jsonml.splice( i ) ); - jsonml[ i ] = code; - break; - case "inlinecode": - jsonml[ 0 ] = "code"; - break; - case "img": - jsonml[ 1 ].src = jsonml[ 1 ].href; - delete jsonml[ 1 ].href; - break; - case "linebreak": - jsonml[0] = "br"; - break; - case "link": - jsonml[ 0 ] = "a"; - break; - case "link_ref": - jsonml[ 0 ] = "a"; - - // grab this ref and clean up the attribute node - var ref = references[ attrs.ref ]; - - // if the reference exists, make the link - if ( ref ) { - delete attrs.ref; - - // add in the href and title, if present - attrs.href = ref.href; - if ( ref.title ) { - attrs.title = ref.title; - } - - // get rid of the unneeded original text - delete attrs.original; - } - // the reference doesn't exist, so revert to plain text - else { - return attrs.original; - } - break; - } - - // convert all the children - var i = 1; - - // deal with the attribute node, if it exists - if ( attrs ) { - // if there are keys, skip over it - for ( var key in jsonml[ 1 ] ) { - i = 2; - } - // if there aren't, remove it - if ( i === 1 ) { - jsonml.splice( i, 1 ); - } - } - - for ( ; i < jsonml.length; ++i ) { - jsonml[ i ] = arguments.callee( jsonml[ i ], references ); - } - - return jsonml; -} - - -// merges adjacent text nodes into a single node -function merge_text_nodes( jsonml ) { - // skip the tag name and attribute hash - var i = extract_attr( jsonml ) ? 2 : 1; - - while ( i < jsonml.length ) { - // if it's a string check the next item too - if ( typeof jsonml[ i ] === "string" ) { - if ( i + 1 < jsonml.length && typeof jsonml[ i + 1 ] === "string" ) { - // merge the second string into the first and remove it - jsonml[ i ] += jsonml.splice( i + 1, 1 )[ 0 ]; - } - else { - ++i; - } - } - // if it's not a string recurse - else { - arguments.callee( jsonml[ i ] ); - ++i; - } - } -} - -} )( (function() { - if ( typeof exports === "undefined" ) { - window.markdown = {}; - return window.markdown; - } - else { - return exports; - } -} )() ); diff --git a/modules/goessner/json2xml.js b/modules/goessner/json2xml.js deleted file mode 100644 index 5283249f..00000000 --- a/modules/goessner/json2xml.js +++ /dev/null @@ -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" : "/>"; - if (hasChild) { - for (var m in v) { - if (m == "#text") - xml += makeSafe(v[m]); - else if (m == "#cdata") - xml += ""; - else if (m.charAt(0) != "@") - xml += toXml(v[m], m, ind+"\t"); - } - xml += (xml.charAt(xml.length-1)=="\n"?ind:"") + "\n"; - } - } - else { // added special-character transform, but this needs to be better handled [micmath] - xml += ind + "<" + name + ">" + makeSafe(v.toString()) + "\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(/ - @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; - }; - -})(); \ No newline at end of file diff --git a/modules/jsdoc/doclet.js b/modules/jsdoc/doclet.js deleted file mode 100644 index 4229ab0e..00000000 --- a/modules/jsdoc/doclet.js +++ /dev/null @@ -1,296 +0,0 @@ -/** - @overview - @author Michael Mathews - @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 (/^\.?/.test(sid)) { sid = sid.replace(/^.?/, ''); } - /** - 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 (/^\.?/.test(name)) { name = name.replace(/^\.?/, ''); } - - /** - 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. - */ - 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. - */ - 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; - } - -})(); \ No newline at end of file diff --git a/modules/jsdoc/name.js b/modules/jsdoc/name.js deleted file mode 100644 index f2f41b05..00000000 --- a/modules/jsdoc/name.js +++ /dev/null @@ -1,180 +0,0 @@ -/** - A collection of functions relating to JSDoc symbol name manipulation. - @module jsdoc/name - @requires jsdoc/tag/dictionary - @author Michael Mathews - @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}; - } - -})(); \ No newline at end of file diff --git a/modules/jsdoc/opts/parser.js b/modules/jsdoc/opts/parser.js deleted file mode 100644 index 85b55ac6..00000000 --- a/modules/jsdoc/opts/parser.js +++ /dev/null @@ -1,75 +0,0 @@ -/** - @module jsdoc/opts/parser - @requires common/args - @author Michael Mathews - @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]; - } - } -})(); \ No newline at end of file diff --git a/modules/jsdoc/package.js b/modules/jsdoc/package.js deleted file mode 100644 index e4fcbf25..00000000 --- a/modules/jsdoc/package.js +++ /dev/null @@ -1,69 +0,0 @@ -/** - @overview - @author Michael Mathews - @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} - */ - 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} - * @example - * "licenses": [ - * { - * "type": "GPLv2", - * "url": "http://www.example.com/licenses/gpl.html" - * } - * ] - */ - this.licenses = json.licenses; - } - -})(); \ No newline at end of file diff --git a/modules/jsdoc/schema.js b/modules/jsdoc/schema.js deleted file mode 100644 index be52250f..00000000 --- a/modules/jsdoc/schema.js +++ /dev/null @@ -1,296 +0,0 @@ -/** - @overview Schema for validating JSON produced by JSDoc Toolkit. - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - @see - */ - -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 - } - } - } - } -}; \ No newline at end of file diff --git a/modules/jsdoc/src/handlers.js b/modules/jsdoc/src/handlers.js deleted file mode 100644 index 8443a73f..00000000 --- a/modules/jsdoc/src/handlers.js +++ /dev/null @@ -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; - } - } -})(); \ No newline at end of file diff --git a/modules/jsdoc/src/parser.js b/modules/jsdoc/src/parser.js deleted file mode 100644 index 6f83a44f..00000000 --- a/modules/jsdoc/src/parser.js +++ /dev/null @@ -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 Create a new parser. - * 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.} sourceFiles An array of filepaths to the JavaScript sources. - * @param {string} [encoding=utf8] - * - * @fires jsdocCommentFound - * @fires symbolFound - * @fires newDoclet - * @fires fileBegin - * @fires fileComplete - * - * @example Parse two source files. - * 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} 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 '~'; - } - 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 ''; // 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: '', - 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. - */ \ No newline at end of file diff --git a/modules/jsdoc/src/scanner.js b/modules/jsdoc/src/scanner.js deleted file mode 100644 index 68f50490..00000000 --- a/modules/jsdoc/src/scanner.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - @module jsdoc/src/scanner - @requires module:common/fs - - @author Michael Mathews - @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.} 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; - } - -})(); \ No newline at end of file diff --git a/modules/jsdoc/tag.js b/modules/jsdoc/tag.js deleted file mode 100644 index c2173b53..00000000 --- a/modules/jsdoc/tag.js +++ /dev/null @@ -1,135 +0,0 @@ -/** - @overview - @author Michael Mathews - @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.*/ 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.} [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]; - } - -})(); \ No newline at end of file diff --git a/modules/jsdoc/tag/dictionary.js b/modules/jsdoc/tag/dictionary.js deleted file mode 100644 index b0484168..00000000 --- a/modules/jsdoc/tag/dictionary.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - @overview - @author Michael Mathews - @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; - -})(); \ No newline at end of file diff --git a/modules/jsdoc/tag/dictionary/definitions.js b/modules/jsdoc/tag/dictionary/definitions.js deleted file mode 100644 index 95815693..00000000 --- a/modules/jsdoc/tag/dictionary/definitions.js +++ /dev/null @@ -1,538 +0,0 @@ -/** - Define tags that are known in JSDoc. - @module jsdoc/tag/dictionary/definitions - - @author Michael Mathews - @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 || ''; - 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 ''; } - } -})(); \ No newline at end of file diff --git a/modules/jsdoc/tag/type.js b/modules/jsdoc/tag/type.js deleted file mode 100644 index 04bdc280..00000000 --- a/modules/jsdoc/tag/type.js +++ /dev/null @@ -1,113 +0,0 @@ -/** - @module jsdoc/tag/type - - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -(function() { - - /** - @param {string} tagValue - @returns {Array.} - */ - 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, ''); - } -})(); \ No newline at end of file diff --git a/modules/jsdoc/tag/validator.js b/modules/jsdoc/tag/validator.js deleted file mode 100644 index 7f714529..00000000 --- a/modules/jsdoc/tag/validator.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - @module jsdoc/tag/validator - @requires jsdoc/tag/dictionary - - @author Michael Mathews - @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; - -})(); \ No newline at end of file diff --git a/modules/sitepen/jsonschema.js b/modules/sitepen/jsonschema.js deleted file mode 100644 index 3d6f6625..00000000 --- a/modules/sitepen/jsonschema.js +++ /dev/null @@ -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 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() { - } -*/ diff --git a/modules/typicaljoe/taffy.js b/modules/typicaljoe/taffy.js deleted file mode 100644 index 03fe852a..00000000 --- a/modules/typicaljoe/taffy.js +++ /dev/null @@ -1,1427 +0,0 @@ -/* - -Software License Agreement (BSD License) -http://taffydb.com -Copyright (c) 2008 -All rights reserved. -Version 1.7.3 - - -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. - -SUMMARY: -TAFFY takes a JavaScript object and returns a set of methods -to search, modify, and manipulate that object. - -*/ - -var TAFFY = function (obj) { - var conf = { - template:null - }, T = TAFFY, raw = (T.isString(obj)) ? T.JSON.parse(obj) : obj, TOb = raw, TIA = [], t = true, f=false; - - - // **************************************** - // * - // * Create prvate mergeTemp function - // * Loop over set of indexes and apply a template to the record - // * - // **************************************** - var mergeTemp = function (rows,tmpl) { - var tmpl = tmpl || conf.template; - if (!TAFFY.isNull(tmpl)) - { - for(var x = 0, xl = rows.length; x < xl; x++) { - TOb[rows[x]] = TAFFY.mergeObj(TOb[rows[x]],tmpl); - } - } - }; - - // **************************************** - // * - // * Create prvate bTIA function - // * Loop over every index within the Taffy Object TOb - // * and populate the Taffy Index Array TIA with the indexes - // * - // **************************************** - var bTIA = function () { - TIA = []; - for(var x = 0, xl = TOb.length; x < xl; x++) { - TIA[TIA.length] = x; - } - }; - bTIA(); - - - // **************************************** - // * - // * Create prvate findTests Object - // * Collect all possible true/false expression used when - // * doing lookups via the public find method. - // * Purpose: Used to house and document all of the - // * possible ways to match a value to a field with the - // * TAFFY Object. Each of the contained functions does an - // * evaluation against a value from the TAFFY Obj and a test - // * provided by the caller of the find method. If this - // * evaluation is true then the find method will add - // * the TAFFY Object record to the results set. - // * - // **************************************** - - var findTests = { - - pickTest:function(Tt) - { - var m = (Tt.indexOf("!") === 0) ? f : t; - if (!m) - { - Tt = Tt.substring(1,Tt.length); - } - return {test:(Tt == 'equal') ? 'is' : - (Tt == 'notequal') ? 'not' : - (Tt == 'startswith') ? 'starts' : - (Tt == 'endswith') ? 'ends' : - (Tt == 'greaterthan') ? 'gt' : - (Tt == 'lessthan') ? 'lt' : - (Tt == 'regexppass') ? 'regex' : Tt,mode:(m) ? {s:t,f:f} : {s:f,f:t}}; - }, - run:function(s,mvalue,mtest,b) { - return ((s=="regex") ? (mtest.test(mvalue)) : - (s=="lt") ? (mvalue < mtest) : - (s=="gt") ? (mvalue > mtest) : - (s=="lte") ? (mvalue <= mtest) : - (s=="gte") ? (mvalue >= mtest) : - (s=="starts") ? (mvalue.indexOf(mtest) === 0) : - (s=="ends") ? (mvalue.substring((mvalue.length - mtest.length)) == mtest) : - (s=="like") ? (mvalue.indexOf(mtest) >= 0) : - (s=="is") ? (mvalue == mtest) : - (s=="has") ? (T.has(mvalue,mtest)) : - (s=="hasAll") ? (T.hasAll(mvalue,mtest)) : - (s=="length") ? (findTests.length(mvalue,mtest,b)) : - findTests[s](mvalue,mtest)) ? b.s : b.f; - }, - length:function (mvalue,mtest,b) - { - // If a value length exits and meets filter criteria - var rlen = (!T.isUndefined(mvalue.length)) ? mvalue.length : (!T.isUndefined(mvalue.getLength)) ? mvalue.getLength() : 0; - if (T.isObject(mtest)) { - for(var kt in mtest) - { - if (mtest.hasOwnProperty(kt)) - { - var pt = findTests.pickTest(kt); - return findTests.run(pt.test,rlen,mtest[kt],pt.mode) ? t : f; - } - } - } - // default return - return rlen == mtest ? b.s : b.f; - } - }; - - // Add in isObjectType checks - (function () { - for(var z in TAFFY) - { - if (TAFFY.hasOwnProperty(z) && z.indexOf("is") === 0) - { - (function (y) { - findTests["is" + y] = function (mvalue,mtest,b) { - return (TAFFY["is" + y](mvalue) == mtest) ? t : f; - }; - }(z.substring(2,z.length))); - } - } - }()); - - // **************************************** - // * - // * Create prvate bDexArray method - // * Return an array of indexes - // * Purpose: Used to create a variable that is an - // * array that contains the indexes of the records - // * that an action should be taken on. If a single - // * number is passed then an array is created with that - // * number being in postion 0. If an array is passed - // * in then that array is returned. If no value is - // * passed in then an array containing every index - // * in the TAFFY Obj is returned. If an object is passed - // * then a call to the find function is made and the - // * resulting array of indexes returned. - // * - // **************************************** - - var bDexArray = function (iA,f) { - var rA = []; - if (!T.isArray(iA) && TAFFY.isNumber(iA)) - { - rA[rA.length] = iA; - } - else if (T.isArray(iA)) - { - rA = iA; - - } - else if (T.isObject(iA)) - { - rA = f(iA); - } - else if (!T.isArray(iA) && !T.isNumber(iA)) - { - rA = TIA; - } - return rA; - }; - - // **************************************** - // * - // * Create private toLogicalArray method - // * return custom array for use in array.sort based on sort obj - // * argument - // * Purpose: This is used by the buildSortFunction function in the case - // * of logical and logicaldesc sort types. This function splits a complex - // * value into an array so that each array item can be compared against - // * the item at the index in each value. - // * - // **************************************** - var toLogicalArray = function (value) { - var rArray = [0],type = "none",value = value + ""; - if (!T.isNull(value) && !T.isUndefined(value)) { - for(var n = 0, nl = value.length;n y[z]){ - returnvar = 1; - break; - } - } - if (x.length < y.length && returnvar==0) - { - returnvar = -1; - } else if (x.length > y.length && returnvar==0) { - returnvar = 1; - } - } else if (custO[sa].sortDir == 'logicaldesc') { - x = toLogicalArray(x); - y = toLogicalArray(y); - for(var z = 0, zl = y.length;z y[z] && z < x.length) { - returnvar = -1; - break; - } else if (x[z] < y[z]){ - returnvar = 1; - break; - } - } - if (x.length < y.length && returnvar==0) - { - returnvar = 1; - } else if (x.length > y.length && returnvar==0) { - returnvar = -1; - } - } else { - if (T.isNull(x) || T.isUndefined(x) || x < y) { - returnvar = -1; - } else if (T.isNull(y) || T.isUndefined(y) || x > y){ - returnvar = 1; - } - } - - } - - } - return returnvar; - - }; - - }; - - // **************************************** - // * - // * Return Obj containing Methods - // * - // **************************************** - return { - - // **************************************** - // * - // * This is a simple true flag to identify - // * the returned collection as being created by - // * TAFFY() - // * - // **************************************** - TAFFY:true, - - // **************************************** - // * - // * Get the length of the TAFFY collection. - // * - // **************************************** - getLength:function () { - return TOb.length; - }, - - // **************************************** - // * - // * This is the date of the last change - // * to the TAFFY object. - // * - // **************************************** - lastModifyDate:new Date(), - - // **************************************** - // * - // * Create public find method - // * Returns array of index numbers for matching array values - // * Purpose: This takes an obj that defines a set of match - // * cases for use against the TOb. Matching indexes are - // * added to an array and then returned to the user. This is the - // * primary "lookup" feature of TAFFY and is how you find individual - // * or sets of records for use in update, remove, get, etc. - // * - // **************************************** - find : function (matchObj,findFilter) { - - - // define findMatches array and findMatchesLoaded flag - var findIndex = 0; - - // if findFilter is provided use findFilter to start findMatches array - // otherwise use TIA which contains all indexes of the TOb - if (T.isArray(findFilter)) { - var findMatches = findFilter; - } else { - var findMatches = TIA; - - } - - // if matchObject is a function run it against every item in findMatches - if (T.isFunction(matchObj)) { - var thisMatchArray = []; - // loop over every element in the findMatches - for (var d = 0, dl = findMatches.length; d < dl; d++) { - // add to matched item list if function returns true - if (matchObj(TOb[d], d)) { - thisMatchArray[thisMatchArray.length] = findMatches[d]; - } - } - findMatches = thisMatchArray; - } - else { - // loop over attributes in matchObj - for (var mi in matchObj) { - if (matchObj.hasOwnProperty(mi)) { - // default matchType, matchValue, matchField - var matchType = 'is', matchValue = '', matchField = mi, matchMode = { - s: t, - f: f - }, pt = {}; - - // If the matchObj attribute is an object - if (T.isObject(matchObj[mi])) { - - // loop over match field attributes - for (var fi in matchObj[mi]) { - if (matchObj[mi].hasOwnProperty(fi)) { - // switch over attributes, extract data - pt = findTests.pickTest(fi); - matchType = pt.test; - matchMode = pt.mode; - - matchValue = matchObj[mi][fi]; - } - } - } - // If the matchObj attribute is not an object - else { - // set the match value to the value provided - matchValue = matchObj[mi]; - } - - //define thisMatchArray for this find method - var thisMatchArray = []; - - // loop over every element in the findMatches - for (var d = 0, dl = findMatches.length; d < dl; d++) { - - // if the value is an array of values, loop rather than do 1 to 1 - if (T.isArray(matchValue) && matchType != 'isSameArray' && matchType != 'hasAll') { - // call the correct filter based on matchType and add the record if the filter returns true for normal mode - if (matchMode.s) { - for (var md = 0; md < matchValue.length; md++) { - - if (findTests.run(matchType, TOb[findMatches[d]][matchField], matchValue[md], matchMode)) { - thisMatchArray[thisMatchArray.length] = findMatches[d]; - - } - - } - } - else { - - // call the correct filter based on matchType and add the record only if fit passes every filter value if negative (!) mode - var pt = 1; - for (var md = 0; md < matchValue.length; md++) { - - if (!findTests.run(matchType, TOb[findMatches[d]][matchField], matchValue[md], matchMode)) { - pt = 0; - - } - - } - if (pt == 1) { - thisMatchArray[thisMatchArray.length] = findMatches[d]; - } - } - } - // if the value is a function call function and append index if it returns true - else - if (T.isFunction(matchValue) && matchValue(TOb[findMatches[d]][matchField], d)) { - thisMatchArray[thisMatchArray.length] = findMatches[d]; - } - // if the value is not an array but a single value - // If an exact match is found then add it to the array - - else - if (findTests.run(matchType, TOb[findMatches[d]][matchField], matchValue, matchMode)) { - thisMatchArray[thisMatchArray.length] = findMatches[d]; - - } - } - - findMatches = thisMatchArray; - } - } - } - // Garther only unique finds - findMatches = T.gatherUniques(findMatches); - - return findMatches; - }, - - // **************************************** - // * - // * Create public remove method - // * Purpose: This is used to remove a record from - // * the TOb by an index or an array of indexes. - // * - // **************************************** - remove : function (dex) { - - var removeIndex = bDexArray(dex,this.find); - - // loop over removeIndex and set each record to remove - // this is done so all records are flagged for remove - // before the size of the array changes do to the splice - // function below - for(var di = 0, dil = removeIndex.length; di < dil; di++) { - if (!T.isNull(this.onRemove)) - { - this.onRemove(TOb[removeIndex[di]]); - } - TOb[removeIndex[di]] = 'remove'; - } - - // nested function find delete - var removeRemaining = function () { - for(var tdi = 0, tdil = TOb.length; tdi < tdil; tdi++) { - if (TOb[tdi] === 'remove') { - return t; - } - } - return f; - }; - - // loop over TOb and remove all rows set to remove - while (removeRemaining()) { - for(var tdi = 0, tdil = TOb.length; tdi < tdil; tdi++) { - if (TOb[tdi] === 'remove') { - TOb.splice(tdi,1); - // update lastModifyDate - this.lastModifyDate = new Date(); - } - } - } - - // populate TIA - bTIA(); - return removeIndex; - }, - - - - - // **************************************** - // * - // * Create public insert method - // * Purpose: this takes an obj and inserts it into - // * the TAFFY Obj array - // * - // **************************************** - insert : function (newRecordObj) { - - var rec = (TAFFY.isArray(newRecordObj)) ? newRecordObj : [newRecordObj]; - - for (var x = 0; x < rec.length; x++) { - if (!T.isNull(this.onInsert)) { - this.onInsert(rec[x]); - } - - - // Do insert - TOb[TOb.length] = (TAFFY.isNull(conf.template)) ? rec[x] : TAFFY.mergeObj(conf.template, rec[x]); - - // update lastModifyDate - this.lastModifyDate = new Date(); - - // populate TIA - TIA[TIA.length] = TOb.length - 1; - - } - return [TOb.length-1]; - }, - - // **************************************** - // * - // * Create public update method - // * Purpose: This takes an obj of name/value - // * pairs and then a set of 1 or more indexes - // * and updates those records with in the TOb - // * - // **************************************** - update : function (updateObj,dex) { - - var updateIndex = bDexArray(dex,this.find), updateCount=0; - - for(var d = 0, dl = updateIndex.length; d < dl; d++) { - // set the updatedex - var updateDex = updateIndex[d]; - - if (!T.isNull(this.onUpdate)) - { - this.onUpdate(updateObj,TOb[updateDex]); - } - - // Merge Objects - TOb[updateDex] = T.mergeObj(TOb[updateDex],updateObj); - - // add the updaecount - updateCount++; - - } - - return updateIndex; - }, - - - // **************************************** - // * - // * Create public get method - // * Purpose: This return an array containing - // * the rows for a set of indexes. Used to get - // * a record set with the help of the find - // * function. Returns an empty array if - // * no records are found. - // * - // **************************************** - - get : function (dex) { - - var nT = []; - - var getIndex = bDexArray(dex,this.find); - - // loop over all of the indexes - for(var d = 0, dl = getIndex.length; d < dl; d++) { - - // add the TOb to the newTAFFYArray array - nT[nT.length] = TOb[getIndex[d]]; - } - return nT; - }, - - // **************************************** - // * - // * Create public first method - // * Purpose: This returns the first row - // * from a set of indexes. Used to get - // * a record with the help of the find - // * function. Returns false if no records - // * are found. - // * - // **************************************** - - first : function (dex) { - - var getIndex = bDexArray(dex,this.find); - - return (getIndex.length > 0) ? TOb[getIndex[0]] : false; - - }, - - // **************************************** - // * - // * Create public last method - // * Purpose: This returns the last row - // * from a set of indexes. Used to get - // * a record with the help of the find - // * function. Returns false if no records - // * are found. - // * - // **************************************** - - last : function (dex) { - - var getIndex = bDexArray(dex,this.find); - - return (getIndex.length > 0) ? TOb[getIndex[(getIndex.length - 1)]] : false; - }, - - // **************************************** - // * - // * Create public stringify method - // * Purpose: This returns a string JSON array - // * from a set of indexes. Used to get records - // * for handling by AJAX or other langauges. - // * - // **************************************** - - stringify : function (dex) { - - return T.JSON.stringify(this.get(dex)); - }, - - // **************************************** - // * - // * Create public orderBy method - // * Purpose: Reorder the array according - // * to a list of fields. Very useful for - // * ordering tables or other types of - // * sorting. - // * - // **************************************** - orderBy : function (Obj) { - - // Only attempt to sort if there is a length - // to the TAFFY array - if (TOb.length > 0) { - // Use the private buildSortFunction method - // to create a custom sort function unless one is provided - - if (T.isFunction(Obj)) { - var customSort = Obj; - } else { - var customSort = buildSortFunction(Obj); - } - - // Call JavaScript's array.sort with the custom - // sort function - TOb.sort(customSort); - - // update lastModifyDate - this.lastModifyDate = new Date(); - - - } - }, - - // **************************************** - // * - // * Create public forEach method - // * Purpose: Loop over every item in a TOb - // * (or at least the ones passed in the forIndex) - // * and call the provided user created function. - // * - // **************************************** - forEach : function (func2call,dex) { - - var forIndex = bDexArray(dex,this.find); - - var row; - // loop over all of the indexes - for(var fe = 0, fel = forIndex.length; fe < fel; fe++) { - // get this row from the TOb - row = TOb[forIndex[fe]]; - // call the function passed in to the method - var nr = func2call(row,forIndex[fe]); - - // If nr is an object then set the row equal to the new object - if (T.isObject(nr)) - { - if (TAFFY.isSameObject(nr,TAFFY.EXIT)) { - break; - } else { - this.update(nr,forIndex[fe]); - } - } - } - - }, - - // **************************************** - // * - // * Create public sum method - // * Purpose: Take a column name and a forIndex - // * and sum up the numeric total for every row. - // * - // **************************************** - sum : function (col,dex) { - var t = 0; - this.forEach(function (r) { - if(TAFFY.isNumeric(r[col])) { - t = t + r[col]; - } - - },dex) - - return t; - }, - - // **************************************** - // * - // * Create public max method - // * Purpose: Take a column name and a forIndex - // * and find the highest value in that column - // * over every row. - // * - // **************************************** - max : function (col,dex) { - var t, f = 0; - this.forEach(function (r) { - if (f==1 && r[col] > t) { - t = r[col]; - } else if (f==0) { - t=r[col]; - f=1; - } - },dex) - - return t; - }, - - // **************************************** - // * - // * Create public min method - // * Purpose: Take a column name and a forIndex - // * and find the lowest value in that column - // * over every row. - // * - // **************************************** - min : function (col,dex) { - var t, f = 0; - this.forEach(function (r) { - if (f==1 && r[col] < t) { - t = r[col]; - } else if (f==0) { - t=r[col]; - f=1; - } - },dex) - - return t; - }, - - // **************************************** - // * - // * Create public values method - // * Purpose: Take a column name and a forIndex - // * and find all the values for the rows returned. - // * - // **************************************** - values : function (col,dex) { - var t = []; - this.forEach(function (r) { - t[t.length] = r[col]; - },dex) - return t; - }, - // **************************************** - // * - // * Create public uniqueValues method - // * Purpose: Take a column name and a forIndex - // * and find only the unique values for the rows returned. - // * - // **************************************** - uniqueValues : function (col,dex) { - var t = TAFFY([]); - this.forEach(function (r) { - if (t.find({value:r[col]}).length == 0) { - t.insert({value:r[col]}); - } - },dex) - return t.values("value"); - }, - // **************************************** - // * - // * config variable object - // * - // **************************************** - config:{ - // **************************************** - // * - // * Create public set method - // * Purpose: Set a config value - // * - // **************************************** - set:function (n,v) { - conf[n] = v; - if (n == 'template' && !TAFFY.isNull(v)) { - mergeTemp(TIA,v); - } - }, - // **************************************** - // * - // * Create public get method - // * Purpose: Get a config value - // * - // **************************************** - get:function (n) { - return conf[n]; - } - }, - - // **************************************** - // * - // * Create public stringify method - // * Purpose: This returns a string JSON array - // * from a set of indexes. Used to get records - // * for handling by AJAX or other langauges. - // * - // **************************************** - - applyTemplate : function (tmp,dex) { - var getIndex = bDexArray(dex,this.find); - - mergeTemp(getIndex,tmp); - }, - // **************************************** - // * - // * Empty On Update Event - This can be replaced with a function - // * to call a custom action as each record is updated. - // * - // **************************************** - onUpdate:null, - - // **************************************** - // * - // * Empty On Remove Event - This can be replaced with a function - // * to call a custom action as each record is removed. - // * - // **************************************** - onRemove:null, - - // **************************************** - // * - // * Empty On Insert Event - This can be replaced with a function - // * to call a custom action as each record is inserted. - // * - // **************************************** - onInsert:null - - }; - -}; - - // **************************************** - // * - // * TAFFY Public Utilities - // * Accessed via TAFFY[methodname]() - // * - // **************************************** - - - // **************************************** - // * - // * typeOf Fixed in JavaScript as public utility - // * - // **************************************** - TAFFY.typeOf = function (v) { - var s = typeof v; - if (s === 'object') { - if (v) { - if (typeof v.length === 'number' && - !(v.propertyIsEnumerable('length')) && - typeof v.splice === 'function') { - s = 'array'; - } - } else { - s = 'null'; - } - } - return s; - }; - - - // **************************************** - // * - // * JSON Object Handler / public utility - // * See http://www.JSON.org/js.html - // * The following JSON Object is Public Domain - // * No warranty expressed or implied. Use at your own risk. - // * - // **************************************** - - TAFFY.JSON = function () { - - function f(n) { - return n < 10 ? '0' + n : n; - } - - Date.prototype.toJSON = function () { - - return this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z'; - }; - - - var m = { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"' : '\\"', - '\\': '\\\\' - }; - - function stringify(value, whitelist) { - var a,i,k,l, r = /["\\\x00-\x1f\x7f-\x9f]/g,v; - - switch (typeof value) { - case 'string': - - return r.test(value) ? - '"' + value.replace(r, function (a) { - var c = m[a]; - if (c) { - return c; - } - c = a.charCodeAt(); - return '\\u00' + Math.floor(c / 16).toString(16) + - (c % 16).toString(16); - }) + '"' : - '"' + value + '"'; - - case 'number': - - return isFinite(value) ? String(value) : 'null'; - - case 'boolean': - case 'null': - return String(value); - - case 'object': - - if (!value) { - return 'null'; - } - - if (typeof value.toJSON === 'function') { - return stringify(value.toJSON()); - } - a = []; - if (typeof value.length === 'number' && - !(value.propertyIsEnumerable('length'))) { - - l = value.length; - for (i = 0; i < l; i += 1) { - a.push(stringify(value[i], whitelist) || 'null'); - } - - return '[' + a.join(',') + ']'; - } - if (whitelist) { - - l = whitelist.length; - for (i = 0; i < l; i += 1) { - k = whitelist[i]; - if (typeof k === 'string') { - v = stringify(value[k], whitelist); - if (v) { - a.push(stringify(k) + ':' + v); - } - } - } - } else { - - for (k in value) { - if (typeof k === 'string') { - v = stringify(value[k], whitelist); - if (v) { - a.push(stringify(k) + ':' + v); - } - } - } - } - - return '{' + a.join(',') + '}'; - } - return ""; - } - - return { - stringify: stringify, - parse: function (text, filter) { - var j; - - function walk(k, v) { - var i, n; - if (v && typeof v === 'object') { - for (i in v) { - if (Object.prototype.hasOwnProperty.apply(v, [i])) { - n = walk(i, v[i]); - if (n !== undefined) { - v[i] = n; - } else { - delete v[i]; - } - } - } - } - return filter(k, v); - } - - - if (/^[\],:{}\s]*$/.test(text.replace(/\\./g, '@'). - replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). - replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { - - j = eval('(' + text + ')'); - - return typeof filter === 'function' ? walk('', j) : j; - } - - throw new SyntaxError('parseJSON'); - } - }; - }(); - - - // **************************************** - // * - // * End JSON Code Object Handler - // * - // **************************************** - - // **************************************** - // * - // * Create public utility mergeObj method - // * Return a new object where items from obj2 - // * have replaced or been added to the items in - // * obj1 - // * Purpose: Used to combine objs - // * - // **************************************** - TAFFY.mergeObj = function (ob1,ob2) { - var c = {}; - for(var n in ob1) - { - if (ob1.hasOwnProperty(n)) { - c[n] = ob1[n]; - } - } - for(var n in ob2) - { - if (ob2.hasOwnProperty(n)) { - c[n] = ob2[n]; - } - } - return c; - }; - - // **************************************** - // * - // * Create public utility getObjectKeys method - // * Returns an array of an objects keys - // * Purpose: Used to get the keys for an object - // * - // **************************************** - TAFFY.getObjectKeys = function (ob) { - var kA = []; - for(var n in ob) - { - if (ob.hasOwnProperty(n)) - { - kA[kA.length] = n; - } - } - kA.sort(); - return kA; - }; - - // **************************************** - // * - // * Create public utility isSameArray - // * Returns an array of an objects keys - // * Purpose: Used to get the keys for an object - // * - // **************************************** - TAFFY.isSameArray = function (ar1,ar2) { - return (TAFFY.isArray(ar1) && TAFFY.isArray(ar2) && ar1.join(",") == ar2.join(",")) ? true : false; - }; - - // **************************************** - // * - // * Create public utility isSameObject method - // * Returns true if objects contain the same - // * material or false if they do not - // * Purpose: Used to comare objects - // * - // **************************************** - TAFFY.isSameObject = function (ob1,ob2) { - var T = TAFFY; - if (T.isObject(ob1) && T.isObject(ob2)) { - if (T.isSameArray(T.getObjectKeys(ob1),T.getObjectKeys(ob2))) { - for(var n in ob1) - { - if (ob1.hasOwnProperty(n)) - { - if ((T.isObject(ob1[n]) && T.isObject(ob2[n]) && T.isSameObject(ob1[n],ob2[n])) - || (T.isArray(ob1[n]) && T.isArray(ob2[n]) && T.isSameArray(ob1[n],ob2[n])) - || (ob1[n] == ob2[n])) { - } else { - return false; - } - } - } - } else { - return false; - } - } else { - return false; - } - return true; - }; - - // **************************************** - // * - // * Create public utility has method - // * Returns true if a complex object, array - // * or taffy collection contains the material - // * provided in the second argument - // * Purpose: Used to comare objects - // * - // **************************************** - TAFFY.has = function(var1, var2){ - var T = TAFFY; - var re = true; - if (T.isTAFFY(var1)) { - re = var1.find(var2); - if (re.length > 0) - { - return true; - } else { - return false; - } - } - else { - switch (T.typeOf(var1)) { - case "object": - if (T.isObject(var2)) { - for (var x in var2) { - if (re === true&& var2.hasOwnProperty(x) && !T.isUndefined(var1[x]) && var1.hasOwnProperty(x)) { - re = T.has(var1[x], var2[x]); - } else { - return false; - } - } - return re; - } - else - if (T.isArray(var2)) { - for (var x = 0; x < var2.length; x++) { - re = T.has(var1, var2[x]); - if (re === true) { - return true; - } - } - } - else - if (T.isString(var2) && !TAFFY.isUndefined(var1[var2])) { - return true; - } - break; - case "array": - if (T.isObject(var2)) { - for (var n = 0; n < var1.length; n++) { - re = T.has(var1[n], var2); - if (re == true) { - return true; - } - } - } - else - if (T.isArray(var2)) { - for (var x = 0; x < var2.length; x++) { - for (var n = 0; n < var1.length; n++) { - re = T.has(var1[n], var2[x]); - if (re == true) { - return true; - } - } } - } - else - if (T.isString(var2)) { - for (var n = 0; n < var1.length; n++) { - re = T.has(var1[n], var2); - if (re == true) { - return true; - } - } - } - break; - case "string": - if (T.isString(var2) && var2 == var1) { - return true; - } - break; - default: - if (T.typeOf(var1) == T.typeOf(var2) && var1 == var2) { - return true; - } - break; - } - } - return false; - }; - - // **************************************** - // * - // * Create public utility hasAll method - // * Returns true if a complex object, array - // * or taffy collection contains the material - // * provided in the call - for arrays it must - // * contain all the material in each array item - // * Purpose: Used to comare objects - // * - // **************************************** - - TAFFY.hasAll = function (var1,var2) { - var T = TAFFY; - if (T.isArray(var2)) { - var ar = true; - for(var i = 0, il = var2.length;i/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; -}; \ No newline at end of file diff --git a/package.json b/package.json deleted file mode 100644 index 344152b7..00000000 --- a/package.json +++ /dev/null @@ -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" - } - ] -} diff --git a/plugins/markdown.js b/plugins/markdown.js deleted file mode 100644 index efacb173..00000000 --- a/plugins/markdown.js +++ /dev/null @@ -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( /&/g, "&" ) // because markdown escapes these - .replace( /</g, "<" ) - .replace( />/g, ">" ); - } - }); - -})(); \ No newline at end of file diff --git a/templates/default/publish.js b/templates/default/publish.js deleted file mode 100644 index 327a7233..00000000 --- a/templates/default/publish.js +++ /dev/null @@ -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 . - @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(/'+htmlsafe(returnTypes.length? ' ⇒ '+returnTypes.join('|') : '')+''; - } - - function addSignatureType(f) { - var types = []; - - if (f.type && f.type.names) { - types = f.type.names; - } - - f.signature = (f.signature || '') + ''+htmlsafe(types.length? ' :'+types.join('|') : '')+''; - } - - 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 = ''+htmlsafe(attribs.length? '<'+attribs.join(', ')+'> ' : '')+''; - } - - 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*([\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? ''+(linktext || longname)+'' : (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 + '

    Modules

      '; - moduleNames.forEach(function(m) { - if ( !seen.hasOwnProperty(m.longname) ) nav += '
    • '+linkto(m.longname, m.name)+'
    • '; - seen[m.longname] = true; - }); - - nav = nav + '
    '; - } - var namespaceNames = data.get( data.find({kind: 'namespace'}) ); - if (namespaceNames.length) { - nav = nav + '

    Namespaces

      '; - namespaceNames.forEach(function(n) { - if ( !seen.hasOwnProperty(n.longname) ) nav += '
    • '+linkto(n.longname, n.name)+'
    • '; - seen[n.longname] = true; - }); - - nav = nav + '
    '; - } - var classNames = data.get( data.find({kind: 'class'}) ); - if (classNames.length) { - nav = nav + '

    Classes

      '; - classNames.forEach(function(c) { - if ( !seen.hasOwnProperty(c.longname) ) nav += '
    • '+linkto(c.longname, c.name)+'
    • '; - seen[c.longname] = true; - }); - - nav = nav + '
    '; - } - - var globalNames = data.get( data.find({kind: ['property', 'function'], 'memberof': {'isUndefined': true}}) ); - - if (globalNames.length) { - nav = nav + '

    Global

      '; - globalNames.forEach(function(g) { - if ( !seen.hasOwnProperty(g.longname) ) nav += '
    • '+linkto(g.longname, g.name)+'
    • '; - seen[g.longname] = true; - }); - - nav = nav + '
    '; - } - - 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) - } - } - -})(); \ No newline at end of file diff --git a/templates/default/static/styles/jsdoc-default.css b/templates/default/static/styles/jsdoc-default.css deleted file mode 100644 index 23a79857..00000000 --- a/templates/default/static/styles/jsdoc-default.css +++ /dev/null @@ -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; } \ No newline at end of file diff --git a/templates/default/static/styles/node-dark.css b/templates/default/static/styles/node-dark.css deleted file mode 100644 index 5849e234..00000000 --- a/templates/default/static/styles/node-dark.css +++ /dev/null @@ -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; -} diff --git a/templates/default/tmpl/container.tmpl b/templates/default/tmpl/container.tmpl deleted file mode 100644 index ebe5ab23..00000000 --- a/templates/default/tmpl/container.tmpl +++ /dev/null @@ -1,202 +0,0 @@ - - - - - JSDoc: <?js= title ?> - - - - - - - - - - - -
    - -

    - - - -
    - -
    - '); - - if (doc.ancestors && doc.ancestors.length) { - print(''+doc.ancestors.join(' » ')+''); - print(' » '+doc.name); - } - else { - print(doc.name) - } - - if (doc.variation) { - print(''+doc.variation+''); - } - - print(''); - - if (doc.classdesc) { - print('

    '+doc.classdesc+'

    '); - } - ?> -
    - -
    - ' + doc.description + '

    '); - } - - print(render('details.tmpl', doc)); - - if (doc.examples && doc.examples.length) { - print('

    Example' + (doc.examples.length > 1? 's':'') + '

    '); - print( render('examples.tmpl', doc.examples) ); - } - } - ?> - - -

    Extends

    - -
      -
    • -
    - - - -

    Requires

    - -
      -
    • -
    - - - - -

    Classes

    - -
    -
    -
    -
    - - - - - -

    Namespaces

    - -
    -
    -
    -
    - - - - - -

    Properties

    - -
    - - - - - -

    Methods

    - -
    - - - - - -

    Events

    - -
    - -
    - -
    - -
    - -
    -
    - Documentation generated by JSDoc 3 on -
    - - - - \ No newline at end of file diff --git a/templates/default/tmpl/details.tmpl b/templates/default/tmpl/details.tmpl deleted file mode 100644 index 17d15e30..00000000 --- a/templates/default/tmpl/details.tmpl +++ /dev/null @@ -1,55 +0,0 @@ -
    - -
    Version:
    -
    - - - -
    Since:
    -
    - - - -
    Deprecated
    Yes
    '); - else print(':
    '+this.deprecated+'
    '); - ?> - - - - -
    Author:
    -
    - - - -
    Copyright:
    -
    - - - -
    License:
    -
    - - - -
    Default Value:
    -
    - - - -
    Source:
    -
    , line
    - - - -
    See:
    -
    -
      '+linkto(s)+''); - }); - ?>
    -
    - -
    diff --git a/templates/default/tmpl/example.tmpl b/templates/default/tmpl/example.tmpl deleted file mode 100644 index 47a10889..00000000 --- a/templates/default/tmpl/example.tmpl +++ /dev/null @@ -1,2 +0,0 @@ - -
    diff --git a/templates/default/tmpl/examples.tmpl b/templates/default/tmpl/examples.tmpl deleted file mode 100644 index fdf78762..00000000 --- a/templates/default/tmpl/examples.tmpl +++ /dev/null @@ -1,10 +0,0 @@ - -

    - -
    - \ No newline at end of file diff --git a/templates/default/tmpl/exceptions.tmpl b/templates/default/tmpl/exceptions.tmpl deleted file mode 100644 index e4449867..00000000 --- a/templates/default/tmpl/exceptions.tmpl +++ /dev/null @@ -1,28 +0,0 @@ -
  • - -
    - -
    - - - -
    -
    - Type -
    -
    - - - -
    -
    - -
  • \ No newline at end of file diff --git a/templates/default/tmpl/fires.tmpl b/templates/default/tmpl/fires.tmpl deleted file mode 100644 index 1eef451f..00000000 --- a/templates/default/tmpl/fires.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -
  • - -
  • \ No newline at end of file diff --git a/templates/default/tmpl/method.tmpl b/templates/default/tmpl/method.tmpl deleted file mode 100644 index 4f6cf04e..00000000 --- a/templates/default/tmpl/method.tmpl +++ /dev/null @@ -1,73 +0,0 @@ - -
    -

    - - -

    - -
    -
    - - -

    - -

    - - - - - This:'); - print( '
    • '+linkto(this['this'], this['this'])+'
    ' ); - } - ?> - - Parameters:'); - print( render('params.tmpl', params) ); - } - ?> - - -
    Fires:
    -
    - - - -
    Throws:
    -
    - - - Returns:'); - print('

    '+rdesc.join('

    ')+'

    '); - } - } - ?> - - Example' + (examples.length > 1? 's':'') + ''); - print( render('examples.tmpl', examples) ); - } - ?> - -
    diff --git a/templates/default/tmpl/params.tmpl b/templates/default/tmpl/params.tmpl deleted file mode 100644 index 41e84ab5..00000000 --- a/templates/default/tmpl/params.tmpl +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NameTypeArgumentDefaultDescription
    - - -
    ' ); - } - - if (param.nullable) { - print( '<nullable>
    ' ); - } - ?> -
    - - Properties' + render('params.tmpl', param.subparams) ); - }?>
    \ No newline at end of file diff --git a/templates/default/tmpl/properties.tmpl b/templates/default/tmpl/properties.tmpl deleted file mode 100644 index 91687252..00000000 --- a/templates/default/tmpl/properties.tmpl +++ /dev/null @@ -1,24 +0,0 @@ - -
    -

    - - -

    - -
    -
    - -

    - -

    - - - - - Example' + (examples.length > 1? 's':'') + ''); - print( render('examples.tmpl', examples) ); - } - ?> -
    diff --git a/templates/default/tmpl/returns.tmpl b/templates/default/tmpl/returns.tmpl deleted file mode 100644 index 464d67f0..00000000 --- a/templates/default/tmpl/returns.tmpl +++ /dev/null @@ -1,31 +0,0 @@ -
  • - -
    - -
    - - - - -
    -
    - Type -
    -
    - - - -
    -
    - -
  • \ No newline at end of file diff --git a/templates/haruki/publish.js b/templates/haruki/publish.js deleted file mode 100644 index 782f3de6..00000000 --- a/templates/haruki/publish.js +++ /dev/null @@ -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( '\n' + xml.convert(root) + '\n' ); - } - 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); - } - }); - } - -})(); - diff --git a/test/cases/accesstag.js b/test/cases/accesstag.js deleted file mode 100644 index 497c20dd..00000000 --- a/test/cases/accesstag.js +++ /dev/null @@ -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; - -} \ No newline at end of file diff --git a/test/cases/alias.js b/test/cases/alias.js deleted file mode 100644 index bbb7305c..00000000 --- a/test/cases/alias.js +++ /dev/null @@ -1,13 +0,0 @@ -var myObject = (function() { - - /** Give x another name. - @alias myObject - @namespace - */ - var x = { - /** document me */ - myProperty: 'foo' - } - - return x; -})(); \ No newline at end of file diff --git a/test/cases/alias2.js b/test/cases/alias2.js deleted file mode 100644 index e1d8e5a5..00000000 --- a/test/cases/alias2.js +++ /dev/null @@ -1,10 +0,0 @@ -(function() { - - /** @alias ns.Myclass# */ - var x = { - /** document me */ - myProperty: 'foo' - } - - return x; -})(); \ No newline at end of file diff --git a/test/cases/alias3.js b/test/cases/alias3.js deleted file mode 100644 index 3cea9aba..00000000 --- a/test/cases/alias3.js +++ /dev/null @@ -1,12 +0,0 @@ -Klass('trackr.CookieManager', - - /** @class - @alias trackr.CookieManager - @param {object} kv - */ - function(kv) { - /** document me */ - this.value = kv; - } - -); \ No newline at end of file diff --git a/test/cases/also.js b/test/cases/also.js deleted file mode 100644 index 602bc041..00000000 --- a/test/cases/also.js +++ /dev/null @@ -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; } -} \ No newline at end of file diff --git a/test/cases/augmentstag.js b/test/cases/augmentstag.js deleted file mode 100644 index 7c2bd4c5..00000000 --- a/test/cases/augmentstag.js +++ /dev/null @@ -1,14 +0,0 @@ -/** -* @constructor -*/ -function Foo() { -} - - -/** -* @extends Foo -*/ -function Bar() { -} - - diff --git a/test/cases/authortag.js b/test/cases/authortag.js deleted file mode 100644 index 155bb570..00000000 --- a/test/cases/authortag.js +++ /dev/null @@ -1,6 +0,0 @@ -/** @constructor - @author Michael Mathews -*/ -function Thingy() { - -} \ No newline at end of file diff --git a/test/cases/borrowstag.js b/test/cases/borrowstag.js deleted file mode 100644 index b6d065dd..00000000 --- a/test/cases/borrowstag.js +++ /dev/null @@ -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) { -} - diff --git a/test/cases/borrowstag2.js b/test/cases/borrowstag2.js deleted file mode 100644 index 9e80dd0d..00000000 --- a/test/cases/borrowstag2.js +++ /dev/null @@ -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) { -} - diff --git a/test/cases/classtag.js b/test/cases/classtag.js deleted file mode 100644 index ea4584b1..00000000 --- a/test/cases/classtag.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - Describe the Ticker class here. - @class - */ -var Ticker = function() { - -}; - -/** - Describe the NewsSource class here. - @class NewsSource - */ \ No newline at end of file diff --git a/test/cases/constructortag.js b/test/cases/constructortag.js deleted file mode 100644 index 275ef3c6..00000000 --- a/test/cases/constructortag.js +++ /dev/null @@ -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() { -} diff --git a/test/cases/constructstag.js b/test/cases/constructstag.js deleted file mode 100644 index a31a1cd0..00000000 --- a/test/cases/constructstag.js +++ /dev/null @@ -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() { - } -}); \ No newline at end of file diff --git a/test/cases/constructstag2.js b/test/cases/constructstag2.js deleted file mode 100644 index 604d4bad..00000000 --- a/test/cases/constructstag2.js +++ /dev/null @@ -1,16 +0,0 @@ -Classify('Menu', - /** - @constructs Menu - @param items - */ - function (items) { - - }, - { - /** - @memberof Menu# - */ - show: function(){ - } - } -); diff --git a/test/cases/constructstag3.js b/test/cases/constructstag3.js deleted file mode 100644 index 3b4e410f..00000000 --- a/test/cases/constructstag3.js +++ /dev/null @@ -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; - } -}); diff --git a/test/cases/copyrighttag.js b/test/cases/copyrighttag.js deleted file mode 100644 index 68a09f34..00000000 --- a/test/cases/copyrighttag.js +++ /dev/null @@ -1,6 +0,0 @@ -/** @constructor - @copyright (c) 2011 Michael Mathews -*/ -function Thingy() { - -} \ No newline at end of file diff --git a/test/cases/defaulttag.js b/test/cases/defaulttag.js deleted file mode 100644 index bd8461aa..00000000 --- a/test/cases/defaulttag.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/test/cases/deprecatedtag.js b/test/cases/deprecatedtag.js deleted file mode 100644 index 6b6269cb..00000000 --- a/test/cases/deprecatedtag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** @deprecated -*/ -function foo() { - -} - -/** @deprecated since version 2.0 -*/ -function bar() { - -} \ No newline at end of file diff --git a/test/cases/exceptiontag.js b/test/cases/exceptiontag.js deleted file mode 100644 index 14d7d9a7..00000000 --- a/test/cases/exceptiontag.js +++ /dev/null @@ -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) { - -} \ No newline at end of file diff --git a/test/cases/exports.js b/test/cases/exports.js deleted file mode 100644 index 9c132478..00000000 --- a/test/cases/exports.js +++ /dev/null @@ -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'); -}; diff --git a/test/cases/exportstag.js b/test/cases/exportstag.js deleted file mode 100644 index 26f787ea..00000000 --- a/test/cases/exportstag.js +++ /dev/null @@ -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; -}); \ No newline at end of file diff --git a/test/cases/exportstag2.js b/test/cases/exportstag2.js deleted file mode 100644 index 5e00268a..00000000 --- a/test/cases/exportstag2.js +++ /dev/null @@ -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; - - } -); \ No newline at end of file diff --git a/test/cases/exportstag3.js b/test/cases/exportstag3.js deleted file mode 100644 index d48e94e2..00000000 --- a/test/cases/exportstag3.js +++ /dev/null @@ -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; - } -); \ No newline at end of file diff --git a/test/cases/file.js b/test/cases/file.js deleted file mode 100644 index 15fb0fc9..00000000 --- a/test/cases/file.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * @overview This is a file doclet. - */ - -function ignoreMe() { -} \ No newline at end of file diff --git a/test/cases/globaltag.js b/test/cases/globaltag.js deleted file mode 100644 index 44f1d186..00000000 --- a/test/cases/globaltag.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/test/cases/ignoretag.js b/test/cases/ignoretag.js deleted file mode 100644 index 4e8c2121..00000000 --- a/test/cases/ignoretag.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - @ignore -*/ -function foo(x) { - -} diff --git a/test/cases/inner.js b/test/cases/inner.js deleted file mode 100644 index 4c07b97a..00000000 --- a/test/cases/inner.js +++ /dev/null @@ -1,7 +0,0 @@ -function sendMessage(text) { - /** document me */ - var encoding = 'utf8'; - - /** document me */ - function encrypt(){} -} \ No newline at end of file diff --git a/test/cases/innerscope.js b/test/cases/innerscope.js deleted file mode 100644 index 5d2d5f5c..00000000 --- a/test/cases/innerscope.js +++ /dev/null @@ -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 = ''; - })() -} - diff --git a/test/cases/innerscope2.js b/test/cases/innerscope2.js deleted file mode 100644 index 68f30cba..00000000 --- a/test/cases/innerscope2.js +++ /dev/null @@ -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 = ''; - })() -} - diff --git a/test/cases/jslangnames.js b/test/cases/jslangnames.js deleted file mode 100644 index 65f8404a..00000000 --- a/test/cases/jslangnames.js +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test/cases/lends.js b/test/cases/lends.js deleted file mode 100644 index 6d86ae6d..00000000 --- a/test/cases/lends.js +++ /dev/null @@ -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; - } - } -); \ No newline at end of file diff --git a/test/cases/lends2.js b/test/cases/lends2.js deleted file mode 100644 index 57c4fa38..00000000 --- a/test/cases/lends2.js +++ /dev/null @@ -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; - } - } -); \ No newline at end of file diff --git a/test/cases/lendsglobal.js b/test/cases/lendsglobal.js deleted file mode 100644 index 13803be1..00000000 --- a/test/cases/lendsglobal.js +++ /dev/null @@ -1,14 +0,0 @@ -declare({ - globals: /** @lends */ { - - /** document me */ - 'test': function() { }, - - /** @namespace */ - 'test1': { - - /** document me */ - 'test2': function() { } - } - } -}); \ No newline at end of file diff --git a/test/cases/memberoftag.js b/test/cases/memberoftag.js deleted file mode 100644 index 2337c49f..00000000 --- a/test/cases/memberoftag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** @constructor - @member mathlib - */ -function Data() { - - /** @property */ - this.point = {}; -} - -/** @namespace */ -mathlib = {Data: Data}; \ No newline at end of file diff --git a/test/cases/memberoftag2.js b/test/cases/memberoftag2.js deleted file mode 100644 index b926dc6a..00000000 --- a/test/cases/memberoftag2.js +++ /dev/null @@ -1,10 +0,0 @@ -create( - 'Observable', - { - /** @memberof Observable */ - cache: [], - - /** @memberof Observable.prototype */ - publish: function(msg) {} - } -); \ No newline at end of file diff --git a/test/cases/modules/data/mod-1.js b/test/cases/modules/data/mod-1.js deleted file mode 100644 index a5de108f..00000000 --- a/test/cases/modules/data/mod-1.js +++ /dev/null @@ -1,5 +0,0 @@ -/** @module */ -define({ - property: "foo", - method: function() {} -}); \ No newline at end of file diff --git a/test/cases/modules/data/mod-2.js b/test/cases/modules/data/mod-2.js deleted file mode 100644 index 1027fd9d..00000000 --- a/test/cases/modules/data/mod-2.js +++ /dev/null @@ -1,5 +0,0 @@ -/** @module my/module/name */ -define({ - property: "foo", - method: function() {} -}); \ No newline at end of file diff --git a/test/cases/modules/data/mod-3.js b/test/cases/modules/data/mod-3.js deleted file mode 100644 index 91a3251a..00000000 --- a/test/cases/modules/data/mod-3.js +++ /dev/null @@ -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; -}); \ No newline at end of file diff --git a/test/cases/moduletag.js b/test/cases/moduletag.js deleted file mode 100644 index fb4c4665..00000000 --- a/test/cases/moduletag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @module bookshelf - */ - -/** - * @class - */ -this.Book = function(title) { - /** document me */ - this.title = title; -} \ No newline at end of file diff --git a/test/cases/moduletag2.js b/test/cases/moduletag2.js deleted file mode 100644 index 0dd0bc3e..00000000 --- a/test/cases/moduletag2.js +++ /dev/null @@ -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) { } \ No newline at end of file diff --git a/test/cases/objectlit.js b/test/cases/objectlit.js deleted file mode 100644 index f976cfb4..00000000 --- a/test/cases/objectlit.js +++ /dev/null @@ -1,8 +0,0 @@ -/** document me */ -var tools = { - /** document me */ - serialiser: { - /** document me */ - value: '' - } -}; diff --git a/test/cases/objectlit2.js b/test/cases/objectlit2.js deleted file mode 100644 index 072d4eda..00000000 --- a/test/cases/objectlit2.js +++ /dev/null @@ -1,8 +0,0 @@ -/** document me */ -var position = { - axis: { - /** document me */ - x: 0, - y: 0 - } -}; \ No newline at end of file diff --git a/test/cases/paramtag.js b/test/cases/paramtag.js deleted file mode 100644 index db431bfc..00000000 --- a/test/cases/paramtag.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @param { String | Array} 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) { -} diff --git a/test/cases/privatetag.js b/test/cases/privatetag.js deleted file mode 100644 index 71e0d971..00000000 --- a/test/cases/privatetag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** -* @constructor -* @private -*/ -function Foo() { - - /** document me */ - this.bar = 1; -} - - diff --git a/test/cases/projecttag.js b/test/cases/projecttag.js deleted file mode 100644 index b00c8e2c..00000000 --- a/test/cases/projecttag.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - An automated documentation generator for JavaScript. - @project JSDoc - @version 3.0.0 - @copyright 2011 (c) Michael Mathews - @license Apache Version 2 - */ -function blah(url) { -} \ No newline at end of file diff --git a/test/cases/quotename.js b/test/cases/quotename.js deleted file mode 100644 index e484db5e..00000000 --- a/test/cases/quotename.js +++ /dev/null @@ -1,19 +0,0 @@ -/** @namespace */ -var chat = {}; - -/** - @namespace - */ -chat["#channel"] = {}; - - -/** - @property - @type {boolean} - @defaultvalue - */ -chat["#channel"].open = true; - -/** - @event chat."#channel"."op:announce-motd" - */ \ No newline at end of file diff --git a/test/cases/quotename2.js b/test/cases/quotename2.js deleted file mode 100644 index b05c8136..00000000 --- a/test/cases/quotename2.js +++ /dev/null @@ -1,10 +0,0 @@ -/** @namespace */ -var contacts = { - - /** @namespace */ - 'say-"hello"@example.com': { - - /** document me */ - "username": 'Sue Smart' - } -} \ No newline at end of file diff --git a/test/cases/readonlytag.js b/test/cases/readonlytag.js deleted file mode 100644 index 30e826ce..00000000 --- a/test/cases/readonlytag.js +++ /dev/null @@ -1,10 +0,0 @@ -/** -* @constructor -*/ -function Collection() { - - /** @readonly */ - this.length = 0; -} - - diff --git a/test/cases/requirestag.js b/test/cases/requirestag.js deleted file mode 100644 index 3fe27229..00000000 --- a/test/cases/requirestag.js +++ /dev/null @@ -1,12 +0,0 @@ -/** -* @requires module:foo/helper -*/ -function foo() { -} - -/** -* @requires foo -* @requires Pez#blat this text is ignored -*/ -function bar() { -} diff --git a/test/cases/returnstag.js b/test/cases/returnstag.js deleted file mode 100644 index d3cf4de4..00000000 --- a/test/cases/returnstag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** -* @returns { String | Array} The names of the found item(s). -*/ -function find(targetName) { -} - -/** -* @return The binding id. -*/ -function bind(callback) { -} diff --git a/test/cases/seetag.js b/test/cases/seetag.js deleted file mode 100644 index 9b9ad723..00000000 --- a/test/cases/seetag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** -* @see #search -*/ -function foo() { -} - -/** -* @see http://example.com/someref -*/ -function bar() { -} diff --git a/test/cases/sincetag.js b/test/cases/sincetag.js deleted file mode 100644 index 527b2a39..00000000 --- a/test/cases/sincetag.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - @since 1.2.3 -*/ -function foo(x) { - -} diff --git a/test/cases/src/_dir2/four.js b/test/cases/src/_dir2/four.js deleted file mode 100644 index e69de29b..00000000 diff --git a/test/cases/src/_ignored.js b/test/cases/src/_ignored.js deleted file mode 100644 index e69de29b..00000000 diff --git a/test/cases/src/dir1/three.js b/test/cases/src/dir1/three.js deleted file mode 100644 index e69de29b..00000000 diff --git a/test/cases/src/ignored.txt b/test/cases/src/ignored.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/test/cases/src/one.js b/test/cases/src/one.js deleted file mode 100644 index e69de29b..00000000 diff --git a/test/cases/src/two.js b/test/cases/src/two.js deleted file mode 100644 index e69de29b..00000000 diff --git a/test/cases/this-and-objectlit.js b/test/cases/this-and-objectlit.js deleted file mode 100644 index c8d5ca0f..00000000 --- a/test/cases/this-and-objectlit.js +++ /dev/null @@ -1,12 +0,0 @@ -/** @constructor */ -function Page(title) { - this.parts = { - title: title, - body: { - /** document me */ - heading: '', - main: '' - } - } -} - diff --git a/test/cases/this.js b/test/cases/this.js deleted file mode 100644 index 7c167606..00000000 --- a/test/cases/this.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - @constructor - */ -function Singer() { - - this.tralala = function() { // method of constructor Singer - /** document me */ - this.isSinging = true; // setting a member of constructor Singer - }; -} \ No newline at end of file diff --git a/test/cases/this2.js b/test/cases/this2.js deleted file mode 100644 index 88fd9fa6..00000000 --- a/test/cases/this2.js +++ /dev/null @@ -1,15 +0,0 @@ -/** @constructor */ -function TemplateBuilder(templateType) { - //** document me */ - //this.templateType = templateType; - - /** @constructor */ - this.Template = function() { // nested constructor of constructor TemplateFactory - /** document me */ - this.render = function(data) { - /** document me */ - this.rendered = true; - } - }; - -} \ No newline at end of file diff --git a/test/cases/this3.js b/test/cases/this3.js deleted file mode 100644 index 7e4e0a77..00000000 --- a/test/cases/this3.js +++ /dev/null @@ -1,5 +0,0 @@ -function setPosition(newP) { - /** document me */ - this.position = newP; // sets global property -} - diff --git a/test/cases/thistag.js b/test/cases/thistag.js deleted file mode 100644 index 1ea79253..00000000 --- a/test/cases/thistag.js +++ /dev/null @@ -1,10 +0,0 @@ -/** @constructor */ -function Foo(name) { - setName.apply(this, name); -} - -/** @this Foo */ -function setName(name) { - /** document me */ - this.name = name; -} \ No newline at end of file diff --git a/test/cases/typedeftag.js b/test/cases/typedeftag.js deleted file mode 100644 index 9d82cfdc..00000000 --- a/test/cases/typedeftag.js +++ /dev/null @@ -1,5 +0,0 @@ -/** @typedef {(string|number)} calc.NumberLike */ - -/** @param {calc.NumberLike} x A number or a string. */ -calc.readNumber = function(x) { -} \ No newline at end of file diff --git a/test/cases/typekind.js b/test/cases/typekind.js deleted file mode 100644 index cc4c5450..00000000 --- a/test/cases/typekind.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - @module {ConnectServer} blog/server -*/ - -module.exports = require('connect').createServer( - Connect.logger(), - Connect.conditionalGet(), - Connect.favicon(), - Connect.cache(), - Connect.gzip(), - require('wheat')(__dirname) -); - -/** - @property {number} module:blog/server.port - @default 8080 -*/ \ No newline at end of file diff --git a/test/cases/typetag.js b/test/cases/typetag.js deleted file mode 100644 index acaa7cac..00000000 --- a/test/cases/typetag.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - @type {string|Array} -*/ -var foo; - - -/** - @type integer -*/ -var bar = +(new Date()).getTime(); \ No newline at end of file diff --git a/test/cases/var.js b/test/cases/var.js deleted file mode 100644 index 0daea9f5..00000000 --- a/test/cases/var.js +++ /dev/null @@ -1,10 +0,0 @@ -/** document me */ -const GREEN = 1, - RED = 0; - -/** document me */ -var validate = function(){}; - -var i, - /** document me */ - results; \ No newline at end of file diff --git a/test/cases/variations.js b/test/cases/variations.js deleted file mode 100644 index e292cae7..00000000 --- a/test/cases/variations.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @namespace anim - */ - -/** - * @method anim.fadein(1) - * @desc Show the nodelist elements by fading them to opaque. - * @since 1.0 - * - * @param {number} [duration=400] How long the animation will run. - * @param {function} [callback] Called once the animation is complete. - * - * @returns {this} - */ - -/** - * @method anim.fadein(2) - * @desc Show the nodelist elements by fading them to opaque. - * @since 1.4.3 - * - * @param {number} [duration=400] How long the animation will run. - * @param {string} [easing=swing] The easing function for the transition. - * @param {function} [callback] Called once the animation is complete. - * - * @returns {this} - */ \ No newline at end of file diff --git a/test/cases/versiontag.js b/test/cases/versiontag.js deleted file mode 100644 index a482075a..00000000 --- a/test/cases/versiontag.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - @version 1.2.3 -*/ -function foo(x) { - -} diff --git a/test/cases/virtual.js b/test/cases/virtual.js deleted file mode 100644 index 4eb25c1d..00000000 --- a/test/cases/virtual.js +++ /dev/null @@ -1,3 +0,0 @@ -/** @name dimensions */ - -var width = 12 \ No newline at end of file diff --git a/test/runner.js b/test/runner.js deleted file mode 100644 index 3bdd56d9..00000000 --- a/test/runner.js +++ /dev/null @@ -1,149 +0,0 @@ -var assert = require('common/assert'); - -var passCount = 0, - failCount = 0, - errorLog = [], - currentTestFile = ''; - -function test(description, f) { - try { - f(); - passCount++; - } - catch(e) { - errorLog.push(description + (currentTestFile? ' ['+currentTestFile+']':'') + '\n' + (e.message||'') + '\n - Expected: ' + e.expected + '\n - Actual: ' + e.actual); - failCount++; - } -} - -function testFile(filepath) { - currentTestFile = filepath; - include(filepath); - currentTestFile = ''; -} - -function report() { - print('\033[032mPASSED: ' + passCount + ' test' + (passCount == 1? '' : 's') + '.\033[0m'); - if (failCount) { - print('\033[031mFAILED: '+ failCount + ' test' + (passCount == 1? '' : 's') + '.\033[0m'); - for (var i = 0, leni = errorLog.length; i < leni; i++) { - print(' ' + (i+1) + '. ' + (i+1 < 10? ' ' : '') + (errorLog[i]||'') + '\n'); - } - } -} - -// helpers -var testhelpers = { - getDocSetFromFile: function(filename) { - var sourceCode = readFile(BASEDIR + filename), - testParser, - doclets; - - testParser = new (require('jsdoc/src/parser')).Parser(); - require('jsdoc/src/handlers').attachTo(testParser); - - doclets = testParser.parse('javascript:' + sourceCode); - testhelpers.indexAll(doclets); - - return { - doclets: doclets, - getByLongname: function(longname) { - return doclets.filter(function(doclet) { - return (doclet.longname || doclet.name) === longname; - }); - } - }; - }, - indexAll: function(docs) { - var index = {}; - docs.forEach(function(doc) { - if (!index[doc.longname]) index[doc.longname] = []; - index[doc.longname].push(doc); - }); - docs.index = index; - } -}; - -testFile('test/t/common/util.js'); -testFile('test/t/common/dumper.js'); -testFile('test/t/common/events.js'); -testFile('test/t/common/query.js'); -testFile('test/t/common/scanner.js'); - -testFile('test/t/jsdoc/opts/parser.js'); -testFile('test/t/jsdoc/src/parser.js'); -testFile('test/t/jsdoc/src/handlers.js'); -testFile('test/t/jsdoc/name.js'); - -testFile('test/t/cases/file.js'); - -testFile('test/t/cases/virtual.js'); - -testFile('test/t/cases/objectlit.js'); -testFile('test/t/cases/objectlit2.js'); - -testFile('test/t/cases/this.js'); -testFile('test/t/cases/this2.js'); -testFile('test/t/cases/this3.js'); - -testFile('test/t/cases/this-and-objectlit.js'); - -testFile('test/t/cases/var.js'); - -testFile('test/t/cases/inner.js'); -testFile('test/t/cases/innerscope.js'); -testFile('test/t/cases/innerscope2.js'); - -testFile('test/t/cases/modules/data/mod-1.js'); -testFile('test/t/cases/modules/data/mod-2.js'); - -testFile('test/t/cases/accesstag.js'); -testFile('test/t/cases/alias.js'); -testFile('test/t/cases/alias2.js'); -testFile('test/t/cases/alias3.js'); -testFile('test/t/cases/also.js'); -testFile('test/t/cases/augmentstag.js'); -testFile('test/t/cases/authortag.js'); -testFile('test/t/cases/borrowstag.js'); -testFile('test/t/cases/borrowstag2.js'); -testFile('test/t/cases/classtag.js'); -testFile('test/t/cases/constructstag.js'); -testFile('test/t/cases/constructstag2.js'); -testFile('test/t/cases/constructstag3.js'); -testFile('test/t/cases/constructortag.js'); -testFile('test/t/cases/copyrighttag.js'); -testFile('test/t/cases/defaulttag.js'); -testFile('test/t/cases/deprecatedtag.js'); -testFile('test/t/cases/exports.js'); -testFile('test/t/cases/exportstag.js'); -testFile('test/t/cases/exportstag2.js'); -testFile('test/t/cases/exportstag3.js'); -testFile('test/t/cases/exceptiontag.js'); -testFile('test/t/cases/globaltag.js'); -testFile('test/t/cases/ignoretag.js'); -testFile('test/t/cases/lends.js'); -testFile('test/t/cases/lends2.js'); -testFile('test/t/cases/lendsglobal.js'); -testFile('test/t/cases/memberoftag.js'); -testFile('test/t/cases/memberoftag2.js'); -testFile('test/t/cases/moduletag.js'); -testFile('test/t/cases/moduletag2.js'); -testFile('test/t/cases/paramtag.js'); -testFile('test/t/cases/privatetag.js'); -testFile('test/t/cases/quotename.js'); -testFile('test/t/cases/quotename2.js'); -testFile('test/t/cases/readonlytag.js'); -testFile('test/t/cases/requirestag.js'); -testFile('test/t/cases/returnstag.js'); -testFile('test/t/cases/seetag.js'); -testFile('test/t/cases/sincetag.js'); -testFile('test/t/cases/thistag.js'); -testFile('test/t/cases/typekind.js'); -testFile('test/t/cases/typetag.js'); -testFile('test/t/cases/typedeftag.js'); -testFile('test/t/cases/variations.js'); -testFile('test/t/cases/versiontag.js'); - - -report(); - diff --git a/test/t/cases/accesstag.js b/test/t/cases/accesstag.js deleted file mode 100644 index 9165cf95..00000000 --- a/test/t/cases/accesstag.js +++ /dev/null @@ -1,39 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/accesstag.js'), - foo = docSet.getByLongname('Thingy~foo')[0], - _bar = docSet.getByLongname('Thingy#_bar')[0], - pez = docSet.getByLongname('Thingy#pez')[0]; - - //dump(docSet.doclets); - - test('When a symbol has a @access private tag, the doclet has a access="private" property.', function() { - assert.equal(foo.access, 'private'); - }); - - test('When a symbol has a @access protected tag, the doclet has a access="protected" property.', function() { - assert.equal(_bar.access, 'protected'); - }); - - test('When a symbol has a @access public tag, the doclet has no access property.', function() { - assert.equal(typeof pez.access, 'undefined'); - }); - - // same as... - - foo = docSet.getByLongname('OtherThingy~foo')[0]; - _bar = docSet.getByLongname('OtherThingy#_bar')[0]; - pez = docSet.getByLongname('OtherThingy#pez')[0]; - - test('When a symbol has a @private tag, the doclet has a access="private" property.', function() { - assert.equal(foo.access, 'private'); - }); - - test('When a symbol has a @protected tag, the doclet has a access="protected" property.', function() { - assert.equal(_bar.access, 'protected'); - }); - - test('When a symbol has a @public tag, the doclet has no access property.', function() { - assert.equal(typeof pez.access, 'undefined'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/alias.js b/test/t/cases/alias.js deleted file mode 100644 index 2ffba19c..00000000 --- a/test/t/cases/alias.js +++ /dev/null @@ -1,20 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/alias.js'), - found = docSet.getByLongname('myObject').filter(function($) { - return ! $.undocumented; - }), - - foundMember = docSet.getByLongname('myObject.myProperty') - - //dump(found); - - test('When a symbol is given an alias it is documented as if the name is the alias value.', function() { - assert.equal(found[0].longname, 'myObject'); - }); - - test('When a symbol is a member of an alias it is documented as if the memberof is the alias value.', function() { - assert.equal(foundMember[0].longname, 'myObject.myProperty'); - assert.equal(foundMember[0].memberof, 'myObject'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/alias2.js b/test/t/cases/alias2.js deleted file mode 100644 index e14f31b2..00000000 --- a/test/t/cases/alias2.js +++ /dev/null @@ -1,18 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/alias2.js'), - found = docSet.getByLongname('myObject').filter(function($) { - return ! $.undocumented; - }), - - foundMember = docSet.getByLongname('ns.Myclass#myProperty') - - //dump(found); - - test('When a symbol is a member of an alias of a nested name it is documented as if the memberof is the nested alias value.', function() { - assert.equal(foundMember[0].longname, 'ns.Myclass#myProperty'); - assert.equal(foundMember[0].name, 'myProperty'); - assert.equal(foundMember[0].memberof, 'ns.Myclass'); - assert.equal(foundMember[0].scope, 'instance'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/alias3.js b/test/t/cases/alias3.js deleted file mode 100644 index 1ff0e0ac..00000000 --- a/test/t/cases/alias3.js +++ /dev/null @@ -1,12 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/alias3.js'), - tcm = docSet.getByLongname('trackr.CookieManager')[0], - tcmValue = docSet.getByLongname('trackr.CookieManager#value')[0]; - - //dump(found); - - test('When a symbol is a member of an aliased class, a this-variables is documented as if it were a member that class.', function() { - assert.equal(tcmValue.memberof, 'trackr.CookieManager'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/also.js b/test/t/cases/also.js deleted file mode 100644 index a48b2381..00000000 --- a/test/t/cases/also.js +++ /dev/null @@ -1,13 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/also.js'), - name = docSet.getByLongname('Asset#name').filter(function($) { - return ! $.undocumented; - }); - - //dump(name); - - test('When a symbol has two doclets adjacent to each other both doclets apply to the symbol.', function() { - assert.equal(name.length, 2, 'myObject'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/augmentstag.js b/test/t/cases/augmentstag.js deleted file mode 100644 index dbaf4b0c..00000000 --- a/test/t/cases/augmentstag.js +++ /dev/null @@ -1,12 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/augmentstag.js'), - foo = docSet.getByLongname('Foo')[0], - bar = docSet.getByLongname('Bar')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @augments tag, the doclet has a augments property that includes that value.', function() { - assert.equal(typeof bar.augments, 'object'); - assert.equal(bar.augments[0], 'Foo'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/authortag.js b/test/t/cases/authortag.js deleted file mode 100644 index 7b7fabe8..00000000 --- a/test/t/cases/authortag.js +++ /dev/null @@ -1,11 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/authortag.js'), - Thingy = docSet.getByLongname('Thingy')[0]; - - //dump(docSet.doclets); - - test('When a symbol has a @author tag, the doclet has a author property with that value.', function() { - assert.equal(Thingy.author, 'Michael Mathews '); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/borrowstag.js b/test/t/cases/borrowstag.js deleted file mode 100644 index 4bef5814..00000000 --- a/test/t/cases/borrowstag.js +++ /dev/null @@ -1,14 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/borrowstag.js'), - util = docSet.getByLongname('util').filter(function($) { - return ! $.undocumented; - })[0]; - - //dump(found); - - test('When a symbol has a @borrows-as tag, that is added to the symbol\'s "borrowed" property.', function() { - assert.equal(util.borrowed.length, 1); - assert.equal(util.borrowed[0].from, 'trstr'); - assert.equal(util.borrowed[0].as, 'trim'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/borrowstag2.js b/test/t/cases/borrowstag2.js deleted file mode 100644 index 002e7cf3..00000000 --- a/test/t/cases/borrowstag2.js +++ /dev/null @@ -1,17 +0,0 @@ -var borrow = require('jsdoc/borrow'); - -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/borrowstag2.js'); - - borrow.resolveBorrows(docSet.doclets); - - var str_rtrim = docSet.getByLongname('str.rtrim').filter(function($) { - return ! $.undocumented; - })[0]; - - //dump(docSet); exit(); - - test('When a symbol has a @borrows tag, the borrowed symbol is added to the symbol.', function() { - assert.equal(typeof str_rtrim, 'object'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/classtag.js b/test/t/cases/classtag.js deleted file mode 100644 index d3293564..00000000 --- a/test/t/cases/classtag.js +++ /dev/null @@ -1,16 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/classtag.js'), - ticker = docSet.getByLongname('Ticker')[0], - news = docSet.getByLongname('NewsSource')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has a @class tag, the doclet has a kind property set to "class".', function() { - assert.equal(ticker.kind, 'class'); - }); - - test('When a symbol has a @class tag with a value, the doclet has a name property set to that value.', function() { - assert.equal(news.kind, 'class'); - assert.equal(news.longname, 'NewsSource'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/constructortag.js b/test/t/cases/constructortag.js deleted file mode 100644 index af23362b..00000000 --- a/test/t/cases/constructortag.js +++ /dev/null @@ -1,15 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/constructortag.js'), - feed = docSet.getByLongname('Feed')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @constructor tag, it is documented as a class.', function() { - assert.equal(feed.kind, 'class'); - }); - - test('When a symbol has an @constructor tag and a @class tag, the value of the @class tag becomes the classdesc property.', function() { - assert.equal(feed.classdesc, 'Describe your class here.'); - assert.equal(feed.description, 'Describe your constructor function here.'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/constructstag.js b/test/t/cases/constructstag.js deleted file mode 100644 index ec8c9d61..00000000 --- a/test/t/cases/constructstag.js +++ /dev/null @@ -1,11 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/constructstag.js'), - textblock = docSet.getByLongname('TextBlock')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @constructs tag, it is documented as a class with that name.', function() { - assert.equal(textblock.kind, 'class'); - assert.equal(textblock.longname, 'TextBlock'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/constructstag2.js b/test/t/cases/constructstag2.js deleted file mode 100644 index 2cd8e5fc..00000000 --- a/test/t/cases/constructstag2.js +++ /dev/null @@ -1,12 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/constructstag2.js'), - menu = docSet.getByLongname('Menu')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @constructs tag, it is documented as a class.', function() { - assert.equal(menu.name, 'Menu'); - assert.equal(menu.kind, 'class'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/constructstag3.js b/test/t/cases/constructstag3.js deleted file mode 100644 index 5e7a9649..00000000 --- a/test/t/cases/constructstag3.js +++ /dev/null @@ -1,12 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/constructstag3.js'), - personName = docSet.getByLongname('Person#name')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a function symbol has an @constructs tag, any this-variables are ducumented as instance members of the class.', function() { - assert.equal(personName.memberof, 'Person'); - assert.equal(personName.scope, 'instance'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/copyrighttag.js b/test/t/cases/copyrighttag.js deleted file mode 100644 index 76a144c4..00000000 --- a/test/t/cases/copyrighttag.js +++ /dev/null @@ -1,11 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/copyrighttag.js'), - Thingy = docSet.getByLongname('Thingy')[0]; - - //dump(docSet.doclets); - - test('When a symbol has a @copyright tag, the doclet has a copyright property with that value.', function() { - assert.equal(Thingy.copyright, '(c) 2011 Michael Mathews'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/defaulttag.js b/test/t/cases/defaulttag.js deleted file mode 100644 index e4d70c93..00000000 --- a/test/t/cases/defaulttag.js +++ /dev/null @@ -1,41 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/defaulttag.js'), - request = (docSet.getByLongname('request') || [])[0], - response = (docSet.getByLongname('response') || [])[0], - rcode = (docSet.getByLongname('rcode') || [])[0], - rvalid = (docSet.getByLongname('rvalid') || [])[0], - rerrored = (docSet.getByLongname('rerrored') || [])[0], - win = (docSet.getByLongname('win') || [])[0]; - header = (docSet.getByLongname('header') || [])[0]; - - //dump(response); - - test('When symbol set to null has a @default tag with no text.', function() { - assert.equal(request.defaultvalue, 'null', 'The doclet\'s defaultValue property should be: undefined.'); - }); - - test('When symbol set to a string has a @default tag with no text.', function() { - assert.equal(response.defaultvalue, '"ok"', 'The doclet\'s defaultValue property should be that quoted string.'); - }); - - test('When symbol set to a number has a @default tag with no text.', function() { - assert.equal(rcode.defaultvalue, '200', 'The doclet\'s defaultValue property should be that number.'); - }); - - test('When symbol has a @default tag with text.', function() { - assert.equal(win.defaultvalue, 'the parent window', 'The doclet\'s defaultValue property should be that text.'); - }); - - test('When symbol has a @default tag with true.', function() { - assert.equal(rvalid.defaultvalue, 'true'); - }); - - test('When symbol has a @default tag with false.', function() { - assert.equal(rerrored.defaultvalue, 'false'); - }); - - test('When symbol has a @default tag with a function call.', function() { - assert.equal(typeof header.defaultvalue, 'undefined'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/deprecatedtag.js b/test/t/cases/deprecatedtag.js deleted file mode 100644 index 5a93f131..00000000 --- a/test/t/cases/deprecatedtag.js +++ /dev/null @@ -1,16 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/deprecatedtag.js'), - foo = docSet.getByLongname('foo')[0], - bar = docSet.getByLongname('bar')[0]; - - //dump(docSet.doclets); - - test('When a symbol has a @deprecated tag with no value, the doclet has a deprecated property set to true.', function() { - assert.equal(foo.deprecated, true); - }); - - test('When a symbol has a @deprec tag with a value, the doclet has a deprecated property set to that value.', function() { - assert.equal(bar.deprecated, 'since version 2.0'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/exceptiontag.js b/test/t/cases/exceptiontag.js deleted file mode 100644 index de0ce730..00000000 --- a/test/t/cases/exceptiontag.js +++ /dev/null @@ -1,20 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/exceptiontag.js'), - foo = docSet.getByLongname('foo')[0], - bar = docSet.getByLongname('bar')[0], - pez = docSet.getByLongname('pez')[0]; - - //dump(docSet.doclets); - - test('When a symbol has an @exception tag, the doclet has a exception property set to that value.', function() { - assert.equal(typeof foo.exceptions, 'object'); - assert.equal(foo.exceptions.length, 1); - - assert.equal(typeof bar.exceptions, 'object'); - assert.equal(bar.exceptions.length, 1); - - assert.equal(typeof pez.exceptions, 'object'); - assert.equal(pez.exceptions.length, 1); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/exports.js b/test/t/cases/exports.js deleted file mode 100644 index fc80c8fc..00000000 --- a/test/t/cases/exports.js +++ /dev/null @@ -1,13 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/exports.js'), - helloworld = docSet.getByLongname('module:hello/world')[0], - sayhello = docSet.getByLongname('module:hello/world.sayHello')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol starts with the special name "exports" and is in a file with a @module tag, the symbol is documented as a member of that module.', function() { - assert.equal(typeof sayhello, 'object'); - assert.equal(sayhello.kind, 'function'); - assert.equal(sayhello.memberof, 'module:hello/world'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/exportstag.js b/test/t/cases/exportstag.js deleted file mode 100644 index c5395615..00000000 --- a/test/t/cases/exportstag.js +++ /dev/null @@ -1,31 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/exportstag.js'), - shirt = docSet.getByLongname('module:my/shirt')[0], - color = docSet.getByLongname('module:my/shirt.color')[0], - tneck = docSet.getByLongname('module:my/shirt.Turtleneck')[0], - size = docSet.getByLongname('module:my/shirt.Turtleneck#size')[0]; - - //dump(docSet.doclets); exit(0); - - test('When an objlit symbol has an @exports tag, the doclet is aliased to "module:" + the tag value.', function() { - assert.equal(typeof shirt, 'object'); - assert.equal(shirt.alias, 'my/shirt'); - }); - - test('When an objlit symbol has an @exports tag, the doclet\'s longname includes the "module:" namespace.', function() { - assert.equal(shirt.longname, 'module:my/shirt'); - }); - - test('When an objlit symbol has an @exports tag, the doclet kind is set to module.', function() { - assert.equal(shirt.kind, 'module'); - }); - - test('When an objlit symbol has an @exports tag, the objlit members are documented as members of the module.', function() { - assert.equal(typeof color, 'object'); - assert.equal(color.memberof, 'module:my/shirt'); - - assert.equal(typeof tneck, 'object'); - assert.equal(typeof size, 'object'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/exportstag2.js b/test/t/cases/exportstag2.js deleted file mode 100644 index c638b9b3..00000000 --- a/test/t/cases/exportstag2.js +++ /dev/null @@ -1,26 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/exportstag2.js'), - coat = docSet.getByLongname('module:my/coat')[0], - wool = docSet.getByLongname('module:my/coat#wool')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a function symbol has an @exports tag, the doclet is aliased to "module:" + the tag value.', function() { - assert.equal(typeof coat, 'object'); - assert.equal(coat.alias, 'my/coat'); - }); - - test('When a function symbol has an @exports tag, the doclet\'s longname includes the "module:" namespace.', function() { - assert.equal(coat.longname, 'module:my/coat'); - }); - - test('When a function symbol has an @exports tag, the doclet kind is set to module.', function() { - assert.equal(coat.kind, 'module'); - }); - - test('When a function symbol has an @exports tag, the this members are documented as instance members of the module.', function() { - assert.equal(typeof wool, 'object'); - assert.equal(wool.memberof, 'module:my/coat'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/exportstag3.js b/test/t/cases/exportstag3.js deleted file mode 100644 index a75c9b37..00000000 --- a/test/t/cases/exportstag3.js +++ /dev/null @@ -1,19 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/exportstag3.js'), - html = docSet.getByLongname('module:html/utils')[0], - getstyle = docSet.getByLongname('module:html/utils.getStyleProperty')[0], - inhead = docSet.getByLongname('module:html/utils.isInHead')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a function symbol has an @exports tag and there is an objlit named "exports" the members are documented as members of the module.', function() { - assert.equal(typeof getstyle, 'object'); - assert.equal(getstyle.memberof, 'module:html/utils'); - }); - - test('When a function symbol has an @exports tag and there are members assinged to an "exports" name, the members are documented as members of the module.', function() { - assert.equal(typeof inhead, 'object'); - assert.equal(inhead.memberof, 'module:html/utils'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/file.js b/test/t/cases/file.js deleted file mode 100644 index 94fd7e66..00000000 --- a/test/t/cases/file.js +++ /dev/null @@ -1,19 +0,0 @@ -(function() { - var srcParser = require('jsdoc/src/parser'), - doclets; - - app.jsdoc.parser = new srcParser.Parser(); - - require('jsdoc/src/handlers').attachTo(app.jsdoc.parser); - - doclets = app.jsdoc.parser.parse(BASEDIR + 'test/cases/file.js') - - //dump(doclets); - - test('When a file overview tag appears in a doclet.', function() { - var m = /^.*([\/\\]cases[\/\\]file\.js)$/.exec(doclets[0].name); - assert.equal(m.length, 2, 'The name of the doclet should start with file: and should end with the path to the file.'); - assert.equal(doclets[0].name, doclets[0].longname, 'The name and longname should be equal.'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/globaltag.js b/test/t/cases/globaltag.js deleted file mode 100644 index efea4807..00000000 --- a/test/t/cases/globaltag.js +++ /dev/null @@ -1,28 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/globaltag.js'), - found = docSet.getByLongname('foo').filter(function($) { - return ! $.undocumented; - }); - - //dump(docSet.doclets); - - test('When an inner symbol has a @global tag it is documented as if it were global.', function() { - assert.equal(found[0].name, 'foo'); - assert.equal(found[0].longname, 'foo'); - assert.equal(found[0].memberof, undefined); - assert.equal(found[0].scope, 'global'); - - }); - - found = docSet.getByLongname('Bar').filter(function($) { - return ! $.undocumented; - }); - - test('When an nested symbol has a @global tag it is documented as if it were global.', function() { - assert.equal(found[0].name, 'Bar'); - assert.equal(found[0].longname, 'Bar'); - assert.equal(found[0].memberof, undefined); - assert.equal(found[0].scope, 'global'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/ignoretag.js b/test/t/cases/ignoretag.js deleted file mode 100644 index c18eabca..00000000 --- a/test/t/cases/ignoretag.js +++ /dev/null @@ -1,11 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/ignoretag.js'), - foo = docSet.getByLongname('foo')[0]; - - //dump(docSet.doclets); - - test('When a symbol has an @ignore tag, the doclet has a ignore property set to true.', function() { - assert.equal(foo.ignore, true); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/inner.js b/test/t/cases/inner.js deleted file mode 100644 index 63a48f76..00000000 --- a/test/t/cases/inner.js +++ /dev/null @@ -1,21 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/inner.js'), - found1 = docSet.getByLongname('sendMessage~encoding'), - found2 = docSet.getByLongname('sendMessage~encrypt'); - - //dump(docSet); - - test('When a documented var member is inside a named function.', function() { - assert.equal(found1.length, 1, 'A doclet with the correct longname should be found.'); - assert.equal(found1[0].name, 'encoding', 'The short name should be correct.'); - assert.equal(found1[0].memberof, 'sendMessage', 'The memberof should be correct.'); - assert.equal(found1[0].scope, 'inner', 'The scope should default to "static".'); - }); - - test('When a documented function is inside a named function.', function() { - assert.equal(found2.length, 1, 'A doclet with the correct longname should be found.'); - assert.equal(found2[0].name, 'encrypt', 'The short name should be correct.'); - assert.equal(found2[0].memberof, 'sendMessage', 'The memberof should be correct.'); - assert.equal(found2[0].scope, 'inner', 'The scope should default to "static".'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/innerscope.js b/test/t/cases/innerscope.js deleted file mode 100644 index 8e6bee7d..00000000 --- a/test/t/cases/innerscope.js +++ /dev/null @@ -1,20 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/innerscope.js'), - to = docSet.getByLongname('Message~headers.to'), - from = docSet.getByLongname('Message~headers.from'), - response = docSet.getByLongname('Message~response.code'); - - //dump(docSet); exit(); - - test('When a member of a var member is documented.', function() { - assert.equal(to.length, 1, 'It is like Outer~inner.member.'); - }); - - test('When a second member of a var member is documented.', function() { - assert.equal(response.length, 1, 'It is like Outer~inner.member.'); - }); - - test('When a deeply nested member of a var member is documented.', function() { - assert.equal(from.length, 1, 'It is still like Outer~inner.member.'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/innerscope2.js b/test/t/cases/innerscope2.js deleted file mode 100644 index c29516ac..00000000 --- a/test/t/cases/innerscope2.js +++ /dev/null @@ -1,21 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/innerscope2.js'), - to = docSet.getByLongname('Message~headers.to'), - from = docSet.getByLongname('~headers.from'), - cache = docSet.getByLongname('~headers.cache'); - - //dump(docSet); - - test('When a var is declared in a function.', function() { - assert.equal(cache.length, 1, 'It is like Inner~member.'); - }); - - test('When a var is masked by an inner var and a member of the inner is documented.', function() { - assert.equal(from.length, 1, 'It is like Inner~inner.member.'); - }); - - test('When a documented member is assigned to a var that masks an outer var.', function() { - assert.equal(from[0].name, 'from'); - assert.equal(from[0].memberof, '~headers'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/lends.js b/test/t/cases/lends.js deleted file mode 100644 index 32459051..00000000 --- a/test/t/cases/lends.js +++ /dev/null @@ -1,14 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/lends.js'), - init = docSet.getByLongname('Person#initialize'), - say = docSet.getByLongname('Person#say'), - name = docSet.getByLongname('Person#name'); - - //dump(docSet); - - test('When a documented member is inside an objlit associated with a @lends tag.', function() { - assert.equal(init.length, 1, 'The member should be documented as a member of the lendee.'); - assert.equal(name.length, 1, 'The this member should be documented as a member of the lendee.'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/lends2.js b/test/t/cases/lends2.js deleted file mode 100644 index d3355fc2..00000000 --- a/test/t/cases/lends2.js +++ /dev/null @@ -1,17 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/lends2.js'), - person = docSet.getByLongname('Person').filter(function($) { - return ! $.undocumented; - })[0], - say = docSet.getByLongname('Person#say'), - name = docSet.getByLongname('Person#name') - - //dump(person); - - test('When a documented member is inside an objlit associated with a @lends tag.', function() { - assert.equal(person.description, 'Construct a Person.', 'A tag with a @constructs tag is documented as a constructor.'); - assert.equal(say.length, 1, 'The member should be documented as a member of the lendee.'); - assert.equal(name.length, 1, 'The this member should be documented as a member of the lendee.'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/lendsglobal.js b/test/t/cases/lendsglobal.js deleted file mode 100644 index 451e9a0a..00000000 --- a/test/t/cases/lendsglobal.js +++ /dev/null @@ -1,17 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/lendsglobal.js'), - testf = docSet.getByLongname('test')[0], - test1 = docSet.getByLongname('test1')[0], - test12 = docSet.getByLongname('test1.test2')[0]; - - //dump(testf, test1, test12); exit(); - - test('When a documented member is inside an objlit associated with a @lends tag that has no value.', function() { - assert.equal(typeof testf.memberof, 'undefined', 'The members of the objlit are not members of any symbol.'); - assert.equal(testf.longname, 'test', 'The members of the objlit are documented as global.'); - - - assert.equal(test12.memberof, 'test1', 'The nested members of the objlit are members of a global symbol.'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/memberoftag.js b/test/t/cases/memberoftag.js deleted file mode 100644 index 895ce5c0..00000000 --- a/test/t/cases/memberoftag.js +++ /dev/null @@ -1,15 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/memberoftag.js'), - Data = docSet.getByLongname('mathlib.Data')[0], - point = docSet.getByLongname('mathlib.Data#point')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @member tag, the doclet has a long name that includes the parent.', function() { - assert.equal(typeof Data, 'object'); - assert.equal(typeof point, 'object'); - - assert.equal(Data.memberof, 'mathlib'); - assert.equal(Data.name, 'Data'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/memberoftag2.js b/test/t/cases/memberoftag2.js deleted file mode 100644 index dc40e577..00000000 --- a/test/t/cases/memberoftag2.js +++ /dev/null @@ -1,23 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/memberoftag2.js'), - publish = docSet.getByLongname('Observable#publish')[0], - cache = docSet.getByLongname('Observable.cache')[0]; - - //dump(docSet.doclets); exit(0); - - test('A symbol is documented as a static @memberof a class.', function() { - assert.equal(typeof cache, 'object', 'it should appear as a static member of that class.'); - assert.equal(cache.memberof, 'Observable'); - assert.equal(cache.scope, 'static'); - assert.equal(cache.name, 'cache'); - assert.equal(cache.longname, 'Observable.cache'); - }); - - test('A symbol is documented as a static @memberof a class prototype.', function() { - assert.equal(typeof publish, 'object', 'it should appear as an instance member of that class.'); - assert.equal(publish.memberof, 'Observable'); - assert.equal(publish.scope, 'instance'); - assert.equal(publish.name, 'publish'); - assert.equal(publish.longname, 'Observable#publish'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/modules/data/mod-1.js b/test/t/cases/modules/data/mod-1.js deleted file mode 100644 index 6f26452f..00000000 --- a/test/t/cases/modules/data/mod-1.js +++ /dev/null @@ -1,18 +0,0 @@ -(function() { - var srcParser = require('jsdoc/src/parser'), - doclets; - - env.opts._ = [BASEDIR + 'test/cases/modules/']; - - app.jsdoc.parser = new srcParser.Parser(); - - require('jsdoc/src/handlers').attachTo(app.jsdoc.parser); - - doclets = app.jsdoc.parser.parse(BASEDIR + 'test/cases/modules/data/mod-1.js') - - test('When a module has no name documented, the name comes from the file path.', function() { - assert.ok(doclets.length > 1); - assert.equal(doclets[0].longname, 'module:data/mod-1'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/modules/data/mod-2.js b/test/t/cases/modules/data/mod-2.js deleted file mode 100644 index 5aff85ab..00000000 --- a/test/t/cases/modules/data/mod-2.js +++ /dev/null @@ -1,18 +0,0 @@ -(function() { - var srcParser = require('jsdoc/src/parser'), - doclets; - - env.opts._ = [BASEDIR + 'test/cases/modules/']; - - app.jsdoc.parser = new srcParser.Parser(); - - require('jsdoc/src/handlers').attachTo(app.jsdoc.parser); - - doclets = app.jsdoc.parser.parse(BASEDIR + 'test/cases/modules/data/mod-2.js') - - test('When a module has a name documented, that name is used.', function() { - assert.ok(doclets.length > 1); - assert.equal(doclets[0].longname, 'module:my/module/name'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/modules/data/mod-3.js b/test/t/cases/modules/data/mod-3.js deleted file mode 100644 index d4dcf9c2..00000000 --- a/test/t/cases/modules/data/mod-3.js +++ /dev/null @@ -1,18 +0,0 @@ -(function() { - var srcParser = require('jsdoc/src/parser'), - doclets; - - env.opts._ = [BASEDIR + 'test/cases/modules/']; - - app.jsdoc.parser = new srcParser.Parser(); - - require('jsdoc/src/handlers').attachTo(app.jsdoc.parser); - - doclets = app.jsdoc.parser.parse(BASEDIR + 'test/cases/modules/data/mod-2.js') - - test('When a module has a name documented, that name is used.', function() { - assert.ok(doclets.length > 1); - assert.equal(doclets[0].name, 'module:my/module/name'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/moduletag.js b/test/t/cases/moduletag.js deleted file mode 100644 index e7acd52c..00000000 --- a/test/t/cases/moduletag.js +++ /dev/null @@ -1,17 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/moduletag.js'), - book = docSet.getByLongname('module:bookshelf.Book')[0], - title = docSet.getByLongname('module:bookshelf.Book#title')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a global symbol starts with "this" and is in a file with a @module tag, the symbol is documented as a member of that module.', function() { - assert.equal(typeof book, 'object'); - assert.equal(book.memberof, 'module:bookshelf'); - }); - - test('When an inner symbol starts with "this" and is in a file with a @module tag, the symbol is documented as a member of its enclosing constructor.', function() { - assert.equal(typeof title, 'object'); - assert.equal(title.memberof, 'module:bookshelf.Book'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/moduletag2.js b/test/t/cases/moduletag2.js deleted file mode 100644 index 7ddba8dd..00000000 --- a/test/t/cases/moduletag2.js +++ /dev/null @@ -1,25 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/moduletag2.js'), - mixer = docSet.getByLongname('module:color/mixer').filter(function($) { - return ! $.undocumented; - })[0], - blend = docSet.getByLongname('module:color/mixer.blend')[0], - darken = docSet.getByLongname('module:color/mixer.darken')[0]; - - //dump(mixer); exit(0); - - test('When a @module tag defines a module module.', function() { - assert.equal(typeof mixer, 'object'); - assert.equal(mixer.kind, 'module', 'A symbol of kind "module" is documented.'); - }); - - test('When an object literal is lent to a module with a @lends tag.', function() { - assert.equal(typeof blend, 'object'); - assert.equal(blend.kind, 'function', 'A member of that object literal is documented as a member of the module.'); - }); - - test('When a documented symbol is a member of a namespace "exports".', function() { - assert.equal(typeof darken, 'object'); - assert.equal(darken.kind, 'function', 'It is documented as a member of the module.'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/objectlit.js b/test/t/cases/objectlit.js deleted file mode 100644 index b777dd7a..00000000 --- a/test/t/cases/objectlit.js +++ /dev/null @@ -1,13 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/objectlit.js'), - found = docSet.getByLongname('tools.serialiser.value'); - - //dump(docSet); - - test('When a child of an objlit has no @name or @memberof tags.', function() { - assert.equal(found.length, 1, 'A doclet with the correct longname should be found.'); - assert.equal(found[0].name, 'value', 'The short name should be correct.'); - assert.equal(found[0].memberof, 'tools.serialiser', 'The memberof should be correct.'); - assert.equal(found[0].scope, 'static', 'The scope should default to "static".'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/objectlit2.js b/test/t/cases/objectlit2.js deleted file mode 100644 index ec486aae..00000000 --- a/test/t/cases/objectlit2.js +++ /dev/null @@ -1,13 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/objectlit2.js'), - found = docSet.getByLongname('position.axis.x'); - - //dump(docSet); - - test('When a parent of an objlit has no documentation.', function() { - assert.equal(found.length, 1, 'A doclet with the correct longname should be found.'); - assert.equal(found[0].name, 'x', 'The short name should be correct.'); - assert.equal(found[0].memberof, 'position.axis', 'The memberof should be correct.'); - assert.equal(found[0].scope, 'static', 'The scope should default to "static".'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/paramtag.js b/test/t/cases/paramtag.js deleted file mode 100644 index 9a62441a..00000000 --- a/test/t/cases/paramtag.js +++ /dev/null @@ -1,69 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/paramtag.js'), - find = docSet.getByLongname('find')[0], - unbind = docSet.getByLongname('unbind')[0], - bind = docSet.getByLongname('bind')[0], - getElement = docSet.getByLongname('getElement')[0], - combine = docSet.getByLongname('combine')[0], - split = docSet.getByLongname('split')[0], - commit = docSet.getByLongname('commit')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @param tag with a type before the name, the doclet has a params property that includes that param.', function() { - assert.equal(typeof find.params, 'object'); - assert.equal(find.params.length, 1); - assert.equal(find.params[0].type.names.join(', '), 'String, Array'); - assert.equal(find.params[0].name, 'targetName'); - assert.equal(find.params[0].description, 'The name (or names) of what to find.'); - }); - - test('When a symbol has an @param tag with only a type and name, the doclet has a params property that includes that param.', function() { - assert.equal(typeof bind.params, 'object'); - assert.equal(bind.params.length, 1); - assert.equal(bind.params[0].type.names.join(', '), 'function'); - assert.equal(bind.params[0].name, 'callback'); - assert.equal(bind.params[0].description, undefined); - }); - - test('When a symbol has an @param tag with only a type, the doclet has a params property that includes that param.', function() { - assert.equal(typeof unbind.params, 'object'); - assert.equal(unbind.params.length, 1); - assert.equal(unbind.params[0].type.names.join(', '), 'function'); - assert.equal(unbind.params[0].name, undefined); - assert.equal(unbind.params[0].description, undefined); - }); - - test('When a symbol has an @param tag with no type, the doclet has a params property that includes that param.', function() { - assert.equal(typeof getElement.params, 'object'); - assert.equal(getElement.params.length, 1); - assert.equal(getElement.params[0].type, undefined); - assert.equal(getElement.params[0].name, 'id'); - assert.equal(getElement.params[0].description, 'The id of the element.'); - }); - - test('When a symbol has an @param tag with a non-alpha name like "...", the doclet has a params property that includes that param.', function() { - assert.equal(typeof combine.params, 'object'); - assert.equal(combine.params.length, 1); - assert.equal(combine.params[0].type, undefined); - assert.equal(combine.params[0].name, '...'); - assert.equal(combine.params[0].description, 'Two or more elements.'); - }); - - test('When a symbol has an @param tag with name followed by a dash, the doclet has a params property that includes that param.', function() { - assert.equal(typeof split.params, 'object'); - assert.equal(split.params.length, 1); - assert.equal(split.params[0].type, undefined); - assert.equal(split.params[0].name, 'delimiter'); - assert.equal(split.params[0].description, 'What to split on.'); - }); - - test('When a symbol has an @param tag with no name or type, the doclet has a params property that includes that param.', function() { - assert.equal(typeof commit.params, 'object'); - assert.equal(commit.params.length, 1); - assert.equal(commit.params[0].type, undefined); - assert.equal(commit.params[0].name, undefined); - assert.equal(commit.params[0].description, 'If true make the commit atomic.'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/privatetag.js b/test/t/cases/privatetag.js deleted file mode 100644 index 9eae4304..00000000 --- a/test/t/cases/privatetag.js +++ /dev/null @@ -1,11 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/privatetag.js'), - foo = docSet.getByLongname('Foo')[0], - bar = docSet.getByLongname('Foo#bar')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @private tag, the doclet has an access property that is "private".', function() { - assert.equal(foo.access, 'private'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/projecttag.js b/test/t/cases/projecttag.js deleted file mode 100644 index 5e7a9649..00000000 --- a/test/t/cases/projecttag.js +++ /dev/null @@ -1,12 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/constructstag3.js'), - personName = docSet.getByLongname('Person#name')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a function symbol has an @constructs tag, any this-variables are ducumented as instance members of the class.', function() { - assert.equal(personName.memberof, 'Person'); - assert.equal(personName.scope, 'instance'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/quotename.js b/test/t/cases/quotename.js deleted file mode 100644 index 489080df..00000000 --- a/test/t/cases/quotename.js +++ /dev/null @@ -1,11 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/quotename.js'), - found1 = docSet.getByLongname('chat.\"#channel\".open')[0]; - - // dump(docSet); - - test('When a member is quoted in square brackets.', function() { - assert.equal(found1.name, 'open', 'The short name should be correct.'); - assert.equal(found1.memberof, 'chat.\"#channel\"', 'The memberof should be correct.'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/quotename2.js b/test/t/cases/quotename2.js deleted file mode 100644 index e33799a2..00000000 --- a/test/t/cases/quotename2.js +++ /dev/null @@ -1,11 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/quotename2.js'), - found1 = docSet.getByLongname("contacts.\"say-\\\"hello\\\"@example.com\".username")[0]; - - // dump(docSet); - - test('When a key name of a member of an objlit is quoted.', function() { - assert.equal(found1.name, 'username', 'The short name should be correct.'); - assert.equal(found1.memberof, "contacts.\"say-\\\"hello\\\"@example.com\"", 'The memberof should be correct.'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/readonlytag.js b/test/t/cases/readonlytag.js deleted file mode 100644 index f295ed35..00000000 --- a/test/t/cases/readonlytag.js +++ /dev/null @@ -1,11 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/readonlytag.js'), - Collection = docSet.getByLongname('Collection')[0], - length = docSet.getByLongname('Collection#length')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @readonly tag, the doclet has an readonly property that is true.', function() { - assert.equal(length.readonly, true); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/requirestag.js b/test/t/cases/requirestag.js deleted file mode 100644 index de4537d5..00000000 --- a/test/t/cases/requirestag.js +++ /dev/null @@ -1,17 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/requirestag.js'), - foo = docSet.getByLongname('foo')[0], - bar = docSet.getByLongname('bar')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @requires tag, the doclet has a requires property that includes that value, with the "module:" namespace added.', function() { - assert.equal(typeof foo.requires, 'object'); - assert.equal(foo.requires[0], 'module:foo/helper'); - - assert.equal(typeof bar.requires, 'object'); - assert.equal(bar.requires[0], 'module:foo'); - assert.equal(bar.requires[1], 'module:Pez#blat'); - - }); -})(); \ No newline at end of file diff --git a/test/t/cases/returnstag.js b/test/t/cases/returnstag.js deleted file mode 100644 index ab04b34e..00000000 --- a/test/t/cases/returnstag.js +++ /dev/null @@ -1,22 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/returnstag.js'), - find = docSet.getByLongname('find')[0], - bind = docSet.getByLongname('bind')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @returns tag with a type and description, the doclet has a returns array that includes that return.', function() { - assert.equal(typeof find.returns, 'object'); - assert.equal(find.returns.length, 1); - assert.equal(find.returns[0].type.names.join(', '), 'String, Array'); - assert.equal(find.returns[0].description, 'The names of the found item(s).'); - }); - - test('When a symbol has an @param tag with only a type and name, the doclet has a returns array property that includes that param.', function() { - assert.equal(typeof bind.returns, 'object'); - assert.equal(bind.returns.length, 1); - assert.equal(bind.returns[0].description, 'The binding id.'); - }); - - -})(); \ No newline at end of file diff --git a/test/t/cases/seetag.js b/test/t/cases/seetag.js deleted file mode 100644 index 646d892b..00000000 --- a/test/t/cases/seetag.js +++ /dev/null @@ -1,15 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/seetag.js'), - foo = docSet.getByLongname('foo')[0], - bar = docSet.getByLongname('bar')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @see tag, the doclet has a see property that includes that value.', function() { - assert.equal(typeof foo.see, 'object'); - assert.equal(foo.see[0], '#search'); - - assert.equal(typeof bar.see, 'object'); - assert.equal(bar.see[0], 'http://example.com/someref'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/sincetag.js b/test/t/cases/sincetag.js deleted file mode 100644 index bf56bafd..00000000 --- a/test/t/cases/sincetag.js +++ /dev/null @@ -1,11 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/sincetag.js'), - foo = docSet.getByLongname('foo')[0]; - - //dump(docSet.doclets); - - test('When a symbol has an @since tag, the doclet has a since property set to true.', function() { - assert.equal(foo.since, '1.2.3'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/this-and-objectlit.js b/test/t/cases/this-and-objectlit.js deleted file mode 100644 index e6bd105d..00000000 --- a/test/t/cases/this-and-objectlit.js +++ /dev/null @@ -1,26 +0,0 @@ -/** @constructor */ -function Page(title) { - this.parts = { - title: title, - body: { - /** document me */ - heading: '', - main: '' - } - } -} - -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/this-and-objectlit.js'), - found = docSet.getByLongname('Page#parts.body.heading'); - - //dump(docSet); - - test('When a member is nested inside an objectlit this property inside a constructor.', function() { - assert.equal(found.length, 1, 'A this member should be like Constructor#objlit.member.'); - assert.equal(found[0].name, 'heading', 'The short name should be correct.'); - assert.equal(found[0].memberof, 'Page#parts.body', 'The memberof should be correct.'); - assert.equal(found[0].scope, 'static', 'The scope should default to "static".'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/this.js b/test/t/cases/this.js deleted file mode 100644 index 212907da..00000000 --- a/test/t/cases/this.js +++ /dev/null @@ -1,21 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/this.js'), - found1 = docSet.getByLongname('Singer#tralala'), - found2 = docSet.getByLongname('Singer#isSinging'); - - // dump(docSet); - - test('When a member is attached to this in a constructor.', function() { - assert.equal(found1.length, 1, 'The longname should be like Constructor#member.'); - assert.equal(found1[0].name, 'tralala', 'The short name should be correct.'); - assert.equal(found1[0].memberof, 'Singer', 'The memberof should be correct.'); - assert.equal(found1[0].scope, 'instance', 'The scope should default to "static".'); - }); - - test('When a member is attached to this in a method of a constructor.', function() { - assert.equal(found2.length, 1, 'The longname should be like Constructor#member.'); - assert.equal(found2[0].name, 'isSinging', 'The short name should be correct.'); - assert.equal(found2[0].memberof, 'Singer', 'The memberof should be correct.'); - assert.equal(found2[0].scope, 'instance', 'The scope should default to "static".'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/this2.js b/test/t/cases/this2.js deleted file mode 100644 index 86990e32..00000000 --- a/test/t/cases/this2.js +++ /dev/null @@ -1,14 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/this2.js'), - found = docSet.getByLongname('TemplateBuilder#Template#rendered'); - - //dump(docSet); - - test('When a constructor is nested inside another a constructor.', function() { - assert.equal(found.length, 1, 'A this member should be like Constructor#Constructor#member.'); - assert.equal(found[0].name, 'rendered', 'The short name should be correct.'); - assert.equal(found[0].memberof, 'TemplateBuilder#Template', 'The memberof should be correct.'); - assert.equal(found[0].scope, 'instance', 'The scope should default to "static".'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/this3.js b/test/t/cases/this3.js deleted file mode 100644 index c7078cd8..00000000 --- a/test/t/cases/this3.js +++ /dev/null @@ -1,13 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/this3.js'), - found = docSet.getByLongname('position'); - - //dump(docSet); - - test('When a this is assigned to inside a non-constructor function.', function() { - assert.equal(found.length, 1, 'The member name should be global, like "member".'); - assert.equal(found[0].name, 'position', 'The short name should be correct.'); - assert.equal(found[0].memberof, undefined, 'The memberof should be correct.'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/thistag.js b/test/t/cases/thistag.js deleted file mode 100644 index 8277ea45..00000000 --- a/test/t/cases/thistag.js +++ /dev/null @@ -1,18 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/thistag.js'), - setName = docSet.getByLongname('setName')[0], - fooName = docSet.getByLongname('Foo#name')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has a @this tag, the doclet has a this property that is set to that value.', function() { - assert.equal(setName['this'], 'Foo'); - }); - - test('When a this symbol is documented inside a function with a @this tag, the symbol is documented as a member of that tags value.', function() { - assert.equal(typeof fooName, 'object'); - assert.equal(fooName.name, 'name'); - assert.equal(fooName.memberof, 'Foo'); - assert.equal(fooName.scope, 'instance'); - }); -})(); \ No newline at end of file diff --git a/test/t/cases/typedeftag.js b/test/t/cases/typedeftag.js deleted file mode 100644 index 1728c4cc..00000000 --- a/test/t/cases/typedeftag.js +++ /dev/null @@ -1,24 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/typedeftag.js'), - numberlike = docSet.getByLongname('calc.NumberLike')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @typedef tag, the doclet has a kind property set to "typedef".', function() { - assert.equal(numberlike.kind, 'typedef'); - }); - - test('When a symbol has an @typedef tag with a type, the doclet has a type property set to that type.', function() { - assert.equal(typeof numberlike.type, 'object'); - assert.equal(typeof numberlike.type.names, 'object'); - assert.equal(numberlike.type.names.length, 2); - assert.equal(numberlike.type.names[0], 'string'); - assert.equal(numberlike.type.names[1], 'number'); - }); - - test('When a symbol has an @typedef tag with a name, the doclet has a name property set to that name.', function() { - assert.equal(numberlike.name, 'NumberLike'); - assert.equal(numberlike.longname, 'calc.NumberLike'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/typekind.js b/test/t/cases/typekind.js deleted file mode 100644 index 8e6b7975..00000000 --- a/test/t/cases/typekind.js +++ /dev/null @@ -1,18 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/typekind.js'), - blog = docSet.getByLongname('module:blog/server')[0], - port = docSet.getByLongname('module:blog/server.port')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a module symbol has an kind tag, that includes a {type} clause', function() { - assert.equal(typeof blog.type, 'object', 'the doclet has a type.'); - assert.equal(blog.type.names.join(', '), 'ConnectServer', 'the doclet has a type property set to that {type} clause.'); - }); - - test('When a property symbol has an kind tag, that includes a {type} clause', function() { - assert.equal(typeof port.type, 'object', 'the doclet has a type.'); - assert.equal(port.type.names.join(', '), 'number', 'the doclet has a type property set to that {type} clause.'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/typetag.js b/test/t/cases/typetag.js deleted file mode 100644 index 4d0dc9bc..00000000 --- a/test/t/cases/typetag.js +++ /dev/null @@ -1,18 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/typetag.js'), - foo = docSet.getByLongname('foo')[0], - bar = docSet.getByLongname('bar')[0]; - - //dump(docSet.doclets); exit(0); - - test('When a symbol has an @type tag, the doclet has a type property set to that value\'s type.', function() { - assert.equal(typeof foo.type, 'object'); - assert.equal(typeof foo.type.names, 'object'); - assert.equal(foo.type.names.join(', '), 'string, Array'); - }); - - test('When a symbol has an @type tag set to a plain string, the doclet has a type property set to that string as if it were a type.', function() { - assert.equal(bar.type.names.join(', '), 'integer'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/var.js b/test/t/cases/var.js deleted file mode 100644 index 0524da08..00000000 --- a/test/t/cases/var.js +++ /dev/null @@ -1,31 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/var.js'), - found = [ - docSet.getByLongname('GREEN'), - docSet.getByLongname('RED'), - docSet.getByLongname('validate'), - docSet.getByLongname('i'), - docSet.getByLongname('results') - ]; - - //dump(docSet); - - test('When a series of constants are documented.', function() { - assert.equal(found[0].length, 1, 'The first constant should be found'); - assert.equal(found[0][0].comment, '/** document me */', 'The first constant should get the docs.'); - assert.equal(found[0][0].name, 'GREEN', 'The short name should be correct.'); - assert.equal(found[0][0].memberof, undefined, 'The memberof should be undefined.'); - assert.equal(found[0][0].scope, undefined, 'The scope should be undefined.'); - - assert.equal(found[1].length, 1, 'The second constant should be found'); - assert.equal(found[1][0].undocumented, true, 'The second constant should not get the docs.'); - }); - - test('When member of a series of vars are documented.', function() { - assert.equal(found[4][0].comment, '/** document me */', 'The correct var should get the docs.'); - assert.equal(found[4][0].name, 'results', 'The short name should be correct.'); - assert.equal(found[4][0].memberof, undefined, 'The memberof should be undefined.'); - assert.equal(found[4][0].scope, undefined, 'The scope should be undefined.'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/variations.js b/test/t/cases/variations.js deleted file mode 100644 index e2a9046f..00000000 --- a/test/t/cases/variations.js +++ /dev/null @@ -1,23 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/variations.js'), - fadein1 = docSet.getByLongname('anim.fadein(1)')[0], - fadein2 = docSet.getByLongname('anim.fadein(2)')[0]; - - //dump(docSet.doclets); - - test('When a symbol has a name with a variation, the doclet has a variation property.', function() { - assert.equal(fadein1.variation, '1'); - assert.equal(fadein2.variation, '2'); - }); - - test('When a symbol has a name with a variation in the name, the doclet name has no variation in it.', function() { - assert.equal(fadein1.name, 'fadein'); - assert.equal(fadein2.name, 'fadein'); - }); - - test('When a symbol has a name with a variation in the name, the doclet longname has the variation in it.', function() { - assert.equal(fadein1.longname, 'anim.fadein(1)'); - assert.equal(fadein2.longname, 'anim.fadein(2)'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/versiontag.js b/test/t/cases/versiontag.js deleted file mode 100644 index a1e24b79..00000000 --- a/test/t/cases/versiontag.js +++ /dev/null @@ -1,11 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/versiontag.js'), - foo = docSet.getByLongname('foo')[0]; - - //dump(docSet.doclets); - - test('When a symbol has an @version tag, the doclet has a version property set to that value.', function() { - assert.equal(foo.version, '1.2.3'); - }); - -})(); \ No newline at end of file diff --git a/test/t/cases/virtual.js b/test/t/cases/virtual.js deleted file mode 100644 index dbe40060..00000000 --- a/test/t/cases/virtual.js +++ /dev/null @@ -1,18 +0,0 @@ -(function() { - var docSet = testhelpers.getDocSetFromFile('test/cases/virtual.js'), - found = [ - docSet.getByLongname('dimensions'), - docSet.getByLongname('width') - ]; - - //dump(docSet); - - test('When a virtual symbol is documented.', function() { - assert.equal(found[0].length, 1, 'The symbol should be documented'); - }); - - test('When an undocumented is after a comment for a virtual symbol is documented.', function() { - assert.equal(found[1].length, 1, 'The symbol should be documented'); - }); - -})(); \ No newline at end of file diff --git a/test/t/common/dumper.js b/test/t/common/dumper.js deleted file mode 100644 index 73d06706..00000000 --- a/test/t/common/dumper.js +++ /dev/null @@ -1,91 +0,0 @@ -var common = {dumper: require('common/dumper')}; - -test('There is a common/dumper module.', function() { - assert.equal(typeof common.dumper, 'object', 'The common/dumper module should be an object.'); -}); - -test('The common/dumper module exports a "dump" function.', function() { - assert.equal(typeof common.dumper.dump, 'function', 'The module:module:common/dumper.dump member should be a function.'); -}); - -test('The module:module:common/dumper.dump function dumps string values.', function() { - assert.equal(common.dumper.dump('hello'), '"hello"'); - assert.equal(common.dumper.dump('hello "world"'), '"hello \\"world\\""', 'Double quotes should be escaped.'); - assert.equal(common.dumper.dump('hello\nworld'), '"hello\\nworld"', 'Newlines should be escaped.'); -}); - -test('The module:module:common/dumper.dump function dumps number values.', function() { - assert.equal(common.dumper.dump(1), '1'); - assert.equal(common.dumper.dump(0.1), '0.1', 'Decimal numbers shuld be dumped.'); -}); - -test('The module:module:common/dumper.dump function dumps boolean values.', function() { - assert.equal(common.dumper.dump(true), 'true'); - assert.equal(common.dumper.dump(false), 'false'); -}); - -test('The module:module:common/dumper.dump function dumps null values.', function() { - assert.equal(common.dumper.dump(null), 'null'); -}); - -test('The module:module:common/dumper.dump function dumps undefined values.', function() { - assert.equal(common.dumper.dump(undefined), 'undefined'); -}); - -test('The module:module:common/dumper.dump function dumps regex values.', function() { - assert.equal(common.dumper.dump(/^[Ff]oo$/gi), ''); -}); - -test('The module:module:common/dumper.dump function dumps date values.', function() { - assert.equal(common.dumper.dump(new Date('January 1, 1901 GMT')), ''); -}); - -test('The module:module:common/dumper.dump function dumps function values.', function() { - assert.equal(common.dumper.dump(function myFunc(){}), ''); - assert.equal(common.dumper.dump(function(){}), ''); -}); - -test('The module:module:common/dumper.dump function dumps array values.', function() { - var actual = common.dumper.dump(["hello", "world"]), - expected = '[\n "hello",\n "world"\n]'; - - assert.equal(actual, expected); -}); - -test('The module:module:common/dumper.dump function dumps simple object values.', function() { - var actual = common.dumper.dump({hello: "world"}), - expected = '{\n "hello": "world"\n}'; - - assert.equal(actual, expected); -}); - -test('The module:common/dumper.dump function dumps constructed instance values.', function() { - function Foo(name){ this.name = name; } - Foo.prototype.sayHello = function(){} - - var actual = common.dumper.dump(new Foo('hello')), - expected = '{\n "name": "hello"\n}'; - - assert.equal(actual, expected, 'Members of the instance should appear, but not prototype members.'); -}); - -test('The module:common/dumper.dump function dumps complex mixed values.', function() { - function Foo(){} - - var actual = common.dumper.dump( - [undefined, null, new Foo(), 1, true, 'hello\n"world', new Error('oops'), /foo/gi, new Date('December 26, 2010 GMT'), {f: function myFunc(){}, o: {a:1}}] - ), - expected = '[\n undefined,\n null,\n {\n },\n 1,\n true,\n "hello\\n\\"world",\n {\n "message": "oops"\n },\n ,\n ,\n {\n "f": ,\n "o": {\n "a": 1\n }\n }\n]'; - - assert.equal(actual, expected); -}); - -test('The module:common/dumper.dump function doesn\'t crash on circular references.', function() { - var a = {}; - a.b = a; - - var actual = common.dumper.dump(a), - expected = '{\n "b": \n}'; - - assert.equal(actual, expected); -}); \ No newline at end of file diff --git a/test/t/common/events.js b/test/t/common/events.js deleted file mode 100644 index 22685a50..00000000 --- a/test/t/common/events.js +++ /dev/null @@ -1,34 +0,0 @@ -var common = {events: require('common/events')}; - -test('The common/events module is defined.', function() { - assert.notEqual(typeof common.events, 'undefined', 'The common/events module should be defined.'); - assert.equal(typeof common.events, 'object', 'The common/events module should be an object.'); -}); - -test('The common/events module exports a "on" function.', function() { - assert.notEqual(typeof common.events.on, 'undefined', 'The common/events.on member should be defined.'); - assert.equal(typeof common.events.on, 'function', 'The common/events.on member should be a function.'); -}); - -test('The common/events module exports a "fire" function.', function() { - assert.notEqual(typeof common.events.fire, 'undefined', 'The common/events.fire member should be defined.'); - assert.equal(typeof common.events.fire, 'function', 'The common/events.fire member should be a function.'); -}); - -test('The common/events module exports a "removeListener" function.', function() { - assert.notEqual(typeof common.events.removeListener, 'undefined', 'The common/events.removeListener member should be defined.'); - assert.equal(typeof common.events.removeListener, 'function', 'The common/events.removeListener member should be a function.'); -}); - -test('The common/events.on function attaches a handler to an object that can be fired.', function() { - var target = {}, - result = false; - - target.on = common.events.on; - target.fire = common.events.fire; - - target.on('test', function() { result = true; }); - target.fire('test'); - - assert.equal(result, true); -}); diff --git a/test/t/common/query.js b/test/t/common/query.js deleted file mode 100644 index f77e9947..00000000 --- a/test/t/common/query.js +++ /dev/null @@ -1,16 +0,0 @@ -var common = {query: require('common/query')}; - -test('The common/query module is defined.', function() { - assert.notEqual(typeof common.query, 'undefined', 'The common/query module should be defined.'); - assert.equal(typeof common.query, 'object', 'The common/query module should be an object.'); -}); - -test('The common/query module exports a "toObject" function.', function() { - assert.notEqual(typeof common.query.toObject, 'undefined', 'The common/query.toObject member should be defined.'); - assert.equal(typeof common.query.toObject, 'function', 'The common/query.toObject member should be a function.'); -}); - -test('The common/query.toObject function dumps an object from a query string.', function() { - assert.deepEqual(common.query.toObject('name=Michael+Mathews'), {name: 'Michael Mathews'}); - assert.deepEqual(common.query.toObject('name=Michael+Mathews&city=London'), {name: 'Michael Mathews', city: 'London'}); -}); diff --git a/test/t/common/scanner.js b/test/t/common/scanner.js deleted file mode 100644 index a1983151..00000000 --- a/test/t/common/scanner.js +++ /dev/null @@ -1,19 +0,0 @@ -var scanner = new (require('jsdoc/src/scanner').Scanner)(), - includeMatch = new RegExp(".+\\.js(doc)?$"), - excludeMatch = new RegExp("(^|\\/)_"), - sourceFiles = scanner.scan([BASEDIR+'/test/cases/src/'], 3, includeMatch, excludeMatch); - -sourceFiles = sourceFiles.map(function($) { - return $.replace(BASEDIR, ''); -}); - -//dump(sourceFiles); exit(); - -test('The scanner should return the correct source files', function() { - - assert.equal(sourceFiles.length, 3); - assert.equal(sourceFiles.indexOf("test/cases/src/one.js") > -1, true); - assert.equal(sourceFiles.indexOf("test/cases/src/two.js") > -1, true); - assert.equal(sourceFiles.indexOf("test/cases/src/dir1/three.js") > -1, true); - -}); diff --git a/test/t/common/util.js b/test/t/common/util.js deleted file mode 100644 index 656df177..00000000 --- a/test/t/common/util.js +++ /dev/null @@ -1,51 +0,0 @@ -var common = {util: require('common/util')}; - -test('There is a common/util module.', function() { - assert.equal(typeof common.util, 'object', 'The common/util module should be an object.'); -}); - -test('The common/util module exports a "mixin" function.', function() { - assert.equal(typeof common.util.mixin, 'function', 'The module:common/util.mixin member should be a function.'); -}); - -test('The module:common/util.mixin function takes a target object and returns it.', function() { - var target = {a:1}, - returned; - - returned = common.util.mixin(target); // mixing nothing in - - assert.deepEqual(returned, target); -}); - -test('The module:common/util.mixin function can mix a source object into the target.', function() { - var target = {a: 1, b: 2}, - source = {c: 3}; - - common.util.mixin(target, source); // modify the target object - - assert.deepEqual( target, {a: 1, b: 2, c: 3} ); -}); - -test('The module:common/util.mixin function overwrites properties in the target if they exist in the source.', function() { - var target = {a: 1, b: 2}, - source = {b: 3, c: 4}; - - common.util.mixin(target, source); - - assert.equal(target.a, 1, 'Existing properties in the target with unique keys are left alone.'); - assert.equal(target.b, source.b, 'Existing properties in the target with same-named keys are overwritten.'); - assert.equal(target.c, source.c, 'Properties in the source with unique keys are added to the target.'); -}); - -test('The module:common/util.mixin function can mix several source objects into the target.', function() { - var target = {}, - source1 = {a: 1, b: 2}, - source2 = {b: 7, c: 4}, - source3 = {b: 3, d: 5}, - returned; - - returned = common.util.mixin({}, source1, source2, source3); // use a dummy target and the return value to avoid modifying the real target (source1) - - assert.deepEqual( source1, {a: 1, b: 2}, 'The source objects themselves are not modified by being mixed in.'); - assert.deepEqual( returned, {a: 1, b: 3, c: 4, d: 5}, 'The returned object has all the properties of the sources.'); -}); diff --git a/test/t/jsdoc/name.js b/test/t/jsdoc/name.js deleted file mode 100644 index 570d144a..00000000 --- a/test/t/jsdoc/name.js +++ /dev/null @@ -1,119 +0,0 @@ -var jsdoc = {name: require('jsdoc/name') }; - -test('There is a jsdoc/name module.', function() { - assert.equal(typeof jsdoc.name, 'object'); -}); - -test('The jsdoc/name module exports an shorten function.', function() { - assert.equal(typeof jsdoc.name.shorten, 'function'); -}); - -test('The module:jsdoc/name.shorten function breaks a longname up into the correct memberof, name and scope parts.', function() { - var startName = 'lib.Panel#open', - parts = jsdoc.name.shorten(startName); - - assert.equal(parts.name, 'open', 'The name should be the bit after the last scoping character.'); - assert.equal(parts.memberof, 'lib.Panel', 'The memberof should be the bit before the last scoping character.'); - assert.equal(parts.scope, '#', 'The scope should be the scoping character itself.'); -}); - -test('The module:jsdoc/name.shorten function works on static names.', function() { - var startName = 'elements.selected.getVisible', - parts = jsdoc.name.shorten(startName); - - assert.equal(parts.name, 'getVisible'); - assert.equal(parts.memberof, 'elements.selected'); - assert.equal(parts.scope, '.'); -}); - -test('The module:jsdoc/name.shorten function works on protoyped names.', function() { - var startName = 'Validator.prototype.$element', - parts = jsdoc.name.shorten(startName); - - assert.equal(parts.name, '$element'); - assert.equal(parts.memberof, 'Validator'); - assert.equal(parts.scope, '#'); -}); - -test('The module:jsdoc/name.shorten function works on inner names.', function() { - var startName = 'Button~_onclick', - parts = jsdoc.name.shorten(startName); - - assert.equal(parts.name, '_onclick'); - assert.equal(parts.memberof, 'Button'); - assert.equal(parts.scope, '~'); -}); - -test('The module:jsdoc/name.shorten function works on global names.', function() { - var startName = 'close', - parts = jsdoc.name.shorten(startName); - - assert.equal(parts.name, 'close'); - assert.equal(parts.memberof, '', 'The memberof should be an empty string for global symbols.'); - assert.equal(parts.scope, '', 'The scope should be an empty string for global symbols.'); -}); - -test('The module:jsdoc/name.shorten function works on bracketed stringy names.', function() { - var startName = 'channels["#ops"]#open', - parts = jsdoc.name.shorten(startName); - - assert.equal(parts.name, 'open'); - assert.equal(parts.memberof, 'channels."#ops"', 'Bracketed stringy names should appear as quoted strings.'); - assert.equal(parts.scope, '#'); - - startName = 'channels["#bots"]["log.max"]', - parts = jsdoc.name.shorten(startName); - - assert.equal(parts.name, '"log.max"'); - assert.equal(parts.memberof, 'channels."#bots"'); - assert.equal(parts.scope, '.'); -}); - -test('The module:jsdoc/name.shorten function works on fully stringy names, like "foo.bar".', function() { - var startName = '"foo.bar"', - parts = jsdoc.name.shorten(startName); - - assert.equal(parts.name, '"foo.bar"', 'The name should be the full quoted string.'); - assert.equal(parts.longname, '"foo.bar"', 'The longname should be the full quoted string.'); - assert.equal(parts.memberof, '', 'There should be no memberof, as it is global.'); - assert.equal(parts.scope, '', 'The scope should be as global.'); -}); - -test('The jsdoc/name module exports an applyNamespace function.', function() { - assert.equal(typeof jsdoc.name.applyNamespace, 'function'); -}); - -test('The module:jsdoc/name.applyNamespace function inserts the namespace in the correct place.', function() { - var startName = 'lib.Panel#open', - endName = jsdoc.name.applyNamespace(startName, 'event'); - - assert.equal(endName, 'lib.Panel#event:open', 'The namespace should be inserted only before the name part of the longname.'); - - startName = 'maths/bigint'; - endName = jsdoc.name.applyNamespace(startName, 'module'); - - assert.equal(endName, 'module:maths/bigint', 'The namespace should be inserted before a global name.'); -}); - -test('The module:jsdoc/name.applyNamespace function treats quoted parts of the name as atomic.', function() { - var startName = 'foo."*dont\'t.look~in#here!"', - endName = jsdoc.name.applyNamespace(startName, 'event'); - - assert.equal(endName, 'foo.event:"*dont\'t.look~in#here!"', 'The namespace should be inserted before a quoted shortname.'); -}); - -test('The module:jsdoc/name.applyNamespace function will not add another namespace if one already exists.', function() { - var startName = 'lib.Panel#event:open', - endName = jsdoc.name.applyNamespace(startName, 'event'); - - assert.equal(endName, 'lib.Panel#event:open', 'The namespace should not be inserted twice.'); -}); - -test('The module:jsdoc/name.shorten function finds the variation.', function() { - var startName = 'anim.fadein(2)', - parts = jsdoc.name.shorten(startName); - - assert.equal(parts.variation, '2'); - assert.equal(parts.name, 'fadein'); - assert.equal(parts.longname, 'anim.fadein(2)'); -}); diff --git a/test/t/jsdoc/opts/parser.js b/test/t/jsdoc/opts/parser.js deleted file mode 100644 index fdfe67bb..00000000 --- a/test/t/jsdoc/opts/parser.js +++ /dev/null @@ -1,37 +0,0 @@ -var opts = require('jsdoc/opts/parser'); - -test('The opts module is defined.', function() { - assert.notEqual(typeof opts, 'undefined', 'The opts module should not be undefined.'); - assert.equal(typeof opts, 'object', 'The opts module should be an object.'); -}); - -test('The opts module exports a "parse" function.', function() { - assert.notEqual(typeof opts.parse, 'undefined', 'The opts.parse method should not be undefined.'); - assert.equal(typeof opts.parse, 'function', 'The opts.parse method should be a function.'); -}); - -test('The opts module exports a "get" function.', function() { - assert.notEqual(typeof opts.get, 'undefined', 'The opts.get method should not be undefined.'); - assert.equal(typeof opts.get, 'function', 'The opts.get method should be a function.'); -}); - -test('The opts.parse function accepts a -t opt.', function() { - opts.parse(['-t', 'mytemplate']); - var r = opts.get(); - - assert.equal(r.template, 'mytemplate', 'The opts.get method should return an object with a set template property.'); -}); - -test('The opts.parse function accepts a -d opt.', function() { - opts.parse(['-d', 'mydestination']); - var r = opts.get(); - - assert.equal(r.destination, 'mydestination', 'The opts.get method should return an object with a set destination property.'); -}); - -test('The opts.parse function accepts a naked opt.', function() { - opts.parse(['myfile1', 'myfile2']); - var r = opts.get(); - - assert.deepEqual(r._, ['myfile1', 'myfile2'], 'The opts.get method should return an object with a set _ property.'); -}); \ No newline at end of file diff --git a/test/t/jsdoc/src/handlers.js b/test/t/jsdoc/src/handlers.js deleted file mode 100644 index 7121d605..00000000 --- a/test/t/jsdoc/src/handlers.js +++ /dev/null @@ -1,16 +0,0 @@ -(function() { - - var jsdoc = {src: { parser: require('jsdoc/src/parser')}}, - testParser = new jsdoc.src.parser.Parser(); - - require('jsdoc/src/handlers').attachTo(testParser); - - test('A jsdoc comment with a @name and no code is turned into a doclet object.', function() { - var sourceCode = 'javascript:/** @name bar */', - result = testParser.parse(sourceCode); - - assert.equal(result.length, 1); - assert.equal(result[0].name, 'bar'); - }); - -})(); \ No newline at end of file diff --git a/test/t/jsdoc/src/parser.js b/test/t/jsdoc/src/parser.js deleted file mode 100644 index 7efa240c..00000000 --- a/test/t/jsdoc/src/parser.js +++ /dev/null @@ -1,52 +0,0 @@ -(function() { - - var jsdoc = {src: { parser: require('jsdoc/src/parser')}}; - - test('There is a jsdoc/src/parser module.', function() { - assert.equal(typeof jsdoc.src.parser, 'object'); - }); - - test('The jsdoc/src/parser module has a Parser constructor.', function() { - assert.equal(typeof jsdoc.src.parser.Parser, 'function'); - }); - - test('The module:jsdoc/src/parser.Parser class has a parse function.', function() { - assert.equal(typeof jsdoc.src.parser.Parser.prototype.parse, 'function'); - }); - - test('The jsdoc/src/parser module has a results function.', function() { - assert.equal(typeof jsdoc.src.parser.Parser.prototype.results, 'function'); - }); - - test('The module:jsdoc/src/parser.Parser#parse function fires jsdocCommentFound events when parsing source code containing a jsdoc comment.', function() { - var sourceCode = 'javascript:/** @name bar */', - jsdocCounter = 0, - event = null, - parser = new jsdoc.src.parser.Parser(); - - parser - .on('jsdocCommentFound', function(e) { - jsdocCounter++; - event = e; - }) - .parse(sourceCode); - - assert.equal(jsdocCounter, 1); - - assert.equal(event.comment, '/** @name bar */', 'The full text of the comment is included in the event.'); - }); - - test('The module:jsdoc/src/parser.Parser#parse function fires symbolFound events when parsing source code containing a named symbol.', function() { - var sourceCode = 'javascript:var foo = 1;', - symbolCounter = 0, - parser = new jsdoc.src.parser.Parser(); - - parser - .on('symbolFound', function(e) { - symbolCounter++; - }) - .parse(sourceCode); - - assert.equal(symbolCounter, 1); - }); -})(); \ No newline at end of file