Skip to content

Commit

Permalink
Initial check in of new 2.0 branch.
Browse files Browse the repository at this point in the history
git-svn-id: http://jsdoc-toolkit.googlecode.com/svn/branches/version2.0@410 c4b26cf2-672e-0410-81b6-737671b986b9
  • Loading branch information
micmath committed Jan 14, 2008
0 parents commit fb496d5
Show file tree
Hide file tree
Showing 173 changed files with 18,525 additions and 0 deletions.
48 changes: 48 additions & 0 deletions app/frame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

load(__DIR__+"app/frame/Chain.js");
load(__DIR__+"app/frame/Hash.js");
load(__DIR__+"app/frame/Namespace.js");

function defined(o) {
return (o !== undefined);
}

function include(path) {
if (!path) return;
if (path.constructor === Array) {
for (var i = 0, l = path.length; i < l; i ++) {
load(path[i]);
}
}
else if (typeof path == "string") {
load(__DIR__+path);
}
}

function include_once(path) {
if (include_once.included.indexOf(path) === -1) {
include(path);
include_once.included.push(path);
}
}
include_once.included = [];

function copy(o) { // todo check for circular refs
if (o == null || typeof(o) != 'object') return o;
var c = new o.constructor();
for(var p in o) c[p] = copy(o[p]);
return c;
}

function isUnique(arr) {
var l = arr.length;
for(var i = 0; i < l; i++ ) {
if (arr.lastIndexOf(arr[i]) > i) return false;
}
return true;
}

/** Returns the given string with all regex meta characters backslashed. */
RegExp.escapeMeta = function(str) {
return str.replace(/([$^\\\/()|?+*\[\]{}.-])/g, "\\$1");
}
101 changes: 101 additions & 0 deletions app/frame/Chain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
function ChainNode(object, link) {
this.value = object;
this.link = link; // describes this node's relationship to the previous node
}

function Chain(valueLinks) {
this.nodes = [];
this.cursor = -1;

if (valueLinks && valueLinks.length > 0) {
this.push(valueLinks[0], "//");
for (var i = 1, l = valueLinks.length; i < l; i+=2) {
this.push(valueLinks[i+1], valueLinks[i]);
}
}
}

Chain.prototype.push = function(o, link) {
if (this.nodes.length > 0 && link) this.nodes.push(new ChainNode(o, link));
else this.nodes.push(new ChainNode(o));
}

Chain.prototype.unshift = function(o, link) {
if (this.nodes.length > 0 && link) this.nodes[0].link = link;
this.nodes.unshift(new ChainNode(o));
this.cursor++;
}

Chain.prototype.get = function() {
if (this.cursor < 0 || this.cursor > this.nodes.length-1) return null;
return this.nodes[this.cursor];
}

Chain.prototype.first = function() {
this.cursor = 0;
return this.get();
}

Chain.prototype.last = function() {
this.cursor = this.nodes.length-1;
return this.get();
}

Chain.prototype.next = function() {
this.cursor++;
return this.get();
}

Chain.prototype.prev = function() {
this.cursor--;
return this.get();
}

Chain.prototype.toString = function() {
var string = "";
for (var i = 0, l = this.nodes.length; i < l; i++) {
if (this.nodes[i].link) string += " -("+this.nodes[i].link+")-> ";
string += this.nodes[i].value.toString();
}
return string;
}

Chain.prototype.joinLeft = function() {
var result = "";
for (var i = 0, l = this.cursor; i < l; i++) {
if (result && this.nodes[i].link) result += this.nodes[i].link;
result += this.nodes[i].value.toString();
}
//print("~~! got result: "+result);
return result;
}


