sproutcore 0.9.13 → 0.9.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. data/History.txt +19 -0
  2. data/Manifest.txt +103 -26
  3. data/app_generators/sproutcore/templates/README +1 -1
  4. data/bin/sc-build +1 -1
  5. data/bin/sc-gen +0 -0
  6. data/bin/sc-ide +278 -0
  7. data/bin/sc-init +38 -0
  8. data/bin/sc-install +96 -0
  9. data/bin/sc-remove +94 -0
  10. data/bin/sc-server +4 -0
  11. data/bin/sc-update +94 -0
  12. data/bin/sproutcore +3 -14
  13. data/clients/sc_docs/controllers/docs.js +1 -1
  14. data/clients/sc_docs/models/doc.js +6 -0
  15. data/clients/sc_docs/views/doc_frame.js +1 -1
  16. data/clients/sc_test_runner/english.lproj/icons/small/next.png +0 -0
  17. data/clients/sc_test_runner/english.lproj/icons/small/reset.png +0 -0
  18. data/frameworks/sproutcore/HISTORY +34 -2
  19. data/frameworks/sproutcore/controllers/array.js +1 -1
  20. data/frameworks/sproutcore/controllers/controller.js +1 -1
  21. data/frameworks/sproutcore/controllers/object.js +9 -6
  22. data/frameworks/sproutcore/core.js +19 -4
  23. data/frameworks/sproutcore/english.lproj/blank.gif +0 -0
  24. data/frameworks/sproutcore/english.lproj/core.css +1 -0
  25. data/frameworks/sproutcore/english.lproj/menu.css +1 -0
  26. data/frameworks/sproutcore/foundation/application.js +3 -3
  27. data/frameworks/sproutcore/foundation/benchmark.js +1 -1
  28. data/frameworks/sproutcore/foundation/node_descriptor.js +13 -1
  29. data/frameworks/sproutcore/foundation/page.js +3 -2
  30. data/frameworks/sproutcore/foundation/path_module.js +33 -16
  31. data/frameworks/sproutcore/foundation/run_loop.js +1 -1
  32. data/frameworks/sproutcore/foundation/server.js +68 -18
  33. data/frameworks/sproutcore/foundation/string.js +1 -1
  34. data/frameworks/sproutcore/globals/window.js +62 -15
  35. data/frameworks/sproutcore/lib/core_views.rb +1 -0
  36. data/frameworks/sproutcore/lib/index.rhtml +4 -3
  37. data/frameworks/sproutcore/lib/menu_views.rb +2 -2
  38. data/frameworks/sproutcore/models/collection.js +122 -107
  39. data/frameworks/sproutcore/models/record.js +2 -2
  40. data/frameworks/sproutcore/panes/manager.js +1 -1
  41. data/frameworks/sproutcore/panes/overlay.js +3 -3
  42. data/frameworks/sproutcore/tests/controllers/object.rhtml +26 -0
  43. data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +2 -2
  44. data/frameworks/sproutcore/views/button/disclosure.js +1 -1
  45. data/frameworks/sproutcore/views/collection/collection.js +19 -15
  46. data/frameworks/sproutcore/views/collection/source_list.js +1 -1
  47. data/frameworks/sproutcore/views/collection/table.js +2 -2
  48. data/frameworks/sproutcore/views/error_explanation.js +1 -1
  49. data/frameworks/sproutcore/views/field/checkbox_field.js +1 -1
  50. data/frameworks/sproutcore/views/field/field.js +1 -1
  51. data/frameworks/sproutcore/views/field/radio_field.js +1 -1
  52. data/frameworks/sproutcore/views/field/select_field.js +1 -1
  53. data/frameworks/sproutcore/views/form.js +1 -1
  54. data/frameworks/sproutcore/views/image.js +1 -1
  55. data/frameworks/sproutcore/views/menu_item.js +1 -1
  56. data/frameworks/sproutcore/views/popup_button.js +1 -1
  57. data/frameworks/sproutcore/views/popup_menu.js +1 -1
  58. data/frameworks/sproutcore/views/progress.js +4 -2
  59. data/frameworks/sproutcore/views/radio_group.js +1 -1
  60. data/frameworks/sproutcore/views/scroll.js +1 -1
  61. data/frameworks/sproutcore/views/source_list_group.js +1 -1
  62. data/frameworks/sproutcore/views/split.js +1 -1
  63. data/frameworks/sproutcore/views/tab.js +3 -1
  64. data/frameworks/sproutcore/views/view.js +19 -3
  65. data/jsdoc/README.txt +89 -57
  66. data/jsdoc/app/frame/Chain.js +102 -0
  67. data/jsdoc/app/frame/Dumper.js +144 -0
  68. data/jsdoc/app/frame/Hash.js +47 -0
  69. data/jsdoc/app/frame/Link.js +142 -0
  70. data/jsdoc/app/frame/Namespace.js +10 -0
  71. data/jsdoc/app/frame/Opt.js +134 -0
  72. data/jsdoc/app/frame/Reflection.js +26 -0
  73. data/jsdoc/app/frame/String.js +93 -0
  74. data/jsdoc/app/frame/Testrun.js +129 -0
  75. data/jsdoc/app/frame.js +33 -0
  76. data/jsdoc/app/handlers/FOODOC.js +26 -0
  77. data/jsdoc/app/handlers/XMLDOC/DomReader.js +159 -0
  78. data/jsdoc/app/handlers/XMLDOC/XMLDoc.js +16 -0
  79. data/jsdoc/app/handlers/XMLDOC/XMLParse.js +292 -0
  80. data/jsdoc/app/handlers/XMLDOC.js +26 -0
  81. data/jsdoc/app/lib/JSDOC/DocComment.js +200 -0
  82. data/jsdoc/app/lib/JSDOC/DocTag.js +294 -0
  83. data/jsdoc/app/lib/JSDOC/JsDoc.js +180 -0
  84. data/jsdoc/app/lib/JSDOC/JsPlate.js +100 -0
  85. data/jsdoc/app/lib/JSDOC/Lang.js +144 -0
  86. data/jsdoc/app/lib/JSDOC/Parser.js +109 -0
  87. data/jsdoc/app/lib/JSDOC/PluginManager.js +33 -0
  88. data/jsdoc/app/lib/JSDOC/Symbol.js +600 -0
  89. data/jsdoc/app/lib/JSDOC/SymbolSet.js +220 -0
  90. data/jsdoc/app/lib/JSDOC/TextStream.js +41 -0
  91. data/jsdoc/app/lib/JSDOC/Token.js +18 -0
  92. data/jsdoc/app/lib/JSDOC/TokenReader.js +323 -0
  93. data/jsdoc/app/lib/JSDOC/TokenStream.js +133 -0
  94. data/jsdoc/app/lib/JSDOC/Util.js +32 -0
  95. data/jsdoc/app/lib/JSDOC/Walker.js +416 -0
  96. data/jsdoc/app/lib/JSDOC.js +97 -0
  97. data/jsdoc/app/main.js +74 -0
  98. data/jsdoc/app/plugins/commentSrcJson.js +19 -0
  99. data/jsdoc/app/plugins/frameworkPrototype.js +16 -0
  100. data/jsdoc/app/plugins/functionCall.js +10 -0
  101. data/jsdoc/app/plugins/publishSrcHilite.js +62 -0
  102. data/jsdoc/app/plugins/sproutcoreTags.js +26 -0
  103. data/jsdoc/app/plugins/symbolLink.js +9 -0
  104. data/jsdoc/app/plugins/tagParamConfig.js +31 -0
  105. data/jsdoc/app/plugins/tagSynonyms.js +43 -0
  106. data/jsdoc/app/run.js +339 -137
  107. data/jsdoc/changes.txt +47 -0
  108. data/jsdoc/conf/sample.conf +31 -0
  109. data/jsdoc/java/build.xml +36 -0
  110. data/jsdoc/java/build_1.4.xml +36 -0
  111. data/jsdoc/java/classes/js.jar +0 -0
  112. data/jsdoc/java/src/JsDebugRun.java +21 -0
  113. data/jsdoc/java/src/JsRun.java +21 -0
  114. data/jsdoc/jsdebug.jar +0 -0
  115. data/jsdoc/jsrun.jar +0 -0
  116. data/jsdoc/t/TestDoc.js +144 -0
  117. data/jsdoc/t/runner.js +13 -0
  118. data/jsdoc/templates/sproutcore/allclasses.tmpl +17 -0
  119. data/jsdoc/templates/sproutcore/allfiles.tmpl +56 -0
  120. data/jsdoc/templates/sproutcore/class.tmpl +408 -326
  121. data/jsdoc/templates/sproutcore/index.tmpl +30 -31
  122. data/jsdoc/templates/sproutcore/publish.js +173 -81
  123. data/jsdoc/templates/sproutcore/static/default.css +191 -0
  124. data/jsdoc/templates/sproutcore/static/header.html +2 -0
  125. data/jsdoc/templates/sproutcore/static/index.html +19 -0
  126. data/jsdoc/templates/sproutcore/symbol.tmpl +35 -0
  127. data/jsdoc/test/addon.js +24 -0
  128. data/jsdoc/test/anon_inner.js +14 -0
  129. data/jsdoc/test/augments.js +31 -0
  130. data/jsdoc/test/augments2.js +26 -0
  131. data/jsdoc/test/borrows.js +41 -0
  132. data/jsdoc/test/borrows2.js +23 -0
  133. data/jsdoc/test/config.js +22 -0
  134. data/jsdoc/test/constructs.js +18 -0
  135. data/jsdoc/test/encoding.js +10 -0
  136. data/jsdoc/test/encoding_other.js +12 -0
  137. data/jsdoc/test/functions_anon.js +39 -0
  138. data/jsdoc/test/functions_nested.js +33 -0
  139. data/jsdoc/test/global.js +13 -0
  140. data/jsdoc/test/globals.js +25 -0
  141. data/jsdoc/test/ignore.js +10 -0
  142. data/jsdoc/test/inner.js +16 -0
  143. data/jsdoc/test/jsdoc_test.js +477 -0
  144. data/jsdoc/test/lend.js +33 -0
  145. data/jsdoc/test/memberof.js +20 -0
  146. data/jsdoc/test/memberof_constructor.js +15 -0
  147. data/jsdoc/test/name.js +19 -0
  148. data/jsdoc/test/namespace_nested.js +23 -0
  149. data/jsdoc/test/nocode.js +13 -0
  150. data/jsdoc/test/oblit_anon.js +20 -0
  151. data/jsdoc/test/overview.js +20 -0
  152. data/jsdoc/test/param_inline.js +37 -0
  153. data/jsdoc/test/params_optional.js +8 -0
  154. data/jsdoc/test/prototype.js +17 -0
  155. data/jsdoc/test/prototype_nested.js +9 -0
  156. data/jsdoc/test/prototype_oblit.js +13 -0
  157. data/jsdoc/test/prototype_oblit_constructor.js +24 -0
  158. data/jsdoc/test/public.js +10 -0
  159. data/jsdoc/test/shared.js +42 -0
  160. data/jsdoc/test/shared2.js +2 -0
  161. data/jsdoc/test/shortcuts.js +22 -0
  162. data/jsdoc/test/static_this.js +13 -0
  163. data/jsdoc/test/synonyms.js +23 -0
  164. data/jsdoc/test/tosource.js +23 -0
  165. data/jsdoc/test/variable_redefine.js +14 -0
  166. data/jsdoc/test.js +304 -0
  167. data/lib/sproutcore/build_tools/resource_builder.rb +6 -1
  168. data/lib/sproutcore/bundle_installer.rb +268 -0
  169. data/lib/sproutcore/jsdoc.rb +7 -6
  170. data/lib/sproutcore/library.rb +38 -0
  171. data/lib/sproutcore/merb/bundle_controller.rb +8 -4
  172. data/lib/sproutcore/version.rb +1 -1
  173. data/lib/sproutcore.rb +1 -1
  174. data/script/destroy +0 -0
  175. data/script/generate +0 -0
  176. data/script/txt2html +0 -0
  177. metadata +117 -29
  178. data/clients/view_builder/core.js +0 -19
  179. data/clients/view_builder/english.lproj/body.css +0 -149
  180. data/clients/view_builder/english.lproj/body.rhtml +0 -18
  181. data/clients/view_builder/english.lproj/strings.js +0 -14
  182. data/clients/view_builder/main.js +0 -37
  183. data/jsdoc/app/DocFile.js +0 -137
  184. data/jsdoc/app/DocTag.js +0 -110
  185. data/jsdoc/app/Doclet.js +0 -63
  186. data/jsdoc/app/Dumper.js +0 -143
  187. data/jsdoc/app/JsDoc.js +0 -103
  188. data/jsdoc/app/JsHilite.js +0 -45
  189. data/jsdoc/app/JsIO.js +0 -163
  190. data/jsdoc/app/JsParse.js +0 -385
  191. data/jsdoc/app/JsPlate.js +0 -130
  192. data/jsdoc/app/JsTestrun.js +0 -129
  193. data/jsdoc/app/JsToke.js +0 -564
  194. data/jsdoc/app/Symbol.js +0 -298
  195. data/jsdoc/app/Transformer.js +0 -14
  196. data/jsdoc/app/Util.js +0 -97
  197. data/jsdoc/app/js.jar +0 -0
  198. data/jsdoc/plugins/min.js +0 -316
  199. data/jsdoc/plugins/strip.js +0 -20
  200. data/jsdoc/templates/sproutcore/default.css +0 -191
  201. data/jsdoc/templates/sproutcore/index.html +0 -13
  202. data/jsdoc/templates/sproutcore/prototype.js +0 -4186
  203. data/jsdoc/templates/sproutcore/splash.html +0 -7
