xultestrunner 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. data/.gitignore +2 -0
  2. data/.gitmodules +3 -0
  3. data/LICENSE +21 -0
  4. data/README +17 -0
  5. data/Rakefile +50 -0
  6. data/VERSION +1 -0
  7. data/bin/xultest +13 -0
  8. data/lib/xultestrunner.rb +1 -0
  9. data/xulapp/application.ini +9 -0
  10. data/xulapp/chrome/chrome.manifest +2 -0
  11. data/xulapp/chrome/content/interface/boot.xul +20 -0
  12. data/xulapp/chrome/content/interface/testharness.html +30 -0
  13. data/xulapp/chrome/content/lib/xultestcase.js +140 -0
  14. data/xulapp/chrome/content/lib/xultestrunner.js +120 -0
  15. data/xulapp/chrome/content/vendor/prototype/LICENSE +16 -0
  16. data/xulapp/chrome/content/vendor/prototype/prototype.js +4874 -0
  17. data/xulapp/chrome/content/vendor/scriptaculous/LICENSE +20 -0
  18. data/xulapp/chrome/content/vendor/scriptaculous/test.css +90 -0
  19. data/xulapp/chrome/content/vendor/scriptaculous/unittest.js +566 -0
  20. data/xulapp/chrome/content/vendor/xpcomcore/LICENSE +21 -0
  21. data/xulapp/chrome/content/vendor/xpcomcore/README +27 -0
  22. data/xulapp/chrome/content/vendor/xpcomcore/Rakefile +83 -0
  23. data/xulapp/chrome/content/vendor/xpcomcore/VERSION.yml +5 -0
  24. data/xulapp/chrome/content/vendor/xpcomcore/bootstrapper.js +32 -0
  25. data/xulapp/chrome/content/vendor/xpcomcore/components/XPCOMCore.js +120 -0
  26. data/xulapp/chrome/content/vendor/xpcomcore/doc/files.html +241 -0
  27. data/xulapp/chrome/content/vendor/xpcomcore/doc/index.html +243 -0
  28. data/xulapp/chrome/content/vendor/xpcomcore/doc/symbols/Error.html +256 -0
  29. data/xulapp/chrome/content/vendor/xpcomcore/doc/symbols/Kernel.html +1030 -0
  30. data/xulapp/chrome/content/vendor/xpcomcore/doc/symbols/LoadError.html +319 -0
  31. data/xulapp/chrome/content/vendor/xpcomcore/doc/symbols/SelfConceptError.html +319 -0
  32. data/xulapp/chrome/content/vendor/xpcomcore/doc/symbols/_global_.html +316 -0
  33. data/xulapp/chrome/content/vendor/xpcomcore/doc/symbols/src/lib_file.js.html +53 -0
  34. data/xulapp/chrome/content/vendor/xpcomcore/doc/symbols/src/lib_kernel.js.html +251 -0
  35. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/README.txt +186 -0
  36. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/frame.js +33 -0
  37. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/frame/Chain.js +102 -0
  38. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/frame/Dumper.js +144 -0
  39. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/frame/Hash.js +84 -0
  40. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/frame/Link.js +153 -0
  41. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/frame/Namespace.js +10 -0
  42. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/frame/Opt.js +134 -0
  43. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/frame/Reflection.js +26 -0
  44. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/frame/String.js +93 -0
  45. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/frame/Testrun.js +129 -0
  46. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/handlers/FOODOC.js +26 -0
  47. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC.js +26 -0
  48. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js +159 -0
  49. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js +16 -0
  50. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js +292 -0
  51. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC.js +104 -0
  52. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +200 -0
  53. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +294 -0
  54. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +126 -0
  55. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +109 -0
  56. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Lang.js +144 -0
  57. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Parser.js +145 -0
  58. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +33 -0
  59. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +645 -0
  60. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +241 -0
  61. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +41 -0
  62. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Token.js +18 -0
  63. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +332 -0
  64. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +133 -0
  65. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Util.js +32 -0
  66. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Walker.js +474 -0
  67. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/main.js +111 -0
  68. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/plugins/commentSrcJson.js +20 -0
  69. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/plugins/frameworkPrototype.js +16 -0
  70. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/plugins/functionCall.js +10 -0
  71. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/plugins/publishSrcHilite.js +62 -0
  72. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/plugins/symbolLink.js +10 -0
  73. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/plugins/tagParamConfig.js +31 -0
  74. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/plugins/tagSynonyms.js +43 -0
  75. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/run.js +348 -0
  76. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/t/TestDoc.js +144 -0
  77. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/t/runner.js +13 -0
  78. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test.js +325 -0
  79. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/addon.js +24 -0
  80. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/anon_inner.js +14 -0
  81. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/augments.js +31 -0
  82. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/augments2.js +26 -0
  83. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/borrows.js +46 -0
  84. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/borrows2.js +23 -0
  85. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/config.js +22 -0
  86. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/constructs.js +18 -0
  87. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/encoding.js +10 -0
  88. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/encoding_other.js +12 -0
  89. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/event.js +54 -0
  90. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/exports.js +14 -0
  91. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/functions_anon.js +39 -0
  92. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/functions_nested.js +33 -0
  93. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/global.js +13 -0
  94. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/globals.js +25 -0
  95. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/ignore.js +10 -0
  96. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/inner.js +16 -0
  97. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/jsdoc_test.js +477 -0
  98. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/lend.js +33 -0
  99. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/memberof.js +19 -0
  100. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/memberof_constructor.js +17 -0
  101. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/module.js +17 -0
  102. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/name.js +19 -0
  103. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/namespace_nested.js +23 -0
  104. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/nocode.js +13 -0
  105. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/oblit_anon.js +20 -0
  106. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/overview.js +20 -0
  107. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/param_inline.js +37 -0
  108. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/params_optional.js +8 -0
  109. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/prototype.js +17 -0
  110. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_nested.js +9 -0
  111. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_oblit.js +13 -0
  112. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +24 -0
  113. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/public.js +10 -0
  114. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/scripts/code.js +5 -0
  115. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/scripts/notcode.txt +5 -0
  116. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/shared.js +42 -0
  117. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/shared2.js +2 -0
  118. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/shortcuts.js +22 -0
  119. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/static_this.js +13 -0
  120. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/synonyms.js +31 -0
  121. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/tosource.js +23 -0
  122. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/app/test/variable_redefine.js +14 -0
  123. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/changes.txt +96 -0
  124. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/conf/sample.conf +31 -0
  125. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/java/build.xml +36 -0
  126. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/java/build_1.4.xml +36 -0
  127. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/java/classes/js.jar +0 -0
  128. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/java/src/JsDebugRun.java +21 -0
  129. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/java/src/JsRun.java +21 -0
  130. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/jsdebug.jar +0 -0
  131. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/jsrun.jar +0 -0
  132. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/jsrun.sh +52 -0
  133. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +17 -0
  134. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +56 -0
  135. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/class.tmpl +646 -0
  136. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/index.tmpl +39 -0
  137. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/publish.js +200 -0
  138. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/default.css +162 -0
  139. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/header.html +2 -0
  140. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/index.html +19 -0
  141. data/xulapp/chrome/content/vendor/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +35 -0
  142. data/xulapp/chrome/content/vendor/xpcomcore/lib/file.js +46 -0
  143. data/xulapp/chrome/content/vendor/xpcomcore/lib/kernel.js +244 -0
  144. data/xulapp/chrome/content/vendor/xpcomcore/test/file_test.js +16 -0
  145. data/xulapp/chrome/content/vendor/xpcomcore/test/fixtures/love.js +1 -0
  146. data/xulapp/chrome/content/vendor/xpcomcore/test/fixtures/mad_love.js +1 -0
  147. data/xulapp/chrome/content/vendor/xpcomcore/test/fixtures/mad_world.js +1 -0
  148. data/xulapp/chrome/content/vendor/xpcomcore/test/fixtures/syntax_error.js +1 -0
  149. data/xulapp/chrome/content/vendor/xpcomcore/test/kernel_test.js +88 -0
  150. data/xulapp/components/bootstrap.js +93 -0
  151. data/xulapp/defaults/preferences/prefs.js +14 -0
  152. data/xultestrunner.gemspec +190 -0
  153. metadata +207 -0
