mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Merge pull request #36 from tschaub/require
Use Rhino's require implementation.
This commit is contained in:
commit
a9574d413b
2
jsdoc
2
jsdoc
@ -3,6 +3,6 @@
|
||||
# rhino discards the path to the current script file, so we must add it back
|
||||
PWD=`pwd`
|
||||
BASEDIR=`dirname $0`
|
||||
java -classpath ${BASEDIR}/lib/js.jar org.mozilla.javascript.tools.shell.Main ${BASEDIR}/jsdoc.js --dirname=${PWD}/${BASEDIR} $@
|
||||
java -classpath ${BASEDIR}/lib/js.jar org.mozilla.javascript.tools.shell.Main -modules ${BASEDIR}/node_modules -modules ${BASEDIR}/rhino_modules ${BASEDIR}/jsdoc.js --dirname=${PWD}/${BASEDIR} $@
|
||||
|
||||
#java -classpath ${BASEDIR}/lib/js.jar org.mozilla.javascript.tools.debugger.Main -debug ${BASEDIR}/jsdoc.js --dirname=${PWD}/${BASEDIR} $@
|
||||
1
jsdoc.js
1
jsdoc.js
@ -30,7 +30,6 @@ for (var i = 0; i < arguments.length; i++) {
|
||||
}
|
||||
}
|
||||
|
||||
load(__dirname + '/lib/require.js');
|
||||
load(__dirname + '/lib/rhino-shim.js');
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
|
||||
|
||||
222
lib/require.js
222
lib/require.js
@ -1,222 +0,0 @@
|
||||
/*
|
||||
Rhino-Require is Public Domain
|
||||
<http://en.wikipedia.org/wiki/Public_Domain>
|
||||
|
||||
The author or authors of this code dedicate any and all copyright interest
|
||||
in this code to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and successors. We
|
||||
intend this dedication to be an overt act of relinquishment in perpetuity of
|
||||
all present and future rights to this code under copyright law.
|
||||
*/
|
||||
|
||||
(function(global) {
|
||||
|
||||
var require = global.require = function(id) {
|
||||
if (typeof arguments[0] !== 'string') throw 'USAGE: require(moduleId)';
|
||||
|
||||
var moduleContent = '',
|
||||
moduleUrl;
|
||||
|
||||
moduleUrl = require.resolve(id);
|
||||
moduleContent = '';
|
||||
|
||||
var file = new java.io.File(moduleUrl);
|
||||
try {
|
||||
var scanner = new java.util.Scanner(file).useDelimiter("\\Z");
|
||||
moduleContent = String( scanner.next() );
|
||||
}
|
||||
catch(e) {
|
||||
throw 'Unable to read file at: '+moduleUrl+', '+e;
|
||||
}
|
||||
|
||||
if (moduleContent) {
|
||||
try {
|
||||
var f = new Function('require', 'exports', 'module', '__dirname', moduleContent),
|
||||
exports = require.cache[moduleUrl] || {},
|
||||
module = { id: id, uri: moduleUrl, exports: exports };
|
||||
|
||||
require._root.unshift(toDir(moduleUrl));
|
||||
(function(__dirname) {
|
||||
|
||||
/*debug*///var lineno=1;print('\n== '+moduleUrl+' ===============\n1'+moduleContent.replace(/(\n)/g, function(m, i){return '\n'+(++lineno);}));
|
||||
f.call({}, require, exports, module, __dirname);
|
||||
})(require._root[0]);
|
||||
require._root.shift();
|
||||
}
|
||||
catch(e) {
|
||||
throw 'Unable to require source code from "' + moduleUrl + '": ' + 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 = [__dirname]; // the dir of the script that is calling require()
|
||||
require.paths = [];
|
||||
require.cache = {}; // cache module exports. Like: {id: exported}
|
||||
|
||||
var SLASH = Packages.java.io.File.separator;
|
||||
|
||||
/** Given a module id, try to find the path to the associated module.
|
||||
*/
|
||||
require.resolve = function(id) {
|
||||
var parts = id.match(/^(\.\/|\/)?(.+)$/),
|
||||
isRelative = false,
|
||||
isAbsolute = false,
|
||||
isInModule = false,
|
||||
basename = id,
|
||||
url = '';
|
||||
|
||||
if (parts) {
|
||||
isRelative = parts[1] === './';
|
||||
isAbsolute = parts[1] === '/';
|
||||
isInModule = !(isRelative || isAbsolute);
|
||||
basename = parts[2];
|
||||
}
|
||||
|
||||
if (typeof basename === 'undefined') {
|
||||
throw new Error('Malformed module identifier: '+id);
|
||||
}
|
||||
|
||||
if (isAbsolute) {
|
||||
rootedId = id;
|
||||
}
|
||||
else if (isRelative) {
|
||||
var root = require._root[0],
|
||||
rootedId = root + '/' + basename;
|
||||
}
|
||||
|
||||
if (rootedId) {
|
||||
if ( url = loadAsFile(rootedId) ) { return url; }
|
||||
else if ( url = loadAsDir(rootedId) ) { return url; }
|
||||
}
|
||||
else if (isInModule) {
|
||||
var url,
|
||||
paths = require.paths;
|
||||
|
||||
for (var i = 0, len = paths.length; i < len; i++) {
|
||||
rootedId = paths[i] + '/' + basename;
|
||||
|
||||
if ( url = loadAsFile(rootedId) ) { return url; }
|
||||
else if ( url = loadAsDir(rootedId) ) { return url; }
|
||||
}
|
||||
if (url = findInNodemodules(require._root[0], basename, 'rhino_modules')) { return url; }
|
||||
if (url = findInNodemodules(require._root[0], basename, 'node_modules')) { return url; }
|
||||
}
|
||||
|
||||
throw new Error('Module not found: '+id);
|
||||
}
|
||||
|
||||
function loadAsFile(id) {
|
||||
if ( isFile(id) ) { return id; }
|
||||
|
||||
if ( isFile(id + '.js') ) { return id + '.js'; }
|
||||
}
|
||||
|
||||
function loadAsDir(id) {
|
||||
// look for the "main" property of the package.json file
|
||||
if ( isFile(id + '/' + 'package.json') ) {
|
||||
var packageJson = readFileSync(id + '/' + 'package.json', 'utf-8');
|
||||
eval( 'packageJson = '+ packageJson);
|
||||
if (packageJson.hasOwnProperty('main')) {
|
||||
var main = deDotPath(id + '/' + packageJson.main);
|
||||
return require.resolve(main);
|
||||
}
|
||||
}
|
||||
|
||||
if ( isFile(id + '/' + 'index.js') ) {
|
||||
return id + '/' + 'index.js';
|
||||
}
|
||||
}
|
||||
|
||||
function findInNodemodules(root, id, moduleFolderName) {
|
||||
var dirs = root.split('/'),
|
||||
dir = '',
|
||||
rootedId;
|
||||
|
||||
while (dirs.length) {
|
||||
dir = dirs.join('/');
|
||||
rootedId = dir + '/' + moduleFolderName + '/' + id;
|
||||
|
||||
if ( url = loadAsFile(rootedId) ) { return url; }
|
||||
else if ( url = loadAsDir(rootedId) ) { return url; }
|
||||
|
||||
dirs.pop();
|
||||
}
|
||||
}
|
||||
|
||||
/** Given a path, return the base directory of that path.
|
||||
@example toDir('/foo/bar/somefile.js'); => '/foo/bar'
|
||||
*/
|
||||
function toDir(path) {
|
||||
var file = new java.io.File(path);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
return path;
|
||||
}
|
||||
|
||||
var parts = path.split('/');
|
||||
parts.pop();
|
||||
return parts.join('/');
|
||||
}
|
||||
|
||||
/** Returns true if the given path exists and is a file.
|
||||
*/
|
||||
function isFile(path) {
|
||||
var file = new java.io.File(path);
|
||||
|
||||
if (file.isFile()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns true if the given path exists and is a directory.
|
||||
*/
|
||||
function isDir(path) {
|
||||
var file = new java.io.File(path);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
Resolve dots in filepaths.
|
||||
*/
|
||||
function deDotPath(path) {
|
||||
return String(path)
|
||||
.replace(/(\/|\\)[^\/\\]+\/\.\.(\/|\\)/g, '/')
|
||||
.replace(/(\/|\\)\.(\/|\\|$)/g, '/');
|
||||
}
|
||||
|
||||
function readFileSync(filename, encoding, callback) {
|
||||
if (typeof arguments[1] === 'function') {
|
||||
encoding = null;
|
||||
callback = arguments[1];
|
||||
}
|
||||
|
||||
encoding = encoding || java.lang.System.getProperty('file.encoding');
|
||||
|
||||
try {
|
||||
var content = new java.util.Scanner(
|
||||
new java.io.File(filename),
|
||||
encoding
|
||||
).useDelimiter("\\Z");
|
||||
|
||||
return String( content.next() );
|
||||
}
|
||||
catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
})(this);
|
||||
@ -1,10 +1,10 @@
|
||||
function readFileSync(filename, encoding) {
|
||||
exports.readFileSync = function(filename, encoding) {
|
||||
encoding = encoding || 'utf-8';
|
||||
|
||||
return readFile(filename, encoding);
|
||||
}
|
||||
};
|
||||
|
||||
function readdirSync(path) {
|
||||
var readdirSync = exports.readdirSync = function(path) {
|
||||
var dir,
|
||||
files;
|
||||
|
||||
@ -14,9 +14,9 @@ function readdirSync(path) {
|
||||
files = dir.list();
|
||||
|
||||
return files;
|
||||
}
|
||||
};
|
||||
|
||||
function ls(dir, recurse, _allFiles, _path) {
|
||||
var ls = exports.ls = function(dir, recurse, _allFiles, _path) {
|
||||
var files,
|
||||
file;
|
||||
|
||||
@ -56,9 +56,9 @@ function ls(dir, recurse, _allFiles, _path) {
|
||||
}
|
||||
|
||||
return _allFiles;
|
||||
}
|
||||
};
|
||||
|
||||
function stat(path, encoding) {
|
||||
var stat = exports.stat = function(path, encoding) {
|
||||
var f = new java.io.File(path)
|
||||
return {
|
||||
isFile: function() {
|
||||
@ -69,9 +69,9 @@ function stat(path, encoding) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function mkPath(/**Array*/ path) {
|
||||
exports.mkPath = function(/**Array*/ path) {
|
||||
if (path.constructor != Array) path = path.split(/[\\\/]/);
|
||||
var make = "";
|
||||
for (var i = 0, l = path.length; i < l; i++) {
|
||||
@ -80,7 +80,7 @@ function mkPath(/**Array*/ path) {
|
||||
makeDir(make);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function makeDir(/**string*/ path) {
|
||||
var dirPath = toDir(path);
|
||||
@ -102,7 +102,7 @@ function exists(path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function toDir(path) {
|
||||
var toDir = exports.toDir = function(path) {
|
||||
var f = new java.io.File(path);
|
||||
|
||||
if (f.isDirectory()){
|
||||
@ -113,9 +113,9 @@ function toDir(path) {
|
||||
parts.pop();
|
||||
|
||||
return parts.join('/');
|
||||
}
|
||||
};
|
||||
|
||||
function copyFile(inFile, outDir, fileName) {
|
||||
exports.copyFile = function(inFile, outDir, fileName) {
|
||||
if (fileName == null) fileName = toFile(inFile);
|
||||
|
||||
outDir = toDir(outDir);
|
||||
@ -131,14 +131,14 @@ function copyFile(inFile, outDir, fileName) {
|
||||
}
|
||||
bos.close();
|
||||
bis.close();
|
||||
}
|
||||
};
|
||||
|
||||
function toFile(path) {
|
||||
var parts = path.split(/[\\\/]/);
|
||||
return parts.pop();
|
||||
}
|
||||
|
||||
function writeFileSync(filename, data, encoding) {
|
||||
exports.writeFileSync = function(filename, data, encoding) {
|
||||
encoding = encoding || 'utf-8';
|
||||
|
||||
var out = new Packages.java.io.PrintWriter(
|
||||
@ -155,16 +155,4 @@ function writeFileSync(filename, data, encoding) {
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
readFileSync: readFileSync,
|
||||
writeFileSync: writeFileSync,
|
||||
readdirSync: readdirSync,
|
||||
stat: stat,
|
||||
|
||||
ls: ls,
|
||||
mkPath: mkPath,
|
||||
toDir: toDir,
|
||||
copyFile: copyFile
|
||||
};
|
||||
@ -4,16 +4,15 @@
|
||||
@author Michael Mathews <micmath@gmail.com>
|
||||
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
|
||||
*/
|
||||
(function() {
|
||||
|
||||
// requires docs to have been indexed: docs.index must be defined here
|
||||
/**
|
||||
// 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) {
|
||||
exports.resolveBorrows = function(docs) {
|
||||
if (!docs.index) {
|
||||
throw 'Docs has not been indexed: docs.index must be defined here.';
|
||||
}
|
||||
@ -47,13 +46,13 @@
|
||||
delete doc.borrowed;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
Deep clone a simple object.
|
||||
@private
|
||||
*/
|
||||
function doop(o) {
|
||||
function doop(o) {
|
||||
if (o instanceof Object && o.constructor != Function) {
|
||||
var clone = o instanceof Array ? [] : {}, prop;
|
||||
|
||||
@ -65,6 +64,4 @@
|
||||
return clone;
|
||||
}
|
||||
return o;
|
||||
};
|
||||
|
||||
})();
|
||||
};
|
||||
|
||||
@ -10,22 +10,22 @@
|
||||
@requires jsdoc/name
|
||||
@requires jsdoc/tag/dictionary
|
||||
*/
|
||||
(function() {
|
||||
var jsdoc = {
|
||||
|
||||
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) {
|
||||
exports.Doclet = function(docletSrc, meta) {
|
||||
var newTags = [];
|
||||
|
||||
/** The original text of the comment from the source code. */
|
||||
@ -42,10 +42,10 @@
|
||||
}
|
||||
|
||||
this.postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
/** Called once after all tags have been added. */
|
||||
exports.Doclet.prototype.postProcess = function() {
|
||||
/** 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);
|
||||
@ -56,13 +56,13 @@
|
||||
if (!this.kind && this.meta && this.meta.code) {
|
||||
this.addTag( 'kind', codetypeToKind(this.meta.code.type) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Add a tag to this doclet.
|
||||
/** 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) {
|
||||
*/
|
||||
exports.Doclet.prototype.addTag = function(title, text) {
|
||||
var tagDef = jsdoc.tag.dictionary.lookUp(title),
|
||||
newTag = new jsdoc.tag.Tag(title, text, this.meta);
|
||||
|
||||
@ -76,24 +76,24 @@
|
||||
}
|
||||
|
||||
applyTag.call(this, newTag);
|
||||
}
|
||||
}
|
||||
|
||||
/** Set the `memberof` property of this doclet.
|
||||
/** 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) {
|
||||
*/
|
||||
exports.Doclet.prototype.setMemberof = function(sid) {
|
||||
if (/^<global>\.?/.test(sid)) { sid = sid.replace(/^<global>.?/, ''); }
|
||||
/**
|
||||
The longname of the symbol that contains this one, if any.
|
||||
@type string
|
||||
*/
|
||||
this.memberof = sid.replace(/\.prototype/g, '#');
|
||||
}
|
||||
}
|
||||
|
||||
/** Set the `longname` property of this doclet.
|
||||
/** Set the `longname` property of this doclet.
|
||||
@param {string} name
|
||||
*/
|
||||
exports.Doclet.prototype.setLongname = function(name) {
|
||||
*/
|
||||
exports.Doclet.prototype.setLongname = function(name) {
|
||||
if (/^<global>\.?/.test(name)) { name = name.replace(/^<global>\.?/, ''); }
|
||||
|
||||
/**
|
||||
@ -104,13 +104,13 @@
|
||||
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.
|
||||
/** 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) {
|
||||
*/
|
||||
exports.Doclet.prototype.borrow = function(source, target) {
|
||||
var about = {from: source};
|
||||
if (target) about.as = target;
|
||||
|
||||
@ -122,9 +122,9 @@
|
||||
this.borrowed = [];
|
||||
}
|
||||
this.borrowed.push(about);
|
||||
}
|
||||
}
|
||||
|
||||
exports.Doclet.prototype.mix = function(source) {
|
||||
exports.Doclet.prototype.mix = function(source) {
|
||||
if (!this.mixes) {
|
||||
/**
|
||||
A list of symbols that are mixed into this one, if any.
|
||||
@ -133,12 +133,12 @@
|
||||
this.mixes = [];
|
||||
}
|
||||
this.mixes.push(source);
|
||||
}
|
||||
}
|
||||
|
||||
/** Add a symbol to this doclet's `augments` array.
|
||||
/** Add a symbol to this doclet's `augments` array.
|
||||
@param {string} base - The longname of the base symbol.
|
||||
*/
|
||||
exports.Doclet.prototype.augment = function(base) {
|
||||
*/
|
||||
exports.Doclet.prototype.augment = function(base) {
|
||||
if (!this.augments) {
|
||||
/**
|
||||
A list of symbols that are augmented by this one, if any.
|
||||
@ -147,13 +147,13 @@
|
||||
this.augments = [];
|
||||
}
|
||||
this.augments.push(base);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
Set the `meta` property of this doclet.
|
||||
@param {object} meta
|
||||
*/
|
||||
exports.Doclet.prototype.setMeta = function(meta) {
|
||||
*/
|
||||
exports.Doclet.prototype.setMeta = function(meta) {
|
||||
if (!this.meta) {
|
||||
/**
|
||||
Information about the source code associated with this doclet.
|
||||
@ -204,9 +204,9 @@
|
||||
this.meta.code.value = meta.code.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function applyTag(tag) {
|
||||
function applyTag(tag) {
|
||||
if (tag.title === 'name') {
|
||||
this.name = tag.value;
|
||||
}
|
||||
@ -222,10 +222,10 @@
|
||||
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) {
|
||||
// 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') {
|
||||
@ -233,13 +233,13 @@
|
||||
}
|
||||
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
Convert the raw source of the doclet comment into an array of Tag objects.
|
||||
@private
|
||||
*/
|
||||
function toTags(docletSrc) {
|
||||
function toTags(docletSrc) {
|
||||
var tagSrcs,
|
||||
tags = [];
|
||||
|
||||
@ -251,9 +251,9 @@
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
|
||||
function unwrap(docletSrc) {
|
||||
function unwrap(docletSrc) {
|
||||
if (!docletSrc) { return ''; }
|
||||
|
||||
// note: keep trailing whitespace for @examples
|
||||
@ -267,16 +267,16 @@
|
||||
.replace(/\s*\\Z$/g, ''); // remove end-marker
|
||||
|
||||
return docletSrc;
|
||||
}
|
||||
}
|
||||
|
||||
function fixDescription(docletSrc) {
|
||||
function fixDescription(docletSrc) {
|
||||
if (!/^\s*@/.test(docletSrc)) {
|
||||
docletSrc = '@description ' + docletSrc;
|
||||
}
|
||||
return docletSrc;
|
||||
}
|
||||
}
|
||||
|
||||
function split(docletSrc) {
|
||||
function split(docletSrc) {
|
||||
var tagSrcs = [];
|
||||
|
||||
// split out the basic tags, keep surrounding whitespace
|
||||
@ -302,6 +302,4 @@
|
||||
});
|
||||
|
||||
return tagSrcs;
|
||||
}
|
||||
|
||||
})();
|
||||
}
|
||||
|
||||
@ -5,20 +5,20 @@
|
||||
@author Michael Mathews <micmath@gmail.com>
|
||||
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
|
||||
*/
|
||||
(function() {
|
||||
var jsdoc = {
|
||||
|
||||
var jsdoc = {
|
||||
tagDictionary: require('jsdoc/tag/dictionary')
|
||||
};
|
||||
|
||||
var puncToScope = { '.': 'static', '~': 'inner', '#': 'instance' },
|
||||
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) {
|
||||
exports.resolve = function(doclet) {
|
||||
var name = doclet.name,
|
||||
memberof = doclet.memberof || '',
|
||||
about = {},
|
||||
@ -84,16 +84,16 @@
|
||||
if (about.variation) {
|
||||
doclet.variation = about.variation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
@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
|
||||
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, '"') + '"';
|
||||
@ -101,20 +101,20 @@
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
RegExp.escape = RegExp.escape || function(str) {
|
||||
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) {
|
||||
exports.applyNamespace = function(longname, ns) {
|
||||
var nameParts = exports.shorten(longname),
|
||||
name = nameParts.name,
|
||||
longname = nameParts.longname;
|
||||
@ -124,15 +124,15 @@
|
||||
}
|
||||
|
||||
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) {
|
||||
exports.shorten = function(longname) {
|
||||
// quoted strings in a longname are atomic, convert to tokens
|
||||
var atoms = [], token;
|
||||
|
||||
@ -177,6 +177,5 @@
|
||||
|
||||
////
|
||||
return {longname: longname, memberof: memberof, scope: scope, name: name, variation: variation};
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
@ -4,38 +4,38 @@
|
||||
@author Michael Mathews <micmath@gmail.com>
|
||||
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
|
||||
*/
|
||||
(function() {
|
||||
var common = {
|
||||
args: require('common/args')
|
||||
};
|
||||
|
||||
var argParser = new common.args.ArgParser(),
|
||||
var common = {
|
||||
args: require('common/args')
|
||||
};
|
||||
|
||||
var argParser = new common.args.ArgParser(),
|
||||
ourOptions,
|
||||
defaults = {
|
||||
template: 'default',
|
||||
destination: './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 __dirname + /conf.json');
|
||||
argParser.addOption('e', 'encoding', true, 'Assume this encoding when reading all source files. Default: utf-8');
|
||||
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('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', 'explain', 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.');
|
||||
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 __dirname + /conf.json');
|
||||
argParser.addOption('e', 'encoding', true, 'Assume this encoding when reading all source files. Default: utf-8');
|
||||
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('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', 'explain', 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) {
|
||||
exports.parse = function(args) {
|
||||
args = args || [];
|
||||
|
||||
if (typeof args === 'string' || args.constructor === String) {
|
||||
@ -45,16 +45,16 @@
|
||||
ourOptions = argParser.parse(args, defaults);
|
||||
|
||||
return ourOptions;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
Display help message for options.
|
||||
*/
|
||||
exports.help = function() {
|
||||
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.
|
||||
@ -62,12 +62,11 @@
|
||||
Get all the options for this app.
|
||||
@return {Object} A collection of key/values representing all the options.
|
||||
*/
|
||||
exports.get = function(name) {
|
||||
exports.get = function(name) {
|
||||
if (typeof name === 'undefined') {
|
||||
return ourOptions;
|
||||
}
|
||||
else {
|
||||
return ourOptions[name];
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
@ -8,13 +8,13 @@
|
||||
@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) {
|
||||
exports.Package = function(json) {
|
||||
/** The source files associated with this package.
|
||||
@type {Array<String>}
|
||||
*/
|
||||
@ -64,6 +64,5 @@
|
||||
* ]
|
||||
*/
|
||||
this.licenses = json.licenses;
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
@ -2,14 +2,14 @@
|
||||
@module jsdoc/src/handlers
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var currentModule = null;
|
||||
|
||||
/**
|
||||
var currentModule = null;
|
||||
|
||||
/**
|
||||
Attach these event handlers to a particular instance of a parser.
|
||||
@param parser
|
||||
*/
|
||||
exports.attachTo = function(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
|
||||
@ -148,5 +148,5 @@
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
|
||||
@ -5,25 +5,24 @@
|
||||
* @requires common/events
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var Token = Packages.org.mozilla.javascript.Token,
|
||||
var Token = Packages.org.mozilla.javascript.Token,
|
||||
currentParser = null,
|
||||
currentSourceName = '';
|
||||
|
||||
/**
|
||||
/**
|
||||
* @class
|
||||
* @mixes module:common/events
|
||||
*
|
||||
* @example <caption>Create a new parser.</caption>
|
||||
* var jsdocParser = new (require('jsdoc/src/parser').Parser)();
|
||||
*/
|
||||
exports.Parser = function() {
|
||||
exports.Parser = function() {
|
||||
this._resultBuffer = [];
|
||||
this.refs = {};
|
||||
}
|
||||
require('common/util').mixin(exports.Parser.prototype, require('common/events'));
|
||||
}
|
||||
require('common/util').mixin(exports.Parser.prototype, require('common/events'));
|
||||
|
||||
/**
|
||||
/**
|
||||
* Parse the given source files for JSDoc comments.
|
||||
* @param {Array.<string>} sourceFiles An array of filepaths to the JavaScript sources.
|
||||
* @param {string} [encoding=utf8]
|
||||
@ -38,7 +37,7 @@
|
||||
* var myFiles = ['file1.js', 'file2.js'];
|
||||
* var docs = jsdocParser.parse(myFiles);
|
||||
*/
|
||||
exports.Parser.prototype.parse = function(sourceFiles, encoding) {
|
||||
exports.Parser.prototype.parse = function(sourceFiles, encoding) {
|
||||
const SCHEMA = 'javascript:';
|
||||
var sourceCode = '',
|
||||
filename = '';
|
||||
@ -67,33 +66,33 @@
|
||||
}
|
||||
|
||||
return this._resultBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @returns {Array<Doclet>} The accumulated results of any calls to parse.
|
||||
*/
|
||||
exports.Parser.prototype.results = function() {
|
||||
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) {
|
||||
exports.Parser.prototype.addResult = function(o) {
|
||||
this._resultBuffer.push(o);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Empty any accumulated results of calls to parse.
|
||||
*/
|
||||
exports.Parser.prototype.clear = function() {
|
||||
exports.Parser.prototype.clear = function() {
|
||||
currentParser = null;
|
||||
currentSourceName = '';
|
||||
this._resultBuffer = [];
|
||||
}
|
||||
}
|
||||
|
||||
/** @private */
|
||||
exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) {
|
||||
/** @private */
|
||||
exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) {
|
||||
currentSourceName = sourceName;
|
||||
|
||||
sourceCode = pretreat(sourceCode);
|
||||
@ -114,22 +113,22 @@
|
||||
this.fire('fileComplete', e);
|
||||
|
||||
currentSourceName = '';
|
||||
}
|
||||
}
|
||||
|
||||
function pretreat(code) {
|
||||
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) {
|
||||
exports.Parser.prototype.astnodeToMemberof = function(node) {
|
||||
var memberof = {};
|
||||
|
||||
if (node.type === Token.VAR || node.type === Token.FUNCTION) {
|
||||
@ -148,14 +147,14 @@
|
||||
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) {
|
||||
exports.Parser.prototype.resolveThis = function(node) {
|
||||
var memberof = {};
|
||||
|
||||
if (node.enclosingFunction) {
|
||||
@ -198,14 +197,14 @@
|
||||
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) {
|
||||
exports.Parser.prototype.resolveVar = function(node, basename) {
|
||||
var doclet,
|
||||
enclosingFunction = node.enclosingFunction;
|
||||
|
||||
@ -217,10 +216,10 @@
|
||||
}
|
||||
|
||||
return this.resolveVar(enclosingFunction, basename);
|
||||
}
|
||||
}
|
||||
|
||||
/** @private */
|
||||
function visitNode(node) {
|
||||
/** @private */
|
||||
function visitNode(node) {
|
||||
var e,
|
||||
commentSrc;
|
||||
|
||||
@ -367,10 +366,10 @@
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/** @private */
|
||||
function parserFactory() {
|
||||
/** @private */
|
||||
function parserFactory() {
|
||||
var cx = Packages.org.mozilla.javascript.Context.getCurrentContext();
|
||||
|
||||
var ce = new Packages.org.mozilla.javascript.CompilerEnvirons();
|
||||
@ -380,14 +379,14 @@
|
||||
|
||||
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) {
|
||||
function aboutNode(node) {
|
||||
about = {};
|
||||
|
||||
if (node.type == Token.FUNCTION) {
|
||||
@ -438,12 +437,12 @@
|
||||
}
|
||||
|
||||
return about;
|
||||
}
|
||||
}
|
||||
|
||||
/** @private
|
||||
/** @private
|
||||
@memberof module:src/parser.Parser
|
||||
*/
|
||||
function nodeToString(node) {
|
||||
*/
|
||||
function nodeToString(node) {
|
||||
var str;
|
||||
|
||||
if (!node) return;
|
||||
@ -474,12 +473,12 @@
|
||||
}
|
||||
|
||||
return '' + str;
|
||||
};
|
||||
};
|
||||
|
||||
/** @private
|
||||
/** @private
|
||||
@memberof module:src/parser.Parser
|
||||
*/
|
||||
function getTypeName(node) {
|
||||
*/
|
||||
function getTypeName(node) {
|
||||
var type = '';
|
||||
|
||||
if (node) {
|
||||
@ -487,16 +486,14 @@
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
/** @private
|
||||
/** @private
|
||||
@memberof module:src/parser.Parser
|
||||
*/
|
||||
function isValidJsdoc(commentSrc) {
|
||||
*/
|
||||
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.
|
||||
@ -506,4 +503,4 @@
|
||||
@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.
|
||||
*/
|
||||
*/
|
||||
@ -6,29 +6,29 @@
|
||||
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var common = {
|
||||
|
||||
var common = {
|
||||
mixin: require('common/util').mixin,
|
||||
events: require('common/events')
|
||||
};
|
||||
};
|
||||
|
||||
var fs = require('fs');
|
||||
var fs = require('fs');
|
||||
|
||||
/**
|
||||
/**
|
||||
@constructor
|
||||
@mixes module:common.events
|
||||
*/
|
||||
exports.Scanner = function() {
|
||||
}
|
||||
common.mixin(exports.Scanner.prototype, common.events);
|
||||
exports.Scanner = function() {
|
||||
}
|
||||
common.mixin(exports.Scanner.prototype, common.events);
|
||||
|
||||
/**
|
||||
/**
|
||||
Recursively searches the given searchPaths for js files.
|
||||
@param {Array.<string>} searchPaths
|
||||
@param {number} [depth=1]
|
||||
@fires sourceFileFound
|
||||
*/
|
||||
exports.Scanner.prototype.scan = function(searchPaths, depth, includeMatch, excludeMatch) {
|
||||
exports.Scanner.prototype.scan = function(searchPaths, depth, includeMatch, excludeMatch) {
|
||||
var filePaths = [],
|
||||
that = this;
|
||||
|
||||
@ -64,6 +64,5 @@
|
||||
});
|
||||
|
||||
return filePaths;
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
@ -11,17 +11,17 @@
|
||||
@requires jsdoc/tag/validator
|
||||
@requires jsdoc/tag/type
|
||||
*/
|
||||
(function() {
|
||||
|
||||
var jsdoc = {
|
||||
|
||||
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.
|
||||
@ -29,7 +29,7 @@
|
||||
@param {string=} tagBody
|
||||
@param {object=} meta
|
||||
*/
|
||||
exports.Tag = function(tagTitle, tagBody, meta) {
|
||||
exports.Tag = function(tagTitle, tagBody, meta) {
|
||||
var tagDef = jsdoc.tag.dictionary.lookUp(tagTitle),
|
||||
meta = meta || {};
|
||||
|
||||
@ -92,9 +92,9 @@
|
||||
}
|
||||
|
||||
jsdoc.tag.validator.validate(this, meta);
|
||||
}
|
||||
}
|
||||
|
||||
function trim(text, newlines) {
|
||||
function trim(text, newlines) {
|
||||
if (!text) { return ''; }
|
||||
|
||||
if (newlines) {
|
||||
@ -103,9 +103,9 @@
|
||||
else {
|
||||
return text.replace(/^\s+|\s+$/g, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
Parse the parameter name and parameter desc from the tag text.
|
||||
@inner
|
||||
@method parseParamText
|
||||
@ -113,7 +113,7 @@
|
||||
@param {string} tagText
|
||||
@returns {Array.<string, string, boolean, boolean>} [pname, pdesc, poptional, pdefault].
|
||||
*/
|
||||
function parseParamText(tagText) {
|
||||
function parseParamText(tagText) {
|
||||
var pname, pdesc, poptional, pdefault;
|
||||
|
||||
// like: pname, pname pdesc, or name - pdesc
|
||||
@ -131,6 +131,4 @@
|
||||
}
|
||||
}
|
||||
return [pname, pdesc, poptional, pdefault];
|
||||
}
|
||||
|
||||
})();
|
||||
}
|
||||
|
||||
@ -3,12 +3,12 @@
|
||||
@author Michael Mathews <micmath@gmail.com>
|
||||
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
|
||||
*/
|
||||
(function() {
|
||||
var _synonyms = {},
|
||||
|
||||
var _synonyms = {},
|
||||
_definitions = {},
|
||||
_namespaces = [];
|
||||
|
||||
function _TagDefinition(title, etc) {
|
||||
function _TagDefinition(title, etc) {
|
||||
etc = etc || {};
|
||||
|
||||
this.title = dictionary.normalise(title);
|
||||
@ -18,15 +18,15 @@
|
||||
this[p] = etc[p];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_TagDefinition.prototype.synonym = function(synonymName) {
|
||||
_TagDefinition.prototype.synonym = function(synonymName) {
|
||||
_synonyms[synonymName.toLowerCase()] = this.title;
|
||||
return this; // chainable
|
||||
}
|
||||
}
|
||||
|
||||
/** @exports jsdoc/tag/dictionary */
|
||||
var dictionary = {
|
||||
/** @exports jsdoc/tag/dictionary */
|
||||
var dictionary = {
|
||||
/** @function */
|
||||
defineTag: function(title, opts) {
|
||||
_definitions[title] = new _TagDefinition(title, opts);
|
||||
@ -64,10 +64,13 @@
|
||||
|
||||
return canonicalName;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
require('jsdoc/tag/dictionary/definitions').defineTags(dictionary);
|
||||
require('jsdoc/tag/dictionary/definitions').defineTags(dictionary);
|
||||
|
||||
module.exports = dictionary;
|
||||
for (var prop in dictionary) {
|
||||
if (dictionary.hasOwnProperty(prop)) {
|
||||
exports[prop] = dictionary[prop];
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
@ -5,11 +5,11 @@
|
||||
@author Michael Mathews <micmath@gmail.com>
|
||||
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
|
||||
*/
|
||||
(function() {
|
||||
/** Populate the given dictionary with all known JSDoc tag definitions.
|
||||
|
||||
/** Populate the given dictionary with all known JSDoc tag definitions.
|
||||
@param {module:jsdoc/tag/dictionary} dictionary
|
||||
*/
|
||||
exports.defineTags = function(dictionary) {
|
||||
*/
|
||||
exports.defineTags = function(dictionary) {
|
||||
|
||||
dictionary.defineTag('access', {
|
||||
mustHaveValue: true,
|
||||
@ -506,48 +506,48 @@
|
||||
doclet.version = tag.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** @private */
|
||||
function setDocletKindToTitle(doclet, tag) {
|
||||
/** @private */
|
||||
function setDocletKindToTitle(doclet, tag) {
|
||||
doclet.addTag( 'kind', tag.title );
|
||||
}
|
||||
}
|
||||
|
||||
function setDocletScopeToTitle(doclet, tag) {
|
||||
function setDocletScopeToTitle(doclet, tag) {
|
||||
doclet.addTag( 'scope', tag.title );
|
||||
}
|
||||
}
|
||||
|
||||
function setDocletNameToValue(doclet, tag) {
|
||||
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) {
|
||||
function setDocletDescriptionToValue(doclet, tag) {
|
||||
if (tag.value) {
|
||||
doclet.addTag( 'description', tag.value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setNameToFile(doclet, tag) {
|
||||
function setNameToFile(doclet, tag) {
|
||||
if (doclet.meta.filename) { doclet.addTag( 'name', 'file:'+doclet.meta.filename ); }
|
||||
}
|
||||
}
|
||||
|
||||
function setDocletMemberof(doclet, tag) {
|
||||
function setDocletMemberof(doclet, tag) {
|
||||
doclet.setMemberof(tag.value);
|
||||
}
|
||||
}
|
||||
|
||||
function applyNamespace(doclet, tag) {
|
||||
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) {
|
||||
function setDocletNameToFilename(doclet, tag) {
|
||||
var name = doclet.meta.filename;
|
||||
name = name.replace(/\.js$/i, '');
|
||||
|
||||
@ -558,9 +558,9 @@
|
||||
}
|
||||
}
|
||||
doclet.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
function parseBorrows(doclet, tag) {
|
||||
function parseBorrows(doclet, tag) {
|
||||
var m = /^(\S+)(?:\s+as\s+(\S+))?$/.exec(tag.text);
|
||||
if (m) {
|
||||
if (m[1] && m[2]) {
|
||||
@ -570,11 +570,10 @@
|
||||
return [ m[1] ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function firstWordOf(string) {
|
||||
function firstWordOf(string) {
|
||||
var m = /^(\S+)/.exec(string);
|
||||
if (m) { return m[1]; }
|
||||
else { return ''; }
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
@ -5,13 +5,12 @@
|
||||
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
/**
|
||||
/**
|
||||
@param {string} tagValue
|
||||
@returns {Array.<string>}
|
||||
*/
|
||||
exports.parse = function(tagValue) {
|
||||
exports.parse = function(tagValue) {
|
||||
if (typeof tagValue !== 'string') { tagValue = ''; }
|
||||
var type = '',
|
||||
text = '',
|
||||
@ -50,9 +49,9 @@
|
||||
type = parseTypes(type); // make it into an array
|
||||
|
||||
return [type, text, optional, nullable, variable];
|
||||
}
|
||||
}
|
||||
|
||||
function parseOptional(type) {
|
||||
function parseOptional(type) {
|
||||
var optional = null;
|
||||
|
||||
// {sometype=} means optional
|
||||
@ -62,9 +61,9 @@
|
||||
}
|
||||
|
||||
return [type, optional];
|
||||
}
|
||||
}
|
||||
|
||||
function parseNullable(type) {
|
||||
function parseNullable(type) {
|
||||
var nullable = null;
|
||||
|
||||
// {?sometype} means nullable, {!sometype} means not-nullable
|
||||
@ -74,9 +73,9 @@
|
||||
}
|
||||
|
||||
return [type, nullable];
|
||||
}
|
||||
}
|
||||
|
||||
function parseVariable(type) {
|
||||
function parseVariable(type) {
|
||||
var variable = null;
|
||||
|
||||
// {...sometype} means variable number of that type
|
||||
@ -86,9 +85,9 @@
|
||||
}
|
||||
|
||||
return [type, variable];
|
||||
}
|
||||
}
|
||||
|
||||
function parseTypes(type) {
|
||||
function parseTypes(type) {
|
||||
var types = [];
|
||||
|
||||
if ( ~type.indexOf('|') ) {
|
||||
@ -104,10 +103,9 @@
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
}
|
||||
|
||||
/** @private */
|
||||
function trim(text) {
|
||||
/** @private */
|
||||
function trim(text) {
|
||||
return text.replace(/^\s+|\s+$/g, '');
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
@ -5,14 +5,14 @@
|
||||
@author Michael Mathews <micmath@gmail.com>
|
||||
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
|
||||
*/
|
||||
(function() {
|
||||
|
||||
var dictionary = require('jsdoc/tag/dictionary');
|
||||
|
||||
/**
|
||||
var dictionary = require('jsdoc/tag/dictionary');
|
||||
|
||||
/**
|
||||
Validate the given tag.
|
||||
*/
|
||||
exports.validate = function(tag, meta) {
|
||||
exports.validate = function(tag, meta) {
|
||||
var tagDef = dictionary.lookUp(tag.title);
|
||||
|
||||
if (!tagDef && !env.conf.tags.allowUnknownTags) {
|
||||
@ -29,24 +29,23 @@
|
||||
throw new TagValueNotPermittedError(tag.title, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function UnknownTagError(tagName, 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;
|
||||
}
|
||||
UnknownTagError.prototype = Error.prototype;
|
||||
|
||||
function TagValueRequiredError(tagName, meta) {
|
||||
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;
|
||||
}
|
||||
TagValueRequiredError.prototype = Error.prototype;
|
||||
|
||||
function TagValueNotPermittedError(tagName, message, meta) {
|
||||
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;
|
||||
}
|
||||
TagValueNotPermittedError.prototype = Error.prototype;
|
||||
|
||||
})();
|
||||
@ -4,65 +4,65 @@
|
||||
@author Michael Mathews <micmath@gmail.com>
|
||||
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
|
||||
*/
|
||||
(function() {
|
||||
/**
|
||||
|
||||
/**
|
||||
@param {any} object
|
||||
*/
|
||||
exports.dump = function(object) {
|
||||
exports.dump = function(object) {
|
||||
indentBy = 0;
|
||||
output = '';
|
||||
|
||||
walk(object);
|
||||
outdent(false);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
const INDENTATION = ' '; // 4 spaces
|
||||
var indentBy,
|
||||
const INDENTATION = ' '; // 4 spaces
|
||||
var indentBy,
|
||||
output;
|
||||
|
||||
function pad(depth) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
function walk(object) {
|
||||
var value;
|
||||
|
||||
if ( value = getValue(object) ) {
|
||||
@ -114,45 +114,44 @@
|
||||
}
|
||||
outdent('}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getValue(o) { // see: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special/typeof
|
||||
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) {
|
||||
function stringify(o) {
|
||||
return JSON.stringify(o);
|
||||
}
|
||||
}
|
||||
|
||||
function isUnwalkable(o) { // some objects are unwalkable, like Java native objects
|
||||
function isUnwalkable(o) { // some objects are unwalkable, like Java native objects
|
||||
return (typeof o === 'object' && typeof o.constructor === 'undefined');
|
||||
}
|
||||
}
|
||||
|
||||
function isArray(o) {
|
||||
function isArray(o) {
|
||||
return o && (o instanceof Array) || o.constructor === Array;
|
||||
}
|
||||
}
|
||||
|
||||
function isRegExp(o) {
|
||||
function isRegExp(o) {
|
||||
return (o instanceof RegExp) ||
|
||||
(typeof o.constructor !== 'undefined' && o.constructor.name === 'RegExp');
|
||||
}
|
||||
}
|
||||
|
||||
function isDate(o) {
|
||||
function isDate(o) {
|
||||
return o && (o instanceof Date) ||
|
||||
(typeof o.constructor !== 'undefined' && o.constructor.name === 'Date');
|
||||
}
|
||||
}
|
||||
|
||||
function isFunction(o) {
|
||||
function isFunction(o) {
|
||||
return o && (typeof o === 'function' || o instanceof Function);// ||
|
||||
//(typeof o.constructor !== 'undefined' && (o.constructor||{}).name === 'Function');
|
||||
}
|
||||
}
|
||||
|
||||
function isObject(o) {
|
||||
function isObject(o) {
|
||||
return o && o instanceof Object ||
|
||||
(typeof o.constructor !== 'undefined' && o.constructor.name === 'Object');
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
17
rhino_modules/path.js
Normal file
17
rhino_modules/path.js
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
exports.basename = function(path) {
|
||||
var parts = path.split('/');
|
||||
parts.pop();
|
||||
path = parts.join('/');
|
||||
return path;
|
||||
};
|
||||
|
||||
exports.existsSync = function(path) {
|
||||
var file = new java.io.File(path);
|
||||
|
||||
if (file.isFile()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
@ -1,18 +0,0 @@
|
||||
|
||||
module.exports = {
|
||||
basename : function(path) {
|
||||
var parts = path.split('/');
|
||||
parts.pop();
|
||||
path = parts.join('/');
|
||||
return path;
|
||||
},
|
||||
existsSync: function(path) {
|
||||
var file = new java.io.File(path);
|
||||
|
||||
if (file.isFile()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
4
rhino_modules/sys.js
Normal file
4
rhino_modules/sys.js
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
exports.puts = function(str) {
|
||||
print(String(str));
|
||||
};
|
||||
@ -1,6 +0,0 @@
|
||||
|
||||
module.exports = {
|
||||
'puts' : function(str) {
|
||||
print(String(str));
|
||||
}
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user