yard 0.2.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yard might be problematic. Click here for more details.

Files changed (365) hide show
  1. data/.yardopts +12 -10
  2. data/ChangeLog +5686 -0
  3. data/{README.markdown → README.md} +65 -11
  4. data/Rakefile +25 -13
  5. data/benchmarks/concat_vs_join.rb +12 -0
  6. data/benchmarks/erb_vs_erubis.rb +14 -14
  7. data/benchmarks/marshal_vs_dbm.rb +1 -1
  8. data/benchmarks/pathname_vs_string.rb +50 -0
  9. data/benchmarks/template_erb.rb +22 -0
  10. data/benchmarks/template_format.rb +6 -0
  11. data/benchmarks/template_profile.rb +17 -0
  12. data/bin/yri +16 -7
  13. data/docs/{CODE_OBJECTS.markdown → CodeObjects.md} +0 -0
  14. data/docs/{GETTING_STARTED.markdown → GettingStarted.md} +49 -11
  15. data/docs/{GLOSSARY.markdown → Glossary.md} +0 -0
  16. data/docs/{HANDLERS.markdown → Handlers.md} +5 -5
  17. data/docs/{OVERVIEW.markdown → Overview.md} +9 -13
  18. data/docs/{PARSER.markdown → Parser.md} +1 -1
  19. data/docs/{TAGS.markdown → Tags.md} +1 -1
  20. data/docs/Templates.md +286 -0
  21. data/docs/{WHATSNEW.markdown → WhatsNew.md} +82 -2
  22. data/lib/rubygems_plugin.rb +17 -20
  23. data/lib/yard.rb +47 -1
  24. data/lib/yard/autoload.rb +38 -47
  25. data/lib/yard/cli/yard_graph.rb +36 -13
  26. data/lib/yard/cli/yardoc.rb +74 -12
  27. data/lib/yard/code_objects/base.rb +182 -14
  28. data/lib/yard/code_objects/class_object.rb +39 -2
  29. data/lib/yard/code_objects/class_variable_object.rb +4 -0
  30. data/lib/yard/code_objects/constant_object.rb +8 -0
  31. data/lib/yard/code_objects/extended_method_object.rb +14 -0
  32. data/lib/yard/code_objects/method_object.rb +60 -2
  33. data/lib/yard/code_objects/module_object.rb +6 -0
  34. data/lib/yard/code_objects/namespace_object.rb +99 -2
  35. data/lib/yard/code_objects/proxy.rb +53 -6
  36. data/lib/yard/code_objects/root_object.rb +2 -0
  37. data/lib/yard/core_ext/array.rb +61 -0
  38. data/lib/yard/core_ext/file.rb +21 -4
  39. data/lib/yard/core_ext/module.rb +11 -1
  40. data/lib/yard/core_ext/string.rb +13 -2
  41. data/lib/yard/core_ext/symbol_hash.rb +51 -3
  42. data/lib/yard/docstring.rb +68 -19
  43. data/lib/yard/globals.rb +5 -2
  44. data/lib/yard/handlers/base.rb +13 -3
  45. data/lib/yard/handlers/processor.rb +64 -2
  46. data/lib/yard/handlers/ruby/class_handler.rb +1 -1
  47. data/lib/yard/handlers/ruby/class_variable_handler.rb +5 -1
  48. data/lib/yard/handlers/ruby/constant_handler.rb +38 -4
  49. data/lib/yard/handlers/ruby/exception_handler.rb +1 -0
  50. data/lib/yard/handlers/ruby/legacy/base.rb +2 -2
  51. data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +6 -3
  52. data/lib/yard/handlers/ruby/legacy/constant_handler.rb +21 -2
  53. data/lib/yard/handlers/ruby/legacy/method_handler.rb +10 -0
  54. data/lib/yard/handlers/ruby/legacy/yield_handler.rb +2 -1
  55. data/lib/yard/handlers/ruby/method_handler.rb +10 -0
  56. data/lib/yard/handlers/ruby/yield_handler.rb +2 -1
  57. data/lib/yard/logging.rb +17 -0
  58. data/lib/yard/parser/ruby/ast_node.rb +101 -0
  59. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +2 -2
  60. data/lib/yard/parser/ruby/legacy/statement_list.rb +10 -9
  61. data/lib/yard/parser/ruby/ruby_parser.rb +32 -3
  62. data/lib/yard/parser/source_parser.rb +82 -5
  63. data/lib/yard/rake/yardoc_task.rb +38 -3
  64. data/lib/yard/registry.rb +112 -2
  65. data/lib/yard/serializers/base.rb +48 -1
  66. data/lib/yard/serializers/file_system_serializer.rb +23 -2
  67. data/lib/yard/serializers/process_serializer.rb +10 -0
  68. data/lib/yard/serializers/stdout_serializer.rb +11 -0
  69. data/lib/yard/tags/library.rb +4 -1
  70. data/lib/yard/tags/overload_tag.rb +3 -12
  71. data/lib/yard/templates/engine.rb +162 -0
  72. data/lib/yard/{generators → templates}/helpers/base_helper.rb +14 -13
  73. data/lib/yard/{generators → templates}/helpers/filter_helper.rb +1 -1
  74. data/lib/yard/templates/helpers/html_helper.rb +287 -0
  75. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +29 -0
  76. data/lib/yard/templates/helpers/html_syntax_highlight_helper18.rb +27 -0
  77. data/lib/yard/{generators → templates}/helpers/markup_helper.rb +15 -11
  78. data/lib/yard/{generators → templates}/helpers/method_helper.rb +8 -1
  79. data/lib/yard/templates/helpers/module_helper.rb +15 -0
  80. data/lib/yard/templates/helpers/text_helper.rb +60 -0
  81. data/lib/yard/templates/helpers/uml_helper.rb +33 -0
  82. data/lib/yard/templates/template.rb +355 -0
  83. data/lib/yard/verifier.rb +110 -0
  84. data/spec/cli/yardoc_spec.rb +23 -1
  85. data/spec/code_objects/base_spec.rb +8 -0
  86. data/spec/code_objects/class_object_spec.rb +166 -156
  87. data/spec/code_objects/method_object_spec.rb +2 -2
  88. data/spec/code_objects/module_object_spec.rb +112 -110
  89. data/spec/code_objects/proxy_spec.rb +9 -0
  90. data/spec/core_ext/array_spec.rb +33 -0
  91. data/spec/core_ext/file_spec.rb +40 -12
  92. data/spec/core_ext/module_spec.rb +15 -0
  93. data/spec/core_ext/string_spec.rb +10 -2
  94. data/spec/docstring_spec.rb +157 -135
  95. data/spec/handlers/class_handler_spec.rb +3 -0
  96. data/spec/handlers/class_variable_handler_spec.rb +3 -1
  97. data/spec/handlers/constant_handler_spec.rb +38 -0
  98. data/spec/handlers/examples/class_handler_001.rb.txt +14 -1
  99. data/spec/handlers/examples/class_variable_handler_001.rb.txt +1 -0
  100. data/spec/handlers/examples/constant_handler_001.rb.txt +10 -1
  101. data/spec/handlers/examples/exception_handler_001.rb.txt +5 -0
  102. data/spec/handlers/examples/method_handler_001.rb.txt +15 -0
  103. data/spec/handlers/examples/mixin_handler_001.rb.txt +13 -0
  104. data/spec/handlers/exception_handler_spec.rb +4 -0
  105. data/spec/handlers/method_handler_spec.rb +22 -0
  106. data/spec/handlers/mixin_handler_spec.rb +5 -3
  107. data/spec/handlers/yield_handler_spec.rb +1 -1
  108. data/spec/parser/ruby/ast_node_spec.rb +16 -0
  109. data/spec/parser/ruby/legacy/statement_list_spec.rb +36 -0
  110. data/spec/parser/ruby/ruby_parser_spec.rb +80 -0
  111. data/spec/parser/source_parser_spec.rb +48 -2
  112. data/spec/rake/yardoc_task_spec.rb +62 -25
  113. data/spec/serializers/file_system_serializer_spec.rb +1 -1
  114. data/spec/templates/class_spec.rb +34 -0
  115. data/spec/templates/engine_spec.rb +121 -0
  116. data/spec/templates/examples/class001.html +271 -0
  117. data/spec/templates/examples/class001.txt +31 -0
  118. data/spec/templates/examples/method001.html +96 -0
  119. data/spec/templates/examples/method001.txt +28 -0
  120. data/spec/templates/examples/method002.html +81 -0
  121. data/spec/templates/examples/method002.txt +20 -0
  122. data/spec/templates/examples/method003.html +137 -0
  123. data/spec/templates/examples/method003.txt +45 -0
  124. data/spec/templates/examples/module001.dot +31 -0
  125. data/spec/templates/examples/module001.html +294 -0
  126. data/spec/templates/examples/module001.txt +33 -0
  127. data/spec/templates/examples/tag001.txt +82 -0
  128. data/spec/templates/helpers/base_helper_spec.rb +129 -0
  129. data/spec/{generators → templates}/helpers/html_helper_spec.rb +73 -16
  130. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +39 -0
  131. data/spec/{generators → templates}/helpers/markup_helper_spec.rb +6 -7
  132. data/spec/templates/method_spec.rb +75 -0
  133. data/spec/templates/module_spec.rb +50 -0
  134. data/spec/templates/spec_helper.rb +33 -0
  135. data/spec/templates/tag_spec.rb +39 -0
  136. data/spec/templates/template_spec.rb +398 -0
  137. data/spec/verifier_spec.rb +51 -0
  138. data/spec/yard_spec.rb +46 -0
  139. data/templates/default/class/dot/setup.rb +6 -0
  140. data/templates/default/class/dot/superklass.erb +3 -0
  141. data/templates/default/class/html/constructor_details.erb +8 -0
  142. data/templates/default/class/html/setup.rb +1 -0
  143. data/templates/default/class/html/subclasses.erb +4 -0
  144. data/templates/default/class/setup.rb +29 -0
  145. data/templates/default/class/text/setup.rb +11 -0
  146. data/templates/default/class/text/subclasses.erb +5 -0
  147. data/templates/default/docstring/html/abstract.erb +4 -0
  148. data/templates/default/docstring/html/deprecated.erb +1 -0
  149. data/templates/default/docstring/html/index.erb +5 -0
  150. data/templates/default/docstring/html/note.erb +6 -0
  151. data/templates/default/docstring/html/text.erb +1 -0
  152. data/templates/default/docstring/html/todo.erb +6 -0
  153. data/templates/default/docstring/setup.rb +39 -0
  154. data/templates/default/docstring/text/abstract.erb +2 -0
  155. data/templates/default/docstring/text/deprecated.erb +2 -0
  156. data/templates/default/docstring/text/index.erb +2 -0
  157. data/templates/default/docstring/text/note.erb +4 -0
  158. data/templates/default/docstring/text/text.erb +1 -0
  159. data/templates/default/docstring/text/todo.erb +4 -0
  160. data/templates/default/fulldoc/html/css/common.css +1 -0
  161. data/templates/default/fulldoc/html/css/full_list.css +23 -0
  162. data/templates/default/fulldoc/html/css/style.css +261 -0
  163. data/templates/default/fulldoc/html/full_list.erb +36 -0
  164. data/templates/default/fulldoc/html/js/app.js +91 -0
  165. data/templates/default/fulldoc/html/js/full_list.js +39 -0
  166. data/templates/default/fulldoc/html/js/jquery.js +19 -0
  167. data/templates/default/fulldoc/html/setup.rb +86 -0
  168. data/templates/default/{uml → layout}/dot/header.erb +2 -2
  169. data/templates/default/layout/dot/setup.rb +14 -0
  170. data/templates/default/layout/html/breadcrumb.erb +11 -0
  171. data/templates/default/layout/html/footer.erb +5 -0
  172. data/templates/default/layout/html/headers.erb +13 -0
  173. data/templates/default/layout/html/index.erb +49 -0
  174. data/templates/default/layout/html/layout.erb +20 -0
  175. data/templates/default/layout/html/search.erb +5 -0
  176. data/templates/default/layout/html/setup.rb +58 -0
  177. data/templates/default/method/html/header.erb +14 -3
  178. data/templates/default/method/setup.rb +3 -0
  179. data/templates/default/method/text/header.erb +1 -1
  180. data/templates/default/method_details/html/header.erb +3 -0
  181. data/templates/default/method_details/html/method_signature.erb +17 -0
  182. data/templates/default/method_details/html/source.erb +10 -0
  183. data/templates/default/method_details/setup.rb +8 -0
  184. data/templates/default/method_details/text/header.erb +10 -0
  185. data/templates/default/method_details/text/method_signature.erb +12 -0
  186. data/templates/default/method_details/text/setup.rb +10 -0
  187. data/templates/default/module/dot/child.erb +1 -0
  188. data/templates/default/module/dot/dependencies.erb +3 -0
  189. data/templates/default/{uml/dot/subgraph.erb → module/dot/header.erb} +3 -3
  190. data/templates/default/{uml → module}/dot/info.erb +4 -4
  191. data/templates/default/module/dot/setup.rb +14 -0
  192. data/templates/default/module/html/attribute_details.erb +11 -0
  193. data/templates/default/module/html/attribute_summary.erb +8 -0
  194. data/templates/default/module/html/box_info.erb +32 -0
  195. data/templates/default/module/html/children.erb +8 -0
  196. data/templates/default/module/html/constant_summary.erb +13 -0
  197. data/templates/default/module/html/defines.erb +3 -0
  198. data/templates/default/module/html/header.erb +4 -4
  199. data/templates/default/module/html/inherited_constants.erb +8 -0
  200. data/templates/default/module/html/inherited_methods.erb +9 -0
  201. data/templates/default/module/html/item_summary.erb +20 -0
  202. data/templates/default/module/html/method_details_list.erb +8 -0
  203. data/templates/default/module/html/method_summary.erb +8 -0
  204. data/templates/default/module/html/methodmissing.erb +12 -0
  205. data/templates/default/module/html/pre_docstring.erb +1 -0
  206. data/templates/default/module/setup.rb +83 -0
  207. data/templates/default/module/text/children.erb +10 -0
  208. data/templates/default/module/text/class_meths_list.erb +8 -0
  209. data/templates/default/module/text/extends.erb +8 -0
  210. data/templates/default/module/text/header.erb +7 -0
  211. data/templates/default/module/text/includes.erb +8 -0
  212. data/templates/default/module/text/instance_meths_list.erb +8 -0
  213. data/templates/default/module/text/setup.rb +12 -0
  214. data/templates/default/root/dot/child.erb +3 -0
  215. data/templates/default/root/dot/setup.rb +5 -0
  216. data/templates/default/tags/html/example.erb +5 -16
  217. data/templates/default/tags/html/index.erb +3 -0
  218. data/templates/default/tags/html/option.erb +17 -20
  219. data/templates/default/tags/html/overload.erb +13 -0
  220. data/templates/default/tags/html/see.erb +5 -10
  221. data/templates/default/tags/html/tag.erb +20 -0
  222. data/templates/default/tags/setup.rb +50 -0
  223. data/templates/default/tags/text/example.erb +8 -10
  224. data/templates/default/tags/text/index.erb +1 -0
  225. data/templates/default/tags/text/option.erb +18 -3
  226. data/templates/default/tags/text/overload.erb +19 -0
  227. data/templates/default/tags/text/see.erb +8 -2
  228. data/templates/default/tags/text/tag.erb +13 -0
  229. metadata +142 -158
  230. data/bin/view_generator +0 -17
  231. data/docs/FAQ.markdown +0 -34
  232. data/docs/GENERATORS.markdown +0 -211
  233. data/lib/yard/generators/attributes_generator.rb +0 -22
  234. data/lib/yard/generators/base.rb +0 -305
  235. data/lib/yard/generators/class_generator.rb +0 -27
  236. data/lib/yard/generators/constants_generator.rb +0 -74
  237. data/lib/yard/generators/constructor_generator.rb +0 -25
  238. data/lib/yard/generators/deprecated_generator.rb +0 -15
  239. data/lib/yard/generators/docstring_generator.rb +0 -15
  240. data/lib/yard/generators/full_doc_generator.rb +0 -127
  241. data/lib/yard/generators/helpers/html_helper.rb +0 -196
  242. data/lib/yard/generators/helpers/html_syntax_highlight_helper.rb +0 -49
  243. data/lib/yard/generators/helpers/uml_helper.rb +0 -16
  244. data/lib/yard/generators/inheritance_generator.rb +0 -16
  245. data/lib/yard/generators/method_details_generator.rb +0 -18
  246. data/lib/yard/generators/method_generator.rb +0 -43
  247. data/lib/yard/generators/method_listing_generator.rb +0 -105
  248. data/lib/yard/generators/method_missing_generator.rb +0 -25
  249. data/lib/yard/generators/method_signature_generator.rb +0 -19
  250. data/lib/yard/generators/method_summary_generator.rb +0 -21
  251. data/lib/yard/generators/mixins_generator.rb +0 -21
  252. data/lib/yard/generators/module_generator.rb +0 -23
  253. data/lib/yard/generators/overloads_generator.rb +0 -20
  254. data/lib/yard/generators/quick_doc_generator.rb +0 -25
  255. data/lib/yard/generators/root_generator.rb +0 -32
  256. data/lib/yard/generators/source_generator.rb +0 -11
  257. data/lib/yard/generators/tags_generator.rb +0 -99
  258. data/lib/yard/generators/uml_generator.rb +0 -102
  259. data/lib/yard/generators/visibility_group_generator.rb +0 -26
  260. data/spec/generators/base_spec.rb +0 -64
  261. data/spec/generators/full_doc_generator_spec.rb +0 -29
  262. data/spec/generators/helpers/base_helper_spec.rb +0 -15
  263. data/spec/generators/quick_doc_generator_spec.rb +0 -13
  264. data/templates/default/attributes/html/header.erb +0 -47
  265. data/templates/default/attributes/text/header.erb +0 -10
  266. data/templates/default/class/html/header.erb +0 -4
  267. data/templates/default/constants/html/constants.erb +0 -9
  268. data/templates/default/constants/html/header.erb +0 -3
  269. data/templates/default/constants/html/included.erb +0 -9
  270. data/templates/default/constants/html/inherited.erb +0 -9
  271. data/templates/default/constructor/html/header.erb +0 -10
  272. data/templates/default/deprecated/html/main.erb +0 -6
  273. data/templates/default/deprecated/text/main.erb +0 -3
  274. data/templates/default/docstring/html/main.erb +0 -3
  275. data/templates/default/docstring/text/main.erb +0 -3
  276. data/templates/default/fulldoc/html/all_files.erb +0 -19
  277. data/templates/default/fulldoc/html/all_methods.erb +0 -26
  278. data/templates/default/fulldoc/html/all_namespaces.erb +0 -22
  279. data/templates/default/fulldoc/html/app.js +0 -18
  280. data/templates/default/fulldoc/html/custom.css +0 -1
  281. data/templates/default/fulldoc/html/file.erb +0 -16
  282. data/templates/default/fulldoc/html/footer.erb +0 -5
  283. data/templates/default/fulldoc/html/header.erb +0 -16
  284. data/templates/default/fulldoc/html/html_head.erb +0 -4
  285. data/templates/default/fulldoc/html/index.erb +0 -19
  286. data/templates/default/fulldoc/html/jquery.js +0 -11
  287. data/templates/default/fulldoc/html/style.css +0 -81
  288. data/templates/default/fulldoc/html/syntax_highlight.css +0 -24
  289. data/templates/default/inheritance/html/header.erb +0 -8
  290. data/templates/default/inheritance/text/header.erb +0 -3
  291. data/templates/default/method/html/aliases.erb +0 -6
  292. data/templates/default/method/html/title.erb +0 -3
  293. data/templates/default/method/text/title.erb +0 -1
  294. data/templates/default/methoddetails/html/header.erb +0 -8
  295. data/templates/default/methoddetails/html/method_header.erb +0 -3
  296. data/templates/default/methodmissing/html/header.erb +0 -12
  297. data/templates/default/methodsignature/html/main.erb +0 -10
  298. data/templates/default/methodsignature/text/main.erb +0 -8
  299. data/templates/default/methodsummary/html/header.erb +0 -5
  300. data/templates/default/methodsummary/html/included.erb +0 -9
  301. data/templates/default/methodsummary/html/inherited.erb +0 -9
  302. data/templates/default/methodsummary/html/summary.erb +0 -29
  303. data/templates/default/methodsummary/text/header.erb +0 -5
  304. data/templates/default/methodsummary/text/included.erb +0 -0
  305. data/templates/default/methodsummary/text/inherited.erb +0 -0
  306. data/templates/default/methodsummary/text/summary.erb +0 -6
  307. data/templates/default/mixins/html/header.erb +0 -4
  308. data/templates/default/overloads/html/header.erb +0 -8
  309. data/templates/default/overloads/text/header.erb +0 -8
  310. data/templates/default/quickdoc/html/header.erb +0 -15
  311. data/templates/default/quickdoc/text/header.erb +0 -12
  312. data/templates/default/root/html/header.erb +0 -4
  313. data/templates/default/source/html/main.erb +0 -15
  314. data/templates/default/source/text/main.erb +0 -4
  315. data/templates/default/tags/html/header.erb +0 -4
  316. data/templates/default/tags/html/param.erb +0 -21
  317. data/templates/default/tags/html/tags.erb +0 -23
  318. data/templates/default/tags/html/todo.erb +0 -8
  319. data/templates/default/tags/text/header.erb +0 -3
  320. data/templates/default/tags/text/param.erb +0 -9
  321. data/templates/default/tags/text/tags.erb +0 -7
  322. data/templates/default/uml/dot/child.erb +0 -1
  323. data/templates/default/uml/dot/dependencies.erb +0 -10
  324. data/templates/default/uml/dot/superclasses.erb +0 -9
  325. data/templates/default/uml/dot/unknown.erb +0 -3
  326. data/templates/default/uml/dot/unknown_child.erb +0 -1
  327. data/templates/default/visibilitygroup/html/header.erb +0 -6
  328. data/templates/javadoc/attributes/html/header.erb +0 -16
  329. data/templates/javadoc/class/html/header.erb +0 -4
  330. data/templates/javadoc/constants/html/constants.erb +0 -9
  331. data/templates/javadoc/constants/html/header.erb +0 -3
  332. data/templates/javadoc/constants/html/included.erb +0 -12
  333. data/templates/javadoc/constants/html/inherited.erb +0 -12
  334. data/templates/javadoc/constructor/html/header.erb +0 -10
  335. data/templates/javadoc/deprecated/html/main.erb +0 -0
  336. data/templates/javadoc/docstring/html/main.erb +0 -6
  337. data/templates/javadoc/fulldoc/html/all_methods.erb +0 -25
  338. data/templates/javadoc/fulldoc/html/all_namespaces.erb +0 -19
  339. data/templates/javadoc/fulldoc/html/app.js +0 -18
  340. data/templates/javadoc/fulldoc/html/header.erb +0 -15
  341. data/templates/javadoc/fulldoc/html/html_head.erb +0 -3
  342. data/templates/javadoc/fulldoc/html/index.erb +0 -18
  343. data/templates/javadoc/fulldoc/html/jquery.js +0 -11
  344. data/templates/javadoc/fulldoc/html/readme.erb +0 -15
  345. data/templates/javadoc/fulldoc/html/style.css +0 -22
  346. data/templates/javadoc/fulldoc/html/syntax_highlight.css +0 -21
  347. data/templates/javadoc/inheritance/html/header.erb +0 -6
  348. data/templates/javadoc/method/html/aliases.erb +0 -6
  349. data/templates/javadoc/method/html/header.erb +0 -4
  350. data/templates/javadoc/method/html/title.erb +0 -4
  351. data/templates/javadoc/methoddetails/html/header.erb +0 -8
  352. data/templates/javadoc/methoddetails/html/method_header.erb +0 -0
  353. data/templates/javadoc/methodmissing/html/header.erb +0 -12
  354. data/templates/javadoc/methodsignature/html/main.erb +0 -8
  355. data/templates/javadoc/methodsummary/html/header.erb +0 -5
  356. data/templates/javadoc/methodsummary/html/included.erb +0 -12
  357. data/templates/javadoc/methodsummary/html/inherited.erb +0 -12
  358. data/templates/javadoc/methodsummary/html/summary.erb +0 -25
  359. data/templates/javadoc/mixins/html/header.erb +0 -5
  360. data/templates/javadoc/module/html/header.erb +0 -4
  361. data/templates/javadoc/source/html/main.erb +0 -15
  362. data/templates/javadoc/tags/html/header.erb +0 -5
  363. data/templates/javadoc/tags/html/see.erb +0 -8
  364. data/templates/javadoc/tags/html/tags.erb +0 -19
  365. data/templates/javadoc/visibilitygroup/html/header.erb +0 -5
