ragaskar-jsdoc_helper 0.0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/README.rdoc +64 -0
  2. data/bin/jsdoc_helper +8 -0
  3. data/ext/jsdoc-toolkit/README.txt +146 -0
  4. data/ext/jsdoc-toolkit/app/frame.js +33 -0
  5. data/ext/jsdoc-toolkit/app/frame/Chain.js +102 -0
  6. data/ext/jsdoc-toolkit/app/frame/Dumper.js +144 -0
  7. data/ext/jsdoc-toolkit/app/frame/Hash.js +84 -0
  8. data/ext/jsdoc-toolkit/app/frame/Link.js +148 -0
  9. data/ext/jsdoc-toolkit/app/frame/Namespace.js +10 -0
  10. data/ext/jsdoc-toolkit/app/frame/Opt.js +134 -0
  11. data/ext/jsdoc-toolkit/app/frame/Reflection.js +26 -0
  12. data/ext/jsdoc-toolkit/app/frame/String.js +93 -0
  13. data/ext/jsdoc-toolkit/app/frame/Testrun.js +129 -0
  14. data/ext/jsdoc-toolkit/app/handlers/FOODOC.js +26 -0
  15. data/ext/jsdoc-toolkit/app/handlers/XMLDOC.js +26 -0
  16. data/ext/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js +159 -0
  17. data/ext/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js +16 -0
  18. data/ext/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js +292 -0
  19. data/ext/jsdoc-toolkit/app/lib/JSDOC.js +101 -0
  20. data/ext/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +200 -0
  21. data/ext/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +294 -0
  22. data/ext/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +126 -0
  23. data/ext/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +109 -0
  24. data/ext/jsdoc-toolkit/app/lib/JSDOC/Lang.js +144 -0
  25. data/ext/jsdoc-toolkit/app/lib/JSDOC/Parser.js +107 -0
  26. data/ext/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +33 -0
  27. data/ext/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +643 -0
  28. data/ext/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +229 -0
  29. data/ext/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +41 -0
  30. data/ext/jsdoc-toolkit/app/lib/JSDOC/Token.js +18 -0
  31. data/ext/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +332 -0
  32. data/ext/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +133 -0
  33. data/ext/jsdoc-toolkit/app/lib/JSDOC/Util.js +32 -0
  34. data/ext/jsdoc-toolkit/app/lib/JSDOC/Walker.js +459 -0
  35. data/ext/jsdoc-toolkit/app/main.js +111 -0
  36. data/ext/jsdoc-toolkit/app/plugins/commentSrcJson.js +20 -0
  37. data/ext/jsdoc-toolkit/app/plugins/frameworkPrototype.js +16 -0
  38. data/ext/jsdoc-toolkit/app/plugins/functionCall.js +10 -0
  39. data/ext/jsdoc-toolkit/app/plugins/publishSrcHilite.js +62 -0
  40. data/ext/jsdoc-toolkit/app/plugins/symbolLink.js +9 -0
  41. data/ext/jsdoc-toolkit/app/plugins/tagParamConfig.js +31 -0
  42. data/ext/jsdoc-toolkit/app/plugins/tagSynonyms.js +43 -0
  43. data/ext/jsdoc-toolkit/app/run.js +348 -0
  44. data/ext/jsdoc-toolkit/app/t/TestDoc.js +144 -0
  45. data/ext/jsdoc-toolkit/app/t/runner.js +13 -0
  46. data/ext/jsdoc-toolkit/app/test.js +307 -0
  47. data/ext/jsdoc-toolkit/app/test/addon.js +24 -0
  48. data/ext/jsdoc-toolkit/app/test/anon_inner.js +14 -0
  49. data/ext/jsdoc-toolkit/app/test/augments.js +31 -0
  50. data/ext/jsdoc-toolkit/app/test/augments2.js +26 -0
  51. data/ext/jsdoc-toolkit/app/test/borrows.js +41 -0
  52. data/ext/jsdoc-toolkit/app/test/borrows2.js +23 -0
  53. data/ext/jsdoc-toolkit/app/test/config.js +22 -0
  54. data/ext/jsdoc-toolkit/app/test/constructs.js +18 -0
  55. data/ext/jsdoc-toolkit/app/test/encoding.js +10 -0
  56. data/ext/jsdoc-toolkit/app/test/encoding_other.js +12 -0
  57. data/ext/jsdoc-toolkit/app/test/event.js +54 -0
  58. data/ext/jsdoc-toolkit/app/test/functions_anon.js +39 -0
  59. data/ext/jsdoc-toolkit/app/test/functions_nested.js +33 -0
  60. data/ext/jsdoc-toolkit/app/test/global.js +13 -0
  61. data/ext/jsdoc-toolkit/app/test/globals.js +25 -0
  62. data/ext/jsdoc-toolkit/app/test/ignore.js +10 -0
  63. data/ext/jsdoc-toolkit/app/test/inner.js +16 -0
  64. data/ext/jsdoc-toolkit/app/test/jsdoc_test.js +477 -0
  65. data/ext/jsdoc-toolkit/app/test/lend.js +33 -0
  66. data/ext/jsdoc-toolkit/app/test/memberof.js +19 -0
  67. data/ext/jsdoc-toolkit/app/test/memberof_constructor.js +17 -0
  68. data/ext/jsdoc-toolkit/app/test/name.js +19 -0
  69. data/ext/jsdoc-toolkit/app/test/namespace_nested.js +23 -0
  70. data/ext/jsdoc-toolkit/app/test/nocode.js +13 -0
  71. data/ext/jsdoc-toolkit/app/test/oblit_anon.js +20 -0
  72. data/ext/jsdoc-toolkit/app/test/overview.js +20 -0
  73. data/ext/jsdoc-toolkit/app/test/param_inline.js +37 -0
  74. data/ext/jsdoc-toolkit/app/test/params_optional.js +8 -0
  75. data/ext/jsdoc-toolkit/app/test/prototype.js +17 -0
  76. data/ext/jsdoc-toolkit/app/test/prototype_nested.js +9 -0
  77. data/ext/jsdoc-toolkit/app/test/prototype_oblit.js +13 -0
  78. data/ext/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +24 -0
  79. data/ext/jsdoc-toolkit/app/test/public.js +10 -0
  80. data/ext/jsdoc-toolkit/app/test/shared.js +42 -0
  81. data/ext/jsdoc-toolkit/app/test/shared2.js +2 -0
  82. data/ext/jsdoc-toolkit/app/test/shortcuts.js +22 -0
  83. data/ext/jsdoc-toolkit/app/test/static_this.js +13 -0
  84. data/ext/jsdoc-toolkit/app/test/synonyms.js +31 -0
  85. data/ext/jsdoc-toolkit/app/test/tosource.js +23 -0
  86. data/ext/jsdoc-toolkit/app/test/variable_redefine.js +14 -0
  87. data/ext/jsdoc-toolkit/changes.txt +75 -0
  88. data/ext/jsdoc-toolkit/conf/sample.conf +31 -0
  89. data/ext/jsdoc-toolkit/java/build.xml +36 -0
  90. data/ext/jsdoc-toolkit/java/build_1.4.xml +36 -0
  91. data/ext/jsdoc-toolkit/java/classes/js.jar +0 -0
  92. data/ext/jsdoc-toolkit/java/src/JsDebugRun.java +21 -0
  93. data/ext/jsdoc-toolkit/java/src/JsRun.java +21 -0
  94. data/ext/jsdoc-toolkit/jsdebug.jar +0 -0
  95. data/ext/jsdoc-toolkit/jsrun.jar +0 -0
  96. data/ext/jsdoc-toolkit/out/jsdoc/files.html +216 -0
  97. data/ext/jsdoc-toolkit/out/jsdoc/index.html +210 -0
  98. data/ext/jsdoc-toolkit/out/jsdoc/symbols/_global_.html +306 -0
  99. data/ext/jsdoc-toolkit/out/jsdoc/symbols/src/lib_test.js.html +13 -0
  100. data/ext/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +17 -0
  101. data/ext/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +56 -0
  102. data/ext/jsdoc-toolkit/templates/jsdoc/class.tmpl +646 -0
  103. data/ext/jsdoc-toolkit/templates/jsdoc/index.tmpl +39 -0
  104. data/ext/jsdoc-toolkit/templates/jsdoc/publish.js +184 -0
  105. data/ext/jsdoc-toolkit/templates/jsdoc/static/default.css +162 -0
  106. data/ext/jsdoc-toolkit/templates/jsdoc/static/header.html +2 -0
  107. data/ext/jsdoc-toolkit/templates/jsdoc/static/index.html +19 -0
  108. data/ext/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +35 -0
  109. data/lib/jsdoc_helper.rb +50 -0
  110. data/lib/jsdoc_helper/rake/task.rb +43 -0
  111. data/lib/jsdoc_helper/rake/task/runner.rb +85 -0
  112. data/spec/jsdoc_helper/jsdoc_helper_spec.rb +4 -0
  113. data/spec/jsdoc_helper/rake/task/runner_spec.rb +45 -0
  114. data/spec/jsdoc_helper/support/file_helper_spec.rb +93 -0
  115. data/spec/spec_helper.rb +25 -0
  116. metadata +168 -0