/* USAGE:
var path = "one/two/three.four/five-six";
var pathChain = new Chain(path.split(/([\/.-])/));
print(pathChain);
var lineage = new Chain();
lineage.push("Port");
lineage.push("Les", "son");
lineage.push("Dawn", "daughter");
lineage.unshift("Purdie", "son");
print(lineage);
// walk left
for (var node = lineage.last(); node !== null; node = lineage.prev()) {
print("< "+node.value);
}
// walk right
var node = lineage.first()
while (node !== null) {
print(node.value);
node = lineage.next();
if (node && node.link) print("had a "+node.link+" named");
}
*/
143 changes: 143 additions & 0 deletions app/frame/Dumper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/**
* @class
<pre>
This is a lightly modified version of Kevin Jones' JavaScript
library Data.Dump. To download the original visit:
<a href="http://openjsan.org/doc/k/ke/kevinj/Data/Dump/">http://openjsan.org/doc/k/ke/kevinj/Data/Dump/</a>
AUTHORS
The Data.Dump JavaScript module is written by Kevin Jones
(kevinj@cpan.org), based on Data::Dump by Gisle Aas (gisle@aas.no),
based on Data::Dumper by Gurusamy Sarathy (gsar@umich.edu).
COPYRIGHT
Copyright 2007 Kevin Jones. Copyright 1998-2000,2003-2004 Gisle Aas.
Copyright 1996-1998 Gurusamy Sarathy.
This program is free software; you can redistribute it and/or modify
it under the terms of the Perl Artistic License
See http://www.perl.com/perl/misc/Artistic.html
</pre>
* @static
*/
Dumper = {
/** @param [...] The objects to dump. */
dump: function () {
if (arguments.length > 1)
return this._dump(arguments);
else if (arguments.length == 1)
return this._dump(arguments[0]);
else
return "()";
},

_dump: function (obj) {
if (typeof obj == 'undefined') return 'undefined';
var out;
var type = this._typeof(obj);
if (obj.circularReference) obj.circularReference++;
switch (type) {
case 'circular':
out = "{ //circularReference\n}";
break;
case 'object':
var pairs = new Array;

for (var prop in obj) {
if (prop != "circularReference" && obj.hasOwnProperty(prop)) { //hide inherited properties
pairs.push(prop + ': ' + this._dump(obj[prop]));
}
}

out = '{' + this._format_list(pairs) + '}';
break;

case 'string':
for (var prop in Dumper.ESC) {
if (Dumper.ESC.hasOwnProperty(prop)) {
obj = obj.replace(prop, Dumper.ESC[prop]);
}
}

// Escape UTF-8 Strings
if (obj.match(/^[\x00-\x7f]*$/)) {
out = '"' + obj.replace(/\"/g, "\\\"").replace(/([\n\r]+)/g, "\\$1") + '"';
}
else {
out = "unescape('"+escape(obj)+"')";
}
break;

case 'array':
var elems = new Array;

for (var i=0; i<obj.length; i++) {
elems.push( this._dump(obj[i]) );
}

out = '[' + this._format_list(elems) + ']';
break;

case 'date':
// firefox returns GMT strings from toUTCString()...
var utc_string = obj.toUTCString().replace(/GMT/,'UTC');
out = 'new Date("' + utc_string + '")';
break;

case 'element':
// DOM element
out = this._dump_dom(obj);
break;

default:
out = obj;
}

out = String(out).replace(/\n/g, '\n ');
out = out.replace(/\n (.*)$/,"\n$1");

return out;
},

_format_list: function (list) {
if (!list.length) return '';
var nl = list.toString().length > 60 ? '\n' : ' ';
return nl + list.join(',' + nl) + nl;
},

_typeof: function (obj) {
if (obj && obj.circularReference && obj.circularReference > 1) return 'circular';
if (Array.prototype.isPrototypeOf(obj)) return 'array';
if (Date.prototype.isPrototypeOf(obj)) return 'date';
if (typeof obj.nodeType != 'undefined') return 'element';
return typeof(obj);
},

_dump_dom: function (obj) {
return '"' + Dumper.nodeTypes[obj.nodeType] + '"';
}
};

Dumper.ESC = {
"\t": "\\t",
"\n": "\\n",
"\f": "\\f"
};

Dumper.nodeTypes = {
1: "ELEMENT_NODE",
2: "ATTRIBUTE_NODE",
3: "TEXT_NODE",
4: "CDATA_SECTION_NODE",
5: "ENTITY_REFERENCE_NODE",
6: "ENTITY_NODE",
7: "PROCESSING_INSTRUCTION_NODE",
8: "COMMENT_NODE",
9: "DOCUMENT_NODE",
10: "DOCUMENT_TYPE_NODE",
11: "DOCUMENT_FRAGMENT_NODE",
12: "NOTATION_NODE"
};
46 changes: 46 additions & 0 deletions app/frame/Hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function Hash() {
this.reset();
}

Hash.prototype.reset = function() {
this.elements = {};
}

Hash.prototype.put = function() {
for (var i = 0, l = arguments.length; i < l; i++) {
this.elements[arguments[i]] = arguments[++i];
}
}

Hash.prototype.has = function(key) {
return this.elements.hasOwnProperty(key);
}

Hash.prototype.get = function(key) {
return (this.has(key)) ? this.elements[key] : undefined;
}

Hash.prototype.drop = function(key) {
if (this.has(key)) {
delete this.elements[key];
}
}

Hash.prototype.rename = function(oldKey, newKey) {
if (oldKey != newKey && this.has(oldKey)) {
this.elements[newKey] = this.elements[oldKey];
delete this.elements[oldKey];
}
}

Hash.prototype.keys = function() {
var keys = [];
for (var key in this.elements) if (this.has(key)) keys.push(key);
return keys;
}

Hash.prototype.values = function() {
var values = [];
for (var key in this.elements) if (this.has(key)) values.push(this.get(key));
return values;
}
10 changes: 10 additions & 0 deletions app/frame/Namespace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Global = this;

function Namespace(name, f) {
var n = name.split(".");
for (var o = Global, i = 0, l = n.length; i < l; i++) {
o = o[n[i]] = o[n[i]] || {};
}

if (f) f();
}
Binary file added app/js.jar
Binary file not shown.
21 changes: 21 additions & 0 deletions app/lib/JSDOC.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
This is the main container for the entire application.
@namespace
*/
JSDOC = {
};

/** The current version string of this application. */
JSDOC.VERSION = "2.0a";

JSDOC.usage = function() {
//todo
}


include("app/lib/JSDOC/IO.js");
include(JSDOC.IO.ls(__DIR__+"app/lib/JSDOC/"));
include("app/plugins/tagParamConfig.js");
include("app/plugins/tagSynonyms.js");
include("app/plugins/tagShortcuts.js");
include("app/plugins/publishSrcHilite.js");
Loading

0 comments on commit fb496d5

Please sign in to comment.