@@ -0,0 +1,126 @@
1
+ /**
2
+ @constructor
3
+ @param [opt] Used to override the commandline options. Useful for testing.
4
+ @version $Id: JsDoc.js 773 2009-01-24 09:42:04Z micmath $
5
+ */
6
+ JSDOC.JsDoc = function(/**object*/ opt) {
7
+ if (opt) {
8
+ JSDOC.opt = opt;
9
+ }
10
+
11
+ if (JSDOC.opt.h) {
12
+ JSDOC.usage();
13
+ quit();
14
+ }
15
+
16
+ // defend against options that are not sane
17
+ if (JSDOC.opt._.length == 0) {
18
+ LOG.warn("No source files to work on. Nothing to do.");
19
+ quit();
20
+ }
21
+ if (JSDOC.opt.t === true || JSDOC.opt.d === true) {
22
+ JSDOC.usage();
23
+ }
24
+
25
+ if (typeof JSDOC.opt.d == "string") {
26
+ if (!JSDOC.opt.d.charAt(JSDOC.opt.d.length-1).match(/[\\\/]/)) {
27
+ JSDOC.opt.d = JSDOC.opt.d+"/";
28
+ }
29
+ LOG.inform("Output directory set to '"+JSDOC.opt.d+"'.");
30
+ IO.mkPath(JSDOC.opt.d);
31
+ }
32
+ if (JSDOC.opt.e) IO.setEncoding(JSDOC.opt.e);
33
+
34
+ // the -r option: scan source directories recursively
35
+ if (typeof JSDOC.opt.r == "boolean") JSDOC.opt.r = 10;
36
+ else if (!isNaN(parseInt(JSDOC.opt.r))) JSDOC.opt.r = parseInt(JSDOC.opt.r);
37
+ else JSDOC.opt.r = 1;
38
+
39
+ // the -D option: define user variables
40
+ var D = {};
41
+ if (JSDOC.opt.D) {
42
+ for (var i = 0; i < JSDOC.opt.D.length; i++) {
43
+ var defineParts = JSDOC.opt.D[i].split(":", 2);
44
+ if (defineParts) D[defineParts[0]] = defineParts[1];
45
+ }
46
+ }
47
+ JSDOC.opt.D = D;
48
+ // combine any conf file D options with the commandline D options
49
+ if (defined(JSDOC.conf)) for (var c in JSDOC.conf.D) {
50
+ if (!defined(JSDOC.opt.D[c])) {
51
+ JSDOC.opt.D[c] = JSDOC.conf.D[c];
52
+ }
53
+ }
54
+
55
+ // Give plugins a chance to initialize
56
+ if (defined(JSDOC.PluginManager)) {
57
+ JSDOC.PluginManager.run("onInit", JSDOC.opt);
58
+ }
59
+
60
+ JSDOC.opt.srcFiles = JSDOC.JsDoc._getSrcFiles();
61
+ JSDOC.JsDoc._parseSrcFiles();
62
+ JSDOC.JsDoc.symbolSet = JSDOC.Parser.symbols;
63
+ }
64
+
65
+ /**
66
+ Retrieve source file list.
67
+ @returns {String[]} The pathnames of the files to be parsed.
68
+ */
69
+ JSDOC.JsDoc._getSrcFiles = function() {
70
+ JSDOC.JsDoc.srcFiles = [];
71
+
72
+ var ext = ["js"];
73
+ if (JSDOC.opt.x) {
74
+ ext = JSDOC.opt.x.split(",").map(function($) {return $.toLowerCase()});
75
+ }
76
+
77
+ for (var i = 0; i < JSDOC.opt._.length; i++) {
78
+ JSDOC.JsDoc.srcFiles = JSDOC.JsDoc.srcFiles.concat(
79
+ IO.ls(JSDOC.opt._[i], JSDOC.opt.r).filter(
80
+ function($) {
81
+ var thisExt = $.split(".").pop().toLowerCase();
82
+
83
+ if (JSDOC.opt.E) {
84
+ for(var n = 0; n < JSDOC.opt.E.length; n++) {
85
+ if ($.match(new RegExp(JSDOC.opt.E[n]))) {
86
+ LOG.inform("Excluding " + $);
87
+ return false; // if the file matches the regex then it's excluded.
88
+ }
89
+ }
90
+ }
91
+
92
+ return (ext.indexOf(thisExt) > -1); // we're only interested in files with certain extensions
93
+ }
94
+ )
95
+ );
96
+ }
97
+
98
+ return JSDOC.JsDoc.srcFiles;
99
+ }
100
+
101
+ JSDOC.JsDoc._parseSrcFiles = function() {
102
+ JSDOC.Parser.init();
103
+ for (var i = 0, l = JSDOC.JsDoc.srcFiles.length; i < l; i++) {
104
+ var srcFile = JSDOC.JsDoc.srcFiles[i];
105
+
106
+ if (JSDOC.opt.v) LOG.inform("Parsing file: " + srcFile);
107
+
108
+ try {
109
+ var src = IO.readFile(srcFile);
110
+ }
111
+ catch(e) {
112
+ LOG.warn("Can't read source file '"+srcFile+"': "+e.message);
113
+ }
114
+
115
+ var tr = new JSDOC.TokenReader();
116
+ var ts = new JSDOC.TokenStream(tr.tokenize(new JSDOC.TextStream(src)));
117
+
118
+ JSDOC.Parser.parse(ts, srcFile);
119
+
120
+ }
121
+ JSDOC.Parser.finish();
122
+
123
+ if (JSDOC.PluginManager) {
124
+ JSDOC.PluginManager.run("onFinishedParsing", JSDOC.Parser.symbols);
125
+ }
126
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ @constructor
3
+ */
4
+ JSDOC.JsPlate = function(templateFile) {
5
+ if (templateFile) this.template = IO.readFile(templateFile);
6
+
7
+ this.templateFile = templateFile;
8
+ this.code = "";
9
+ this.parse();
10
+ }
11
+
12
+ JSDOC.JsPlate.prototype.parse = function() {
13
+ this.template = this.template.replace(/\{#[\s\S]+?#\}/gi, "");
14
+ this.code = "var output=``"+this.template;
15
+
16
+ this.code = this.code.replace(
17
+ /<for +each="(.+?)" +in="(.+?)" *>/gi,
18
+ function (match, eachName, inName) {
19
+ return "``;\rvar $"+eachName+"_keys = keys("+inName+");\rfor(var $"+eachName+"_i = 0; $"+eachName+"_i < $"+eachName+"_keys.length; $"+eachName+"_i++) {\rvar $"+eachName+"_last = ($"+eachName+"_i == $"+eachName+"_keys.length-1);\rvar $"+eachName+"_key = $"+eachName+"_keys[$"+eachName+"_i];\rvar "+eachName+" = "+inName+"[$"+eachName+"_key];\routput+=``";
20
+ }
21
+ );
22
+ this.code = this.code.replace(/<if test="(.+?)">/g, "``;\rif ($1) { output+=``");
23
+ this.code = this.code.replace(/<elseif test="(.+?)"\s*\/>/g, "``;}\relse if ($1) { output+=``");
24
+ this.code = this.code.replace(/<else\s*\/>/g, "``;}\relse { output+=``");
25
+ this.code = this.code.replace(/<\/(if|for)>/g, "``;\r};\routput+=``");
26
+ this.code = this.code.replace(
27
+ /\{\+\s*([\s\S]+?)\s*\+\}/gi,
28
+ function (match, code) {
29
+ code = code.replace(/"/g, "``"); // prevent qoute-escaping of inline code
30
+ code = code.replace(/(\r?\n)/g, " ");
31
+ return "``+ ("+code+") +``";
32
+ }
33
+ );
34
+ this.code = this.code.replace(
35
+ /\{!\s*([\s\S]+?)\s*!\}/gi,
36
+ function (match, code) {
37
+ code = code.replace(/"/g, "``"); // prevent qoute-escaping of inline code
38
+ code = code.replace(/(\n)/g, " ");
39
+ return "``; "+code+";\routput+=``";
40
+ }
41
+ );
42
+ this.code = this.code+"``;";
43
+
44
+ this.code = this.code.replace(/(\r?\n)/g, "\\n");
45
+ this.code = this.code.replace(/"/g, "\\\"");
46
+ this.code = this.code.replace(/``/g, "\"");
47
+ }
48
+
49
+ JSDOC.JsPlate.prototype.toCode = function() {
50
+ return this.code;
51
+ }
52
+
53
+ JSDOC.JsPlate.keys = function(obj) {
54
+ var keys = [];
55
+ if (obj.constructor.toString().indexOf("Array") > -1) {
56
+ for (var i = 0; i < obj.length; i++) {
57
+ keys.push(i);
58
+ }
59
+ }
60
+ else {
61
+ for (var i in obj) {
62
+ keys.push(i);
63
+ }
64
+ }
65
+ return keys;
66
+ };
67
+
68
+ JSDOC.JsPlate.values = function(obj) {
69
+ var values = [];
70
+ if (obj.constructor.toString().indexOf("Array") > -1) {
71
+ for (var i = 0; i < obj.length; i++) {
72
+ values.push(obj[i]);
73
+ }
74
+ }
75
+ else {
76
+ for (var i in obj) {
77
+ values.push(obj[i]);
78
+ }
79
+ }
80
+ return values;
81
+ };
82
+
83
+ JSDOC.JsPlate.prototype.process = function(data, compact) {
84
+ var keys = JSDOC.JsPlate.keys;
85
+ var values = JSDOC.JsPlate.values;
86
+
87
+ try {
88
+ eval(this.code);
89
+ }
90
+ catch (e) {
91
+ print(">> There was an error evaluating the compiled code from template: "+this.templateFile);
92
+ print(" The error was on line "+e.lineNumber+" "+e.name+": "+e.message);
93
+ var lines = this.code.split("\r");
94
+ if (e.lineNumber-2 >= 0) print("line "+(e.lineNumber-1)+": "+lines[e.lineNumber-2]);
95
+ print("line "+e.lineNumber+": "+lines[e.lineNumber-1]);
96
+ print("");
97
+ }
98
+
99
+ if (compact) { // patch by mcbain.asm
100
+ // Remove lines that contain only space-characters, usually left by lines in the template
101
+ // which originally only contained JSPlate tags or code. This makes it easier to write
102
+ // non-tricky templates which still put out nice code (not bloated with extra lines).
103
+ // Lines purposely left blank (just a line ending) are left alone.
104
+ output = output.replace(/\s+?(\r?)\n/g, "$1\n");
105
+ }
106
+
107
+ /*debug*///print(this.code);
108
+ return output;
109
+ }
@@ -0,0 +1,144 @@
1
+ /**
2
+ @namespace
3
+ */
4
+ JSDOC.Lang = {
5
+ }
6
+
7
+ JSDOC.Lang.isBuiltin = function(name) {
8
+ return (JSDOC.Lang.isBuiltin.coreObjects.indexOf(name) > -1);
9
+ }
10
+ JSDOC.Lang.isBuiltin.coreObjects = ['_global_', 'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math', 'Number', 'Object', 'RegExp', 'String'];
11
+
12
+ JSDOC.Lang.whitespace = function(ch) {
13
+ return JSDOC.Lang.whitespace.names[ch];
14
+ }
15
+ JSDOC.Lang.whitespace.names = {
16
+ " ": "SPACE",
17
+ "\f": "FORMFEED",
18
+ "\t": "TAB",
19
+ "\u0009": "UNICODE_TAB",
20
+ "\u000A": "UNICODE_NBR",
21
+ "\u0008": "VERTICAL_TAB"
22
+ };
23
+
24
+ JSDOC.Lang.newline = function(ch) {
25
+ return JSDOC.Lang.newline.names[ch];
26
+ }
27
+ JSDOC.Lang.newline.names = {
28
+ "\n": "NEWLINE",
29
+ "\r": "RETURN",
30
+ "\u000A": "UNICODE_LF",
31
+ "\u000D": "UNICODE_CR",
32
+ "\u2029": "UNICODE_PS",
33
+ "\u2028": "UNICODE_LS"
34
+ };
35
+
36
+ JSDOC.Lang.keyword = function(word) {
37
+ return JSDOC.Lang.keyword.names["="+word];
38
+ }
39
+ JSDOC.Lang.keyword.names = {
40
+ "=break": "BREAK",
41
+ "=case": "CASE",
42
+ "=catch": "CATCH",
43
+ "=const": "VAR",
44
+ "=continue": "CONTINUE",
45
+ "=default": "DEFAULT",
46
+ "=delete": "DELETE",
47
+ "=do": "DO",
48
+ "=else": "ELSE",
49
+ "=false": "FALSE",
50
+ "=finally": "FINALLY",
51
+ "=for": "FOR",
52
+ "=function": "FUNCTION",
53
+ "=if": "IF",
54
+ "=in": "IN",
55
+ "=instanceof": "INSTANCEOF",
56
+ "=new": "NEW",
57
+ "=null": "NULL",
58
+ "=return": "RETURN",
59
+ "=switch": "SWITCH",
60
+ "=this": "THIS",
61
+ "=throw": "THROW",
62
+ "=true": "TRUE",
63
+ "=try": "TRY",
64
+ "=typeof": "TYPEOF",
65
+ "=void": "VOID",
66
+ "=while": "WHILE",
67
+ "=with": "WITH",
68
+ "=var": "VAR"
69
+ };
70
+
71
+ JSDOC.Lang.punc = function(ch) {
72
+ return JSDOC.Lang.punc.names[ch];
73
+ }
74
+ JSDOC.Lang.punc.names = {
75
+ ";": "SEMICOLON",
76
+ ",": "COMMA",
77
+ "?": "HOOK",
78
+ ":": "COLON",
79
+ "||": "OR",
80
+ "&&": "AND",
81
+ "|": "BITWISE_OR",
82
+ "^": "BITWISE_XOR",
83
+ "&": "BITWISE_AND",
84
+ "===": "STRICT_EQ",
85
+ "==": "EQ",
86
+ "=": "ASSIGN",
87
+ "!==": "STRICT_NE",
88
+ "!=": "NE",
89
+ "<<": "LSH",
90
+ "<=": "LE",
91
+ "<": "LT",
92
+ ">>>": "URSH",
93
+ ">>": "RSH",
94
+ ">=": "GE",
95
+ ">": "GT",
96
+ "++": "INCREMENT",
97
+ "--": "DECREMENT",
98
+ "+": "PLUS",
99
+ "-": "MINUS",
100
+ "*": "MUL",
101
+ "/": "DIV",
102
+ "%": "MOD",
103
+ "!": "NOT",
104
+ "~": "BITWISE_NOT",
105
+ ".": "DOT",
106
+ "[": "LEFT_BRACKET",
107
+ "]": "RIGHT_BRACKET",
108
+ "{": "LEFT_CURLY",
109
+ "}": "RIGHT_CURLY",
110
+ "(": "LEFT_PAREN",
111
+ ")": "RIGHT_PAREN"
112
+ };
113
+
114
+ JSDOC.Lang.matching = function(name) {
115
+ return JSDOC.Lang.matching.names[name];
116
+ }
117
+ JSDOC.Lang.matching.names = {
118
+ "LEFT_PAREN": "RIGHT_PAREN",
119
+ "RIGHT_PAREN": "LEFT_PAREN",
120
+ "LEFT_CURLY": "RIGHT_CURLY",
121
+ "RIGHT_CURLY": "LEFT_CURLY",
122
+ "LEFT_BRACE": "RIGHT_BRACE",
123
+ "RIGHT_BRACE": "LEFT_BRACE"
124
+ }
125
+
126
+ JSDOC.Lang.isNumber = function(str) {
127
+ return /^(\.[0-9]|[0-9]+\.|[0-9])[0-9]*([eE][+-][0-9]+)?$/i.test(str);
128
+ }
129
+
130
+ JSDOC.Lang.isHexDec = function(str) {
131
+ return /^0x[0-9A-F]+$/i.test(str);
132
+ }
133
+
134
+ JSDOC.Lang.isWordChar = function(str) {
135
+ return /^[a-zA-Z0-9$_.]+$/.test(str);
136
+ }
137
+
138
+ JSDOC.Lang.isSpace = function(str) {
139
+ return (typeof JSDOC.Lang.whitespace(str) != "undefined");
140
+ }
141
+
142
+ JSDOC.Lang.isNewline = function(str) {
143
+ return (typeof JSDOC.Lang.newline(str) != "undefined");
144
+ }
@@ -0,0 +1,145 @@
1
+ if (typeof JSDOC == "undefined") JSDOC = {};
2
+
3
+ /**
4
+ @namespace
5
+ @requires JSDOC.Walker
6
+ @requires JSDOC.Symbol
7
+ @requires JSDOC.DocComment
8
+ */
9
+ JSDOC.Parser = {
10
+ conf: {
11
+ ignoreCode: JSDOC.opt.n,
12
+ ignoreAnonymous: true, // factory: true
13
+ treatUnderscoredAsPrivate: true, // factory: true
14
+ explain: false // factory: false
15
+ },
16
+
17
+ addSymbol: function(symbol) {
18
+
19
+ if (JSDOC.Parser.rename) {
20
+ for (var n in JSDOC.Parser.rename) {
21
+ if (symbol.alias.indexOf(n) == 0) {
22
+ if (symbol.name == symbol.alias) {
23
+ symbol.name = symbol.name.replace(n, JSDOC.Parser.rename[n]);
24
+ }
25
+ symbol.alias = symbol.alias.replace(n, JSDOC.Parser.rename[n]);
26
+ }
27
+ }
28
+ }
29
+
30
+ if (JSDOC.opt.S) {
31
+ if (typeof JSDOC.Parser.secureModules == "undefined") JSDOC.Parser.secureModules = {};
32
+ if (/^exports\./.test(symbol.alias)) {
33
+ symbol.srcFile.match(/(^|[\\\/])([^\\\/]+)\.js/i);
34
+ var fileNS = RegExp.$2;
35
+ symbol.alias = symbol.alias.replace(/^exports\./, fileNS);
36
+ symbol.name = symbol.name.replace(/^exports\./, "");
37
+ symbol.memberOf = fileNS;
38
+
39
+ // need to create the namespace associated with this file first
40
+ if (!JSDOC.Parser.secureModules[fileNS]) {
41
+ JSDOC.Parser.secureModules[fileNS] = 1;
42
+ var nsSymbol = new JSDOC.Symbol(fileNS, [], "GLOBAL", new JSDOC.DocComment(""));
43
+ nsSymbol.isNamespace = true;
44
+ nsSymbol.srcFile = "";
45
+ nsSymbol.isPrivate = false;
46
+ nsSymbol.srcFile = symbol.srcFile;
47
+ nsSymbol.desc = (JSDOC.Parser.symbols.getSymbol(symbol.srcFile) || {desc: ""}).desc;
48
+ JSDOC.Parser.addSymbol(nsSymbol);
49
+
50
+ }
51
+ }
52
+ else { // a method that is not exported?
53
+ if (!symbol.isNamespace) return;
54
+ }
55
+ }
56
+ // if a symbol alias is documented more than once the last one with the user docs wins
57
+ if (JSDOC.Parser.symbols.hasSymbol(symbol.alias)) {
58
+ var oldSymbol = JSDOC.Parser.symbols.getSymbol(symbol.alias);
59
+ if (oldSymbol.comment.isUserComment) {
60
+ if (symbol.comment.isUserComment) { // old and new are both documented
61
+ LOG.warn("The symbol '"+symbol.alias+"' is documented more than once.");
62
+ }
63
+ else { // old is documented but new isn't
64
+ return;
65
+ }
66
+ }
67
+ }
68
+
69
+ // we don't document anonymous things
70
+ if (JSDOC.Parser.conf.ignoreAnonymous && symbol.name.match(/\$anonymous\b/)) return;
71
+
72
+ // uderscored things may be treated as if they were marked private, this cascades
73
+ if (JSDOC.Parser.conf.treatUnderscoredAsPrivate && symbol.name.match(/[.#-]_[^.#-]+$/)) {
74
+ if (!symbol.comment.getTag("public").length > 0) symbol.isPrivate = true;
75
+ }
76
+
77
+ // -p flag is required to document private things
78
+ if (!JSDOC.opt.p && symbol.isPrivate) return; // issue #161 fixed by mcbain.asm
79
+
80
+ // ignored things are not documented, this doesn't cascade
81
+ if (symbol.isIgnored) return;
82
+ JSDOC.Parser.symbols.addSymbol(symbol);
83
+ },
84
+
85
+ addBuiltin: function(name) {
86
+ var builtin = new JSDOC.Symbol(name, [], "CONSTRUCTOR", new JSDOC.DocComment(""));
87
+ builtin.isNamespace = true;
88
+ builtin.srcFile = "";
89
+ builtin.isPrivate = false;
90
+ JSDOC.Parser.addSymbol(builtin);
91
+ return builtin;
92
+ },
93
+
94
+ init: function() {
95
+ JSDOC.Parser.symbols = new JSDOC.SymbolSet();
96
+ JSDOC.Parser.walker = new JSDOC.Walker();
97
+ },
98
+
99
+ finish: function() {
100
+ JSDOC.Parser.symbols.relate();
101
+
102
+ // make a litle report about what was found
103
+ if (JSDOC.Parser.conf.explain) {
104
+ var symbols = JSDOC.Parser.symbols.toArray();
105
+ var srcFile = "";
106
+ for (var i = 0, l = symbols.length; i < l; i++) {
107
+ var symbol = symbols[i];
108
+ if (srcFile != symbol.srcFile) {
109
+ srcFile = symbol.srcFile;
110
+ print("\n"+srcFile+"\n-------------------");
111
+ }
112
+ print(i+":\n alias => "+symbol.alias + "\n name => "+symbol.name+ "\n isa => "+symbol.isa + "\n memberOf => " + symbol.memberOf + "\n isStatic => " + symbol.isStatic + ", isInner => " + symbol.isInner+ ", isPrivate => " + symbol.isPrivate);
113
+ }
114
+ print("-------------------\n");
115
+ }
116
+ }
117
+ }
118
+
119
+ JSDOC.Parser.parse = function(/**JSDOC.TokenStream*/ts, /**String*/srcFile) {
120
+ JSDOC.Symbol.srcFile = (srcFile || "");
121
+ JSDOC.DocComment.shared = ""; // shared comments don't cross file boundaries
122
+
123
+ if (!JSDOC.Parser.walker) JSDOC.Parser.init();
124
+ JSDOC.Parser.walker.walk(ts); // adds to our symbols
125
+
126
+ // filter symbols by option
127
+ for (var p = JSDOC.Parser.symbols._index.first(); p; p = JSDOC.Parser.symbols._index.next()) {
128
+ var symbol = p.value;
129
+
130
+ if (!symbol) continue;
131
+
132
+ if (symbol.is("FILE") || symbol.is("GLOBAL")) {
133
+ continue;
134
+ }
135
+ else if (!JSDOC.opt.a && !symbol.comment.isUserComment) {
136
+ JSDOC.Parser.symbols.deleteSymbol(symbol.alias);
137
+ }
138
+
139
+ if (/#$/.test(symbol.alias)) { // we don't document prototypes
140
+ JSDOC.Parser.symbols.deleteSymbol(symbol.alias);
141
+ }
142
+ }
143
+
144
+ return JSDOC.Parser.symbols.toArray();
145
+ }