@@ -0,0 +1,29 @@
1
+ module YARD
2
+ module Templates
3
+ module Helpers
4
+ module HtmlSyntaxHighlightHelper
5
+ def html_syntax_highlight(source)
6
+ return "" unless source
7
+ return source if options[:no_highlight]
8
+ tokenlist = Parser::Ruby::RubyParser.parse(source, "(syntax_highlight)").tokens
9
+ output = ""
10
+ tokenlist.each do |s|
11
+ output << "<span class='tstring'>" if [:tstring_beg, :regexp_beg].include?(s[0])
12
+ case s.first
13
+ when :nl, :ignored_nl, :sp
14
+ output << h(s.last)
15
+ when :ident
16
+ output << "<span class='id #{h(s.last)}'>#{h(s.last)}</span>"
17
+ else
18
+ output << "<span class='#{s.first}'>#{h(s.last)}</span>"
19
+ end
20
+ output << "</span>" if [:tstring_end, :regexp_end].include?(s[0])
21
+ end
22
+ output
23
+ rescue Parser::ParserSyntaxError
24
+ h(source)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ module YARD
2
+ module Templates
3
+ module Helpers
4
+ module HtmlSyntaxHighlightHelper
5
+ def html_syntax_highlight(source)
6
+ return "" unless source
7
+ return source if options[:no_highlight]
8
+ tokenlist = Parser::Ruby::Legacy::TokenList.new(source)
9
+ tokenlist.map do |s|
10
+ prettyclass = s.class.class_name.sub(/^Tk/, '').downcase
11
+ prettysuper = s.class.superclass.class_name.sub(/^Tk/, '').downcase
12
+
13
+ case s
14
+ when Parser::Ruby::Legacy::RubyToken::TkWhitespace, Parser::Ruby::Legacy::RubyToken::TkUnknownChar
15
+ h s.text
16
+ when Parser::Ruby::Legacy::RubyToken::TkId
17
+ prettyval = h(s.text)
18
+ "<span class='#{prettyval} #{prettyclass} #{prettysuper}'>#{prettyval}</span>"
19
+ else
20
+ "<span class='#{prettyclass} #{prettysuper}'>#{h s.text}</span>"
21
+ end
22
+ end.join
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,14 +1,7 @@
1
- if RUBY19
2
- require 'rdoc/markup'
3
- require 'rdoc/markup/to_html'
4
- else
5
- require 'rdoc/markup/simple_markup'
6
- require 'rdoc/markup/simple_markup/to_html'
7
- require 'rubygems'
8
- end
1
+ require 'rubygems'
9
2
 
