ragaskar-jsdoc_helper 0.0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,33 @@
1
+ /**
2
+ @namespace Holds functionality related to running plugins.
3
+ */
4
+ JSDOC.PluginManager = {
5
+ }
6
+
7
+ /**
8
+ @param name A unique name that identifies that plugin.
9
+ @param handlers A collection of named functions. The names correspond to hooks in the core code.
10
+ */
11
+ JSDOC.PluginManager.registerPlugin = function(/**String*/name, /**Object*/handlers) {
12
+ if (!defined(JSDOC.PluginManager.plugins))
13
+ /** The collection of all plugins. Requires a unique name for each.
14
+ */
15
+ JSDOC.PluginManager.plugins = {};
16
+
17
+
18
+ JSDOC.PluginManager.plugins[name] = handlers;
19
+ }
20
+
21
+ /**
22
+ @param hook The name of the hook that is being caught.
23
+ @param target Any object. This will be passed as the only argument to the handler whose
24
+ name matches the hook name. Handlers cannot return a value, so must modify the target
25
+ object to have an effect.
26
+ */
27
+ JSDOC.PluginManager.run = function(/**String*/hook, /**Mixed*/target) {
28
+ for (var name in JSDOC.PluginManager.plugins) {
29
+ if (defined(JSDOC.PluginManager.plugins[name][hook])) {
30
+ JSDOC.PluginManager.plugins[name][hook](target);
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,643 @@
1
+ if (typeof JSDOC == "undefined") JSDOC = {};
2
+
3
+ /**
4
+ Create a new Symbol.
5
+ @class Represents a symbol in the source code.
6
+ */
7
+ JSDOC.Symbol = function() {
8
+ this.init();
9
+ if (arguments.length) this.populate.apply(this, arguments);
10
+ }
11
+
12
+ JSDOC.Symbol.prototype.init = function() {
13
+ this.$args = [];
14
+ this.addOn = "";
15
+ this.alias = "";
16
+ this.augments = [];
17
+ this.author = "";
18
+ this.classDesc = "";
19
+ this.comment = {};
20
+ this.defaultValue = undefined;
21
+ this.deprecated = "";
22
+ this.desc = "";
23
+ this.fires = [];
24
+ this.example = [];
25
+ this.exceptions = [];
26
+ this.inherits = [];
27
+ this.inheritsFrom = [];
28
+ this.isa = "OBJECT";
29
+ this.isEvent = false;
30
+ this.isConstant = false;
31
+ this.isIgnored = false;
32
+ this.isInner = false;
33
+ this.isEvent = false;
34
+ this.isNamespace = false;
35
+ this.isPrivate = false;
36
+ this.isStatic = false;
37
+ this.memberOf = "";
38
+ this.methods = [];
39
+ this._name = "";
40
+ this._params = [];
41
+ this.properties = [];
42
+ this.requires = [];
43
+ this.returns = [];
44
+ this.see = [];
45
+ this.since = "";
46
+ this.srcFile = {};
47
+ this.type = "";
48
+ this.version = "";
49
+ }
50
+
51
+ JSDOC.Symbol.prototype.serialize = function() {
52
+ var keys = [];
53
+ for (var p in this) {
54
+ keys.push (p);
55
+ }
56
+ keys = keys.sort();
57
+
58
+ var out = "";
59
+ for (var i in keys) {
60
+ if (typeof this[keys[i]] == "function") continue;
61
+ out += keys[i]+" => "+Dumper.dump(this[keys[i]])+",\n";
62
+ }
63
+ return "\n{\n" + out + "}\n";
64
+ }
65
+
66
+ JSDOC.Symbol.prototype.clone = function() {
67
+ var clone = new JSDOC.Symbol();
68
+ clone.populate.apply(clone, this.$args); // repopulate using the original arguments
69
+ clone.srcFile = this.srcFile; // not the current srcFile, the one when the original was made
70
+ return clone;
71
+ }
72
+
73
+ JSDOC.Symbol.prototype.__defineSetter__("name",
74
+ function(n) { n = n.replace(/^_global_[.#-]/, ""); n = n.replace(/\.prototype\.?/g, '#'); this._name = n; }
75
+ );
76
+ JSDOC.Symbol.prototype.__defineGetter__("name",
77
+ function() { return this._name; }
78
+ );
79
+ JSDOC.Symbol.prototype.__defineSetter__("params",
80
+ function(v) {
81
+ for (var i = 0, l = v.length; i < l; i++) {
82
+ if (v[i].constructor != JSDOC.DocTag) { // may be a generic object parsed from signature, like {type:..., name:...}
83
+ this._params[i] = new JSDOC.DocTag("param"+((v[i].type)?" {"+v[i].type+"}":"")+" "+v[i].name);
84
+ }
85
+ else {
86
+ this._params[i] = v[i];
87
+ }
88
+ }
89
+ }
90
+ );
91
+ JSDOC.Symbol.prototype.__defineGetter__("params",
92
+ function() { return this._params; }
93
+ );
94
+
95
+ JSDOC.Symbol.prototype.getEvents = function() {
96
+ var events = [];
97
+ for (var i = 0, l = this.methods.length; i < l; i++) {
98
+ if (this.methods[i].isEvent) {
99
+ this.methods[i].name = this.methods[i].name.replace("event:", "");
100
+ events.push(this.methods[i]);
101
+ }
102
+ }
103
+ return events;
104
+ }
105
+
106
+ JSDOC.Symbol.prototype.getMethods = function() {
107
+ var nonEvents = [];
108
+ for (var i = 0, l = this.methods.length; i < l; i++) {
109
+ if (!this.methods[i].isEvent) {
110
+ nonEvents.push(this.methods[i]);
111
+ }
112
+ }
113
+ return nonEvents;
114
+ }
115
+
116
+
117
+ JSDOC.Symbol.prototype.populate = function(
118
+ /** String */ name,
119
+ /** Object[] */ params,
120
+ /** String */ isa,
121
+ /** JSDOC.DocComment */ comment
122
+ ) {
123
+ this.$args = arguments;
124
+
125
+ this.name = name;
126
+ this.alias = this.name;
127
+
128
+ this.params = params;
129
+ this.isa = (isa == "VIRTUAL")? "OBJECT":isa;
130
+ this.comment = comment || new JSDOC.DocComment("");
131
+ this.srcFile = JSDOC.Symbol.srcFile;
132
+
133
+ if (this.is("FILE") && !this.alias) this.alias = this.srcFile;
134
+
135
+ this.setTags();
136
+
137
+ if (typeof JSDOC.PluginManager != "undefined") {
138
+ JSDOC.PluginManager.run("onSymbol", this);
139
+ }
140
+ }
141
+
142
+ JSDOC.Symbol.prototype.setTags = function() {
143
+ // @author
144
+ var authors = this.comment.getTag("author");
145
+ if (authors.length) {
146
+ this.author = authors.map(function($){return $.desc;}).join(", ");
147
+ }
148
+
149
+ /*t:
150
+ plan(34, "testing JSDOC.Symbol");
151
+
152
+ requires("../lib/JSDOC/DocComment.js");
153
+ requires("../frame/String.js");
154
+ requires("../lib/JSDOC/DocTag.js");
155
+
156
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@author Joe Smith*"+"/"));
157
+ is(sym.author, "Joe Smith", "@author tag, author is found.");
158
+ */
159
+
160
+ // @desc
161
+ var descs = this.comment.getTag("desc");
162
+ if (descs.length) {
163
+ this.desc = descs.map(function($){return $.desc;}).join("\n"); // multiple descriptions are concatenated into one
164
+ }
165
+
166
+ /*t:
167
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@desc This is a description.*"+"/"));
168
+ is(sym.desc, "This is a description.", "@desc tag, description is found.");
169
+ */
170
+
171
+ // @overview
172
+ if (this.is("FILE")) {
173
+ if (!this.alias) this.alias = this.srcFile;
174
+
175
+ var overviews = this.comment.getTag("overview");
176
+ if (overviews.length) {
177
+ this.desc = [this.desc].concat(overviews.map(function($){return $.desc;})).join("\n");
178
+ }
179
+ }
180
+
181
+ /*t:
182
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@overview This is an overview.*"+"/"));
183
+ is(sym.desc, "\nThis is an overview.", "@overview tag, description is found.");
184
+ */
185
+
186
+ // @since
187
+ var sinces = this.comment.getTag("since");
188
+ if (sinces.length) {
189
+ this.since = sinces.map(function($){return $.desc;}).join(", ");
190
+ }
191
+
192
+ /*t:
193
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@since 1.01*"+"/"));
194
+ is(sym.since, "1.01", "@since tag, description is found.");
195
+ */
196
+
197
+ // @constant
198
+ if (this.comment.getTag("constant").length) {
199
+ this.isConstant = true;
200
+ }
201
+
202
+ /*t:
203
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@constant*"+"/"));
204
+ is(sym.isConstant, true, "@constant tag, isConstant set.");
205
+ */
206
+
207
+ // @version
208
+ var versions = this.comment.getTag("version");
209
+ if (versions.length) {
210
+ this.version = versions.map(function($){return $.desc;}).join(", ");
211
+ }
212
+
213
+ /*t:
214
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@version 2.0x*"+"/"));
215
+ is(sym.version, "2.0x", "@version tag, version is found.");
216
+ */
217
+
218
+ // @deprecated
219
+ var deprecateds = this.comment.getTag("deprecated");
220
+ if (deprecateds.length) {
221
+ this.deprecated = deprecateds.map(function($){return $.desc;}).join("\n");
222
+ }
223
+
224
+ /*t:
225
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@deprecated Use other method.*"+"/"));
226
+ is(sym.deprecated, "Use other method.", "@deprecated tag, desc is found.");
227
+ */
228
+
229
+ // @example
230
+ var examples = this.comment.getTag("example");
231
+ if (examples.length) {
232
+ this.example = examples.map(
233
+ // trim trailing whitespace
234
+ function($) {
235
+ $.desc = $.desc.replace(/\s+$/, "");
236
+ return $;
237
+ }
238
+ );
239
+ }
240
+
241
+ /*t:
242
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@example This\n is an example. \n*"+"/"));
243
+ isnt(typeof sym.example[0], "undefined", "@example tag, creates sym.example array.");
244
+ is(sym.example[0], "This\n is an example.", "@example tag, desc is found.");
245
+ */
246
+
247
+ // @see
248
+ var sees = this.comment.getTag("see");
249
+ if (sees.length) {
250
+ var thisSee = this.see;
251
+ sees.map(function($){thisSee.push($.desc);});
252
+ }
253
+
254
+ /*t:
255
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@see The other thing.*"+"/"));
256
+ is(sym.see, "The other thing.", "@see tag, desc is found.");
257
+ */
258
+
259
+ // @class
260
+ var classes = this.comment.getTag("class");
261
+ if (classes.length) {
262
+ this.isa = "CONSTRUCTOR";
263
+ this.classDesc = classes[0].desc; // desc can't apply to the constructor as there is none.
264
+ }
265
+
266
+ /*t:
267
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@class This describes the class.*"+"/"));
268
+ is(sym.isa, "CONSTRUCTOR", "@class tag, makes symbol a constructor.");
269
+ is(sym.classDesc, "This describes the class.", "@class tag, class description is found.");
270
+ */
271
+
272
+ // @namespace
273
+ var namespaces = this.comment.getTag("namespace");
274
+ if (namespaces.length) {
275
+ this.classDesc = namespaces[0].desc;
276
+ this.isNamespace = true;
277
+ }
278
+
279
+ /*t:
280
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@namespace This describes the namespace.*"+"/"));
281
+ is(sym.classDesc, "This describes the namespace.", "@namespace tag, class description is found.");
282
+ */
283
+
284
+ // @param
285
+ var params = this.comment.getTag("param");
286
+ if (params.length) {
287
+ // user-defined params overwrite those with same name defined by the parser
288
+ var thisParams = this.params;
289
+
290
+ if (thisParams.length == 0) { // none exist yet, so just bung all these user-defined params straight in
291
+ this.params = params;
292
+ }
293
+ else { // need to overlay these user-defined params on to existing parser-defined params
294
+ for (var i = 0, l = params.length; i < l; i++) {
295
+ if (thisParams[i]) {
296
+ if (params[i].type) thisParams[i].type = params[i].type;
297
+ thisParams[i].name = params[i].name;
298
+ thisParams[i].desc = params[i].desc;
299
+ thisParams[i].isOptional = params[i].isOptional;
300
+ thisParams[i].defaultValue = params[i].defaultValue;
301
+ }
302
+ else thisParams[i] = params[i];
303
+ }
304
+ }
305
+ }
306
+
307
+ /*t:
308
+ var sym = new JSDOC.Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new JSDOC.DocComment("/**Description.*"+"/"));
309
+ is(sym.params.length, 1, "parser defined param is found.");
310
+
311
+ sym = new JSDOC.Symbol("foo", [], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {array} pages*"+"/"));
312
+ is(sym.params.length, 1, "user defined param is found.");
313
+ is(sym.params[0].type, "array", "user defined param type is found.");
314
+ is(sym.params[0].name, "pages", "user defined param name is found.");
315
+
316
+ sym = new JSDOC.Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {string} uid*"+"/"));
317
+ is(sym.params.length, 1, "user defined param overwrites parser defined param.");
318
+ is(sym.params[0].type, "string", "user defined param type overwrites parser defined param type.");
319
+ is(sym.params[0].name, "uid", "user defined param name overwrites parser defined param name.");
320
+
321
+ sym = new JSDOC.Symbol("foo", [{type: "array", name: "pages"}, {type: "number", name: "count"}], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {string} uid*"+"/"));
322
+ is(sym.params.length, 2, "user defined params overlay parser defined params.");
323
+ is(sym.params[1].type, "number", "user defined param type overlays parser defined param type.");
324
+ is(sym.params[1].name, "count", "user defined param name overlays parser defined param name.");
325
+
326
+ sym = new JSDOC.Symbol("foo", [], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {array} pages The pages description.*"+"/"));
327
+ is(sym.params.length, 1, "user defined param with description is found.");
328
+ is(sym.params[0].desc, "The pages description.", "user defined param description is found.");
329
+ */
330
+
331
+ // @constructor
332
+ if (this.comment.getTag("constructor").length) {
333
+ this.isa = "CONSTRUCTOR";
334
+ }
335
+
336
+ /*t:
337
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@constructor*"+"/"));
338
+ is(sym.isa, "CONSTRUCTOR", "@constructor tag, makes symbol a constructor.");
339
+ */
340
+
341
+ // @static
342
+ if (this.comment.getTag("static").length) {
343
+ this.isStatic = true;
344
+ if (this.isa == "CONSTRUCTOR") {
345
+ this.isNamespace = true;
346
+ }
347
+ }
348
+
349
+ /*t:
350
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@static\n@constructor*"+"/"));
351
+ is(sym.isStatic, true, "@static tag, makes isStatic true.");
352
+ is(sym.isNamespace, true, "@static and @constructor tag, makes isNamespace true.");
353
+ */
354
+
355
+ // @inner
356
+ if (this.comment.getTag("inner").length) {
357
+ this.isInner = true;
358
+ this.isStatic = false;
359
+ }
360
+
361
+ /*t:
362
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@inner*"+"/"));
363
+ is(sym.isStatic, false, "@inner tag, makes isStatic false.");
364
+ is(sym.isInner, true, "@inner makes isInner true.");
365
+ */
366
+
367
+ // @name
368
+ var names = this.comment.getTag("name");
369
+ if (names.length) {
370
+ this.name = names[0].desc;
371
+ }
372
+
373
+ /*t:
374
+ // todo
375
+ */
376
+
377
+ // @field
378
+ if (this.comment.getTag("field").length) {
379
+ this.isa = "OBJECT";
380
+ }
381
+
382
+ /*t:
383
+ var sym = new JSDOC.Symbol("foo", [], "FUNCTION", new JSDOC.DocComment("/**@field*"+"/"));
384
+ is(sym.isa, "OBJECT", "@field tag, makes symbol an object.");
385
+ */
386
+
387
+ // @function
388
+ if (this.comment.getTag("function").length) {
389
+ this.isa = "FUNCTION";
390
+ if (/event:/.test(this.alias)) this.isEvent = true;
391
+ }
392
+
393
+ /*t:
394
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@function*"+"/"));
395
+ is(sym.isa, "FUNCTION", "@function tag, makes symbol a function.");
396
+ */
397
+
398
+ // @event
399
+ var events = this.comment.getTag("event");
400
+ if (events.length) {
401
+ this.isa = "FUNCTION";
402
+ this.isEvent = true;
403
+ if (!/event:/.test(this.alias))
404
+ this.alias = this.alias.replace(/^(.*[.#-])([^.#-]+)$/, "$1event:$2");
405
+ }
406
+
407
+ /*t:
408
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@event*"+"/"));
409
+ is(sym.isa, "FUNCTION", "@event tag, makes symbol a function.");
410
+ is(sym.isEvent, true, "@event makes isEvent true.");
411
+ */
412
+
413
+ // @fires
414
+ var fires = this.comment.getTag("fires");
415
+ if (fires.length) {
416
+ for (var i = 0; i < fires.length; i++) {
417
+ this.fires.push(fires[i].desc);
418
+ }
419
+ }
420
+
421
+ /*t:
422
+ // todo
423
+ */
424
+
425
+ // @property
426
+ var properties = this.comment.getTag("property");
427
+ if (properties.length) {
428
+ thisProperties = this.properties;
429
+ for (var i = 0; i < properties.length; i++) {
430
+ var property = new JSDOC.Symbol(this.alias+"#"+properties[i].name, [], "OBJECT", new JSDOC.DocComment("/**"+properties[i].desc+"\n@name "+properties[i].name+"\n@memberOf "+this.alias+"#*/"));
431
+ // TODO: shouldn't the following happen in the addProperty method of Symbol?
432
+ property.name = properties[i].name;
433
+ property.memberOf = this.alias;
434
+ if (properties[i].type) property.type = properties[i].type;
435
+ if (properties[i].defaultValue) property.defaultValue = properties[i].defaultValue;
436
+ this.addProperty(property);
437
+ JSDOC.Parser.addSymbol(property);
438
+ }
439
+ }
440
+
441
+ /*t:
442
+ // todo
443
+ */
444
+
445
+ // @return
446
+ var returns = this.comment.getTag("return");
447
+ if (returns.length) { // there can be many return tags in a single doclet
448
+ this.returns = returns;
449
+ this.type = returns.map(function($){return $.type}).join(", ");
450
+ }
451
+
452
+ /*t:
453
+ // todo
454
+ */
455
+
456
+ // @exception
457
+ this.exceptions = this.comment.getTag("throws");
458
+
459
+ /*t:
460
+ // todo
461
+ */
462
+
463
+ // @requires
464
+ var requires = this.comment.getTag("requires");
465
+ if (requires.length) {
466
+ this.requires = requires.map(function($){return $.desc});
467
+ }
468
+
469
+ /*t:
470
+ // todo
471
+ */
472
+
473
+ // @type
474
+ var types = this.comment.getTag("type");
475
+ if (types.length) {
476
+ this.type = types[0].desc; //multiple type tags are ignored
477
+ }
478
+
479
+ /*t:
480
+ // todo
481
+ */
482
+
483
+ // @private
484
+ if (this.comment.getTag("private").length || this.isInner) {
485
+ this.isPrivate = true;
486
+ }
487
+
488
+ // @ignore
489
+ if (this.comment.getTag("ignore").length) {
490
+ this.isIgnored = true;
491
+ }
492
+
493
+ /*t:
494
+ // todo
495
+ */
496
+
497
+ // @inherits ... as ...
498
+ var inherits = this.comment.getTag("inherits");
499
+ if (inherits.length) {
500
+ for (var i = 0; i < inherits.length; i++) {
501
+ if (/^\s*([a-z$0-9_.#:-]+)(?:\s+as\s+([a-z$0-9_.#:-]+))?/i.test(inherits[i].desc)) {
502
+ var inAlias = RegExp.$1;
503
+ var inAs = RegExp.$2 || inAlias;
504
+
505
+ if (inAlias) inAlias = inAlias.replace(/\.prototype\.?/g, "#");
506
+
507
+ if (inAs) {
508
+ inAs = inAs.replace(/\.prototype\.?/g, "#");
509
+ inAs = inAs.replace(/^this\.?/, "#");
510
+ }
511
+
512
+ if (inAs.indexOf(inAlias) != 0) { //not a full namepath
513
+ var joiner = ".";
514
+ if (this.alias.charAt(this.alias.length-1) == "#" || inAs.charAt(0) == "#") {
515
+ joiner = "";
516
+ }
517
+ inAs = this.alias + joiner + inAs;
518
+ }
519
+ }
520
+ this.inherits.push({alias: inAlias, as: inAs});
521
+ }
522
+ }
523
+
524
+ /*t:
525
+ // todo
526
+ */
527
+
528
+ // @augments
529
+ this.augments = this.comment.getTag("augments");
530
+
531
+ // @default
532
+ var defaults = this.comment.getTag("default");
533
+ if (defaults.length) {
534
+ if (this.is("OBJECT")) {
535
+ this.defaultValue = defaults[0].desc;
536
+ }
537
+ }
538
+
539
+ /*t:
540
+ // todo
541
+ */
542
+
543
+ // @memberOf
544
+ var memberOfs = this.comment.getTag("memberOf");
545
+ if (memberOfs.length) {
546
+ this.memberOf = memberOfs[0].desc;
547
+ this.memberOf = this.memberOf.replace(/\.prototype\.?/g, "#");
548
+ }
549
+
550
+ /*t:
551
+ // todo
552
+ */
553
+
554
+ // @public
555
+ if (this.comment.getTag("public").length) {
556
+ this.isPrivate = false;
557
+ }
558
+
559
+ /*t:
560
+ // todo
561
+ */
562
+
563
+ if (JSDOC.PluginManager) {
564
+ JSDOC.PluginManager.run("onSetTags", this);
565
+ }
566
+ }
567
+
568
+ JSDOC.Symbol.prototype.is = function(what) {
569
+ return this.isa === what;
570
+ }
571
+
572
+ JSDOC.Symbol.prototype.isBuiltin = function() {
573
+ return JSDOC.Lang.isBuiltin(this.alias);
574
+ }
575
+
576
+ JSDOC.Symbol.prototype.setType = function(/**String*/comment, /**Boolean*/overwrite) {
577
+ if (!overwrite && this.type) return;
578
+ var typeComment = JSDOC.DocComment.unwrapComment(comment);
579
+ this.type = typeComment;
580
+ }
581
+
582
+ JSDOC.Symbol.prototype.inherit = function(symbol) {
583
+ if (!this.hasMember(symbol.name) && !symbol.isInner) {
584
+ if (symbol.is("FUNCTION"))
585
+ this.methods.push(symbol);
586
+ else if (symbol.is("OBJECT"))
587
+ this.properties.push(symbol);
588
+ }
589
+ }
590
+
591
+ JSDOC.Symbol.prototype.hasMember = function(name) {
592
+ return (this.hasMethod(name) || this.hasProperty(name));
593
+ }
594
+
595
+ JSDOC.Symbol.prototype.addMember = function(symbol) {
596
+ if (symbol.is("FUNCTION")) { this.addMethod(symbol); }
597
+ else if (symbol.is("OBJECT")) { this.addProperty(symbol); }
598
+ }
599
+
600
+ JSDOC.Symbol.prototype.hasMethod = function(name) {
601
+ var thisMethods = this.methods;
602
+ for (var i = 0, l = thisMethods.length; i < l; i++) {
603
+ if (thisMethods[i].name == name) return true;
604
+ if (thisMethods[i].alias == name) return true;
605
+ }
606
+ return false;
607
+ }
608
+
609
+ JSDOC.Symbol.prototype.addMethod = function(symbol) {
610
+ var methodAlias = symbol.alias;
611
+ var thisMethods = this.methods;
612
+ for (var i = 0, l = thisMethods.length; i < l; i++) {
613
+ if (thisMethods[i].alias == methodAlias) {
614
+ thisMethods[i] = symbol; // overwriting previous method
615
+ return;
616
+ }
617
+ }
618
+ thisMethods.push(symbol); // new method with this alias
619
+ }
620
+
621
+ JSDOC.Symbol.prototype.hasProperty = function(name) {
622
+ var thisProperties = this.properties;
623
+ for (var i = 0, l = thisProperties.length; i < l; i++) {
624
+ if (thisProperties[i].name == name) return true;
625
+ if (thisProperties[i].alias == name) return true;
626
+ }
627
+ return false;
628
+ }
629
+
630
+ JSDOC.Symbol.prototype.addProperty = function(symbol) {
631
+ var propertyAlias = symbol.alias;
632
+ var thisProperties = this.properties;
633
+ for (var i = 0, l = thisProperties.length; i < l; i++) {
634
+ if (thisProperties[i].alias == propertyAlias) {
635
+ thisProperties[i] = symbol; // overwriting previous property
636
+ return;
637
+ }
638
+ }
639
+
640
+ thisProperties.push(symbol); // new property with this alias
641
+ }
642
+
643
+ JSDOC.Symbol.srcFile = ""; //running reference to the current file being parsed