@@ -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("WHIT"))) {
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,459 @@
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) {
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 in file " + symbol.srcFile + ".");
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 in file " + symbol.srcFile + ".");
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
+ if (this.ts.look(1).is("JSDOC")) {
141
+ var inlineReturn = ""+this.ts.look(1).data;
142
+ inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
143
+ symbol.type = inlineReturn;
144
+ }
145
+
146
+ JSDOC.Parser.addSymbol(symbol);
147
+
148
+ this.namescope.push(symbol);
149
+
150
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
151
+ if (matching) matching.popNamescope = name;
152
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
153
+ }
154
+ // foo = function() {}
155
+ else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("FUNCTION")) {
156
+ var isInner;
157
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
158
+ name = this.namescope.last().alias+"-"+name
159
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
160
+ }
161
+ else if (name.indexOf("this.") == 0) {
162
+ name = this.resolveThis(name);
163
+ }
164
+
165
+ if (this.lastDoc) doc = this.lastDoc;
166
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
167
+
168
+ symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
169
+ if (isInner) symbol.isInner = true;
170
+
171
+ if (this.ts.look(1).is("JSDOC")) {
172
+ var inlineReturn = ""+this.ts.look(1).data;
173
+ inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
174
+ symbol.type = inlineReturn;
175
+ }
176
+
177
+ JSDOC.Parser.addSymbol(symbol);
178
+
179
+ this.namescope.push(symbol);
180
+
181
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
182
+ if (matching) matching.popNamescope = name;
183
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
184
+ }
185
+ // foo = new function() {}
186
+ else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("NEW") && this.ts.look(3).is("FUNCTION")) {
187
+ var isInner;
188
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
189
+ name = this.namescope.last().alias+"-"+name
190
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
191
+ }
192
+ else if (name.indexOf("this.") == 0) {
193
+ name = this.resolveThis(name);
194
+ }
195
+
196
+ if (this.lastDoc) doc = this.lastDoc;
197
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
198
+
199
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
200
+ if (isInner) symbol.isInner = true;
201
+
202
+ if (this.ts.look(1).is("JSDOC")) {
203
+ var inlineReturn = ""+this.ts.look(1).data;
204
+ inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
205
+ symbol.type = inlineReturn;
206
+ }
207
+
208
+ JSDOC.Parser.addSymbol(symbol);
209
+
210
+ symbol.scopeType = "INSTANCE";
211
+ this.namescope.push(symbol);
212
+
213
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
214
+ if (matching) matching.popNamescope = name;
215
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
216
+ }
217
+ // foo: function() {}
218
+ else if (this.ts.look(1).is("COLON") && this.ts.look(2).is("FUNCTION")) {
219
+ name = (this.namescope.last().alias+"."+name).replace("#.", "#");
220
+
221
+ if (this.lastDoc) doc = this.lastDoc;
222
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
223
+
224
+ if (doc && doc.getTag("constructs").length) {
225
+ name = name.replace(/\.prototype(\.|$)/, "#");
226
+
227
+ if (name.indexOf("#") > -1) name = name.match(/(^[^#]+)/)[0];
228
+ else name = this.namescope.last().alias;
229
+
230
+ symbol = new JSDOC.Symbol(name, params, "CONSTRUCTOR", doc);
231
+ }
232
+ else {
233
+ symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
234
+ }
235
+
236
+ if (this.ts.look(1).is("JSDOC")) {
237
+ var inlineReturn = ""+this.ts.look(1).data;
238
+ inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
239
+ symbol.type = inlineReturn;
240
+ }
241
+
242
+ JSDOC.Parser.addSymbol(symbol);
243
+
244
+ this.namescope.push(symbol);
245
+
246
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
247
+ if (matching) matching.popNamescope = name;
248
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
249
+ }
250
+ // foo = {}
251
+ else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("LEFT_CURLY")) {
252
+ var isInner;
253
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
254
+ name = this.namescope.last().alias+"-"+name
255
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
256
+ }
257
+ else if (name.indexOf("this.") == 0) {
258
+ name = this.resolveThis(name);
259
+ }
260
+
261
+ if (this.lastDoc) doc = this.lastDoc;
262
+
263
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
264
+ if (isInner) symbol.isInner = true;
265
+
266
+
267
+ if (doc) JSDOC.Parser.addSymbol(symbol);
268
+
269
+ this.namescope.push(symbol);
270
+
271
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
272
+ if (matching) matching.popNamescope = name;
273
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
274
+ }
275
+ // var foo;
276
+ else if (this.ts.look(1).is("SEMICOLON")) {
277
+ var isInner;
278
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
279
+ name = this.namescope.last().alias+"-"+name
280
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
281
+
282
+ if (this.lastDoc) doc = this.lastDoc;
283
+
284
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
285
+ if (isInner) symbol.isInner = true;
286
+
287
+
288
+ if (doc) JSDOC.Parser.addSymbol(symbol);
289
+ }
290
+ }
291
+ // foo = x
292
+ else if (this.ts.look(1).is("ASSIGN")) {
293
+
294
+ var isInner;
295
+ if (this.ts.look(-1).is("VAR") || this.isInner) {
296
+ name = this.namescope.last().alias+"-"+name
297
+ if (!this.namescope.last().is("GLOBAL")) isInner = true;
298
+ }
299
+ else if (name.indexOf("this.") == 0) {
300
+ name = this.resolveThis(name);
301
+ }
302
+
303
+ if (this.lastDoc) doc = this.lastDoc;
304
+
305
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
306
+ if (isInner) symbol.isInner = true;
307
+
308
+
309
+ if (doc) JSDOC.Parser.addSymbol(symbol);
310
+ }
311
+ // foo: {}
312
+ else if (this.ts.look(1).is("COLON") && this.ts.look(2).is("LEFT_CURLY")) {
313
+ name = (this.namescope.last().alias+"."+name).replace("#.", "#");
314
+
315
+ if (this.lastDoc) doc = this.lastDoc;
316
+
317
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
318
+
319
+
320
+ if (doc) JSDOC.Parser.addSymbol(symbol);
321
+
322
+ this.namescope.push(symbol);
323
+
324
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
325
+ if (matching) matching.popNamescope = name;
326
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
327
+ }
328
+ // foo: x
329
+ else if (this.ts.look(1).is("COLON")) {
330
+ name = (this.namescope.last().alias+"."+name).replace("#.", "#");;
331
+
332
+ if (this.lastDoc) doc = this.lastDoc;
333
+
334
+ symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
335
+
336
+
337
+ if (doc) JSDOC.Parser.addSymbol(symbol);
338
+ }
339
+ // foo(...)
340
+ else if (this.ts.look(1).is("LEFT_PAREN")) {
341
+ if (typeof JSDOC.PluginManager != "undefined") {
342
+ var functionCall = {name: name};
343
+
344
+ var cursor = this.ts.cursor;
345
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
346
+ this.ts.cursor = cursor;
347
+
348
+ for (var i = 0; i < params.length; i++)
349
+ functionCall["arg" + (i + 1)] = params[i].name;
350
+
351
+ JSDOC.PluginManager.run("onFunctionCall", functionCall);
352
+ if (functionCall.doc) {
353
+ this.ts.insertAhead(new JSDOC.Token(functionCall.doc, "COMM", "JSDOC"));
354
+ }
355
+ }
356
+ }
357
+ this.lastDoc = null;
358
+ }
359
+ else if (this.token.is("FUNCTION")) { // it's an anonymous function
360
+ if (
361
+ (!this.ts.look(-1).is("COLON") || !this.ts.look(-1).is("ASSIGN"))
362
+ && !this.ts.look(1).is("NAME")
363
+ ) {
364
+ if (this.lastDoc) doc = this.lastDoc;
365
+
366
+ name = "$anonymous";
367
+ name = this.namescope.last().alias+"-"+name
368
+
369
+ params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
370
+
371
+ symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
372
+
373
+
374
+ JSDOC.Parser.addSymbol(symbol);
375
+
376
+ this.namescope.push(symbol);
377
+
378
+ var matching = this.ts.getMatchingToken("LEFT_CURLY");
379
+ if (matching) matching.popNamescope = name;
380
+ else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
381
+ }
382
+ }
383
+ }
384
+ return true;
385
+ }
386
+
387
+ /**
388
+ Resolves what "this." means when it appears in a name.
389
+ @param name The name that starts with "this.".
390
+ @returns The name with "this." resolved.
391
+ */
392
+ JSDOC.Walker.prototype.resolveThis = function(name) {
393
+ name.match(/^this\.(.+)$/)
394
+ var nameFragment = RegExp.$1;
395
+ if (!nameFragment) return name;
396
+
397
+ var symbol = this.namescope.last();
398
+ var scopeType = symbol.scopeType || symbol.isa;
399
+
400
+ // if we are in a constructor function, `this` means the instance
401
+ if (scopeType == "CONSTRUCTOR") {
402
+ name = symbol.alias+"#"+nameFragment;
403
+ }
404
+
405
+ // if we are in an anonymous constructor function, `this` means the instance
406
+ else if (scopeType == "INSTANCE") {
407
+ name = symbol.alias+"."+nameFragment;
408
+ }
409
+
410
+ // if we are in a function, `this` means the container (possibly the global)
411
+ else if (scopeType == "FUNCTION") {
412
+ // in a method of a prototype, so `this` means the constructor
413
+ if (symbol.alias.match(/(^.*)[#.-][^#.-]+/)) {
414
+ var parentName = RegExp.$1;
415
+ var parent = JSDOC.Parser.symbols.getSymbol(parentName);
416
+
417
+ if (!parent) {
418
+ if (JSDOC.Lang.isBuiltin(parentName)) parent = JSDOC.Parser.addBuiltin(parentName);
419
+ else {
420
+ if (symbol.alias.indexOf("$anonymous") < 0) // these will be ignored eventually
421
+ LOG.warn("Trying to document "+symbol.alias+" without first documenting "+parentName+".");
422
+ }
423
+ }
424
+ if (parent) name = parentName+(parent.is("CONSTRUCTOR")?"#":".")+nameFragment;
425
+ }
426
+ else {
427
+ parent = this.namescope.last(1);
428
+ name = parent.alias+(parent.is("CONSTRUCTOR")?"#":".")+nameFragment;
429
+ }
430
+ }
431
+ // otherwise it means the global
432
+ else {
433
+ name = nameFragment;
434
+ }
435
+
436
+ return name;
437
+ }
438
+
439
+ JSDOC.Walker.onParamList = function(/**Array*/paramTokens) {
440
+ if (!paramTokens) {
441
+ LOG.warn("Malformed parameter list. Can't parse code.");
442
+ return [];
443
+ }
444
+ var params = [];
445
+ for (var i = 0, l = paramTokens.length; i < l; i++) {
446
+ if (paramTokens[i].is("JSDOC")) {
447
+ var paramType = paramTokens[i].data.replace(/(^\/\*\* *| *\*\/$)/g, "");
448
+
449
+ if (paramTokens[i+1] && paramTokens[i+1].is("NAME")) {
450
+ i++;
451
+ params.push({type: paramType, name: paramTokens[i].data});
452
+ }
453
+ }
454
+ else if (paramTokens[i].is("NAME")) {
455
+ params.push({name: paramTokens[i].data});
456
+ }
457
+ }
458
+ return params;
459
+ }