jsdoc-rails 0.0.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 (213) hide show
  1. data/.gitignore +8 -0
  2. data/Gemfile +5 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +94 -0
  5. data/Rakefile +29 -0
  6. data/app/controllers/jsdoc/documentation_controller.rb +48 -0
  7. data/app/helpers/jsdoc/documentation_helper.rb +50 -0
  8. data/app/models/jsdoc/borrowed_function.rb +7 -0
  9. data/app/models/jsdoc/borrowed_property.rb +7 -0
  10. data/app/models/jsdoc/example.rb +5 -0
  11. data/app/models/jsdoc/function.rb +21 -0
  12. data/app/models/jsdoc/param.rb +7 -0
  13. data/app/models/jsdoc/property.rb +13 -0
  14. data/app/models/jsdoc/require.rb +5 -0
  15. data/app/models/jsdoc/return.rb +5 -0
  16. data/app/models/jsdoc/see.rb +4 -0
  17. data/app/models/jsdoc/symbol.rb +58 -0
  18. data/app/models/jsdoc/throw.rb +4 -0
  19. data/app/views/jsdoc/documentation/_inheritance_tree_branch.html.erb +12 -0
  20. data/app/views/jsdoc/documentation/_members_table.html.erb +38 -0
  21. data/app/views/jsdoc/documentation/_param_list.html.erb +11 -0
  22. data/app/views/jsdoc/documentation/index.html.erb +7 -0
  23. data/app/views/jsdoc/documentation/source.html.erb +11 -0
  24. data/app/views/jsdoc/documentation/symbol.html.erb +111 -0
  25. data/app/views/layouts/jsdoc/_aside_symbol_list.html.erb +12 -0
  26. data/app/views/layouts/jsdoc/_header.html.erb +1 -0
  27. data/app/views/layouts/jsdoc/_symbol_tree_branch.html.erb +3 -0
  28. data/app/views/layouts/jsdoc/documentation.html.erb +44 -0
  29. data/app/views/layouts/jsdoc/documentation_wrapper.html.erb +2 -0
  30. data/config/routes.rb +8 -0
  31. data/jsdoc-rails.gemspec +25 -0
  32. data/jsdoc-toolkit/README.txt +183 -0
  33. data/jsdoc-toolkit/app/frame.js +33 -0
  34. data/jsdoc-toolkit/app/frame/Chain.js +102 -0
  35. data/jsdoc-toolkit/app/frame/Dumper.js +144 -0
  36. data/jsdoc-toolkit/app/frame/Hash.js +84 -0
  37. data/jsdoc-toolkit/app/frame/Link.js +173 -0
  38. data/jsdoc-toolkit/app/frame/Namespace.js +10 -0
  39. data/jsdoc-toolkit/app/frame/Opt.js +134 -0
  40. data/jsdoc-toolkit/app/frame/Reflection.js +26 -0
  41. data/jsdoc-toolkit/app/frame/String.js +93 -0
  42. data/jsdoc-toolkit/app/frame/Testrun.js +129 -0
  43. data/jsdoc-toolkit/app/handlers/FOODOC.js +26 -0
  44. data/jsdoc-toolkit/app/handlers/XMLDOC.js +26 -0
  45. data/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js +159 -0
  46. data/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js +16 -0
  47. data/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js +292 -0
  48. data/jsdoc-toolkit/app/lib/JSDOC.js +106 -0
  49. data/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +204 -0
  50. data/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +294 -0
  51. data/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +140 -0
  52. data/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +109 -0
  53. data/jsdoc-toolkit/app/lib/JSDOC/Lang.js +144 -0
  54. data/jsdoc-toolkit/app/lib/JSDOC/Parser.js +146 -0
  55. data/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +33 -0
  56. data/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +646 -0
  57. data/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +243 -0
  58. data/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +41 -0
  59. data/jsdoc-toolkit/app/lib/JSDOC/Token.js +18 -0
  60. data/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +332 -0
  61. data/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +133 -0
  62. data/jsdoc-toolkit/app/lib/JSDOC/Util.js +32 -0
  63. data/jsdoc-toolkit/app/lib/JSDOC/Walker.js +557 -0
  64. data/jsdoc-toolkit/app/main.js +111 -0
  65. data/jsdoc-toolkit/app/plugins/commentSrcJson.js +20 -0
  66. data/jsdoc-toolkit/app/plugins/frameworkPrototype.js +16 -0
  67. data/jsdoc-toolkit/app/plugins/functionCall.js +10 -0
  68. data/jsdoc-toolkit/app/plugins/publishSrcHilite.js +62 -0
  69. data/jsdoc-toolkit/app/plugins/symbolLink.js +10 -0
  70. data/jsdoc-toolkit/app/plugins/tagParamConfig.js +31 -0
  71. data/jsdoc-toolkit/app/plugins/tagSynonyms.js +45 -0
  72. data/jsdoc-toolkit/app/run.js +348 -0
  73. data/jsdoc-toolkit/app/t/TestDoc.js +144 -0
  74. data/jsdoc-toolkit/app/t/runner.js +13 -0
  75. data/jsdoc-toolkit/app/test.js +342 -0
  76. data/jsdoc-toolkit/app/test/addon.js +24 -0
  77. data/jsdoc-toolkit/app/test/anon_inner.js +14 -0
  78. data/jsdoc-toolkit/app/test/augments.js +31 -0
  79. data/jsdoc-toolkit/app/test/augments2.js +26 -0
  80. data/jsdoc-toolkit/app/test/borrows.js +46 -0
  81. data/jsdoc-toolkit/app/test/borrows2.js +23 -0
  82. data/jsdoc-toolkit/app/test/config.js +22 -0
  83. data/jsdoc-toolkit/app/test/constructs.js +18 -0
  84. data/jsdoc-toolkit/app/test/encoding.js +10 -0
  85. data/jsdoc-toolkit/app/test/encoding_other.js +12 -0
  86. data/jsdoc-toolkit/app/test/event.js +54 -0
  87. data/jsdoc-toolkit/app/test/exports.js +14 -0
  88. data/jsdoc-toolkit/app/test/functions_anon.js +39 -0
  89. data/jsdoc-toolkit/app/test/functions_nested.js +33 -0
  90. data/jsdoc-toolkit/app/test/global.js +13 -0
  91. data/jsdoc-toolkit/app/test/globals.js +25 -0
  92. data/jsdoc-toolkit/app/test/ignore.js +10 -0
  93. data/jsdoc-toolkit/app/test/inner.js +16 -0
  94. data/jsdoc-toolkit/app/test/jsdoc_test.js +477 -0
  95. data/jsdoc-toolkit/app/test/lend.js +33 -0
  96. data/jsdoc-toolkit/app/test/memberof.js +19 -0
  97. data/jsdoc-toolkit/app/test/memberof2.js +38 -0
  98. data/jsdoc-toolkit/app/test/memberof3.js +33 -0
  99. data/jsdoc-toolkit/app/test/memberof_constructor.js +17 -0
  100. data/jsdoc-toolkit/app/test/module.js +17 -0
  101. data/jsdoc-toolkit/app/test/multi_methods.js +25 -0
  102. data/jsdoc-toolkit/app/test/name.js +19 -0
  103. data/jsdoc-toolkit/app/test/namespace_nested.js +23 -0
  104. data/jsdoc-toolkit/app/test/nocode.js +13 -0
  105. data/jsdoc-toolkit/app/test/oblit_anon.js +20 -0
  106. data/jsdoc-toolkit/app/test/overview.js +20 -0
  107. data/jsdoc-toolkit/app/test/param_inline.js +37 -0
  108. data/jsdoc-toolkit/app/test/params_optional.js +8 -0
  109. data/jsdoc-toolkit/app/test/prototype.js +17 -0
  110. data/jsdoc-toolkit/app/test/prototype_nested.js +9 -0
  111. data/jsdoc-toolkit/app/test/prototype_oblit.js +13 -0
  112. data/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +24 -0
  113. data/jsdoc-toolkit/app/test/public.js +10 -0
  114. data/jsdoc-toolkit/app/test/scripts/code.js +5 -0
  115. data/jsdoc-toolkit/app/test/scripts/notcode.txt +5 -0
  116. data/jsdoc-toolkit/app/test/shared.js +42 -0
  117. data/jsdoc-toolkit/app/test/shared2.js +2 -0
  118. data/jsdoc-toolkit/app/test/shortcuts.js +22 -0
  119. data/jsdoc-toolkit/app/test/static_this.js +13 -0
  120. data/jsdoc-toolkit/app/test/synonyms.js +31 -0
  121. data/jsdoc-toolkit/app/test/tosource.js +23 -0
  122. data/jsdoc-toolkit/app/test/variable_redefine.js +14 -0
  123. data/jsdoc-toolkit/changes.txt +124 -0
  124. data/jsdoc-toolkit/conf/sample.conf +31 -0
  125. data/jsdoc-toolkit/java/build.xml +36 -0
  126. data/jsdoc-toolkit/java/build_1.4.xml +36 -0
  127. data/jsdoc-toolkit/java/classes/js.jar +0 -0
  128. data/jsdoc-toolkit/java/src/JsDebugRun.java +21 -0
  129. data/jsdoc-toolkit/java/src/JsRun.java +21 -0
  130. data/jsdoc-toolkit/jsdebug.jar +0 -0
  131. data/jsdoc-toolkit/jsrun.jar +0 -0
  132. data/jsdoc-toolkit/jsrun.sh +52 -0
  133. data/jsdoc-toolkit/templates/jsdoc-rails/publish.js +202 -0
  134. data/jsdoc-toolkit/templates/jsdoc-rails/seeds.tmpl +449 -0
  135. data/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +17 -0
  136. data/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +56 -0
  137. data/jsdoc-toolkit/templates/jsdoc/class.tmpl +649 -0
  138. data/jsdoc-toolkit/templates/jsdoc/index.tmpl +39 -0
  139. data/jsdoc-toolkit/templates/jsdoc/publish.js +201 -0
  140. data/jsdoc-toolkit/templates/jsdoc/static/default.css +162 -0
  141. data/jsdoc-toolkit/templates/jsdoc/static/header.html +2 -0
  142. data/jsdoc-toolkit/templates/jsdoc/static/index.html +19 -0
  143. data/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +35 -0
  144. data/lib/generators/jsdoc/jsdoc_generator.rb +71 -0
  145. data/lib/generators/jsdoc/templates/migrations/jsdoc_create_borrowed_functions_table.rb +19 -0
  146. data/lib/generators/jsdoc/templates/migrations/jsdoc_create_borrowed_properties_table.rb +19 -0
  147. data/lib/generators/jsdoc/templates/migrations/jsdoc_create_examples_table.rb +18 -0
  148. data/lib/generators/jsdoc/templates/migrations/jsdoc_create_functions_table.rb +33 -0
  149. data/lib/generators/jsdoc/templates/migrations/jsdoc_create_params_table.rb +24 -0
  150. data/lib/generators/jsdoc/templates/migrations/jsdoc_create_properties_table.rb +37 -0
  151. data/lib/generators/jsdoc/templates/migrations/jsdoc_create_requires_table.rb +16 -0
  152. data/lib/generators/jsdoc/templates/migrations/jsdoc_create_returns_table.rb +18 -0
  153. data/lib/generators/jsdoc/templates/migrations/jsdoc_create_sees_table.rb +18 -0
  154. data/lib/generators/jsdoc/templates/migrations/jsdoc_create_symbols_table.rb +31 -0
  155. data/lib/generators/jsdoc/templates/migrations/jsdoc_create_throws_table.rb +18 -0
  156. data/lib/jsdoc.rb +3 -0
  157. data/lib/jsdoc/engine.rb +30 -0
  158. data/lib/jsdoc/railties/tasks.rake +89 -0
  159. data/lib/jsdoc/version.rb +3 -0
  160. data/public/images/jsdoc/icons/class.gif +0 -0
  161. data/public/images/jsdoc/icons/cmp.gif +0 -0
  162. data/public/images/jsdoc/icons/docs.gif +0 -0
  163. data/public/images/jsdoc/icons/elbow-end.gif +0 -0
  164. data/public/images/jsdoc/icons/elbow-minus.gif +0 -0
  165. data/public/images/jsdoc/icons/elbow-plus.gif +0 -0
  166. data/public/images/jsdoc/icons/elbow.gif +0 -0
  167. data/public/images/jsdoc/icons/event.gif +0 -0
  168. data/public/images/jsdoc/icons/inherited.gif +0 -0
  169. data/public/images/jsdoc/icons/method.gif +0 -0
  170. data/public/images/jsdoc/icons/pkg.gif +0 -0
  171. data/public/images/jsdoc/icons/prop.gif +0 -0
  172. data/public/images/jsdoc/icons/static.gif +0 -0
  173. data/public/javascripts/jsdoc/jsdoc.js +52 -0
  174. data/public/stylesheets/jsdoc/documentation.css +483 -0
  175. data/test/dummy/.gitignore +4 -0
  176. data/test/dummy/Rakefile +7 -0
  177. data/test/dummy/app/controllers/application_controller.rb +3 -0
  178. data/test/dummy/app/helpers/application_helper.rb +2 -0
  179. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  180. data/test/dummy/config.ru +4 -0
  181. data/test/dummy/config/application.rb +45 -0
  182. data/test/dummy/config/boot.rb +10 -0
  183. data/test/dummy/config/database.yml +22 -0
  184. data/test/dummy/config/environment.rb +5 -0
  185. data/test/dummy/config/environments/development.rb +26 -0
  186. data/test/dummy/config/environments/production.rb +49 -0
  187. data/test/dummy/config/environments/test.rb +35 -0
  188. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  189. data/test/dummy/config/initializers/inflections.rb +10 -0
  190. data/test/dummy/config/initializers/jsdoc.rb +5 -0
  191. data/test/dummy/config/initializers/mime_types.rb +5 -0
  192. data/test/dummy/config/initializers/secret_token.rb +7 -0
  193. data/test/dummy/config/initializers/session_store.rb +8 -0
  194. data/test/dummy/config/locales/en.yml +5 -0
  195. data/test/dummy/config/routes.rb +58 -0
  196. data/test/dummy/db/.gitkeep +0 -0
  197. data/test/dummy/public/404.html +26 -0
  198. data/test/dummy/public/422.html +26 -0
  199. data/test/dummy/public/500.html +26 -0
  200. data/test/dummy/public/favicon.ico +0 -0
  201. data/test/dummy/public/javascripts/application.js +2 -0
  202. data/test/dummy/public/javascripts/controls.js +965 -0
  203. data/test/dummy/public/javascripts/dragdrop.js +974 -0
  204. data/test/dummy/public/javascripts/effects.js +1123 -0
  205. data/test/dummy/public/javascripts/prototype.js +6001 -0
  206. data/test/dummy/public/javascripts/rails.js +175 -0
  207. data/test/dummy/public/stylesheets/.gitkeep +0 -0
  208. data/test/dummy/script/rails +6 -0
  209. data/test/integration/navigation_test.rb +7 -0
  210. data/test/jsdoc_test.rb +7 -0
  211. data/test/support/integration_case.rb +5 -0
  212. data/test/test_helper.rb +22 -0
  213. metadata +297 -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,646 @@
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.count = 0;
13
+
14
+ JSDOC.Symbol.prototype.init = function() {
15
+ this._name = "";
16
+ this._params = [];
17
+ this.$args = [];
18
+ this.addOn = "";
19
+ this.alias = "";
20
+ this.augments = [];
21
+ this.author = "";
22
+ this.classDesc = "";
23
+ this.comment = {};
24
+ this.defaultValue = undefined;
25
+ this.deprecated = "";
26
+ this.desc = "";
27
+ this.example = [];
28
+ this.exceptions = [];
29
+ this.fires = [];
30
+ this.id = JSDOC.Symbol.count++;
31
+ this.inherits = [];
32
+ this.inheritsFrom = [];
33
+ this.isa = "OBJECT";
34
+ this.isConstant = false;
35
+ this.isEvent = false;
36
+ this.isIgnored = false;
37
+ this.isInner = false;
38
+ this.isNamespace = false;
39
+ this.isPrivate = false;
40
+ this.isStatic = false;
41
+ this.isReadable = true;
42
+ this.isWritable = true;
43
+ this.memberOf = "";
44
+ this.methods = [];
45
+ this.properties = [];
46
+ this.requires = [];
47
+ this.returns = [];
48
+ this.see = [];
49
+ this.since = "";
50
+ this.srcFile = {};
51
+ this.type = "";
52
+ this.version = "";
53
+ }
54
+
55
+ JSDOC.Symbol.prototype.serialize = function() {
56
+ var keys = [];
57
+ for (var p in this) {
58
+ keys.push (p);
59
+ }
60
+ keys = keys.sort();
61
+
62
+ var out = "";
63
+ for (var i in keys) {
64
+ if (typeof this[keys[i]] == "function") continue;
65
+ out += keys[i]+" => "+Dumper.dump(this[keys[i]])+",\n";
66
+ }
67
+ return "\n{\n" + out + "}\n";
68
+ }
69
+
70
+ JSDOC.Symbol.prototype.clone = function() {
71
+ var clone = new JSDOC.Symbol();
72
+ clone.populate.apply(clone, this.$args); // repopulate using the original arguments
73
+ clone.srcFile = this.srcFile; // not the current srcFile, the one when the original was made
74
+ return clone;
75
+ }
76
+
77
+ JSDOC.Symbol.prototype.__defineSetter__("name",
78
+ function(n) { n = n.replace(/^_global_[.#-]/, ""); n = n.replace(/\.prototype\.?/g, '#'); this._name = n; }
79
+ );
80
+ JSDOC.Symbol.prototype.__defineGetter__("name",
81
+ function() { return this._name; }
82
+ );
83
+ JSDOC.Symbol.prototype.__defineSetter__("params",
84
+ function(v) {
85
+ for (var i = 0, l = v.length; i < l; i++) {
86
+ if (v[i].constructor != JSDOC.DocTag) { // may be a generic object parsed from signature, like {type:..., name:...}
87
+ this._params[i] = new JSDOC.DocTag("param"+((v[i].type)?" {"+v[i].type+"}":"")+" "+v[i].name);
88
+ }
89
+ else {
90
+ this._params[i] = v[i];
91
+ }
92
+ }
93
+ }
94
+ );
95
+ JSDOC.Symbol.prototype.__defineGetter__("params",
96
+ function() { return this._params; }
97
+ );
98
+
99
+ JSDOC.Symbol.prototype.getEvents = function() {
100
+ var events = [];
101
+ for (var i = 0, l = this.methods.length; i < l; i++) {
102
+ if (this.methods[i].isEvent) {
103
+ this.methods[i].name = this.methods[i].name.replace("event:", "");
104
+ events.push(this.methods[i]);
105
+ }
106
+ }
107
+ return events;
108
+ }
109
+
110
+ JSDOC.Symbol.prototype.getMethods = function() {
111
+ var nonEvents = [];
112
+ for (var i = 0, l = this.methods.length; i < l; i++) {
113
+ if (!this.methods[i].isEvent) {
114
+ nonEvents.push(this.methods[i]);
115
+ }
116
+ }
117
+ return nonEvents;
118
+ }
119
+
120
+
121
+ JSDOC.Symbol.prototype.populate = function(
122
+ /** String */ name,
123
+ /** Object[] */ params,
124
+ /** String */ isa,
125
+ /** JSDOC.DocComment */ comment
126
+ ) {
127
+ this.$args = arguments;
128
+
129
+ this.name = name;
130
+ this.alias = this.name;
131
+
132
+ this.params = params;
133
+ this.isa = (isa == "VIRTUAL")? "OBJECT":isa;
134
+ this.comment = comment || new JSDOC.DocComment("");
135
+ this.srcFile = JSDOC.Symbol.srcFile;
136
+
137
+ if (this.is("FILE") && !this.alias) this.alias = this.srcFile;
138
+
139
+ this.setTags();
140
+
141
+ if (typeof JSDOC.PluginManager != "undefined") {
142
+ JSDOC.PluginManager.run("onSymbol", this);
143
+ }
144
+ }
145
+
146
+ JSDOC.Symbol.prototype.setTags = function() {
147
+ // @author
148
+ var authors = this.comment.getTag("author");
149
+ if (authors.length) {
150
+ this.author = authors.map(function($){return $.desc;}).join(", ");
151
+ }
152
+
153
+ /*t:
154
+ plan(34, "testing JSDOC.Symbol");
155
+
156
+ requires("../lib/JSDOC/DocComment.js");
157
+ requires("../frame/String.js");
158
+ requires("../lib/JSDOC/DocTag.js");
159
+
160
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@author Joe Smith*"+"/"));
161
+ is(sym.author, "Joe Smith", "@author tag, author is found.");
162
+ */
163
+
164
+ // @desc
165
+ var descs = this.comment.getTag("desc");
166
+ if (descs.length) {
167
+ this.desc = descs.map(function($){return $.desc;}).join("\n"); // multiple descriptions are concatenated into one
168
+ }
169
+
170
+ /*t:
171
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@desc This is a description.*"+"/"));
172
+ is(sym.desc, "This is a description.", "@desc tag, description is found.");
173
+ */
174
+
175
+ // @overview
176
+ if (this.is("FILE")) {
177
+ if (!this.alias) this.alias = this.srcFile;
178
+
179
+ var overviews = this.comment.getTag("overview");
180
+ if (overviews.length) {
181
+ this.desc = [this.desc].concat(overviews.map(function($){return $.desc;})).join("\n");
182
+ }
183
+ }
184
+
185
+ /*t:
186
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@overview This is an overview.*"+"/"));
187
+ is(sym.desc, "\nThis is an overview.", "@overview tag, description is found.");
188
+ */
189
+
190
+ // @since
191
+ var sinces = this.comment.getTag("since");
192
+ if (sinces.length) {
193
+ this.since = sinces.map(function($){return $.desc;}).join(", ");
194
+ }
195
+
196
+ /*t:
197
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@since 1.01*"+"/"));
198
+ is(sym.since, "1.01", "@since tag, description is found.");
199
+ */
200
+
201
+ // @constant
202
+ if (this.comment.getTag("constant").length) {
203
+ this.isConstant = true;
204
+ }
205
+
206
+ /*t:
207
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@constant*"+"/"));
208
+ is(sym.isConstant, true, "@constant tag, isConstant set.");
209
+ */
210
+
211
+ // @version
212
+ var versions = this.comment.getTag("version");
213
+ if (versions.length) {
214
+ this.version = versions.map(function($){return $.desc;}).join(", ");
215
+ }
216
+
217
+ /*t:
218
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@version 2.0x*"+"/"));
219
+ is(sym.version, "2.0x", "@version tag, version is found.");
220
+ */
221
+
222
+ // @deprecated
223
+ var deprecateds = this.comment.getTag("deprecated");
224
+ if (deprecateds.length) {
225
+ this.deprecated = deprecateds.map(function($){return $.desc;}).join("\n");
226
+ }
227
+
228
+ /*t:
229
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@deprecated Use other method.*"+"/"));
230
+ is(sym.deprecated, "Use other method.", "@deprecated tag, desc is found.");
231
+ */
232
+
233
+ // @example
234
+ var examples = this.comment.getTag("example");
235
+ if (examples.length) {
236
+ this.example = examples.map(
237
+ // trim trailing whitespace
238
+ function($) {
239
+ $.desc = $.desc.replace(/\s+$/, "");
240
+ return $;
241
+ }
242
+ );
243
+ }
244
+
245
+ /*t:
246
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@example This\n is an example. \n*"+"/"));
247
+ isnt(typeof sym.example[0], "undefined", "@example tag, creates sym.example array.");
248
+ is(sym.example[0], "This\n is an example.", "@example tag, desc is found.");
249
+ */
250
+
251
+ // @see
252
+ var sees = this.comment.getTag("see");
253
+ if (sees.length) {
254
+ var thisSee = this.see;
255
+ sees.map(function($){thisSee.push($.desc);});
256
+ }
257
+
258
+ /*t:
259
+ var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@see The other thing.*"+"/"));
260
+ is(sym.see, "The other thing.", "@see tag, desc is found.");
261
+ */
262
+
263
+ // @class
264
+ var classes = this.comment.getTag("class");
265
+ if (classes.length) {
266
+ this.isa = "CONSTRUCTOR";
267
+ this.classDesc = classes[0].desc; // desc can't apply to the constructor as there is none.
268
+ }
269
+
270
+ /*t:
271
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@class This describes the class.*"+"/"));
272
+ is(sym.isa, "CONSTRUCTOR", "@class tag, makes symbol a constructor.");
273
+ is(sym.classDesc, "This describes the class.", "@class tag, class description is found.");
274
+ */
275
+
276
+ // @namespace
277
+ var namespaces = this.comment.getTag("namespace");
278
+ if (namespaces.length) {
279
+ this.classDesc = namespaces[0].desc;
280
+ this.isNamespace = true;
281
+ }
282
+
283
+ /*t:
284
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@namespace This describes the namespace.*"+"/"));
285
+ is(sym.classDesc, "This describes the namespace.", "@namespace tag, class description is found.");
286
+ */
287
+
288
+ // @param
289
+ var params = this.comment.getTag("param");
290
+ if (params.length) {
291
+ // user-defined params overwrite those with same name defined by the parser
292
+ var thisParams = this.params;
293
+
294
+ if (thisParams.length == 0) { // none exist yet, so just bung all these user-defined params straight in
295
+ this.params = params;
296
+ }
297
+ else { // need to overlay these user-defined params on to existing parser-defined params
298
+ for (var i = 0, l = params.length; i < l; i++) {
299
+ if (thisParams[i]) {
300
+ if (params[i].type) thisParams[i].type = params[i].type;
301
+ thisParams[i].name = params[i].name;
302
+ thisParams[i].desc = params[i].desc;
303
+ thisParams[i].isOptional = params[i].isOptional;
304
+ thisParams[i].defaultValue = params[i].defaultValue;
305
+ }
306
+ else thisParams[i] = params[i];
307
+ }
308
+ }
309
+ }
310
+
311
+ /*t:
312
+ var sym = new JSDOC.Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new JSDOC.DocComment("/**Description.*"+"/"));
313
+ is(sym.params.length, 1, "parser defined param is found.");
314
+
315
+ sym = new JSDOC.Symbol("foo", [], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {array} pages*"+"/"));
316
+ is(sym.params.length, 1, "user defined param is found.");
317
+ is(sym.params[0].type, "array", "user defined param type is found.");
318
+ is(sym.params[0].name, "pages", "user defined param name is found.");
319
+
320
+ sym = new JSDOC.Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {string} uid*"+"/"));
321
+ is(sym.params.length, 1, "user defined param overwrites parser defined param.");
322
+ is(sym.params[0].type, "string", "user defined param type overwrites parser defined param type.");
323
+ is(sym.params[0].name, "uid", "user defined param name overwrites parser defined param name.");
324
+
325
+ sym = new JSDOC.Symbol("foo", [{type: "array", name: "pages"}, {type: "number", name: "count"}], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {string} uid*"+"/"));
326
+ is(sym.params.length, 2, "user defined params overlay parser defined params.");
327
+ is(sym.params[1].type, "number", "user defined param type overlays parser defined param type.");
328
+ is(sym.params[1].name, "count", "user defined param name overlays parser defined param name.");
329
+
330
+ sym = new JSDOC.Symbol("foo", [], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {array} pages The pages description.*"+"/"));
331
+ is(sym.params.length, 1, "user defined param with description is found.");
332
+ is(sym.params[0].desc, "The pages description.", "user defined param description is found.");
333
+ */
334
+
335
+ // @constructor
336
+ if (this.comment.getTag("constructor").length) {
337
+ this.isa = "CONSTRUCTOR";
338
+ }
339
+
340
+ /*t:
341
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@constructor*"+"/"));
342
+ is(sym.isa, "CONSTRUCTOR", "@constructor tag, makes symbol a constructor.");
343
+ */
344
+
345
+ // @static
346
+ if (this.comment.getTag("static").length) {
347
+ this.isStatic = true;
348
+ if (this.isa == "CONSTRUCTOR") {
349
+ this.isNamespace = true;
350
+ }
351
+ }
352
+
353
+ /*t:
354
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@static\n@constructor*"+"/"));
355
+ is(sym.isStatic, true, "@static tag, makes isStatic true.");
356
+ is(sym.isNamespace, true, "@static and @constructor tag, makes isNamespace true.");
357
+ */
358
+
359
+ // @inner
360
+ if (this.comment.getTag("inner").length) {
361
+ this.isInner = true;
362
+ this.isStatic = false;
363
+ }
364
+
365
+ /*t:
366
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@inner*"+"/"));
367
+ is(sym.isStatic, false, "@inner tag, makes isStatic false.");
368
+ is(sym.isInner, true, "@inner makes isInner true.");
369
+ */
370
+
371
+ // @name
372
+ var names = this.comment.getTag("name");
373
+ if (names.length) {
374
+ this.name = names[0].desc;
375
+ }
376
+
377
+ /*t:
378
+ // todo
379
+ */
380
+
381
+ // @field
382
+ if (this.comment.getTag("field").length) {
383
+ this.isa = "OBJECT";
384
+ }
385
+
386
+ /*t:
387
+ var sym = new JSDOC.Symbol("foo", [], "FUNCTION", new JSDOC.DocComment("/**@field*"+"/"));
388
+ is(sym.isa, "OBJECT", "@field tag, makes symbol an object.");
389
+ */
390
+
391
+ // @function
392
+ if (this.comment.getTag("function").length) {
393
+ this.isa = "FUNCTION";
394
+ if (/event:/.test(this.alias)) this.isEvent = true;
395
+ }
396
+
397
+ /*t:
398
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@function*"+"/"));
399
+ is(sym.isa, "FUNCTION", "@function tag, makes symbol a function.");
400
+ */
401
+
402
+ // @event
403
+ var events = this.comment.getTag("event");
404
+ if (events.length) {
405
+ this.isa = "FUNCTION";
406
+ this.isEvent = true;
407
+ if (!/event:/.test(this.alias))
408
+ this.alias = this.alias.replace(/^(.*[.#-])([^.#-]+)$/, "$1event:$2");
409
+ }
410
+
411
+ /*t:
412
+ var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@event*"+"/"));
413
+ is(sym.isa, "FUNCTION", "@event tag, makes symbol a function.");
414
+ is(sym.isEvent, true, "@event makes isEvent true.");
415
+ */
416
+
417
+ // @fires
418
+ var fires = this.comment.getTag("fires");
419
+ if (fires.length) {
420
+ for (var i = 0; i < fires.length; i++) {
421
+ this.fires.push(fires[i].desc);
422
+ }
423
+ }
424
+
425
+ /*t:
426
+ // todo
427
+ */
428
+
429
+ // @property
430
+ var properties = this.comment.getTag("property");
431
+ if (properties.length) {
432
+ thisProperties = this.properties;
433
+ for (var i = 0; i < properties.length; i++) {
434
+ var property = new JSDOC.Symbol(this.alias+"#"+properties[i].name, [], "OBJECT", new JSDOC.DocComment("/**"+properties[i].desc+"*/"));
435
+ // TODO: shouldn't the following happen in the addProperty method of Symbol?
436
+ if (properties[i].type) property.type = properties[i].type;
437
+ if (properties[i].defaultValue) property.defaultValue = properties[i].defaultValue;
438
+ this.addProperty(property);
439
+ if (!JSDOC.Parser.symbols.getSymbolByName(property.name))
440
+ JSDOC.Parser.addSymbol(property);
441
+ }
442
+ }
443
+
444
+ /*t:
445
+ // todo
446
+ */
447
+
448
+ // @return
449
+ var returns = this.comment.getTag("return");
450
+ if (returns.length) { // there can be many return tags in a single doclet
451
+ this.returns = returns;
452
+ this.type = returns.map(function($){return $.type}).join(", ");
453
+ }
454
+
455
+ /*t:
456
+ // todo
457
+ */
458
+
459
+ // @exception
460
+ this.exceptions = this.comment.getTag("throws");
461
+
462
+ /*t:
463
+ // todo
464
+ */
465
+
466
+ // @requires
467
+ var requires = this.comment.getTag("requires");
468
+ if (requires.length) {
469
+ this.requires = requires.map(function($){return $.desc});
470
+ }
471
+
472
+ /*t:
473
+ // todo
474
+ */
475
+
476
+ // @type
477
+ var types = this.comment.getTag("type");
478
+ if (types.length) {
479
+ this.type = types[0].desc; //multiple type tags are ignored
480
+ }
481
+
482
+ /*t:
483
+ // todo
484
+ */
485
+
486
+ // @private
487
+ if (this.comment.getTag("private").length || this.isInner) {
488
+ this.isPrivate = true;
489
+ }
490
+
491
+ // @ignore
492
+ if (this.comment.getTag("ignore").length) {
493
+ this.isIgnored = true;
494
+ }
495
+
496
+ /*t:
497
+ // todo
498
+ */
499
+
500
+ // @inherits ... as ...
501
+ var inherits = this.comment.getTag("inherits");
502
+ if (inherits.length) {
503
+ for (var i = 0; i < inherits.length; i++) {
504
+ if (/^\s*([a-z$0-9_.#:-]+)(?:\s+as\s+([a-z$0-9_.#:-]+))?/i.test(inherits[i].desc)) {
505
+ var inAlias = RegExp.$1;
506
+ var inAs = RegExp.$2 || inAlias;
507
+
508
+ if (inAlias) inAlias = inAlias.replace(/\.prototype\.?/g, "#");
509
+
510
+ if (inAs) {
511
+ inAs = inAs.replace(/\.prototype\.?/g, "#");
512
+ inAs = inAs.replace(/^this\.?/, "#");
513
+ }
514
+
515
+ if (inAs.indexOf(inAlias) != 0) { //not a full namepath
516
+ var joiner = ".";
517
+ if (this.alias.charAt(this.alias.length-1) == "#" || inAs.charAt(0) == "#") {
518
+ joiner = "";
519
+ }
520
+ inAs = this.alias + joiner + inAs;
521
+ }
522
+ }
523
+ this.inherits.push({alias: inAlias, as: inAs});
524
+ }
525
+ }
526
+
527
+ /*t:
528
+ // todo
529
+ */
530
+
531
+ // @augments
532
+ this.augments = this.comment.getTag("augments");
533
+
534
+ // @default
535
+ var defaults = this.comment.getTag("default");
536
+ if (defaults.length) {
537
+ if (this.is("OBJECT")) {
538
+ this.defaultValue = defaults[0].desc;
539
+ }
540
+ }
541
+
542
+ /*t:
543
+ // todo
544
+ */
545
+
546
+ // @memberOf
547
+ var memberOfs = this.comment.getTag("memberOf");
548
+ if (memberOfs.length) {
549
+ this.memberOf = memberOfs[0].desc;
550
+ this.memberOf = this.memberOf.replace(/\.prototype\.?/g, "#");
551
+ }
552
+
553
+ /*t:
554
+ // todo
555
+ */
556
+
557
+ // @public
558
+ if (this.comment.getTag("public").length) {
559
+ this.isPrivate = false;
560
+ }
561
+
562
+ /*t:
563
+ // todo
564
+ */
565
+
566
+ if (JSDOC.PluginManager) {
567
+ JSDOC.PluginManager.run("onSetTags", this);
568
+ }
569
+ }
570
+
571
+ JSDOC.Symbol.prototype.is = function(what) {
572
+ return this.isa === what;
573
+ }
574
+
575
+ JSDOC.Symbol.prototype.isBuiltin = function() {
576
+ return JSDOC.Lang.isBuiltin(this.alias);
577
+ }
578
+
579
+ JSDOC.Symbol.prototype.setType = function(/**String*/comment, /**Boolean*/overwrite) {
580
+ if (!overwrite && this.type) return;
581
+ var typeComment = JSDOC.DocComment.unwrapComment(comment);
582
+ this.type = typeComment;
583
+ }
584
+
585
+ JSDOC.Symbol.prototype.inherit = function(symbol) {
586
+ if (!this.hasMember(symbol.name) && !symbol.isInner) {
587
+ if (symbol.is("FUNCTION"))
588
+ this.methods.push(symbol);
589
+ else if (symbol.is("OBJECT"))
590
+ this.properties.push(symbol);
591
+ }
592
+ }
593
+
594
+ JSDOC.Symbol.prototype.hasMember = function(name) {
595
+ return (this.hasMethod(name) || this.hasProperty(name));
596
+ }
597
+
598
+ JSDOC.Symbol.prototype.addMember = function(symbol) {
599
+ if (symbol.is("FUNCTION")) { this.addMethod(symbol); }
600
+ else if (symbol.is("OBJECT")) { this.addProperty(symbol); }
601
+ }
602
+
603
+ JSDOC.Symbol.prototype.hasMethod = function(name) {
604
+ var thisMethods = this.methods;
605
+ for (var i = 0, l = thisMethods.length; i < l; i++) {
606
+ if (thisMethods[i].name == name) return true;
607
+ if (thisMethods[i].alias == name) return true;
608
+ }
609
+ return false;
610
+ }
611
+
612
+ JSDOC.Symbol.prototype.addMethod = function(symbol) {
613
+ var methodAlias = symbol.alias;
614
+ var thisMethods = this.methods;
615
+ for (var i = 0, l = thisMethods.length; i < l; i++) {
616
+ if (thisMethods[i].alias == methodAlias) {
617
+ thisMethods[i] = symbol; // overwriting previous method
618
+ return;
619
+ }
620
+ }
621
+ thisMethods.push(symbol); // new method with this alias
622
+ }
623
+
624
+ JSDOC.Symbol.prototype.hasProperty = function(name) {
625
+ var thisProperties = this.properties;
626
+ for (var i = 0, l = thisProperties.length; i < l; i++) {
627
+ if (thisProperties[i].name == name) return true;
628
+ if (thisProperties[i].alias == name) return true;
629
+ }
630
+ return false;
631
+ }
632
+
633
+ JSDOC.Symbol.prototype.addProperty = function(symbol) {
634
+ var propertyAlias = symbol.alias;
635
+ var thisProperties = this.properties;
636
+ for (var i = 0, l = thisProperties.length; i < l; i++) {
637
+ if (thisProperties[i].alias == propertyAlias) {
638
+ thisProperties[i] = symbol; // overwriting previous property
639
+ return;
640
+ }
641
+ }
642
+
643
+ thisProperties.push(symbol); // new property with this alias
644
+ }
645
+
646
+ JSDOC.Symbol.srcFile = ""; //running reference to the current file being parsed