@@ -0,0 +1,133 @@
1
+ if (typeof JSDOC == "undefined") JSDOC = {};
2
+
3
+ /**
4
+ @constructor
5
+ */
6
+ JSDOC.TokenStream = function(tokens) {
7
+ this.tokens = (tokens || []);
8
+ this.rewind();
9
+ }
10
+
11
+ /**
12
+ @constructor
13
+ @private
14
+ */
15
+ function VoidToken(/**String*/type) {
16
+ this.toString = function() {return "<VOID type=\""+type+"\">"};
17
+ this.is = function(){return false;}
18
+ }
19
+
20
+ JSDOC.TokenStream.prototype.rewind = function() {
21
+ this.cursor = -1;
22
+ }
23
+
24
+ /**
25
+ @type JSDOC.Token
26
+ */
27
+ JSDOC.TokenStream.prototype.look = function(/**Number*/n, /**Boolean*/considerWhitespace) {
28
+ if (typeof n == "undefined") n = 0;
29
+
30
+ if (considerWhitespace == true) {
31
+ if (this.cursor+n < 0 || this.cursor+n > this.tokens.length) return {};
32
+ return this.tokens[this.cursor+n];
33
+ }
34
+ else {
35
+ var count = 0;
36
+ var i = this.cursor;
37
+
38
+ while (true) {
39
+ if (i < 0) return new JSDOC.Token("", "VOID", "START_OF_STREAM");
40
+ else if (i > this.tokens.length) return new JSDOC.Token("", "VOID", "END_OF_STREAM");
41
+
42
+ if (i != this.cursor && (this.tokens[i] === undefined || this.tokens[i].is("SPACE") || this.tokens[i].is("NEWLINE"))) {
43
+ if (n < 0) i--; else i++;
44
+ continue;
45
+ }
46
+
47
+ if (count == Math.abs(n)) {
48
+ return this.tokens[i];
49
+ }
50
+ count++;
51
+ (n < 0)? i-- : i++;
52
+ }
53
+
54
+ return new JSDOC.Token("", "VOID", "STREAM_ERROR"); // because null isn't an object and caller always expects an object
55
+ }
56
+ }
57
+
58
+ /**
59
+ @type JSDOC.Token|JSDOC.Token[]
60
+ */
61
+ JSDOC.TokenStream.prototype.next = function(/**Number*/howMany) {
62
+ if (typeof howMany == "undefined") howMany = 1;
63
+ if (howMany < 1) return null;
64
+ var got = [];
65
+
66
+ for (var i = 1; i <= howMany; i++) {
67
+ if (this.cursor+i >= this.tokens.length) {
68
+ return null;
69
+ }
70
+ got.push(this.tokens[this.cursor+i]);
71
+ }
72
+ this.cursor += howMany;
73
+
74
+ if (howMany == 1) {
75
+ return got[0];
76
+ }
77
+ else return got;
78
+ }
79
+
80
+ /**
81
+ @type JSDOC.Token[]
82
+ */
83
+ JSDOC.TokenStream.prototype.balance = function(/**String*/start, /**String*/stop) {
84
+ if (!stop) stop = JSDOC.Lang.matching(start);
85
+
86
+ var depth = 0;
87
+ var got = [];
88
+ var started = false;
89
+
90
+ while ((token = this.look())) {
91
+ if (token.is(start)) {
92
+ depth++;
93
+ started = true;
94
+ }
95
+
96
+ if (started) {
97
+ got.push(token);
98
+ }
99
+
100
+ if (token.is(stop)) {
101
+ depth--;
102
+ if (depth == 0) return got;
103
+ }
104
+ if (!this.next()) break;
105
+ }
106
+ }
107
+
108
+ JSDOC.TokenStream.prototype.getMatchingToken = function(/**String*/start, /**String*/stop) {
109
+ var depth = 0;
110
+ var cursor = this.cursor;
111
+
112
+ if (!start) {
113
+ start = JSDOC.Lang.matching(stop);
114
+ depth = 1;
115
+ }
116
+ if (!stop) stop = JSDOC.Lang.matching(start);
117
+
118
+ while ((token = this.tokens[cursor])) {
119
+ if (token.is(start)) {
120
+ depth++;
121
+ }
122
+
123
+ if (token.is(stop) && cursor) {
124
+ depth--;
125
+ if (depth == 0) return this.tokens[cursor];
126
+ }
127
+ cursor++;
128
+ }
129
+ }
130
+
131
+ JSDOC.TokenStream.prototype.insertAhead = function(/**JSDOC.Token*/token) {
132
+ this.tokens.splice(this.cursor+1, 0, token);
133
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @namespace
3
+ * @deprecated Use {@link FilePath} instead.
4
+ */
5
+ JSDOC.Util = {
6
+ }
7
+
8
+ /**
9
+ * @deprecated Use {@link FilePath.fileName} instead.
10
+ */
11
+ JSDOC.Util.fileName = function(path) {
12
+ LOG.warn("JSDOC.Util.fileName is deprecated. Use FilePath.fileName instead.");
13
+ var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0);
14
+ return path.substring(nameStart);
15
+ }
16
+
17
+ /**
18
+ * @deprecated Use {@link FilePath.fileExtension} instead.
19
+ */
20
+ JSDOC.Util.fileExtension = function(filename) {
21
+ LOG.warn("JSDOC.Util.fileExtension is deprecated. Use FilePath.fileExtension instead.");
22
+ return filename.split(".").pop().toLowerCase();
23
+ };
24
+
25
+ /**
26
+ * @deprecated Use {@link FilePath.dir} instead.
27
+ */
28
+ JSDOC.Util.dir = function(path) {
29
+ LOG.warn("JSDOC.Util.dir is deprecated. Use FilePath.dir instead.");
30
+ var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0);
31
+ return path.substring(0, nameStart-1);
32
+ }
@@ -0,0 +1,416 @@
1
+ if (typeof JSDOC == "undefined") JSDOC = {};
2
+
3
+ /** @constructor */
4
+ JSDOC.Walker = function(/**JSDOC.TokenStream*/ts) {
5
+ this.init();
6
+ if (typeof ts != "undefined") {
7
+ this.walk(ts);
8
+ }
9
+ }
10
+
11
+ JSDOC.Walker.prototype.init = function() {
12
+ this.ts = null;
13
+
14
+ var globalSymbol = new JSDOC.Symbol("_global_", [], "GLOBAL", new JSDOC.DocComment(""));
15
+ globalSymbol.isNamespace = true;
16
+ globalSymbol.srcFile = "";
17
+ globalSymbol.isPrivate = false;
18
+ JSDOC.Parser.addSymbol(globalSymbol);
19
+ this.lastDoc = null;
20
+ this.token = null;
21
+
22
+ /**
23
+ The chain of symbols under which we are currently nested.
24
+ @type Array
25
+ */
26
+ this.namescope = [globalSymbol];
27
+ this.namescope.last = function(n){ if (!n) n = 0; return this[this.length-(1+n)] || "" };
28
+ }
29
+
30
+ JSDOC.Walker.prototype.walk = function(/**JSDOC.TokenStream*/ts) {
31
+ this.ts = ts;
32
+ while (this.token = this.ts.look()) {
33
+ if (this.token.popNamescope) {
34
+
35
+ var symbol = this.namescope.pop();
36
+ if (symbol.is("FUNCTION")) {
37
+ if (this.ts.look(1).is("LEFT_PAREN") && symbol.comment.getTag("function").length == 0) {
38
+ symbol.isa = "OBJECT";
39
+ }
40
+ }
41
+ }
42
+ this.step();
43
+ if (!this.ts.next()) break;
44
+ }
45
+ }
46
+
47
+ JSDOC.Walker.prototype.step = function() {
48
+ if (this.token.is("JSDOC")) { // it's a doc comment
49
+
50
+ var doc = new JSDOC.DocComment(this.token.data);
51
+
52
+ if (doc.getTag("lends").length > 0) { // it's a new namescope
53
+ var lends = doc.getTag("lends")[0];
54
+
55
+ var name = lends.desc
56
+ if (!name) throw "@lends tag requires a value.";
57
+
58
+ var symbol = new JSDOC.Symbol(name, [], "OBJECT", doc);
59
+
60
+ this.namescope.push(symbol);
61
+
62
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
63
+ if (matching) matching.popNamescope = name;
64
+ else LOG.warn("Mismatched } character. Can't parse code.");
65
+
66
+ this.lastDoc = null;
67
+ return true;
68
+ }
69
+ else if (doc.getTag("name").length > 0 && doc.getTag("overview").length == 0) { // it's a virtual symbol
70
+ var virtualName = doc.getTag("name")[0].desc;
71
+ if (!virtualName) throw "@name tag requires a value.";
72
+
73
+ var symbol = new JSDOC.Symbol(virtualName, [], "VIRTUAL", doc);
74
+
75
+ JSDOC.Parser.addSymbol(symbol);
76
+
77
+ this.lastDoc = null;
78
+ return true;
79
+ }
80
+ else if (doc.meta) { // it's a meta doclet
81
+ if (doc.meta == "@+") JSDOC.DocComment.shared = doc.src;
82
+ else if (doc.meta == "@-") JSDOC.DocComment.shared = "";
83
+ else if (doc.meta == "nocode+") JSDOC.Parser.conf.ignoreCode = true;
84
+ else if (doc.meta == "nocode-") JSDOC.Parser.conf.ignoreCode = JSDOC.opt.n;
85
+ else throw "Unrecognized meta comment: "+doc.meta;
86
+
87
+ this.lastDoc = null;
88
+ return true;
89
+ }
90
+ else if (doc.getTag("overview").length > 0) { // it's a file overview
91
+ symbol = new JSDOC.Symbol("", [], "FILE", doc);
92
+
93
+ JSDOC.Parser.addSymbol(symbol);
94
+
95
+ this.lastDoc = null;
96
+ return true;
97
+ }
98
+ else {
99
+ this.lastDoc = doc;
100
+ return false;
101
+ }
102
+ }
103
+ else if (!JSDOC.Parser.conf.ignoreCode) { // it's code
104
+ if (this.token.is("NAME")) {
105
+ var symbol;
106
+ var name = this.token.data;
107
+ var doc = null; if (this.lastDoc) doc = this.lastDoc;
108
+ var params = [];
109
+
110
+ // it's inside an anonymous object
111
+ if (this.ts.look(1).is("COLON") && this.ts.look(-1).is("LEFT_CURLY") && !(this.ts.look(-2).is("JSDOC") || this.namescope.last().comment.getTag("lends").length || this.ts.look(-2).is("ASSIGN") || this.ts.look(-2).is("COLON"))) {
112
+ name = "$anonymous";
113
+ name = this.namescope.last().alias+"-"+name
114
+
115
+ params = [];
116
+
117
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
118
+
119
+ JSDOC.Parser.addSymbol(symbol);
120
+
121
+ this.namescope.push(symbol);
122
+
123
+ var matching = this.ts.getMatchingToken(null, "RIGHT_CURLY");
124
+ if (matching) matching.popNamescope = name;
125
+ else LOG.warn("Mismatched } character. Can't parse code.");
126
+ }
127
+ // function foo() {}
128
+ else if (this.ts.look(-1).is("FUNCTION") && this.ts.look(1).is("LEFT_PAREN")) {
129
+ var isInner;
130
+
131
+ if (this.lastDoc) doc = this.lastDoc;
132
+ name = this.namescope.last().alias+"-"+name;
133
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
134
+
135
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
136
+
137
+ symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
138
+ if (isInner) symbol.isInner = true;
139
+
140
+
141
+ JSDOC.Parser.addSymbol(symbol);
142
+
143
+ this.namescope.push(symbol);
144
+
145
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
146
+ if (matching) matching.popNamescope = name;
147
+ else LOG.warn("Mismatched } character. Can't parse code.");
148
+ }
149
+ // foo = function() {}
150
+ else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("FUNCTION")) {
151
+ var isInner;
152
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
153
+ name = this.namescope.last().alias+"-"+name
154
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
155
+ }
156
+ else if (name.indexOf("this.") == 0) {
157
+ name = this.resolveThis(name);
158
+ }
159
+
160
+ if (this.lastDoc) doc = this.lastDoc;
161
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
162
+
163
+ symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
164
+ if (isInner) symbol.isInner = true;
165
+
166
+ JSDOC.Parser.addSymbol(symbol);
167
+
168
+ this.namescope.push(symbol);
169
+
170
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
171
+ if (matching) matching.popNamescope = name;
172
+ else LOG.warn("Mismatched } character. Can't parse code.");
173
+ }
174
+ // foo = new function() {}
175
+ else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("NEW") && this.ts.look(3).is("FUNCTION")) {
176
+ var isInner;
177
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
178
+ name = this.namescope.last().alias+"-"+name
179
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
180
+ }
181
+ else if (name.indexOf("this.") == 0) {
182
+ name = this.resolveThis(name);
183
+ }
184
+
185
+ if (this.lastDoc) doc = this.lastDoc;
186
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
187
+
188
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
189
+ if (isInner) symbol.isInner = true;
190
+
191
+
192
+ JSDOC.Parser.addSymbol(symbol);
193
+
194
+ symbol.scopeType = "INSTANCE";
195
+ this.namescope.push(symbol);
196
+
197
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
198
+ if (matching) matching.popNamescope = name;
199
+ else LOG.warn("Mismatched } character. Can't parse code.");
200
+ }
201
+ // foo: function() {}
202
+ else if (this.ts.look(1).is("COLON") && this.ts.look(2).is("FUNCTION")) {
203
+ name = (this.namescope.last().alias+"."+name).replace("#.", "#");
204
+
205
+ if (this.lastDoc) doc = this.lastDoc;
206
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
207
+
208
+ if (doc && doc.getTag("constructs").length) {
209
+ name = name.replace(/\.prototype(\.|$)/, "#");
210
+
211
+ if (name.indexOf("#") > -1) name = name.match(/(^[^#]+)/)[0];
212
+ else name = this.namescope.last().alias;
213
+
214
+ symbol = new JSDOC.Symbol(name, params, "CONSTRUCTOR", doc);
215
+ }
216
+ else {
217
+ symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
218
+ }
219
+
220
+
221
+ JSDOC.Parser.addSymbol(symbol);
222
+
223
+ this.namescope.push(symbol);
224
+
225
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
226
+ if (matching) matching.popNamescope = name;
227
+ else LOG.warn("Mismatched } character. Can't parse code.");
228
+ }
229
+ // foo = {}
230
+ else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("LEFT_CURLY")) {
231
+ var isInner;
232
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
233
+ name = this.namescope.last().alias+"-"+name
234
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
235
+ }
236
+ else if (name.indexOf("this.") == 0) {
237
+ name = this.resolveThis(name);
238
+ }
239
+
240
+ if (this.lastDoc) doc = this.lastDoc;
241
+
242
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
243
+ if (isInner) symbol.isInner = true;
244
+
245
+
246
+ if (doc) JSDOC.Parser.addSymbol(symbol);
247
+
248
+ this.namescope.push(symbol);
249
+
250
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
251
+ if (matching) matching.popNamescope = name;
252
+ else LOG.warn("Mismatched } character. Can't parse code.");
253
+ }
254
+ // foo = x
255
+ else if (this.ts.look(1).is("ASSIGN")) {
256
+
257
+ var isInner;
258
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
259
+ name = this.namescope.last().alias+"-"+name
260
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
261
+ }
262
+ else if (name.indexOf("this.") == 0) {
263
+ name = this.resolveThis(name);
264
+ }
265
+
266
+ if (this.lastDoc) doc = this.lastDoc;
267
+
268
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
269
+ if (isInner) symbol.isInner = true;
270
+
271
+
272
+ if (doc) JSDOC.Parser.addSymbol(symbol);
273
+ }
274
+ // foo: {}
275
+ else if (this.ts.look(1).is("COLON") && this.ts.look(2).is("LEFT_CURLY")) {
276
+ name = (this.namescope.last().alias+"."+name).replace("#.", "#");
277
+
278
+ if (this.lastDoc) doc = this.lastDoc;
279
+
280
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
281
+
282
+
283
+ if (doc) JSDOC.Parser.addSymbol(symbol);
284
+
285
+ this.namescope.push(symbol);
286
+
287
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
288
+ if (matching) matching.popNamescope = name;
289
+ else LOG.warn("Mismatched } character. Can't parse code.");
290
+ }
291
+ // foo: x
292
+ else if (this.ts.look(1).is("COLON")) {
293
+ name = (this.namescope.last().alias+"."+name).replace("#.", "#");;
294
+
295
+ if (this.lastDoc) doc = this.lastDoc;
296
+
297
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
298
+
299
+
300
+ if (doc) JSDOC.Parser.addSymbol(symbol);
301
+ }
302
+ // foo(...)
303
+ else if (this.ts.look(1).is("LEFT_PAREN")) {
304
+ var functionCall = {name: name};
305
+ if (!this.ts.look(2).is("RIGHT_PAREN")) functionCall.arg1 = this.ts.look(2).data;
306
+
307
+ if (typeof JSDOC.PluginManager != "undefined") {
308
+ JSDOC.PluginManager.run("onFunctionCall", functionCall);
309
+ if (functionCall.doc) {
310
+ this.ts.insertAhead(new JSDOC.Token(functionCall.doc, "COMM", "JSDOC"));
311
+ }
312
+ }
313
+ }
314
+ this.lastDoc = null;
315
+ }
316
+ else if (this.token.is("FUNCTION")) { // it's an anonymous function
317
+ if (
318
+ (!this.ts.look(-1).is("COLON") || !this.ts.look(-1).is("ASSIGN"))
319
+ && !this.ts.look(1).is("NAME")
320
+ ) {
321
+ if (this.lastDoc) doc = this.lastDoc;
322
+
323
+ name = "$anonymous";
324
+ name = this.namescope.last().alias+"-"+name
325
+
326
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
327
+
328
+ symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
329
+
330
+
331
+ JSDOC.Parser.addSymbol(symbol);
332
+
333
+ this.namescope.push(symbol);
334
+
335
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
336
+ if (matching) matching.popNamescope = name;
337
+ else LOG.warn("Mismatched } character. Can't parse code.");
338
+ }
339
+ }
340
+ }
341
+ return true;
342
+ }
343
+
344
+ /**
345
+ Resolves what "this." means when it appears in a name.
346
+ @param name The name that starts with "this.".
347
+ @returns The name with "this." resolved.
348
+ */
349
+ JSDOC.Walker.prototype.resolveThis = function(name) {
350
+ name.match(/^this\.(.+)$/)
351
+ var nameFragment = RegExp.$1;
352
+ if (!nameFragment) return name;
353
+
354
+ var symbol = this.namescope.last();
355
+ var scopeType = symbol.scopeType || symbol.isa;
356
+
357
+ // if we are in a constructor function, `this` means the instance
358
+ if (scopeType == "CONSTRUCTOR") {
359
+ name = symbol.alias+"#"+nameFragment;
360
+ }
361
+
362
+ // if we are in an anonymous constructor function, `this` means the instance
363
+ else if (scopeType == "INSTANCE") {
364
+ name = symbol.alias+"."+nameFragment;
365
+ }
366
+
367
+ // if we are in a function, `this` means the container (possibly the global)
368
+ else if (scopeType == "FUNCTION") {
369
+ // in a method of a prototype, so `this` means the constructor
370
+ if (symbol.alias.match(/(^.*)[#.-][^#.-]+/)) {
371
+ var parentName = RegExp.$1;
372
+ var parent = JSDOC.Parser.symbols.getSymbol(parentName);
373
+
374
+ if (!parent) {
375
+ if (JSDOC.Lang.isBuiltin(parentName)) parent = JSDOC.Parser.addBuiltin(parentName);
376
+ else {
377
+ if (symbol.alias.indexOf("$anonymous") < 0) // these will be ignored eventually
378
+ LOG.warn("Can't document "+symbol.alias+" without first documenting "+parentName+".");
379
+ }
380
+ }
381
+ if (parent) name = parentName+(parent.is("CONSTRUCTOR")?"#":".")+nameFragment;
382
+ }
383
+ else {
384
+ parent = this.namescope.last(1);
385
+ name = parent.alias+(parent.is("CONSTRUCTOR")?"#":".")+nameFragment;
386
+ }
387
+ }
388
+ // otherwise it means the global
389
+ else {
390
+ name = nameFragment;
391
+ }
392
+
393
+ return name;
394
+ }
395
+
396
+ JSDOC.Walker.onParamList = function(/**Array*/paramTokens) {
397
+ if (!paramTokens) {
398
+ LOG.warn("Malformed parameter list. Can't parse code.");
399
+ return [];
400
+ }
401
+ var params = [];
402
+ for (var i = 0, l = paramTokens.length; i < l; i++) {
403
+ if (paramTokens[i].is("JSDOC")) {
404
+ var paramType = paramTokens[i].data.replace(/(^\/\*\* *| *\*\/$)/g, "");
405
+
406
+ if (paramTokens[i+1] && paramTokens[i+1].is("NAME")) {
407
+ i++;
408
+ params.push({type: paramType, name: paramTokens[i].data});
409
+ }
410
+ }
411
+ else if (paramTokens[i].is("NAME")) {
412
+ params.push({name: paramTokens[i].data});
413
+ }
414
+ }
415
+ return params;
416
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ @overview
3
+ @date $Date: 2008-06-08 22:57:25 +0100 (Sun, 08 Jun 2008) $
4
+ @version $Revision: 638 $
5
+ @location $HeadURL: https://jsdoc-toolkit.googlecode.com/svn/tags/jsdoc_toolkit-2.0.1/jsdoc-toolkit/app/lib/JSDOC.js $
6
+ */
7
+
8
+ /**
9
+ This is the main container for the JSDOC application.
10
+ @namespace
11
+ */
12
+ JSDOC = {
13
+ };
14
+
15
+ /**
16
+ @requires Opt
17
+ */
18
+ if (typeof arguments == "undefined") arguments = [];
19
+ JSDOC.opt = Opt.get(
20
+ arguments,
21
+ {
22
+ d: "directory",
23
+ c: "conf",
24
+ t: "template",
25
+ r: "recurse",
26
+ x: "ext",
27
+ p: "private",
28
+ a: "allfunctions",
29
+ e: "encoding",
30
+ n: "nocode",
31
+ o: "out",
32
+ s: "suppress",
33
+ T: "testmode",
34
+ h: "help",
35
+ v: "verbose",
36
+ "D[]": "define",
37
+ "H[]": "handler"
38
+ }
39
+ );
40
+
41
+ /** The current version string of this application. */
42
+ JSDOC.VERSION = "2.0.1";
43
+
44
+ /** Print out usage information and quit. */
45
+ JSDOC.usage = function() {
46
+ print("USAGE: java -jar jsrun.jar app/run.js [OPTIONS] <SRC_DIR> <SRC_FILE> ...");
47
+ print("");
48
+ print("OPTIONS:");
49
+ print(" -a or --allfunctions\n Include all functions, even undocumented ones.\n");
50
+ print(" -c or --conf\n Load a configuration file.\n");
51
+ print(" -d=<PATH> or --directory=<PATH>\n Output to this directory (defaults to \"out\").\n");
52
+ print(" -D=\"myVar:My value\" or --define=\"myVar:My value\"\n Multiple. Define a variable, available in JsDoc as JSDOC.opt.D.myVar\n");
53
+ print(" -e=<ENCODING> or --encoding=<ENCODING>\n Use this encoding to read and write files.\n");
54
+ print(" -h or --help\n Show this message and exit.\n");
55
+ //print(" -H=ext:handler or --handler=ext:handler\n Multiple. Load handlers/handler.js to handle files with .ext names.\n");
56
+ print(" -n or --nocode\n Ignore all code, only document comments with @name tags.\n");
57
+ print(" -o=<PATH> or --out=<PATH>\n Print log messages to a file (defaults to stdout).\n");
58
+ print(" -p or --private\n Include symbols tagged as private, underscored and inner symbols.\n");
59
+ print(" -r=<DEPTH> or --recurse=<DEPTH>\n Descend into src directories.\n");
60
+ print(" -s or --suppress\n Suppress source code output.\n");
61
+ print(" -t=<PATH> or --template=<PATH>\n Required. Use this template to format the output.\n");
62
+ print(" -T or --test\n Run all unit tests and exit.\n");
63
+ print(" -v or --verbose\n Provide verbose feedback about what is happening.\n");
64
+ print(" -x=<EXT>[,EXT]... or --ext=<EXT>[,EXT]...\n Scan source files with the given extension/s (defaults to js).\n");
65
+
66
+ quit();
67
+ }
68
+
69
+ /*t:
70
+ plan(4, "Testing JSDOC namespace.");
71
+
72
+ is(
73
+ typeof JSDOC,
74
+ "object",
75
+ "JSDOC.usage is a function."
76
+ );
77
+
78
+ is(
79
+ typeof JSDOC.VERSION,
80
+ "string",
81
+ "JSDOC.VERSION is a string."
82
+ );
83
+
84
+ is(
85
+ typeof JSDOC.usage,
86
+ "function",
87
+ "JSDOC.usage is a function."
88
+ );
89
+
90
+ is(
91
+ typeof JSDOC.opt,
92
+ "object",
93
+ "JSDOC.opt is a object."
94
+ );
95
+ */
96
+
97
+ if (this.IO) IO.includeDir("lib/JSDOC/");