10
3
  module YARD
11
- module Generators::Helpers
4
+ module Templates::Helpers
12
5
  module MarkupHelper
13
6
  MARKUP_PROVIDERS = {
14
7
  :markdown => [
@@ -21,8 +14,19 @@ module YARD
21
14
  {:lib => :redcloth, :const => 'RedCloth'}
22
15
  ]
23
16
  }
24
-
25
- SimpleMarkup = RUBY19 ? RDoc::Markup.new : SM::SimpleMarkup.new
17
+
18
+ begin
19
+ require 'rdoc/markup'
20
+ require 'rdoc/markup/to_html'
21
+ SimpleMarkup = RDoc::Markup.new
22
+ rescue Gem::LoadError
23
+ raise
24
+ rescue LoadError
25
+ require 'rubygems'
26
+ require 'rdoc/markup/simple_markup'
27
+ require 'rdoc/markup/simple_markup/to_html'
28
+ SimpleMarkup = SM::SimpleMarkup.new
29
+ end
26
30
 
27
31
  private
28
32
 
@@ -1,5 +1,5 @@
1
1
  module YARD
2
- module Generators::Helpers
2
+ module Templates::Helpers
3
3
  module MethodHelper
4
4
  def format_args(object)
5
5
  unless object.parameters.empty?
