sproutcore 0.9.13 → 0.9.14
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +19 -0
- data/Manifest.txt +103 -26
- data/app_generators/sproutcore/templates/README +1 -1
- data/bin/sc-build +1 -1
- data/bin/sc-gen +0 -0
- data/bin/sc-ide +278 -0
- data/bin/sc-init +38 -0
- data/bin/sc-install +96 -0
- data/bin/sc-remove +94 -0
- data/bin/sc-server +4 -0
- data/bin/sc-update +94 -0
- data/bin/sproutcore +3 -14
- data/clients/sc_docs/controllers/docs.js +1 -1
- data/clients/sc_docs/models/doc.js +6 -0
- data/clients/sc_docs/views/doc_frame.js +1 -1
- data/clients/sc_test_runner/english.lproj/icons/small/next.png +0 -0
- data/clients/sc_test_runner/english.lproj/icons/small/reset.png +0 -0
- data/frameworks/sproutcore/HISTORY +34 -2
- data/frameworks/sproutcore/controllers/array.js +1 -1
- data/frameworks/sproutcore/controllers/controller.js +1 -1
- data/frameworks/sproutcore/controllers/object.js +9 -6
- data/frameworks/sproutcore/core.js +19 -4
- data/frameworks/sproutcore/english.lproj/blank.gif +0 -0
- data/frameworks/sproutcore/english.lproj/core.css +1 -0
- data/frameworks/sproutcore/english.lproj/menu.css +1 -0
- data/frameworks/sproutcore/foundation/application.js +3 -3
- data/frameworks/sproutcore/foundation/benchmark.js +1 -1
- data/frameworks/sproutcore/foundation/node_descriptor.js +13 -1
- data/frameworks/sproutcore/foundation/page.js +3 -2
- data/frameworks/sproutcore/foundation/path_module.js +33 -16
- data/frameworks/sproutcore/foundation/run_loop.js +1 -1
- data/frameworks/sproutcore/foundation/server.js +68 -18
- data/frameworks/sproutcore/foundation/string.js +1 -1
- data/frameworks/sproutcore/globals/window.js +62 -15
- data/frameworks/sproutcore/lib/core_views.rb +1 -0
- data/frameworks/sproutcore/lib/index.rhtml +4 -3
- data/frameworks/sproutcore/lib/menu_views.rb +2 -2
- data/frameworks/sproutcore/models/collection.js +122 -107
- data/frameworks/sproutcore/models/record.js +2 -2
- data/frameworks/sproutcore/panes/manager.js +1 -1
- data/frameworks/sproutcore/panes/overlay.js +3 -3
- data/frameworks/sproutcore/tests/controllers/object.rhtml +26 -0
- data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +2 -2
- data/frameworks/sproutcore/views/button/disclosure.js +1 -1
- data/frameworks/sproutcore/views/collection/collection.js +19 -15
- data/frameworks/sproutcore/views/collection/source_list.js +1 -1
- data/frameworks/sproutcore/views/collection/table.js +2 -2
- data/frameworks/sproutcore/views/error_explanation.js +1 -1
- data/frameworks/sproutcore/views/field/checkbox_field.js +1 -1
- data/frameworks/sproutcore/views/field/field.js +1 -1
- data/frameworks/sproutcore/views/field/radio_field.js +1 -1
- data/frameworks/sproutcore/views/field/select_field.js +1 -1
- data/frameworks/sproutcore/views/form.js +1 -1
- data/frameworks/sproutcore/views/image.js +1 -1
- data/frameworks/sproutcore/views/menu_item.js +1 -1
- data/frameworks/sproutcore/views/popup_button.js +1 -1
- data/frameworks/sproutcore/views/popup_menu.js +1 -1
- data/frameworks/sproutcore/views/progress.js +4 -2
- data/frameworks/sproutcore/views/radio_group.js +1 -1
- data/frameworks/sproutcore/views/scroll.js +1 -1
- data/frameworks/sproutcore/views/source_list_group.js +1 -1
- data/frameworks/sproutcore/views/split.js +1 -1
- data/frameworks/sproutcore/views/tab.js +3 -1
- data/frameworks/sproutcore/views/view.js +19 -3
- data/jsdoc/README.txt +89 -57
- data/jsdoc/app/frame/Chain.js +102 -0
- data/jsdoc/app/frame/Dumper.js +144 -0
- data/jsdoc/app/frame/Hash.js +47 -0
- data/jsdoc/app/frame/Link.js +142 -0
- data/jsdoc/app/frame/Namespace.js +10 -0
- data/jsdoc/app/frame/Opt.js +134 -0
- data/jsdoc/app/frame/Reflection.js +26 -0
- data/jsdoc/app/frame/String.js +93 -0
- data/jsdoc/app/frame/Testrun.js +129 -0
- data/jsdoc/app/frame.js +33 -0
- data/jsdoc/app/handlers/FOODOC.js +26 -0
- data/jsdoc/app/handlers/XMLDOC/DomReader.js +159 -0
- data/jsdoc/app/handlers/XMLDOC/XMLDoc.js +16 -0
- data/jsdoc/app/handlers/XMLDOC/XMLParse.js +292 -0
- data/jsdoc/app/handlers/XMLDOC.js +26 -0
- data/jsdoc/app/lib/JSDOC/DocComment.js +200 -0
- data/jsdoc/app/lib/JSDOC/DocTag.js +294 -0
- data/jsdoc/app/lib/JSDOC/JsDoc.js +180 -0
- data/jsdoc/app/lib/JSDOC/JsPlate.js +100 -0
- data/jsdoc/app/lib/JSDOC/Lang.js +144 -0
- data/jsdoc/app/lib/JSDOC/Parser.js +109 -0
- data/jsdoc/app/lib/JSDOC/PluginManager.js +33 -0
- data/jsdoc/app/lib/JSDOC/Symbol.js +600 -0
- data/jsdoc/app/lib/JSDOC/SymbolSet.js +220 -0
- data/jsdoc/app/lib/JSDOC/TextStream.js +41 -0
- data/jsdoc/app/lib/JSDOC/Token.js +18 -0
- data/jsdoc/app/lib/JSDOC/TokenReader.js +323 -0
- data/jsdoc/app/lib/JSDOC/TokenStream.js +133 -0
- data/jsdoc/app/lib/JSDOC/Util.js +32 -0
- data/jsdoc/app/lib/JSDOC/Walker.js +416 -0
- data/jsdoc/app/lib/JSDOC.js +97 -0
- data/jsdoc/app/main.js +74 -0
- data/jsdoc/app/plugins/commentSrcJson.js +19 -0
- data/jsdoc/app/plugins/frameworkPrototype.js +16 -0
- data/jsdoc/app/plugins/functionCall.js +10 -0
- data/jsdoc/app/plugins/publishSrcHilite.js +62 -0
- data/jsdoc/app/plugins/sproutcoreTags.js +26 -0
- data/jsdoc/app/plugins/symbolLink.js +9 -0
- data/jsdoc/app/plugins/tagParamConfig.js +31 -0
- data/jsdoc/app/plugins/tagSynonyms.js +43 -0
- data/jsdoc/app/run.js +339 -137
- data/jsdoc/changes.txt +47 -0
- data/jsdoc/conf/sample.conf +31 -0
- data/jsdoc/java/build.xml +36 -0
- data/jsdoc/java/build_1.4.xml +36 -0
- data/jsdoc/java/classes/js.jar +0 -0
- data/jsdoc/java/src/JsDebugRun.java +21 -0
- data/jsdoc/java/src/JsRun.java +21 -0
- data/jsdoc/jsdebug.jar +0 -0
- data/jsdoc/jsrun.jar +0 -0
- data/jsdoc/t/TestDoc.js +144 -0
- data/jsdoc/t/runner.js +13 -0
- data/jsdoc/templates/sproutcore/allclasses.tmpl +17 -0
- data/jsdoc/templates/sproutcore/allfiles.tmpl +56 -0
- data/jsdoc/templates/sproutcore/class.tmpl +408 -326
- data/jsdoc/templates/sproutcore/index.tmpl +30 -31
- data/jsdoc/templates/sproutcore/publish.js +173 -81
- data/jsdoc/templates/sproutcore/static/default.css +191 -0
- data/jsdoc/templates/sproutcore/static/header.html +2 -0
- data/jsdoc/templates/sproutcore/static/index.html +19 -0
- data/jsdoc/templates/sproutcore/symbol.tmpl +35 -0
- data/jsdoc/test/addon.js +24 -0
- data/jsdoc/test/anon_inner.js +14 -0
- data/jsdoc/test/augments.js +31 -0
- data/jsdoc/test/augments2.js +26 -0
- data/jsdoc/test/borrows.js +41 -0
- data/jsdoc/test/borrows2.js +23 -0
- data/jsdoc/test/config.js +22 -0
- data/jsdoc/test/constructs.js +18 -0
- data/jsdoc/test/encoding.js +10 -0
- data/jsdoc/test/encoding_other.js +12 -0
- data/jsdoc/test/functions_anon.js +39 -0
- data/jsdoc/test/functions_nested.js +33 -0
- data/jsdoc/test/global.js +13 -0
- data/jsdoc/test/globals.js +25 -0
- data/jsdoc/test/ignore.js +10 -0
- data/jsdoc/test/inner.js +16 -0
- data/jsdoc/test/jsdoc_test.js +477 -0
- data/jsdoc/test/lend.js +33 -0
- data/jsdoc/test/memberof.js +20 -0
- data/jsdoc/test/memberof_constructor.js +15 -0
- data/jsdoc/test/name.js +19 -0
- data/jsdoc/test/namespace_nested.js +23 -0
- data/jsdoc/test/nocode.js +13 -0
- data/jsdoc/test/oblit_anon.js +20 -0
- data/jsdoc/test/overview.js +20 -0
- data/jsdoc/test/param_inline.js +37 -0
- data/jsdoc/test/params_optional.js +8 -0
- data/jsdoc/test/prototype.js +17 -0
- data/jsdoc/test/prototype_nested.js +9 -0
- data/jsdoc/test/prototype_oblit.js +13 -0
- data/jsdoc/test/prototype_oblit_constructor.js +24 -0
- data/jsdoc/test/public.js +10 -0
- data/jsdoc/test/shared.js +42 -0
- data/jsdoc/test/shared2.js +2 -0
- data/jsdoc/test/shortcuts.js +22 -0
- data/jsdoc/test/static_this.js +13 -0
- data/jsdoc/test/synonyms.js +23 -0
- data/jsdoc/test/tosource.js +23 -0
- data/jsdoc/test/variable_redefine.js +14 -0
- data/jsdoc/test.js +304 -0
- data/lib/sproutcore/build_tools/resource_builder.rb +6 -1
- data/lib/sproutcore/bundle_installer.rb +268 -0
- data/lib/sproutcore/jsdoc.rb +7 -6
- data/lib/sproutcore/library.rb +38 -0
- data/lib/sproutcore/merb/bundle_controller.rb +8 -4
- data/lib/sproutcore/version.rb +1 -1
- data/lib/sproutcore.rb +1 -1
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/script/txt2html +0 -0
- metadata +117 -29
- data/clients/view_builder/core.js +0 -19
- data/clients/view_builder/english.lproj/body.css +0 -149
- data/clients/view_builder/english.lproj/body.rhtml +0 -18
- data/clients/view_builder/english.lproj/strings.js +0 -14
- data/clients/view_builder/main.js +0 -37
- data/jsdoc/app/DocFile.js +0 -137
- data/jsdoc/app/DocTag.js +0 -110
- data/jsdoc/app/Doclet.js +0 -63
- data/jsdoc/app/Dumper.js +0 -143
- data/jsdoc/app/JsDoc.js +0 -103
- data/jsdoc/app/JsHilite.js +0 -45
- data/jsdoc/app/JsIO.js +0 -163
- data/jsdoc/app/JsParse.js +0 -385
- data/jsdoc/app/JsPlate.js +0 -130
- data/jsdoc/app/JsTestrun.js +0 -129
- data/jsdoc/app/JsToke.js +0 -564
- data/jsdoc/app/Symbol.js +0 -298
- data/jsdoc/app/Transformer.js +0 -14
- data/jsdoc/app/Util.js +0 -97
- data/jsdoc/app/js.jar +0 -0
- data/jsdoc/plugins/min.js +0 -316
- data/jsdoc/plugins/strip.js +0 -20
- data/jsdoc/templates/sproutcore/default.css +0 -191
- data/jsdoc/templates/sproutcore/index.html +0 -13
- data/jsdoc/templates/sproutcore/prototype.js +0 -4186
- data/jsdoc/templates/sproutcore/splash.html +0 -7
@@ -0,0 +1,129 @@
|
|
1
|
+
/**
|
2
|
+
* @fileOverview
|
3
|
+
* @name JsTestrun
|
4
|
+
* @author Michael Mathews micmath@gmail.com
|
5
|
+
* @url $HeadURL: https://jsdoc-toolkit.googlecode.com/svn/tags/jsdoc_toolkit-2.0.1/jsdoc-toolkit/app/frame/Testrun.js $
|
6
|
+
* @revision $Id: Testrun.js 418 2008-01-15 21:40:33Z micmath $
|
7
|
+
* @license <a href="http://en.wikipedia.org/wiki/MIT_License">X11/MIT License</a>
|
8
|
+
* (See the accompanying README file for full details.)
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
Yet another unit testing tool for JavaScript.
|
13
|
+
@author Michael Mathews <a href="mailto:micmath@gmail.com">micmath@gmail.com</a>
|
14
|
+
@param {object} testCases Properties are testcase names, values are functions to execute as tests.
|
15
|
+
*/
|
16
|
+
function testrun(testCases) {
|
17
|
+
var ran = 0;
|
18
|
+
for (t in testCases) {
|
19
|
+
var result = testCases[t]();
|
20
|
+
ran++;
|
21
|
+
}
|
22
|
+
|
23
|
+
return testrun.reportOut+"-------------------------------\n"+((testrun.fails>0)? ":( Failed "+testrun.fails+"/" : ":) Passed all ")+testrun.count+" test"+((testrun.count == 1)? "":"s")+".\n";
|
24
|
+
}
|
25
|
+
|
26
|
+
|
27
|
+
testrun.count = 0;
|
28
|
+
testrun.current = null;
|
29
|
+
testrun.passes = 0;
|
30
|
+
testrun.fails = 0;
|
31
|
+
testrun.reportOut = "";
|
32
|
+
|
33
|
+
/** @private */
|
34
|
+
testrun.report = function(text) {
|
35
|
+
testrun.reportOut += text+"\n";
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
Check if test evaluates to true.
|
40
|
+
@param {string} test To be evaluated.
|
41
|
+
@param {string} message Optional. To be displayed in the report.
|
42
|
+
@return {boolean} True if the string test evaluates to true.
|
43
|
+
*/
|
44
|
+
ok = function(test, message) {
|
45
|
+
testrun.count++;
|
46
|
+
|
47
|
+
var result;
|
48
|
+
try {
|
49
|
+
result = eval(test);
|
50
|
+
|
51
|
+
if (result) {
|
52
|
+
testrun.passes++;
|
53
|
+
testrun.report(" OK "+testrun.count+" - "+((message != null)? message : ""));
|
54
|
+
}
|
55
|
+
else {
|
56
|
+
testrun.fails++;
|
57
|
+
testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : ""));
|
58
|
+
}
|
59
|
+
}
|
60
|
+
catch(e) {
|
61
|
+
testrun.fails++
|
62
|
+
testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : ""));
|
63
|
+
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
Check if test is same as expected.
|
69
|
+
@param {string} test To be evaluated.
|
70
|
+
@param {string} expected
|
71
|
+
@param {string} message Optional. To be displayed in the report.
|
72
|
+
@return {boolean} True if (test == expected). Note that the comparison is not a strict equality check.
|
73
|
+
*/
|
74
|
+
is = function(test, expected, message) {
|
75
|
+
testrun.count++;
|
76
|
+
|
77
|
+
var result;
|
78
|
+
try {
|
79
|
+
result = eval(test);
|
80
|
+
|
81
|
+
if (result == expected) {
|
82
|
+
testrun.passes++
|
83
|
+
testrun.report(" OK "+testrun.count+" - "+((message != null)? message : ""));
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
testrun.fails++
|
87
|
+
testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : ""));
|
88
|
+
testrun.report("expected: "+expected);
|
89
|
+
testrun.report(" got: "+result);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
catch(e) {
|
93
|
+
testrun.fails++
|
94
|
+
testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : ""));
|
95
|
+
testrun.report("expected: "+expected);
|
96
|
+
testrun.report(" got: "+result);}
|
97
|
+
}
|
98
|
+
|
99
|
+
/**
|
100
|
+
Check if test matches pattern.
|
101
|
+
@param {string} test To be evaluated.
|
102
|
+
@param {string} pattern Used to create a RegExp.
|
103
|
+
@param {string} message Optional. To be displayed in the report.
|
104
|
+
@return {boolean} True if test matches pattern.
|
105
|
+
*/
|
106
|
+
like = function(test, pattern, message) {
|
107
|
+
testrun.count++;
|
108
|
+
|
109
|
+
var result;
|
110
|
+
try {
|
111
|
+
result = eval(test);
|
112
|
+
var rgx = new RegExp(pattern);
|
113
|
+
|
114
|
+
if (rgx.test(result)) {
|
115
|
+
testrun.passes++
|
116
|
+
testrun.report(" OK "+testrun.count+" - "+((message != null)? message : ""));
|
117
|
+
}
|
118
|
+
else {
|
119
|
+
testrun.fails++
|
120
|
+
testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : ""));
|
121
|
+
testrun.report(" this: "+result);
|
122
|
+
testrun.report("is not like: "+pattern);
|
123
|
+
}
|
124
|
+
}
|
125
|
+
catch(e) {
|
126
|
+
testrun.fails++
|
127
|
+
testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : ""));
|
128
|
+
}
|
129
|
+
}
|
data/jsdoc/app/frame.js
ADDED
@@ -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,26 @@
|
|
1
|
+
/**
|
2
|
+
This is the main container for the FOODOC handler.
|
3
|
+
@namespace
|
4
|
+
*/
|
5
|
+
FOODOC = {
|
6
|
+
};
|
7
|
+
|
8
|
+
/** The current version string of this application. */
|
9
|
+
FOODOC.VERSION = "1.0";
|
10
|
+
|
11
|
+
FOODOC.handle = function(srcFile, src) {
|
12
|
+
LOG.inform("Handling file '" + srcFile + "'");
|
13
|
+
|
14
|
+
return [
|
15
|
+
new JSDOC.Symbol(
|
16
|
+
"foo",
|
17
|
+
[],
|
18
|
+
"VIRTUAL",
|
19
|
+
new JSDOC.DocComment("/** This is a foo. */")
|
20
|
+
)
|
21
|
+
];
|
22
|
+
};
|
23
|
+
|
24
|
+
FOODOC.publish = function(symbolgroup) {
|
25
|
+
LOG.inform("Publishing symbolgroup.");
|
26
|
+
};
|
@@ -0,0 +1,159 @@
|
|
1
|
+
LOG.inform("XMLDOC.DomReader loaded");
|
2
|
+
|
3
|
+
XMLDOC.DomReader = function(root) {
|
4
|
+
|
5
|
+
this.dom = root;
|
6
|
+
|
7
|
+
/**
|
8
|
+
* The current node the reader is on
|
9
|
+
*/
|
10
|
+
this.node = root;
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Get the current node the reader is on
|
14
|
+
* @type XMLDOC.Parser.node
|
15
|
+
*/
|
16
|
+
XMLDOC.DomReader.prototype.getNode = function() {
|
17
|
+
return this.node;
|
18
|
+
};
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Set the node the reader should be positioned on.
|
22
|
+
* @param node {XMLDOC.Parser.node}
|
23
|
+
*/
|
24
|
+
XMLDOC.DomReader.prototype.setNode = function(node) {
|
25
|
+
this.node = node;
|
26
|
+
};
|
27
|
+
|
28
|
+
/**
|
29
|
+
* A helper method to make sure the current node will
|
30
|
+
* never return null, unless null is passed as the root.
|
31
|
+
* @param step {String} An expression to evaluate - should return a node or null
|
32
|
+
*/
|
33
|
+
XMLDOC.DomReader.prototype.navigate = function(step) {
|
34
|
+
var n;
|
35
|
+
if ((n = step) != null)
|
36
|
+
{
|
37
|
+
this.node = n;
|
38
|
+
return this.node;
|
39
|
+
}
|
40
|
+
return null;
|
41
|
+
};
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Get the root node of the current node's document.
|
45
|
+
*/
|
46
|
+
XMLDOC.DomReader.prototype.root = function() {
|
47
|
+
this.navigate(this.dom);
|
48
|
+
};
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Get the parent of the current node.
|
52
|
+
*/
|
53
|
+
XMLDOC.DomReader.prototype.parent = function() {
|
54
|
+
return this.navigate(this.node.parentNode());
|
55
|
+
};
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Get the first child of the current node.
|
59
|
+
*/
|
60
|
+
XMLDOC.DomReader.prototype.firstChild = function() {
|
61
|
+
return this.navigate(this.node.firstChild());
|
62
|
+
};
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Get the last child of the current node.
|
66
|
+
*/
|
67
|
+
XMLDOC.DomReader.prototype.lastChild = function() {
|
68
|
+
return this.navigate(this.node.lastChild());
|
69
|
+
};
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Get the next sibling of the current node.
|
73
|
+
*/
|
74
|
+
XMLDOC.DomReader.prototype.nextSibling = function() {
|
75
|
+
return this.navigate(this.node.nextSibling());
|
76
|
+
};
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Get the previous sibling of the current node.
|
80
|
+
*/
|
81
|
+
XMLDOC.DomReader.prototype.prevSibling = function() {
|
82
|
+
return this.navigate(this.node.prevSibling());
|
83
|
+
};
|
84
|
+
|
85
|
+
//===============================================================================================
|
86
|
+
// Support methods
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Walk the tree starting with the current node, calling the plug-in for
|
90
|
+
* each node visited. Each time the plug-in is called, the DomReader
|
91
|
+
* is passed as the only parameter. Use the {@link XMLDOC.DomReader#getNode} method
|
92
|
+
* to access the current node. <i>This method uses a depth first traversal pattern.</i>
|
93
|
+
*
|
94
|
+
* @param srcFile {String} The source file being evaluated
|
95
|
+
*/
|
96
|
+
XMLDOC.DomReader.prototype.getSymbols = function(srcFile)
|
97
|
+
{
|
98
|
+
XMLDOC.DomReader.symbols = [];
|
99
|
+
XMLDOC.DomReader.currentFile = srcFile;
|
100
|
+
JSDOC.Symbol.srcFile = (srcFile || "");
|
101
|
+
|
102
|
+
if (defined(JSDOC.PluginManager)) {
|
103
|
+
JSDOC.PluginManager.run("onDomGetSymbols", this);
|
104
|
+
}
|
105
|
+
|
106
|
+
return XMLDOC.DomReader.symbols;
|
107
|
+
};
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Find the node with the given name using a depth first traversal.
|
111
|
+
* Does not modify the DomReader's current node.
|
112
|
+
*
|
113
|
+
* @param name {String} The name of the node to find
|
114
|
+
* @return the node that was found, or null if not found
|
115
|
+
*/
|
116
|
+
XMLDOC.DomReader.prototype.findNode = function(name)
|
117
|
+
{
|
118
|
+
var findNode = null;
|
119
|
+
|
120
|
+
// Start at the current node and move into the subtree,
|
121
|
+
// looking for the node with the given name
|
122
|
+
function deeper(node, find)
|
123
|
+
{
|
124
|
+
var look = null;
|
125
|
+
|
126
|
+
if (node) {
|
127
|
+
if (node.name == find)
|
128
|
+
{
|
129
|
+
return node;
|
130
|
+
}
|
131
|
+
|
132
|
+
if (node.firstChild())
|
133
|
+
{
|
134
|
+
look = deeper(node.firstChild(), find);
|
135
|
+
}
|
136
|
+
|
137
|
+
if (!look && node.nextSibling())
|
138
|
+
{
|
139
|
+
look = deeper(node.nextSibling(), find);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
return look;
|
144
|
+
}
|
145
|
+
|
146
|
+
return deeper(this.getNode().firstChild(), name);
|
147
|
+
};
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Find the next node with the given name using a depth first traversal.
|
151
|
+
*
|
152
|
+
* @param name {String} The name of the node to find
|
153
|
+
*/
|
154
|
+
XMLDOC.DomReader.prototype.findPreviousNode = function(name)
|
155
|
+
{
|
156
|
+
};
|
157
|
+
|
158
|
+
};
|
159
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
LOG.inform("XMLDOC.symbolize loaded");
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Convert the source file to a set of symbols
|
5
|
+
*/
|
6
|
+
XMLDOC.symbolize = function(srcFile, src) {
|
7
|
+
|
8
|
+
LOG.inform("Symbolizing file '" + srcFile + "'");
|
9
|
+
|
10
|
+
// XML files already have a defined structure, so we don't need to
|
11
|
+
// do anything but parse them. The DOM reader can create a symbol
|
12
|
+
// table from the parsed XML.
|
13
|
+
var dr = new XMLDOC.DomReader(XMLDOC.Parser.parse(src));
|
14
|
+
return dr.getSymbols(srcFile);
|
15
|
+
|
16
|
+
};
|
@@ -0,0 +1,292 @@
|
|
1
|
+
LOG.inform("XMLDOC.Parser loaded");
|
2
|
+
|
3
|
+
/**
|
4
|
+
* XML Parser object. Returns an {@link #XMLDOC.Parser.node} which is
|
5
|
+
* the root element of the parsed document.
|
6
|
+
* <p/>
|
7
|
+
* By default, this parser will only handle well formed XML. To
|
8
|
+
* allow the parser to handle HTML, set the <tt>XMLDOC.Parser.strictMode</tt>
|
9
|
+
* variable to <tt>false</tt> before calling <tt>XMLDOC.Parser.parse()</tt>.
|
10
|
+
* <p/>
|
11
|
+
* <i>Note: If you pass poorly formed XML, it will cause the parser to throw
|
12
|
+
* an exception.</i>
|
13
|
+
*
|
14
|
+
* @author Brett Fattori (bfattori@fry.com)
|
15
|
+
* @author $Author: micmath $
|
16
|
+
* @version $Revision: 497 $
|
17
|
+
*/
|
18
|
+
XMLDOC.Parser = {};
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Strict mode setting. Setting this to false allows HTML-style source to
|
22
|
+
* be parsed. Normally, well formed XML has defined end tags, or empty tags
|
23
|
+
* are properly formed. Default: <tt>true</tt>
|
24
|
+
* @type Boolean
|
25
|
+
*/
|
26
|
+
XMLDOC.Parser.strictMode = true;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* A node in an XML Document. Node types are ROOT, ELEMENT, COMMENT, PI, and TEXT.
|
30
|
+
* @param parent {XMLDOC.Parser.node} The parent node
|
31
|
+
* @param name {String} The node name
|
32
|
+
* @param type {String} One of the types
|
33
|
+
*/
|
34
|
+
XMLDOC.Parser.node = function(parent, name, type)
|
35
|
+
{
|
36
|
+
this.name = name;
|
37
|
+
this.type = type || "ELEMENT";
|
38
|
+
this.parent = parent;
|
39
|
+
this.charData = "";
|
40
|
+
this.attrs = {};
|
41
|
+
this.nodes = [];
|
42
|
+
this.cPtr = 0;
|
43
|
+
|
44
|
+
XMLDOC.Parser.node.prototype.getAttributeNames = function() {
|
45
|
+
var a = [];
|
46
|
+
for (var o in this.attrs)
|
47
|
+
{
|
48
|
+
a.push(o);
|
49
|
+
}
|
50
|
+
|
51
|
+
return a;
|
52
|
+
};
|
53
|
+
|
54
|
+
XMLDOC.Parser.node.prototype.getAttribute = function(attr) {
|
55
|
+
return this.attrs[attr];
|
56
|
+
};
|
57
|
+
|
58
|
+
XMLDOC.Parser.node.prototype.setAttribute = function(attr, val) {
|
59
|
+
this.attrs[attr] = val;
|
60
|
+
};
|
61
|
+
|
62
|
+
XMLDOC.Parser.node.prototype.getChild = function(idx) {
|
63
|
+
return this.nodes[idx];
|
64
|
+
};
|
65
|
+
|
66
|
+
XMLDOC.Parser.node.prototype.parentNode = function() {
|
67
|
+
return this.parent;
|
68
|
+
};
|
69
|
+
|
70
|
+
XMLDOC.Parser.node.prototype.firstChild = function() {
|
71
|
+
return this.nodes[0];
|
72
|
+
};
|
73
|
+
|
74
|
+
XMLDOC.Parser.node.prototype.lastChild = function() {
|
75
|
+
return this.nodes[this.nodes.length - 1];
|
76
|
+
};
|
77
|
+
|
78
|
+
XMLDOC.Parser.node.prototype.nextSibling = function() {
|
79
|
+
var p = this.parent;
|
80
|
+
if (p && (p.nodes.indexOf(this) + 1 != p.nodes.length))
|
81
|
+
{
|
82
|
+
return p.getChild(p.nodes.indexOf(this) + 1);
|
83
|
+
}
|
84
|
+
return null;
|
85
|
+
};
|
86
|
+
|
87
|
+
XMLDOC.Parser.node.prototype.prevSibling = function() {
|
88
|
+
var p = this.parent;
|
89
|
+
if (p && (p.nodes.indexOf(this) - 1 >= 0))
|
90
|
+
{
|
91
|
+
return p.getChild(p.nodes.indexOf(this) - 1);
|
92
|
+
}
|
93
|
+
return null;
|
94
|
+
};
|
95
|
+
};
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Parse an XML Document from the specified source. The XML should be
|
99
|
+
* well formed, unless strict mode is disabled, then the parser will
|
100
|
+
* handle HTML-style XML documents.
|
101
|
+
* @param src {String} The source to parse
|
102
|
+
*/
|
103
|
+
XMLDOC.Parser.parse = function(src)
|
104
|
+
{
|
105
|
+
var A = [];
|
106
|
+
|
107
|
+
// Normailize whitespace
|
108
|
+
A = src.split("\r\n");
|
109
|
+
src = A.join("\n");
|
110
|
+
A = src.split("\r");
|
111
|
+
src = A.join("\n");
|
112
|
+
|
113
|
+
// Remove XML and DOCTYPE specifier
|
114
|
+
src.replace(/<\?XML .*\?>/i, "");
|
115
|
+
src.replace(/<!DOCTYPE .*\>/i, "");
|
116
|
+
|
117
|
+
// The document is the root node and cannot be modified or removed
|
118
|
+
var doc = new XMLDOC.Parser.node(null, "ROOT", "DOCUMENT");
|
119
|
+
|
120
|
+
// Let's break it down
|
121
|
+
XMLDOC.Parser.eat(doc, src);
|
122
|
+
|
123
|
+
return doc;
|
124
|
+
};
|
125
|
+
|
126
|
+
/**
|
127
|
+
* The XML fragment processing routine. This method is private and should not be called
|
128
|
+
* directly.
|
129
|
+
* @param parentNode {XMLDOC.Parser.node} The node which is the parent of this fragment
|
130
|
+
* @param src {String} The source within the fragment to process
|
131
|
+
* @private
|
132
|
+
*/
|
133
|
+
XMLDOC.Parser.eat = function(parentNode, src)
|
134
|
+
{
|
135
|
+
// A simple tag def
|
136
|
+
var reTag = new RegExp("<(!|)(\\?|--|)((.|\\s)*?)\\2>","g");
|
137
|
+
|
138
|
+
// Special tag types
|
139
|
+
var reCommentTag = /<!--((.|\s)*?)-->/;
|
140
|
+
var rePITag = /<\?((.|\s)*?)\?>/;
|
141
|
+
|
142
|
+
// A start tag (with potential empty marker)
|
143
|
+
var reStartTag = /<(.*?)( +([\w_\-]*)=(\"|')(.*)\4)*(\/)?>/;
|
144
|
+
|
145
|
+
// An empty HTML style tag (not proper XML, but we'll accept it so we can process HTML)
|
146
|
+
var reHTMLEmptyTag = /<(.*?)( +([\w_\-]*)=(\"|')(.*)\4)*>/;
|
147
|
+
|
148
|
+
// Fully enclosing tag with nested tags
|
149
|
+
var reEnclosingTag = /<(.*?)( +([\w_\-]*)=(\"|')(.*?)\4)*>((.|\s)*?)<\/\1>/;
|
150
|
+
|
151
|
+
// Breaks down attributes
|
152
|
+
var reAttributes = new RegExp(" +([\\w_\\-]*)=(\"|')(.*?)\\2","g");
|
153
|
+
|
154
|
+
// Find us a tag
|
155
|
+
var tag;
|
156
|
+
while ((tag = reTag.exec(src)) != null)
|
157
|
+
{
|
158
|
+
if (tag.index > 0)
|
159
|
+
{
|
160
|
+
// The next tag has some text before it
|
161
|
+
var text = src.substring(0, tag.index).replace(/^[ \t\n]+((.|\n)*?)[ \t\n]+$/, "$1");
|
162
|
+
|
163
|
+
if (text.length > 0 && (text != "\n"))
|
164
|
+
{
|
165
|
+
var txtnode = new XMLDOC.Parser.node(parentNode, "", "TEXT");
|
166
|
+
txtnode.charData = text;
|
167
|
+
|
168
|
+
// Append the new text node
|
169
|
+
parentNode.nodes.push(txtnode);
|
170
|
+
}
|
171
|
+
|
172
|
+
// Reset the lastIndex of reTag
|
173
|
+
reTag.lastIndex -= src.substring(0, tag.index).length;
|
174
|
+
|
175
|
+
// Eat the text
|
176
|
+
src = src.substring(tag.index);
|
177
|
+
}
|
178
|
+
|
179
|
+
if (reCommentTag.test(tag[0]))
|
180
|
+
{
|
181
|
+
// Is this a comment?
|
182
|
+
var comment = new XMLDOC.Parser.node(parentNode, "", "COMMENT");
|
183
|
+
comment.charData = reCommentTag.exec(tag[0])[1];
|
184
|
+
|
185
|
+
// Append the comment
|
186
|
+
parentNode.nodes.push(comment);
|
187
|
+
|
188
|
+
// Move the lastIndex of reTag
|
189
|
+
reTag.lastIndex -= tag[0].length;
|
190
|
+
|
191
|
+
// Eat the tag
|
192
|
+
src = src.replace(reCommentTag, "");
|
193
|
+
}
|
194
|
+
else if (rePITag.test(tag[0]))
|
195
|
+
{
|
196
|
+
// Is this a processing instruction?
|
197
|
+
var pi = new XMLDOC.Parser.node(parentNode, "", "PI");
|
198
|
+
pi.charData = rePITag.exec(tag[0])[1];
|
199
|
+
|
200
|
+
// Append the processing instruction
|
201
|
+
parentNode.nodes.push(pi);
|
202
|
+
|
203
|
+
// Move the lastIndex of reTag
|
204
|
+
reTag.lastIndex -= tag[0].length;
|
205
|
+
|
206
|
+
// Eat the tag
|
207
|
+
src = src.replace(rePITag, "");
|
208
|
+
}
|
209
|
+
else if (reStartTag.test(tag[0]))
|
210
|
+
{
|
211
|
+
// Break it down
|
212
|
+
var e = reStartTag.exec(tag[0]);
|
213
|
+
var elem = new XMLDOC.Parser.node(parentNode, e[1], "ELEMENT");
|
214
|
+
|
215
|
+
// Get attributes from the tag
|
216
|
+
var a;
|
217
|
+
while ((a = reAttributes.exec(e[2])) != null )
|
218
|
+
{
|
219
|
+
elem.attrs[a[1]] = a[3];
|
220
|
+
}
|
221
|
+
|
222
|
+
// Is this an empty XML-style tag?
|
223
|
+
if (e[6] == "/")
|
224
|
+
{
|
225
|
+
// Append the empty element
|
226
|
+
parentNode.nodes.push(elem);
|
227
|
+
|
228
|
+
// Move the lastIndex of reTag (include the start tag length)
|
229
|
+
reTag.lastIndex -= e[0].length;
|
230
|
+
|
231
|
+
// Eat the tag
|
232
|
+
src = src.replace(reStartTag, "");
|
233
|
+
}
|
234
|
+
else
|
235
|
+
{
|
236
|
+
// Check for malformed XML tags
|
237
|
+
var htmlParsed = false;
|
238
|
+
var htmlStartTag = reHTMLEmptyTag.exec(src);
|
239
|
+
|
240
|
+
// See if there isn't an end tag within this block
|
241
|
+
var reHTMLEndTag = new RegExp("</" + htmlStartTag[1] + ">");
|
242
|
+
var htmlEndTag = reHTMLEndTag.exec(src);
|
243
|
+
|
244
|
+
if (XMLDOC.Parser.strictMode && htmlEndTag == null)
|
245
|
+
{
|
246
|
+
// Poorly formed XML fails in strict mode
|
247
|
+
var err = new Error("Malformed XML passed to XMLDOC.Parser... Error contains malformed 'src'");
|
248
|
+
err.src = src;
|
249
|
+
throw err;
|
250
|
+
}
|
251
|
+
else if (htmlEndTag == null)
|
252
|
+
{
|
253
|
+
// This is an HTML-style empty tag, store the element for it in non-strict mode
|
254
|
+
parentNode.nodes.push(elem);
|
255
|
+
|
256
|
+
// Eat the tag
|
257
|
+
src = src.replace(reHTMLEmptyTag, "");
|
258
|
+
htmlParsed = true;
|
259
|
+
}
|
260
|
+
|
261
|
+
// If we didn't parse HTML-style, it must be an enclosing tag
|
262
|
+
if (!htmlParsed)
|
263
|
+
{
|
264
|
+
var enc = reEnclosingTag.exec(src);
|
265
|
+
|
266
|
+
// Go deeper into the document
|
267
|
+
XMLDOC.Parser.eat(elem, enc[6]);
|
268
|
+
|
269
|
+
// Append the new element node
|
270
|
+
parentNode.nodes.push(elem);
|
271
|
+
|
272
|
+
// Eat the tag
|
273
|
+
src = src.replace(reEnclosingTag, "");
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
// Reset the lastIndex of reTag
|
278
|
+
reTag.lastIndex = 0;
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
// No tag was found... append the text if there is any
|
283
|
+
src = src.replace(/^[ \t\n]+((.|\n)*?)[ \t\n]+$/, "$1");
|
284
|
+
if (src.length > 0 && (src != "\n"))
|
285
|
+
{
|
286
|
+
var txtNode = new XMLDOC.Parser.node(parentNode, "", "TEXT");
|
287
|
+
txtNode.charData = src;
|
288
|
+
|
289
|
+
// Append the new text node
|
290
|
+
parentNode.nodes.push(txtNode);
|
291
|
+
}
|
292
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/**
|
2
|
+
* This is the main container for the XMLDOC handler.
|
3
|
+
* @namespace
|
4
|
+
* @author Brett Fattori (bfattori@fry.com)
|
5
|
+
* @version $Revision: 498 $
|
6
|
+
*/
|
7
|
+
XMLDOC = {
|
8
|
+
|
9
|
+
};
|
10
|
+
|
11
|
+
/** The current version string of this application. */
|
12
|
+
XMLDOC.VERSION = "1.0";
|
13
|
+
|
14
|
+
/** Include the library necessary to handle XML files */
|
15
|
+
IO.includeDir("handlers/XMLDOC/");
|
16
|
+
|
17
|
+
/**
|
18
|
+
* @type Symbol[]
|
19
|
+
*/
|
20
|
+
XMLDOC.handle = function(srcFile, src) {
|
21
|
+
|
22
|
+
};
|
23
|
+
|
24
|
+
XMLDOC.publish = function(symbolgroup) {
|
25
|
+
|
26
|
+
}
|