ragaskar-jsdoc_helper 0.0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +64 -0
- data/bin/jsdoc_helper +8 -0
- data/ext/jsdoc-toolkit/README.txt +146 -0
- data/ext/jsdoc-toolkit/app/frame.js +33 -0
- data/ext/jsdoc-toolkit/app/frame/Chain.js +102 -0
- data/ext/jsdoc-toolkit/app/frame/Dumper.js +144 -0
- data/ext/jsdoc-toolkit/app/frame/Hash.js +84 -0
- data/ext/jsdoc-toolkit/app/frame/Link.js +148 -0
- data/ext/jsdoc-toolkit/app/frame/Namespace.js +10 -0
- data/ext/jsdoc-toolkit/app/frame/Opt.js +134 -0
- data/ext/jsdoc-toolkit/app/frame/Reflection.js +26 -0
- data/ext/jsdoc-toolkit/app/frame/String.js +93 -0
- data/ext/jsdoc-toolkit/app/frame/Testrun.js +129 -0
- data/ext/jsdoc-toolkit/app/handlers/FOODOC.js +26 -0
- data/ext/jsdoc-toolkit/app/handlers/XMLDOC.js +26 -0
- data/ext/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js +159 -0
- data/ext/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js +16 -0
- data/ext/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js +292 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC.js +101 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +200 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +294 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +126 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +109 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/Lang.js +144 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/Parser.js +107 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +33 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +643 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +229 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +41 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/Token.js +18 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +332 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +133 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/Util.js +32 -0
- data/ext/jsdoc-toolkit/app/lib/JSDOC/Walker.js +459 -0
- data/ext/jsdoc-toolkit/app/main.js +111 -0
- data/ext/jsdoc-toolkit/app/plugins/commentSrcJson.js +20 -0
- data/ext/jsdoc-toolkit/app/plugins/frameworkPrototype.js +16 -0
- data/ext/jsdoc-toolkit/app/plugins/functionCall.js +10 -0
- data/ext/jsdoc-toolkit/app/plugins/publishSrcHilite.js +62 -0
- data/ext/jsdoc-toolkit/app/plugins/symbolLink.js +9 -0
- data/ext/jsdoc-toolkit/app/plugins/tagParamConfig.js +31 -0
- data/ext/jsdoc-toolkit/app/plugins/tagSynonyms.js +43 -0
- data/ext/jsdoc-toolkit/app/run.js +348 -0
- data/ext/jsdoc-toolkit/app/t/TestDoc.js +144 -0
- data/ext/jsdoc-toolkit/app/t/runner.js +13 -0
- data/ext/jsdoc-toolkit/app/test.js +307 -0
- data/ext/jsdoc-toolkit/app/test/addon.js +24 -0
- data/ext/jsdoc-toolkit/app/test/anon_inner.js +14 -0
- data/ext/jsdoc-toolkit/app/test/augments.js +31 -0
- data/ext/jsdoc-toolkit/app/test/augments2.js +26 -0
- data/ext/jsdoc-toolkit/app/test/borrows.js +41 -0
- data/ext/jsdoc-toolkit/app/test/borrows2.js +23 -0
- data/ext/jsdoc-toolkit/app/test/config.js +22 -0
- data/ext/jsdoc-toolkit/app/test/constructs.js +18 -0
- data/ext/jsdoc-toolkit/app/test/encoding.js +10 -0
- data/ext/jsdoc-toolkit/app/test/encoding_other.js +12 -0
- data/ext/jsdoc-toolkit/app/test/event.js +54 -0
- data/ext/jsdoc-toolkit/app/test/functions_anon.js +39 -0
- data/ext/jsdoc-toolkit/app/test/functions_nested.js +33 -0
- data/ext/jsdoc-toolkit/app/test/global.js +13 -0
- data/ext/jsdoc-toolkit/app/test/globals.js +25 -0
- data/ext/jsdoc-toolkit/app/test/ignore.js +10 -0
- data/ext/jsdoc-toolkit/app/test/inner.js +16 -0
- data/ext/jsdoc-toolkit/app/test/jsdoc_test.js +477 -0
- data/ext/jsdoc-toolkit/app/test/lend.js +33 -0
- data/ext/jsdoc-toolkit/app/test/memberof.js +19 -0
- data/ext/jsdoc-toolkit/app/test/memberof_constructor.js +17 -0
- data/ext/jsdoc-toolkit/app/test/name.js +19 -0
- data/ext/jsdoc-toolkit/app/test/namespace_nested.js +23 -0
- data/ext/jsdoc-toolkit/app/test/nocode.js +13 -0
- data/ext/jsdoc-toolkit/app/test/oblit_anon.js +20 -0
- data/ext/jsdoc-toolkit/app/test/overview.js +20 -0
- data/ext/jsdoc-toolkit/app/test/param_inline.js +37 -0
- data/ext/jsdoc-toolkit/app/test/params_optional.js +8 -0
- data/ext/jsdoc-toolkit/app/test/prototype.js +17 -0
- data/ext/jsdoc-toolkit/app/test/prototype_nested.js +9 -0
- data/ext/jsdoc-toolkit/app/test/prototype_oblit.js +13 -0
- data/ext/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +24 -0
- data/ext/jsdoc-toolkit/app/test/public.js +10 -0
- data/ext/jsdoc-toolkit/app/test/shared.js +42 -0
- data/ext/jsdoc-toolkit/app/test/shared2.js +2 -0
- data/ext/jsdoc-toolkit/app/test/shortcuts.js +22 -0
- data/ext/jsdoc-toolkit/app/test/static_this.js +13 -0
- data/ext/jsdoc-toolkit/app/test/synonyms.js +31 -0
- data/ext/jsdoc-toolkit/app/test/tosource.js +23 -0
- data/ext/jsdoc-toolkit/app/test/variable_redefine.js +14 -0
- data/ext/jsdoc-toolkit/changes.txt +75 -0
- data/ext/jsdoc-toolkit/conf/sample.conf +31 -0
- data/ext/jsdoc-toolkit/java/build.xml +36 -0
- data/ext/jsdoc-toolkit/java/build_1.4.xml +36 -0
- data/ext/jsdoc-toolkit/java/classes/js.jar +0 -0
- data/ext/jsdoc-toolkit/java/src/JsDebugRun.java +21 -0
- data/ext/jsdoc-toolkit/java/src/JsRun.java +21 -0
- data/ext/jsdoc-toolkit/jsdebug.jar +0 -0
- data/ext/jsdoc-toolkit/jsrun.jar +0 -0
- data/ext/jsdoc-toolkit/out/jsdoc/files.html +216 -0
- data/ext/jsdoc-toolkit/out/jsdoc/index.html +210 -0
- data/ext/jsdoc-toolkit/out/jsdoc/symbols/_global_.html +306 -0
- data/ext/jsdoc-toolkit/out/jsdoc/symbols/src/lib_test.js.html +13 -0
- data/ext/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +17 -0
- data/ext/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +56 -0
- data/ext/jsdoc-toolkit/templates/jsdoc/class.tmpl +646 -0
- data/ext/jsdoc-toolkit/templates/jsdoc/index.tmpl +39 -0
- data/ext/jsdoc-toolkit/templates/jsdoc/publish.js +184 -0
- data/ext/jsdoc-toolkit/templates/jsdoc/static/default.css +162 -0
- data/ext/jsdoc-toolkit/templates/jsdoc/static/header.html +2 -0
- data/ext/jsdoc-toolkit/templates/jsdoc/static/index.html +19 -0
- data/ext/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +35 -0
- data/lib/jsdoc_helper.rb +50 -0
- data/lib/jsdoc_helper/rake/task.rb +43 -0
- data/lib/jsdoc_helper/rake/task/runner.rb +85 -0
- data/spec/jsdoc_helper/jsdoc_helper_spec.rb +4 -0
- data/spec/jsdoc_helper/rake/task/runner_spec.rb +45 -0
- data/spec/jsdoc_helper/support/file_helper_spec.rb +93 -0
- data/spec/spec_helper.rb +25 -0
- metadata +168 -0
data/README.rdoc
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
jsdoc_helper
|
2
|
+
by Pete Gadomski
|
3
|
+
http://github.com/quentonc/jsdoc_helper/tree/master
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Rake tasks for jsdoc-toolkit, a Javascript documentation generator.
|
8
|
+
|
9
|
+
jsdoc_helper includes:
|
10
|
+
* jsdoc-toolkit v2.1.0
|
11
|
+
* jsdoc-toolkit is an application, written in JavaScript, for automatically generating template-formatted, multi-page HTML (or XML, JSON, or any other text-based) documentation from commented JavaScript source code
|
12
|
+
* learn more at http://code.google.com/p/jsdoc-toolkit
|
13
|
+
* rake tasks to generate your jsdoc
|
14
|
+
|
15
|
+
== FEATURES/PROBLEMS:
|
16
|
+
|
17
|
+
* Customize your file names, templates, options, or use your own installation of jsdoc-toolkit
|
18
|
+
|
19
|
+
== SYNOPSIS:
|
20
|
+
|
21
|
+
Include the following in your Rakefile:
|
22
|
+
require 'rubygems' # if needed
|
23
|
+
require 'jsdoc_helper'
|
24
|
+
|
25
|
+
JsdocHelper::Rake::Task.new
|
26
|
+
|
27
|
+
Generate your doc with
|
28
|
+
$rake jsdoc
|
29
|
+
|
30
|
+
You can give your jsdoc task a new name
|
31
|
+
JsdocHelper::Rake::Task.new(:jsdoc_toolkit)
|
32
|
+
|
33
|
+
Or specify other options
|
34
|
+
JsdocHelper::Rake::Task.new do |t|
|
35
|
+
t[:options] = '--private'
|
36
|
+
t[:out] = 'html'
|
37
|
+
t[:template] = 'prettier/template'
|
38
|
+
t[:toolkit] = '/usr/local/lib/jsdoc-toolkit'
|
39
|
+
end
|
40
|
+
|
41
|
+
== REQUIREMENTS:
|
42
|
+
|
43
|
+
* Java. Refer to the jsdoc-toolkit <tt>README.txt</tt>, located in <tt>ext/jsdoc-toolkit</tt>, for exact requirements and instructions
|
44
|
+
* rake
|
45
|
+
sudo gem install rake
|
46
|
+
* (optional) open4 for testing
|
47
|
+
sudo gem install open4
|
48
|
+
|
49
|
+
== INSTALL:
|
50
|
+
|
51
|
+
JsdocHelper can be installed via RubyGems, hosted on github. If you haven't already
|
52
|
+
gem sources -a http://gems.github.com
|
53
|
+
Then
|
54
|
+
sudo gem install quentonc-jsdoc_helper
|
55
|
+
The source is on GitHub
|
56
|
+
git clone git://github.com/quentonc/jsdoc_helper.git
|
57
|
+
|
58
|
+
== LICENSE:
|
59
|
+
|
60
|
+
Creative Commons Attribution-Share Alike 3.0 Unported
|
61
|
+
http://creativecommons.org/licenses/by-sa/3.0/
|
62
|
+
|
63
|
+
jsdoc-toolkit is released under the MIT license
|
64
|
+
http://www.opensource.org/licenses/mit-license.php
|
data/bin/jsdoc_helper
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
======================================================================
|
2
|
+
|
3
|
+
DESCRIPTION:
|
4
|
+
|
5
|
+
This is the source code for JsDoc Toolkit, an automatic documentation
|
6
|
+
generation tool for JavaScript. It is written in JavaScript and is run
|
7
|
+
from a command line (or terminal) using the Java and Mozilla's Rhino
|
8
|
+
JavaScript runtime engine.
|
9
|
+
|
10
|
+
Using this tool you can automatically turn JavaDoc-like comments in
|
11
|
+
your JavaScript source code into published output files, such as HTML
|
12
|
+
or XML.
|
13
|
+
|
14
|
+
For more information, to report a bug, or to browse the technical
|
15
|
+
documentation for this tool please visit the official JsDoc Toolkit
|
16
|
+
project homepage at http://code.google.com/p/jsdoc-toolkit/
|
17
|
+
|
18
|
+
For the most up-to-date documentation on JsDoc Toolkit see the
|
19
|
+
official wiki at http://code.google.com/p/jsdoc-toolkit/w/list
|
20
|
+
|
21
|
+
======================================================================
|
22
|
+
|
23
|
+
REQUIREMENTS:
|
24
|
+
|
25
|
+
JsDoc Toolkit is known to work with:
|
26
|
+
java version "1.6.0_03"
|
27
|
+
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
|
28
|
+
on Windows XP,
|
29
|
+
and java version "1.5.0_13"
|
30
|
+
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-241)
|
31
|
+
on Mac OS X 10.4.
|
32
|
+
|
33
|
+
Other versions of java may or may not work with JsDoc Toolkit.
|
34
|
+
|
35
|
+
======================================================================
|
36
|
+
|
37
|
+
USAGE:
|
38
|
+
|
39
|
+
Running JsDoc Toolkit requires you to have Java installed on your
|
40
|
+
computer. For more information see http://www.java.com/getjava/
|
41
|
+
|
42
|
+
Before running the JsDoc Toolkit app you should change your current
|
43
|
+
working directory to the jsdoc-toolkit folder. Then follow the
|
44
|
+
examples below, or as shown on the project wiki.
|
45
|
+
|
46
|
+
On a computer running Windows a valid command line to run JsDoc
|
47
|
+
Toolkit might look like this:
|
48
|
+
|
49
|
+
> java -jar jsrun.jar app\run.js -a -t=templates\jsdoc mycode.js
|
50
|
+
|
51
|
+
On Mac OS X or Linux the same command would look like this:
|
52
|
+
|
53
|
+
$ java -jar jsrun.jar app/run.js -a -t=templates/jsdoc mycode.js
|
54
|
+
|
55
|
+
The above assumes your current working directory contains jsrun.jar,
|
56
|
+
the "app" and "templates" subdirectories from the standard JsDoc
|
57
|
+
Toolkit distribution and that the relative path to the code you wish
|
58
|
+
to document is "mycode.js".
|
59
|
+
|
60
|
+
The output documentation files will be saved to a new directory named
|
61
|
+
"out" (by default) in the current directory, or if you specify a
|
62
|
+
-d=somewhere_else option, to the somewhere_else directory.
|
63
|
+
|
64
|
+
For help (usage notes) enter this on the command line:
|
65
|
+
|
66
|
+
$ java -jar jsrun.jar app/run.js --help
|
67
|
+
|
68
|
+
More information about the various command line options used by JsDoc
|
69
|
+
Toolkit are available on the project wiki.
|
70
|
+
|
71
|
+
======================================================================
|
72
|
+
|
73
|
+
TESTING:
|
74
|
+
|
75
|
+
To run the suite of unit tests included with JsDoc Toolkit enter this
|
76
|
+
on the command line:
|
77
|
+
|
78
|
+
$ java -jar jsrun.jar app/run.js -T
|
79
|
+
|
80
|
+
To see a dump of the internal data structure that JsDoc Toolkit has
|
81
|
+
built from your source files use this command:
|
82
|
+
|
83
|
+
$ java -jar jsrun.jar app/run.js mycode.js -Z
|
84
|
+
|
85
|
+
======================================================================
|
86
|
+
|
87
|
+
LICENSE:
|
88
|
+
|
89
|
+
JSDoc.pm
|
90
|
+
|
91
|
+
This project is based on the JSDoc.pm tool, created by Michael
|
92
|
+
Mathews and Gabriel Reid. More information on JsDoc.pm can
|
93
|
+
be found on the JSDoc.pm homepage: http://jsdoc.sourceforge.net/
|
94
|
+
|
95
|
+
Complete documentation on JsDoc Toolkit can be found on the project
|
96
|
+
wiki at http://code.google.com/p/jsdoc-toolkit/w/list
|
97
|
+
|
98
|
+
Rhino
|
99
|
+
|
100
|
+
Rhino (JavaScript in Java) is open source and licensed by Mozilla
|
101
|
+
under the MPL 1.1 or later/GPL 2.0 or later licenses, the text of
|
102
|
+
which is available at http://www.mozilla.org/MPL/
|
103
|
+
|
104
|
+
You can obtain the source code for Rhino from the Mozilla web site at
|
105
|
+
http://www.mozilla.org/rhino/download.html
|
106
|
+
|
107
|
+
JsDoc Toolkit is a larger work that uses the Rhino JavaScript engine
|
108
|
+
but is not derived from it in any way. The Rhino library is used
|
109
|
+
without modification and without any claims whatsoever.
|
110
|
+
|
111
|
+
The Rhino Debugger
|
112
|
+
|
113
|
+
You can obtain more information about the Rhino Debugger from the
|
114
|
+
Mozilla web site at http://www.mozilla.org/rhino/debugger.html
|
115
|
+
|
116
|
+
JsDoc Toolkit is a larger work that uses the Rhino Debugger but
|
117
|
+
is not derived from it in any way. The Rhino Debugger is used
|
118
|
+
without modification and without any claims whatsoever.
|
119
|
+
|
120
|
+
JsDoc Toolkit
|
121
|
+
|
122
|
+
All code specific to JsDoc Toolkit are free, open source and licensed
|
123
|
+
for use under the X11/MIT License.
|
124
|
+
|
125
|
+
JsDoc Toolkit is Copyright (c)2009 Michael Mathews <micmath@gmail.com>
|
126
|
+
|
127
|
+
This program is free software; you can redistribute it and/or
|
128
|
+
modify it under the terms below.
|
129
|
+
|
130
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
131
|
+
a copy of this software and associated documentation files (the
|
132
|
+
"Software"), to deal in the Software without restriction, including
|
133
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
134
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
135
|
+
permit persons to whom the Software is furnished to do so, subject to
|
136
|
+
the following conditions: The above copyright notice and this
|
137
|
+
permission notice must be included in all copies or substantial
|
138
|
+
portions of the Software.
|
139
|
+
|
140
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
141
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
142
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
143
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
144
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
145
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
146
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,33 @@
|
|
1
|
+
IO.include("frame/Opt.js");
|
2
|
+
IO.include("frame/Chain.js");
|
3
|
+
IO.include("frame/Link.js");
|
4
|
+
IO.include("frame/String.js");
|
5
|
+
IO.include("frame/Hash.js");
|
6
|
+
IO.include("frame/Namespace.js");
|
7
|
+
//IO.include("frame/Reflection.js");
|
8
|
+
|
9
|
+
/** A few helper functions to make life a little easier. */
|
10
|
+
|
11
|
+
function defined(o) {
|
12
|
+
return (o !== undefined);
|
13
|
+
}
|
14
|
+
|
15
|
+
function copy(o) { // todo check for circular refs
|
16
|
+
if (o == null || typeof(o) != 'object') return o;
|
17
|
+
var c = new o.constructor();
|
18
|
+
for(var p in o) c[p] = copy(o[p]);
|
19
|
+
return c;
|
20
|
+
}
|
21
|
+
|
22
|
+
function isUnique(arr) {
|
23
|
+
var l = arr.length;
|
24
|
+
for(var i = 0; i < l; i++ ) {
|
25
|
+
if (arr.lastIndexOf(arr[i]) > i) return false;
|
26
|
+
}
|
27
|
+
return true;
|
28
|
+
}
|
29
|
+
|
30
|
+
/** Returns the given string with all regex meta characters backslashed. */
|
31
|
+
RegExp.escapeMeta = function(str) {
|
32
|
+
return str.replace(/([$^\\\/()|?+*\[\]{}.-])/g, "\\$1");
|
33
|
+
}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
/**@constructor*/
|
2
|
+
function ChainNode(object, link) {
|
3
|
+
this.value = object;
|
4
|
+
this.link = link; // describes this node's relationship to the previous node
|
5
|
+
}
|
6
|
+
|
7
|
+
/**@constructor*/
|
8
|
+
function Chain(valueLinks) {
|
9
|
+
this.nodes = [];
|
10
|
+
this.cursor = -1;
|
11
|
+
|
12
|
+
if (valueLinks && valueLinks.length > 0) {
|
13
|
+
this.push(valueLinks[0], "//");
|
14
|
+
for (var i = 1, l = valueLinks.length; i < l; i+=2) {
|
15
|
+
this.push(valueLinks[i+1], valueLinks[i]);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
Chain.prototype.push = function(o, link) {
|
21
|
+
if (this.nodes.length > 0 && link) this.nodes.push(new ChainNode(o, link));
|
22
|
+
else this.nodes.push(new ChainNode(o));
|
23
|
+
}
|
24
|
+
|
25
|
+
Chain.prototype.unshift = function(o, link) {
|
26
|
+
if (this.nodes.length > 0 && link) this.nodes[0].link = link;
|
27
|
+
this.nodes.unshift(new ChainNode(o));
|
28
|
+
this.cursor++;
|
29
|
+
}
|
30
|
+
|
31
|
+
Chain.prototype.get = function() {
|
32
|
+
if (this.cursor < 0 || this.cursor > this.nodes.length-1) return null;
|
33
|
+
return this.nodes[this.cursor];
|
34
|
+
}
|
35
|
+
|
36
|
+
Chain.prototype.first = function() {
|
37
|
+
this.cursor = 0;
|
38
|
+
return this.get();
|
39
|
+
}
|
40
|
+
|
41
|
+
Chain.prototype.last = function() {
|
42
|
+
this.cursor = this.nodes.length-1;
|
43
|
+
return this.get();
|
44
|
+
}
|
45
|
+
|
46
|
+
Chain.prototype.next = function() {
|
47
|
+
this.cursor++;
|
48
|
+
return this.get();
|
49
|
+
}
|
50
|
+
|
51
|
+
Chain.prototype.prev = function() {
|
52
|
+
this.cursor--;
|
53
|
+
return this.get();
|
54
|
+
}
|
55
|
+
|
56
|
+
Chain.prototype.toString = function() {
|
57
|
+
var string = "";
|
58
|
+
for (var i = 0, l = this.nodes.length; i < l; i++) {
|
59
|
+
if (this.nodes[i].link) string += " -("+this.nodes[i].link+")-> ";
|
60
|
+
string += this.nodes[i].value.toString();
|
61
|
+
}
|
62
|
+
return string;
|
63
|
+
}
|
64
|
+
|
65
|
+
Chain.prototype.joinLeft = function() {
|
66
|
+
var result = "";
|
67
|
+
for (var i = 0, l = this.cursor; i < l; i++) {
|
68
|
+
if (result && this.nodes[i].link) result += this.nodes[i].link;
|
69
|
+
result += this.nodes[i].value.toString();
|
70
|
+
}
|
71
|
+
return result;
|
72
|
+
}
|
73
|
+
|
74
|
+
|
75
|
+
/* USAGE:
|
76
|
+
|
77
|
+
var path = "one/two/three.four/five-six";
|
78
|
+
var pathChain = new Chain(path.split(/([\/.-])/));
|
79
|
+
print(pathChain);
|
80
|
+
|
81
|
+
var lineage = new Chain();
|
82
|
+
lineage.push("Port");
|
83
|
+
lineage.push("Les", "son");
|
84
|
+
lineage.push("Dawn", "daughter");
|
85
|
+
lineage.unshift("Purdie", "son");
|
86
|
+
|
87
|
+
print(lineage);
|
88
|
+
|
89
|
+
// walk left
|
90
|
+
for (var node = lineage.last(); node !== null; node = lineage.prev()) {
|
91
|
+
print("< "+node.value);
|
92
|
+
}
|
93
|
+
|
94
|
+
// walk right
|
95
|
+
var node = lineage.first()
|
96
|
+
while (node !== null) {
|
97
|
+
print(node.value);
|
98
|
+
node = lineage.next();
|
99
|
+
if (node && node.link) print("had a "+node.link+" named");
|
100
|
+
}
|
101
|
+
|
102
|
+
*/
|
@@ -0,0 +1,144 @@
|
|
1
|
+
/**
|
2
|
+
* @class
|
3
|
+
<pre>
|
4
|
+
This is a lightly modified version of Kevin Jones' JavaScript
|
5
|
+
library Data.Dump. To download the original visit:
|
6
|
+
<a href="http://openjsan.org/doc/k/ke/kevinj/Data/Dump/">http://openjsan.org/doc/k/ke/kevinj/Data/Dump/</a>
|
7
|
+
|
8
|
+
AUTHORS
|
9
|
+
|
10
|
+
The Data.Dump JavaScript module is written by Kevin Jones
|
11
|
+
(kevinj@cpan.org), based on Data::Dump by Gisle Aas (gisle@aas.no),
|
12
|
+
based on Data::Dumper by Gurusamy Sarathy (gsar@umich.edu).
|
13
|
+
|
14
|
+
COPYRIGHT
|
15
|
+
|
16
|
+
Copyright 2007 Kevin Jones. Copyright 1998-2000,2003-2004 Gisle Aas.
|
17
|
+
Copyright 1996-1998 Gurusamy Sarathy.
|
18
|
+
|
19
|
+
This program is free software; you can redistribute it and/or modify
|
20
|
+
it under the terms of the Perl Artistic License
|
21
|
+
|
22
|
+
See http://www.perl.com/perl/misc/Artistic.html
|
23
|
+
</pre>
|
24
|
+
* @static
|
25
|
+
*/
|
26
|
+
Dumper = {
|
27
|
+
/** @param [...] The objects to dump. */
|
28
|
+
dump: function () {
|
29
|
+
if (arguments.length > 1)
|
30
|
+
return this._dump(arguments);
|
31
|
+
else if (arguments.length == 1)
|
32
|
+
return this._dump(arguments[0]);
|
33
|
+
else
|
34
|
+
return "()";
|
35
|
+
},
|
36
|
+
|
37
|
+
_dump: function (obj) {
|
38
|
+
if (typeof obj == 'undefined') return 'undefined';
|
39
|
+
var out;
|
40
|
+
if (obj.serialize) { return obj.serialize(); }
|
41
|
+
var type = this._typeof(obj);
|
42
|
+
if (obj.circularReference) obj.circularReference++;
|
43
|
+
switch (type) {
|
44
|
+
case 'circular':
|
45
|
+
out = "{ //circularReference\n}";
|
46
|
+
break;
|
47
|
+
case 'object':
|
48
|
+
var pairs = new Array;
|
49
|
+
|
50
|
+
for (var prop in obj) {
|
51
|
+
if (prop != "circularReference" && obj.hasOwnProperty(prop)) { //hide inherited properties
|
52
|
+
pairs.push(prop + ': ' + this._dump(obj[prop]));
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
out = '{' + this._format_list(pairs) + '}';
|
57
|
+
break;
|
58
|
+
|
59
|
+
case 'string':
|
60
|
+
for (var prop in Dumper.ESC) {
|
61
|
+
if (Dumper.ESC.hasOwnProperty(prop)) {
|
62
|
+
obj = obj.replace(prop, Dumper.ESC[prop]);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
// Escape UTF-8 Strings
|
67
|
+
if (obj.match(/^[\x00-\x7f]*$/)) {
|
68
|
+
out = '"' + obj.replace(/\"/g, "\\\"").replace(/([\n\r]+)/g, "\\$1") + '"';
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
out = "unescape('"+escape(obj)+"')";
|
72
|
+
}
|
73
|
+
break;
|
74
|
+
|
75
|
+
case 'array':
|
76
|
+
var elems = new Array;
|
77
|
+
|
78
|
+
for (var i=0; i<obj.length; i++) {
|
79
|
+
elems.push( this._dump(obj[i]) );
|
80
|
+
}
|
81
|
+
|
82
|
+
out = '[' + this._format_list(elems) + ']';
|
83
|
+
break;
|
84
|
+
|
85
|
+
case 'date':
|
86
|
+
// firefox returns GMT strings from toUTCString()...
|
87
|
+
var utc_string = obj.toUTCString().replace(/GMT/,'UTC');
|
88
|
+
out = 'new Date("' + utc_string + '")';
|
89
|
+
break;
|
90
|
+
|
91
|
+
case 'element':
|
92
|
+
// DOM element
|
93
|
+
out = this._dump_dom(obj);
|
94
|
+
break;
|
95
|
+
|
96
|
+
default:
|
97
|
+
out = obj;
|
98
|
+
}
|
99
|
+
|
100
|
+
out = String(out).replace(/\n/g, '\n ');
|
101
|
+
out = out.replace(/\n (.*)$/,"\n$1");
|
102
|
+
|
103
|
+
return out;
|
104
|
+
},
|
105
|
+
|
106
|
+
_format_list: function (list) {
|
107
|
+
if (!list.length) return '';
|
108
|
+
var nl = list.toString().length > 60 ? '\n' : ' ';
|
109
|
+
return nl + list.join(',' + nl) + nl;
|
110
|
+
},
|
111
|
+
|
112
|
+
_typeof: function (obj) {
|
113
|
+
if (obj && obj.circularReference && obj.circularReference > 1) return 'circular';
|
114
|
+
if (Array.prototype.isPrototypeOf(obj)) return 'array';
|
115
|
+
if (Date.prototype.isPrototypeOf(obj)) return 'date';
|
116
|
+
if (typeof obj.nodeType != 'undefined') return 'element';
|
117
|
+
return typeof(obj);
|
118
|
+
},
|
119
|
+
|
120
|
+
_dump_dom: function (obj) {
|
121
|
+
return '"' + Dumper.nodeTypes[obj.nodeType] + '"';
|
122
|
+
}
|
123
|
+
};
|
124
|
+
|
125
|
+
Dumper.ESC = {
|
126
|
+
"\t": "\\t",
|
127
|
+
"\n": "\\n",
|
128
|
+
"\f": "\\f"
|
129
|
+
};
|
130
|
+
|
131
|
+
Dumper.nodeTypes = {
|
132
|
+
1: "ELEMENT_NODE",
|
133
|
+
2: "ATTRIBUTE_NODE",
|
134
|
+
3: "TEXT_NODE",
|
135
|
+
4: "CDATA_SECTION_NODE",
|
136
|
+
5: "ENTITY_REFERENCE_NODE",
|
137
|
+
6: "ENTITY_NODE",
|
138
|
+
7: "PROCESSING_INSTRUCTION_NODE",
|
139
|
+
8: "COMMENT_NODE",
|
140
|
+
9: "DOCUMENT_NODE",
|
141
|
+
10: "DOCUMENT_TYPE_NODE",
|
142
|
+
11: "DOCUMENT_FRAGMENT_NODE",
|
143
|
+
12: "NOTATION_NODE"
|
144
|
+
};
|