@@ -25,6 +25,7 @@ module YARD
25
25
  end
26
26
 
27
27
  def format_lines(object)
28
+ return "" unless object.source
28
29
  i = -1
29
30
  object.source.split(/\n/).map { object.line + (i += 1) }.join("\n")
30
31
  end
@@ -38,6 +39,12 @@ module YARD
38
39
  (" " * (longestline - lineno.to_s.length)) + lineno.to_s + " " + line
39
40
  end.join("\n")
40
41
  end
42
+
43
+ def format_constant(value)
44
+ sp = value.split("\n").last[/^(\s+)/, 1]
45
+ num = sp ? sp.size : 0
46
+ html_syntax_highlight value.gsub(/^\s{#{num}}/, '')
47
+ end
41
48
  end
42
49
  end
43
50
  end
@@ -0,0 +1,15 @@
1
+ module YARD
2
+ module Templates
3
+ module Helpers
4
+ module ModuleHelper
5
+ def prune_method_listing(list, hide_attributes = true)
6
+ list = run_verifier(list)
7
+ list = list.reject {|o| !options[:visibilities].include? o.visibility } if options[:visibilities]
8
+ list = list.reject {|o| o.is_alias? unless CodeObjects::Proxy === o.namespace }
9
+ list = list.reject {|o| o.is_attribute? unless CodeObjects::Proxy === o.namespace } if hide_attributes
10
+ list
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,60 @@
1
+ module YARD
2
+ module Templates
3
+ module Helpers
4
+ module TextHelper
5
+ def h(text)
6
+ out = ""
7
+ text = text.split(/\n/)
8
+ text.each_with_index do |line, i|
9
+ out <<
10
+ case line
11
+ when /^\s*$/; "\n\n"
12
+ when /^\s+\S/, /^=/; line + "\n"
13
+ else; line + (text[i + 1] =~ /^\s+\S/ ? "\n" : " ")
14
+ end
15
+ end
16
+ out
17
+ end
18
+
19
+ def wrap(text, col = 72)
20
+ text.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/, "\\1\\3\n")
21
+ end
22
+
23
+ def indent(text, len = 4)
24
+ text.gsub(/^/, ' ' * len)
25
+ end
26
+
27
+ def title_align_right(text, col = 72)
28
+ align_right(text, '-', col)
29
+ end
30
+
31
+ def align_right(text, spacer = ' ', col = 72)
32
+ spacer * (col - 1 - text.length) + " " + text
33
+ end
34
+
35
+ def hr(col = 72, sep = "-")
36
+ sep * col
37
+ end
38
+
39
+ def signature(meth)
40
+ type = (meth.tag(:return) && meth.tag(:return).types ? meth.tag(:return).types.first : nil) || "Object"
41
+ scope = meth.scope == :class ? "#{meth.namespace.name}." : "#{meth.namespace.name.to_s.downcase}."
42
+ name = meth.name
43
+ blk = format_block(meth)
44
+ args = format_args(meth)
45
+ extras = []
46
+ extras_text = ''
47
+ if rw = meth.namespace.attributes[meth.scope][meth.name]
48
+ attname = [rw[:read] ? 'read' : nil, rw[:write] ? 'write' : nil].compact
49
+ attname = attname.size == 1 ? attname.join('') + 'only' : nil
50
+ extras << attname if attname
51
+ end
52
+ extras << meth.visibility if meth.visibility != :public
53
+ extras_text = '(' + extras.join(", ") + ')' unless extras.empty?
54
+ title = "%s%s%s %s -> %s %s" % [scope, name, args, blk, type, extras_text]
55
+ title.gsub(/\s+/, ' ')
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,33 @@
1
+ module YARD
2
+ module Templates::Helpers
3
+ module UMLHelper
4
+ def uml_visibility(object)
5
+ case object.visibility
6
+ when :public; '+'
7
+ when :protected; '#'
8
+ when :private; '-'
9
+ end
10
+ end
11
+
12
+ def format_path(object)
13
+ object.path.gsub('::', '_')
14
+ end
15
+
16
+ def h(text)
17
+ text.to_s.gsub(/(\W)/, '\\\\\1')
18
+ end
19
+
20
+ def tidy(data)
21
+ indent = 0
22
+ data.split(/\n/).map do |line|
23
+ line.gsub!(/^\s*/, '')
24
+ next if line.empty?
25
+ indent -= 1 if line =~ /^\s*\}\s*$/
26
+ line = (' ' * (indent * 2)) + line
27
+ indent += 1 if line =~ /\{\s*$/
28
+ line
29
+ end.compact.join("\n") + "\n"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,355 @@
1
+ require 'erb'
2
+
3
+ module YARD
4
+ module Templates
5
+ module Template
6
+ attr_accessor :class, :options, :subsections, :section
7
+
8
+ class << self
9
+ # @return [Array<Module>] a list of modules to be automatically included
10
+ # into any new template module
11
+ attr_accessor :extra_includes
12
+
13
+ # @private
14
+ def included(klass)
15
+ klass.extend(ClassMethods)
16
+ end
17
+ end
18
+
19
+ self.extra_includes = []
20
+
21
+ include Helpers::BaseHelper
22
+ include Helpers::MethodHelper
23
+
24
+ module ClassMethods
25
+ attr_accessor :path, :full_path
26
+
27
+ def full_paths
28
+ included_modules.inject([full_path]) do |paths, mod|
29
+ paths |= mod.full_paths if mod.respond_to?(:full_paths)
30
+ paths
31
+ end
32
+ end
33
+
34
+ def initialize(path, full_paths)
35
+ full_path = full_paths.shift
36
+ self.path = path
37
+ self.full_path = full_path
38
+ include_inherited(full_paths)
39
+ include_parent
40
+ load_setup_rb
41
+ end
42
+
43
+ # Searches for a file identified by +basename+ in the template's
44
+ # path as well as any mixed in template paths. Equivalent to calling
45
+ # {ClassMethods#find_nth_file} with index of 1.
46
+ #
47
+ # @param [String] basename the filename to search for
48
+ # @return [String] the full path of a file on disk with filename
49
+ # +basename+ in one of the template's paths.
50
+ # @see find_nth_file
51
+ def find_file(basename)
52
+ find_nth_file(basename)
53
+ end
54
+
55
+ # Searches for the nth file (where n = +index+) identified
56
+ # by basename in the template's path and any mixed in template paths.
57
+ #
58
+ # @param [String] basename the filename to search for
59
+ # @param [Fixnum] index the nth existing file to return
60
+ # @return [String] the full path of the nth file on disk with
61
+ # filename +basename+ in one of the template paths
62
+ def find_nth_file(basename, index = 1)
63
+ n = 1
64
+ full_paths.each do |path|
65
+ file = File.join(path, basename)
66
+ if File.file?(file)
67
+ return file if index == n
68
+ n += 1
69
+ end
70
+ end
71
+
72
+ nil
73
+ end
74
+
75
+ def is_a?(klass)
76
+ return true if klass == Template
77
+ super(klass)
78
+ end
79
+
80
+ # Creates a new template object to be rendered with {Template#run}
81
+ def new(*args)
82
+ obj = Object.new.extend(self)
83
+ obj.class = self
84
+ obj.send(:initialize, *args)
85
+ obj
86
+ end
87
+
88
+ def run(*args)
89
+ new(*args).run
90
+ end
91
+
92
+ def T(*path)
93
+ Engine.template(*path)
94
+ end
95
+
96
+ private
97
+
98
+ def include_parent
99
+ pc = path.to_s.split('/')
100
+ if pc.size > 1
101
+ pc.pop
102
+ include Engine.template!(pc.join('/'), full_path.gsub(%r{/[^/]+$}, ''))
103
+ end
104
+ end
105
+
106
+ def include_inherited(full_paths)
107
+ full_paths.each do |full_path|
108
+ include Engine.template!(path, full_path)
109
+ end
110
+ end
111
+
112
+ def load_setup_rb
113
+ setup_file = File.join(full_path, 'setup.rb')
114
+ if File.file? setup_file
115
+ module_eval(File.read(setup_file).taint, setup_file, 1)
116
+ end
117
+ end
118
+ end
119
+
120
+ def initialize(opts = {})
121
+ @cache, @cache_filename = {}, {}
122
+ @sections, @options = [], {}
123
+ add_options(opts)
124
+
125
+ extend(Helpers::HtmlHelper) if options[:format] == :html
126
+ extend(Helpers::TextHelper) if options[:format] == :text
127
+ extend(Helpers::UMLHelper) if options[:format] == :dot
128
+ extend(*Template.extra_includes) unless Template.extra_includes.empty?
129
+
130
+ init
131
+ end
132
+
133
+ # Loads a template specified by path. If +:template+ or +:format+ is
134
+ # specified in the {#options} hash, they are prependend and appended
135
+ # to the path respectively.
136
+ #
137
+ # @param [Array<String, Symbol>] path the path of the template
138
+ # @return [Template] the loaded template module
139
+ def T(*path)
140
+ path.unshift(options[:template]) if options[:template]
141
+ path.push(options[:format]) if options[:format]
142
+ self.class.T(*path)
143
+ end
144
+
145
+ # Sets the sections (and subsections) to be rendered for the template
146
+ #
147
+ # @example Sets a set of erb sections
148
+ # sections :a, :b, :c # searches for a.erb, b.erb, c.erb
149
+ # @example Sets a set of method and erb sections
150
+ # sections :a, :b, :c # a is a method, the rest are erb files
151
+ # @example Sections with subsections
152
+ # sections :header, [:name, :children]
153
+ # # the above will call header.erb and only renders the subsections
154
+ # # if they are yielded by the template (see #yieldall)
155
+ # @param [Array<Symbol, String, Template, Array>] args the sections
156
+ # to use to render the template. For symbols and strings, the
157
+ # section will be executed as a method (if one exists), or rendered
158
+ # from the file "name.erb" where name is the section name. For
159
+ # templates, they will have {Template::ClassMethods#run} called on them.
160
+ # Any subsections can be yielded to using yield or {#yieldall}
161
+ def sections(*args)
162
+ @sections.replace(args) if args.size > 0
163
+ @sections
164
+ end
165
+
166
+ # Initialization called on the template. Override this in a 'setup.rb'
167
+ # file in the template's path to implement a template
168
+ #
169
+ # @example A default set of sections
170
+ # def init
171
+ # sections :section1, :section2, [:subsection1, :etc]
172
+ # end
173
+ def init
174
+ end
175
+
176
+ # Runs a template on +sects+ using extra options. This method should
177
+ # not be called directly. Instead, call the class method {ClassMethods#run}
178
+ #
179
+ # @param [Hash, nil] opts any extra options to apply to sections
180
+ # @param [Array] sects a list of sections to render
181
+ # @param [Fixnum] start_at the index in the section list to start from
182
+ # @param [Boolean] break_first if true, renders only the first section
183
+ # @yield [opts] calls for the subsections to be rendered
184
+ # @yieldparam [Hash] opts any extra options to yield
185
+ # @return [String] the rendered sections joined together
186
+ def run(opts = nil, sects = sections, start_at = 0, break_first = false, &block)
187
+ out = ""
188
+ return out if sects.nil?
189
+ sects = sects[start_at..-1] if start_at > 0
190
+ add_options(opts) do
191
+ sects.each_with_index do |s, index|
192
+ next if Array === s
193
+ self.section = s
194
+ self.subsections = sects[index + 1]
195
+ subsection_index = 0
196
+ value = render_section(section) do |*args|
197
+ value = with_section do
198
+ run(args.first, subsections, subsection_index, true, &block)
199
+ end
200
+ subsection_index += 1
201
+ subsection_index += 1 until subsections.nil? ||
202
+ subsections[subsection_index].nil? ||
203
+ !subsections[subsection_index].is_a?(Array)
204
+ value
205
+ end
206
+ out << (value || "")
207
+ break if break_first
208
+ end
209
+ end
210
+ out
211
+ end
212
+
213
+ # Yields all subsections with any extra options
214
+ #
215
+ # @param [Hash] opts extra options to be applied to subsections
216
+ def yieldall(opts = nil, &block)
217
+ with_section { run(opts, subsections, &block) }
218
+ end
219
+
220
+ # @param [String, Symbol] section the section name
221
+ # @yield calls subsections to be rendered
222
+ # @return [String] the contents of the ERB rendered section
223
+ def erb(section, &block)
224
+ erb = erb_with(cache(section), cache_filename(section))
225
+ erb.result(binding, &block)
226
+ end
227
+
228
+ # Returns the contents of a file. If +allow_inherited+ is set to +true+,
229
+ # use +{{{__super__}}}+ inside the file contents to insert the contents
230
+ # of the file from an inherited template. For instance, if +templates/b+
231
+ # inherits from +templates/a+ and file "test.css" exists in both directories,
232
+ # both file contents can be retrieved by having +templates/b/test.css+ look
233
+ # like:
234
+ #
235
+ # {{{__super__}}}
236
+ # ...
237
+ # body { css styles here }
238
+ # p.class { other styles }
239
+ #
240
+ # @param [String] basename the name of the file
241
+ # @param [Boolean] allow_inherited whether inherited templates can
242
+ # be inserted with +{{{__super__}}}+
243
+ # @return [String] the contents of a file identified by +basename+. All
244
+ # template paths (including any mixed in templates) are searched for
245
+ # the file
246
+ # @see ClassMethods#find_file
247
+ # @see ClassMethods#find_nth_file
248
+ def file(basename, allow_inherited = false)
249
+ file = self.class.find_file(basename)
250
+ raise ArgumentError, "no file for '#{basename}' in #{self.class.path}" unless file
251
+
252
+ data = IO.read(file)
253
+ if allow_inherited
254
+ superfile = self.class.find_nth_file(basename, 2)
255
+ data.gsub!('{{{__super__}}}', superfile ? IO.read(superfile) : "")
256
+ end
257
+
258
+ data
259
+ end
260
+
261
+ # Calls the ERB file from the last inherited template with {#section}.erb
262
+ #
263
+ # @param [Symbol, String] section if provided, uses a specific section name
264
+ # @return [String] the rendered ERB file in any of the inherited template
265
+ # paths.
266
+ def superb(section = section, &block)
267
+ filename = self.class.find_nth_file(erb_file_for(section), 2)
268
+ return "" unless filename
269
+ erb = erb_with(IO.read(filename), filename)
270
+ erb.result(binding, &block)
271
+ end
272
+
273
+ def options=(value)
274
+ @options = value
275
+ set_ivars
276
+ end
277
+
278
+ def inspect
279
+ "Template(#{self.class.path}) [section=#{section}]"
280
+ end
281
+
282
+ protected
283
+
284
+ def erb_file_for(section)
285
+ "#{section}.erb"
286
+ end
287
+
288
+ def erb_with(content, filename = nil)
289
+ erb = ERB.new(content, nil, options[:format] == :text ? '<>' : nil)
290
+ erb.filename = filename if filename
291
+ erb
292
+ end
293
+
294
+ private
295
+
296
+ def subsections=(value)
297
+ @subsections = Array === value ? value : nil
298
+ end
299
+
300
+ def render_section(section, &block)
301
+ case section
302
+ when String, Symbol
303
+ if respond_to?(section)
304
+ send(section, &block)
305
+ else
306
+ erb(section, &block)
307
+ end
308
+ when Module, Template
309
+ section.run(options, &block) if section.is_a?(Template)
310
+ end || ""
311
+ end
312
+
313
+ def cache(section)
314
+ content = @cache[section.to_sym]
315
+ return content if content
316
+
317
+ file = self.class.find_file(erb_file_for(section))
318
+ @cache_filename[section.to_sym] = file
319
+ raise ArgumentError, "no template for section '#{section}' in #{self.class.path}" unless file
320
+ @cache[section.to_sym] = IO.read(file)
321
+ end
322
+
323
+ def cache_filename(section)
324
+ @cache_filename[section.to_sym]
325
+ end
326
+
327
+ def set_ivars
328
+ options.each do |k, v|
329
+ instance_variable_set("@#{k}", v)
330
+ end
331
+ end
332
+
333
+ def add_options(opts = nil)
334
+ return(yield) if opts.nil? && block_given?
335
+ cur_opts = options if block_given?
336
+
337
+ self.options = options.merge(opts)
338
+
339
+ if block_given?
340
+ value = yield
341
+ self.options = cur_opts
342
+ value
343
+ end
344
+ end
345
+
346
+ def with_section(&block)
347
+ s1, s2 = section, subsections
348
+ value = yield
349
+ self.section, self.subsections = s1, s2
350
+ value
351
+ end
352
+ end
353
+ end
354
+ end
355
+