yard 0.9.5 → 0.9.6

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 (575) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +0 -0
  3. data/CHANGELOG.md +20 -0
  4. data/LEGAL +0 -0
  5. data/LICENSE +0 -0
  6. data/README.md +70 -35
  7. data/Rakefile +10 -39
  8. data/benchmarks/builtins_vs_eval.rb +9 -8
  9. data/benchmarks/concat_vs_join.rb +1 -0
  10. data/benchmarks/erb_vs_erubis.rb +3 -2
  11. data/benchmarks/format_args.rb +1 -0
  12. data/benchmarks/generation.rb +2 -1
  13. data/benchmarks/marshal_vs_dbm.rb +2 -1
  14. data/benchmarks/parsing.rb +1 -1
  15. data/benchmarks/pathname_vs_string.rb +1 -0
  16. data/benchmarks/rdoc_vs_yardoc.rb +2 -1
  17. data/benchmarks/registry_store_types.rb +1 -0
  18. data/benchmarks/ri_vs_yri.rb +1 -0
  19. data/benchmarks/ripper_parser.rb +2 -1
  20. data/benchmarks/splat_vs_flatten.rb +4 -3
  21. data/benchmarks/template_erb.rb +2 -1
  22. data/benchmarks/template_format.rb +1 -0
  23. data/benchmarks/template_profile.rb +4 -3
  24. data/benchmarks/yri_cache.rb +2 -1
  25. data/bin/yard +2 -1
  26. data/bin/yardoc +2 -1
  27. data/bin/yri +2 -1
  28. data/docs/CodeObjects.md +0 -0
  29. data/docs/GettingStarted.md +0 -0
  30. data/docs/Handlers.md +0 -0
  31. data/docs/Overview.md +0 -0
  32. data/docs/Parser.md +0 -0
  33. data/docs/Tags.md +0 -0
  34. data/docs/TagsArch.md +0 -0
  35. data/docs/Templates.md +0 -0
  36. data/docs/WhatsNew.md +0 -0
  37. data/docs/images/code-objects-class-diagram.png +0 -0
  38. data/docs/images/tags-class-diagram.png +0 -0
  39. data/docs/templates/default/fulldoc/html/full_list_tag.erb +0 -0
  40. data/docs/templates/default/fulldoc/html/setup.rb +1 -1
  41. data/docs/templates/default/layout/html/setup.rb +1 -0
  42. data/docs/templates/default/layout/html/tag_list.erb +0 -0
  43. data/docs/templates/default/yard_tags/html/list.erb +0 -0
  44. data/docs/templates/default/yard_tags/html/setup.rb +18 -19
  45. data/docs/templates/plugin.rb +18 -13
  46. data/lib/rubygems_plugin.rb +1 -0
  47. data/lib/yard.rb +5 -6
  48. data/lib/yard/autoload.rb +4 -0
  49. data/lib/yard/cli/command.rb +3 -2
  50. data/lib/yard/cli/command_parser.rb +4 -3
  51. data/lib/yard/cli/config.rb +5 -4
  52. data/lib/yard/cli/diff.rb +39 -39
  53. data/lib/yard/cli/display.rb +2 -1
  54. data/lib/yard/cli/gems.rb +6 -5
  55. data/lib/yard/cli/graph.rb +4 -5
  56. data/lib/yard/cli/help.rb +4 -2
  57. data/lib/yard/cli/i18n.rb +2 -1
  58. data/lib/yard/cli/list.rb +2 -1
  59. data/lib/yard/cli/markup_types.rb +4 -5
  60. data/lib/yard/cli/server.rb +27 -24
  61. data/lib/yard/cli/stats.rb +20 -16
  62. data/lib/yard/cli/yardoc.rb +22 -19
  63. data/lib/yard/cli/yardopts_command.rb +3 -2
  64. data/lib/yard/cli/yri.rb +26 -25
  65. data/lib/yard/code_objects/base.rb +41 -37
  66. data/lib/yard/code_objects/class_object.rb +3 -2
  67. data/lib/yard/code_objects/class_variable_object.rb +2 -1
  68. data/lib/yard/code_objects/constant_object.rb +2 -1
  69. data/lib/yard/code_objects/extended_method_object.rb +2 -1
  70. data/lib/yard/code_objects/extra_file_object.rb +1 -0
  71. data/lib/yard/code_objects/macro_object.rb +10 -10
  72. data/lib/yard/code_objects/method_object.rb +15 -13
  73. data/lib/yard/code_objects/module_object.rb +1 -0
  74. data/lib/yard/code_objects/namespace_mapper.rb +1 -0
  75. data/lib/yard/code_objects/namespace_object.rb +2 -5
  76. data/lib/yard/code_objects/proxy.rb +35 -53
  77. data/lib/yard/code_objects/root_object.rb +3 -1
  78. data/lib/yard/config.rb +8 -9
  79. data/lib/yard/core_ext/array.rb +1 -0
  80. data/lib/yard/core_ext/file.rb +4 -3
  81. data/lib/yard/core_ext/hash.rb +3 -2
  82. data/lib/yard/core_ext/insertion.rb +7 -4
  83. data/lib/yard/core_ext/module.rb +2 -1
  84. data/lib/yard/core_ext/string.rb +5 -4
  85. data/lib/yard/core_ext/symbol_hash.rb +8 -6
  86. data/lib/yard/docstring.rb +26 -15
  87. data/lib/yard/docstring_parser.rb +61 -61
  88. data/lib/yard/gem_index.rb +17 -0
  89. data/lib/yard/globals.rb +6 -2
  90. data/lib/yard/handlers/base.rb +22 -23
  91. data/lib/yard/handlers/c/alias_handler.rb +3 -2
  92. data/lib/yard/handlers/c/attribute_handler.rb +2 -2
  93. data/lib/yard/handlers/c/base.rb +13 -13
  94. data/lib/yard/handlers/c/class_handler.rb +1 -0
  95. data/lib/yard/handlers/c/constant_handler.rb +3 -2
  96. data/lib/yard/handlers/c/handler_methods.rb +24 -25
  97. data/lib/yard/handlers/c/init_handler.rb +4 -2
  98. data/lib/yard/handlers/c/method_handler.rb +7 -6
  99. data/lib/yard/handlers/c/mixin_handler.rb +3 -1
  100. data/lib/yard/handlers/c/module_handler.rb +1 -0
  101. data/lib/yard/handlers/c/override_comment_handler.rb +2 -1
  102. data/lib/yard/handlers/c/path_handler.rb +1 -0
  103. data/lib/yard/handlers/c/struct_handler.rb +1 -0
  104. data/lib/yard/handlers/c/symbol_handler.rb +2 -1
  105. data/lib/yard/handlers/processor.rb +14 -15
  106. data/lib/yard/handlers/ruby/alias_handler.rb +4 -2
  107. data/lib/yard/handlers/ruby/attribute_handler.rb +11 -6
  108. data/lib/yard/handlers/ruby/base.rb +5 -4
  109. data/lib/yard/handlers/ruby/class_condition_handler.rb +4 -3
  110. data/lib/yard/handlers/ruby/class_handler.rb +7 -9
  111. data/lib/yard/handlers/ruby/class_variable_handler.rb +2 -1
  112. data/lib/yard/handlers/ruby/comment_handler.rb +1 -0
  113. data/lib/yard/handlers/ruby/constant_handler.rb +9 -5
  114. data/lib/yard/handlers/ruby/decorator_handler_methods.rb +15 -28
  115. data/lib/yard/handlers/ruby/dsl_handler.rb +1 -0
  116. data/lib/yard/handlers/ruby/dsl_handler_methods.rb +7 -6
  117. data/lib/yard/handlers/ruby/exception_handler.rb +1 -0
  118. data/lib/yard/handlers/ruby/extend_handler.rb +1 -0
  119. data/lib/yard/handlers/ruby/legacy/alias_handler.rb +6 -4
  120. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +12 -7
  121. data/lib/yard/handlers/ruby/legacy/base.rb +21 -26
  122. data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +7 -7
  123. data/lib/yard/handlers/ruby/legacy/class_handler.rb +7 -5
  124. data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +2 -1
  125. data/lib/yard/handlers/ruby/legacy/comment_handler.rb +1 -0
  126. data/lib/yard/handlers/ruby/legacy/constant_handler.rb +2 -1
  127. data/lib/yard/handlers/ruby/legacy/dsl_handler.rb +1 -0
  128. data/lib/yard/handlers/ruby/legacy/exception_handler.rb +2 -1
  129. data/lib/yard/handlers/ruby/legacy/extend_handler.rb +2 -1
  130. data/lib/yard/handlers/ruby/legacy/method_handler.rb +11 -6
  131. data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +5 -5
  132. data/lib/yard/handlers/ruby/legacy/module_function_handler.rb +2 -1
  133. data/lib/yard/handlers/ruby/legacy/module_handler.rb +2 -1
  134. data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +2 -1
  135. data/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +2 -1
  136. data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +3 -2
  137. data/lib/yard/handlers/ruby/legacy/yield_handler.rb +1 -0
  138. data/lib/yard/handlers/ruby/method_condition_handler.rb +2 -1
  139. data/lib/yard/handlers/ruby/method_handler.rb +9 -11
  140. data/lib/yard/handlers/ruby/mixin_handler.rb +2 -1
  141. data/lib/yard/handlers/ruby/module_function_handler.rb +2 -1
  142. data/lib/yard/handlers/ruby/module_handler.rb +2 -1
  143. data/lib/yard/handlers/ruby/private_class_method_handler.rb +1 -0
  144. data/lib/yard/handlers/ruby/private_constant_handler.rb +2 -2
  145. data/lib/yard/handlers/ruby/public_class_method_handler.rb +1 -0
  146. data/lib/yard/handlers/ruby/struct_handler_methods.rb +5 -4
  147. data/lib/yard/handlers/ruby/visibility_handler.rb +1 -0
  148. data/lib/yard/handlers/ruby/yield_handler.rb +1 -0
  149. data/lib/yard/i18n/locale.rb +1 -0
  150. data/lib/yard/i18n/message.rb +5 -4
  151. data/lib/yard/i18n/messages.rb +2 -1
  152. data/lib/yard/i18n/po_parser.rb +5 -4
  153. data/lib/yard/i18n/pot_generator.rb +8 -8
  154. data/lib/yard/i18n/text.rb +9 -9
  155. data/lib/yard/logging.rb +9 -6
  156. data/lib/yard/options.rb +8 -7
  157. data/lib/yard/parser/base.rb +3 -2
  158. data/lib/yard/parser/c/c_parser.rb +22 -21
  159. data/lib/yard/parser/c/comment_parser.rb +9 -6
  160. data/lib/yard/parser/c/statement.rb +1 -0
  161. data/lib/yard/parser/ruby/ast_node.rb +20 -18
  162. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +99 -122
  163. data/lib/yard/parser/ruby/legacy/ruby_parser.rb +3 -2
  164. data/lib/yard/parser/ruby/legacy/statement.rb +4 -3
  165. data/lib/yard/parser/ruby/legacy/statement_list.rb +52 -42
  166. data/lib/yard/parser/ruby/legacy/token_list.rb +16 -13
  167. data/lib/yard/parser/ruby/ruby_parser.rb +87 -63
  168. data/lib/yard/parser/ruby/token_resolver.rb +156 -0
  169. data/lib/yard/parser/source_parser.rb +28 -20
  170. data/lib/yard/rake/yardoc_task.rb +3 -3
  171. data/lib/yard/registry.rb +14 -16
  172. data/lib/yard/registry_resolver.rb +36 -20
  173. data/lib/yard/registry_store.rb +19 -15
  174. data/lib/yard/rubygems/backports.rb +2 -0
  175. data/lib/yard/rubygems/backports/LICENSE.txt +0 -0
  176. data/lib/yard/rubygems/backports/MIT.txt +0 -0
  177. data/lib/yard/rubygems/backports/gem.rb +1 -0
  178. data/lib/yard/rubygems/backports/source_index.rb +25 -30
  179. data/lib/yard/rubygems/doc_manager.rb +10 -8
  180. data/lib/yard/rubygems/hook.rb +11 -18
  181. data/lib/yard/rubygems/specification.rb +1 -0
  182. data/lib/yard/serializers/base.rb +5 -2
  183. data/lib/yard/serializers/file_system_serializer.rb +7 -6
  184. data/lib/yard/serializers/process_serializer.rb +2 -2
  185. data/lib/yard/serializers/stdout_serializer.rb +8 -6
  186. data/lib/yard/serializers/yardoc_serializer.rb +31 -26
  187. data/lib/yard/server.rb +2 -1
  188. data/lib/yard/server/adapter.rb +1 -1
  189. data/lib/yard/server/commands/base.rb +15 -2
  190. data/lib/yard/server/commands/display_file_command.rb +2 -2
  191. data/lib/yard/server/commands/display_object_command.rb +6 -3
  192. data/lib/yard/server/commands/frames_command.rb +1 -0
  193. data/lib/yard/server/commands/library_command.rb +50 -14
  194. data/lib/yard/server/commands/library_index_command.rb +5 -4
  195. data/lib/yard/server/commands/list_command.rb +1 -0
  196. data/lib/yard/server/commands/root_request_command.rb +1 -0
  197. data/lib/yard/server/commands/search_command.rb +17 -16
  198. data/lib/yard/server/commands/static_file_command.rb +2 -1
  199. data/lib/yard/server/commands/static_file_helpers.rb +23 -14
  200. data/lib/yard/server/doc_server_helper.rb +15 -1
  201. data/lib/yard/server/doc_server_serializer.rb +3 -5
  202. data/lib/yard/server/library_version.rb +44 -22
  203. data/lib/yard/server/rack_adapter.rb +2 -1
  204. data/lib/yard/server/router.rb +15 -14
  205. data/lib/yard/server/static_caching.rb +1 -0
  206. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +0 -0
  207. data/lib/yard/server/templates/default/fulldoc/html/images/processing.gif +0 -0
  208. data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +0 -0
  209. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +0 -0
  210. data/lib/yard/server/templates/default/layout/html/script_setup.erb +0 -0
  211. data/lib/yard/server/templates/default/layout/html/setup.rb +2 -1
  212. data/lib/yard/server/templates/default/method_details/html/permalink.erb +0 -0
  213. data/lib/yard/server/templates/default/method_details/html/setup.rb +1 -0
  214. data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +2 -2
  215. data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +0 -0
  216. data/lib/yard/server/templates/doc_server/library_list/html/listing.erb +1 -1
  217. data/lib/yard/server/templates/doc_server/library_list/html/setup.rb +2 -1
  218. data/lib/yard/server/templates/doc_server/library_list/html/title.erb +0 -0
  219. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
  220. data/lib/yard/server/templates/doc_server/processing/html/setup.rb +2 -1
  221. data/lib/yard/server/templates/doc_server/search/html/search.erb +0 -0
  222. data/lib/yard/server/templates/doc_server/search/html/setup.rb +2 -1
  223. data/lib/yard/server/webrick_adapter.rb +4 -2
  224. data/lib/yard/tags/default_factory.rb +19 -13
  225. data/lib/yard/tags/default_tag.rb +2 -1
  226. data/lib/yard/tags/directives.rb +17 -19
  227. data/lib/yard/tags/library.rb +9 -6
  228. data/lib/yard/tags/option_tag.rb +1 -0
  229. data/lib/yard/tags/overload_tag.rb +6 -4
  230. data/lib/yard/tags/ref_tag.rb +1 -0
  231. data/lib/yard/tags/ref_tag_list.rb +2 -1
  232. data/lib/yard/tags/tag.rb +16 -2
  233. data/lib/yard/tags/tag_format_error.rb +3 -2
  234. data/lib/yard/tags/types_explainer.rb +160 -0
  235. data/lib/yard/templates/engine.rb +3 -2
  236. data/lib/yard/templates/erb_cache.rb +3 -2
  237. data/lib/yard/templates/helpers/base_helper.rb +9 -6
  238. data/lib/yard/templates/helpers/filter_helper.rb +1 -0
  239. data/lib/yard/templates/helpers/html_helper.rb +65 -37
  240. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +25 -7
  241. data/lib/yard/templates/helpers/markup/rdoc_markdown.rb +2 -1
  242. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +10 -7
  243. data/lib/yard/templates/helpers/markup_helper.rb +12 -13
  244. data/lib/yard/templates/helpers/method_helper.rb +8 -7
  245. data/lib/yard/templates/helpers/module_helper.rb +1 -0
  246. data/lib/yard/templates/helpers/text_helper.rb +16 -11
  247. data/lib/yard/templates/helpers/uml_helper.rb +2 -1
  248. data/lib/yard/templates/section.rb +3 -4
  249. data/lib/yard/templates/template.rb +18 -11
  250. data/lib/yard/templates/template_options.rb +1 -0
  251. data/lib/yard/verifier.rb +2 -0
  252. data/lib/yard/version.rb +2 -1
  253. data/spec/cli/command_parser_spec.rb +7 -7
  254. data/spec/cli/command_spec.rb +2 -2
  255. data/spec/cli/config_spec.rb +3 -4
  256. data/spec/cli/diff_spec.rb +7 -9
  257. data/spec/cli/display_spec.rb +2 -2
  258. data/spec/cli/gems_spec.rb +11 -11
  259. data/spec/cli/graph_spec.rb +4 -3
  260. data/spec/cli/help_spec.rb +3 -3
  261. data/spec/cli/i18n_spec.rb +3 -3
  262. data/spec/cli/list_spec.rb +2 -2
  263. data/spec/cli/markup_types_spec.rb +2 -2
  264. data/spec/cli/server_spec.rb +21 -18
  265. data/spec/cli/stats_spec.rb +23 -22
  266. data/spec/cli/yardoc_spec.rb +49 -47
  267. data/spec/cli/yri_spec.rb +6 -6
  268. data/spec/code_objects/base_spec.rb +6 -4
  269. data/spec/code_objects/class_object_spec.rb +10 -9
  270. data/spec/code_objects/code_object_list_spec.rb +3 -2
  271. data/spec/code_objects/constants_spec.rb +17 -6
  272. data/spec/code_objects/extra_file_object_spec.rb +6 -5
  273. data/spec/code_objects/macro_object_spec.rb +5 -3
  274. data/spec/code_objects/method_object_spec.rb +6 -5
  275. data/spec/code_objects/module_object_spec.rb +3 -2
  276. data/spec/code_objects/namespace_object_spec.rb +10 -9
  277. data/spec/code_objects/proxy_spec.rb +9 -8
  278. data/spec/code_objects/spec_helper.rb +2 -2
  279. data/spec/config_spec.rb +9 -14
  280. data/spec/core_ext/array_spec.rb +2 -3
  281. data/spec/core_ext/file_spec.rb +3 -3
  282. data/spec/core_ext/hash_spec.rb +5 -5
  283. data/spec/core_ext/insertion_spec.rb +2 -2
  284. data/spec/core_ext/module_spec.rb +3 -3
  285. data/spec/core_ext/string_spec.rb +5 -5
  286. data/spec/core_ext/symbol_hash_spec.rb +8 -8
  287. data/spec/docstring_parser_spec.rb +6 -7
  288. data/spec/docstring_spec.rb +30 -3
  289. data/spec/examples.txt +1848 -0
  290. data/spec/handlers/alias_handler_spec.rb +2 -1
  291. data/spec/handlers/attribute_handler_spec.rb +7 -5
  292. data/spec/handlers/base_spec.rb +9 -8
  293. data/spec/handlers/c/alias_handler_spec.rb +2 -1
  294. data/spec/handlers/c/attribute_handler_spec.rb +2 -1
  295. data/spec/handlers/c/class_handler_spec.rb +2 -1
  296. data/spec/handlers/c/constant_handler_spec.rb +5 -4
  297. data/spec/handlers/c/init_handler_spec.rb +2 -1
  298. data/spec/handlers/c/method_handler_spec.rb +2 -1
  299. data/spec/handlers/c/mixin_handler_spec.rb +2 -1
  300. data/spec/handlers/c/module_handler_spec.rb +2 -1
  301. data/spec/handlers/c/override_comment_handler_spec.rb +2 -1
  302. data/spec/handlers/c/path_handler_spec.rb +2 -1
  303. data/spec/handlers/c/spec_helper.rb +1 -1
  304. data/spec/handlers/c/struct_handler_spec.rb +3 -2
  305. data/spec/handlers/class_condition_handler_spec.rb +3 -2
  306. data/spec/handlers/class_handler_spec.rb +3 -2
  307. data/spec/handlers/class_method_handler_shared_examples.rb +9 -8
  308. data/spec/handlers/class_variable_handler_spec.rb +3 -2
  309. data/spec/handlers/constant_handler_spec.rb +28 -3
  310. data/spec/handlers/decorator_handler_methods_spec.rb +47 -59
  311. data/spec/handlers/dsl_handler_spec.rb +3 -2
  312. data/spec/handlers/examples/alias_handler_001.rb.txt +0 -0
  313. data/spec/handlers/examples/attribute_handler_001.rb.txt +0 -0
  314. data/spec/handlers/examples/class_condition_handler_001.rb.txt +0 -0
  315. data/spec/handlers/examples/class_handler_001.rb.txt +0 -0
  316. data/spec/handlers/examples/class_variable_handler_001.rb.txt +0 -0
  317. data/spec/handlers/examples/constant_handler_001.rb.txt +0 -0
  318. data/spec/handlers/examples/dsl_handler_001.rb.txt +0 -0
  319. data/spec/handlers/examples/exception_handler_001.rb.txt +0 -0
  320. data/spec/handlers/examples/extend_handler_001.rb.txt +0 -0
  321. data/spec/handlers/examples/method_condition_handler_001.rb.txt +0 -0
  322. data/spec/handlers/examples/method_handler_001.rb.txt +2 -0
  323. data/spec/handlers/examples/mixin_handler_001.rb.txt +0 -0
  324. data/spec/handlers/examples/module_handler_001.rb.txt +0 -0
  325. data/spec/handlers/examples/private_constant_handler_001.rb.txt +0 -0
  326. data/spec/handlers/examples/process_handler_001.rb.txt +0 -0
  327. data/spec/handlers/examples/visibility_handler_001.rb.txt +0 -0
  328. data/spec/handlers/examples/yield_handler_001.rb.txt +0 -0
  329. data/spec/handlers/exception_handler_spec.rb +3 -2
  330. data/spec/handlers/extend_handler_spec.rb +2 -1
  331. data/spec/handlers/legacy_base_spec.rb +5 -5
  332. data/spec/handlers/method_condition_handler_spec.rb +3 -2
  333. data/spec/handlers/method_handler_spec.rb +7 -1
  334. data/spec/handlers/mixin_handler_spec.rb +3 -2
  335. data/spec/handlers/module_function_handler_spec.rb +2 -1
  336. data/spec/handlers/module_handler_spec.rb +3 -2
  337. data/spec/handlers/private_class_method_handler_spec.rb +2 -1
  338. data/spec/handlers/private_constant_handler_spec.rb +2 -1
  339. data/spec/handlers/processor_spec.rb +2 -1
  340. data/spec/handlers/public_class_method_handler_spec.rb +2 -1
  341. data/spec/handlers/ruby/base_spec.rb +6 -5
  342. data/spec/handlers/ruby/legacy/base_spec.rb +4 -4
  343. data/spec/handlers/spec_helper.rb +3 -3
  344. data/spec/handlers/visibility_handler_spec.rb +3 -2
  345. data/spec/handlers/yield_handler_spec.rb +3 -2
  346. data/spec/i18n/locale_spec.rb +3 -3
  347. data/spec/i18n/message_spec.rb +2 -2
  348. data/spec/i18n/messages_spec.rb +3 -3
  349. data/spec/i18n/pot_generator_spec.rb +34 -34
  350. data/spec/i18n/text_spec.rb +16 -12
  351. data/spec/logging_spec.rb +2 -2
  352. data/spec/options_spec.rb +9 -9
  353. data/spec/parser/base_spec.rb +2 -2
  354. data/spec/parser/c_parser_spec.rb +5 -4
  355. data/spec/parser/examples/array.c.txt +0 -0
  356. data/spec/parser/examples/example1.rb.txt +0 -0
  357. data/spec/parser/examples/extrafile.c.txt +0 -0
  358. data/spec/parser/examples/multifile.c.txt +0 -0
  359. data/spec/parser/examples/override.c.txt +0 -0
  360. data/spec/parser/examples/parse_in_order_001.rb.txt +0 -0
  361. data/spec/parser/examples/parse_in_order_002.rb.txt +0 -0
  362. data/spec/parser/examples/tag_handler_001.rb.txt +0 -0
  363. data/spec/parser/ruby/ast_node_spec.rb +7 -7
  364. data/spec/parser/ruby/legacy/statement_list_spec.rb +7 -7
  365. data/spec/parser/ruby/legacy/token_list_spec.rb +4 -4
  366. data/spec/parser/ruby/ruby_parser_spec.rb +42 -20
  367. data/spec/parser/ruby/token_resolver_spec.rb +165 -0
  368. data/spec/parser/source_parser_spec.rb +18 -18
  369. data/spec/parser/tag_parsing_spec.rb +2 -2
  370. data/spec/rake/yardoc_task_spec.rb +4 -4
  371. data/spec/registry_spec.rb +62 -56
  372. data/spec/registry_store_spec.rb +7 -7
  373. data/spec/rubygems/doc_manager_spec.rb +2 -2
  374. data/spec/serializers/data/serialized_yardoc/checksums +0 -0
  375. data/spec/serializers/data/serialized_yardoc/objects/Foo.dat +0 -0
  376. data/spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat +0 -0
  377. data/spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat +0 -0
  378. data/spec/serializers/data/serialized_yardoc/objects/root.dat +0 -0
  379. data/spec/serializers/data/serialized_yardoc/proxy_types +0 -0
  380. data/spec/serializers/file_system_serializer_spec.rb +8 -7
  381. data/spec/serializers/spec_helper.rb +2 -2
  382. data/spec/serializers/yardoc_serializer_spec.rb +5 -4
  383. data/spec/server/adapter_spec.rb +3 -2
  384. data/spec/server/commands/base_spec.rb +15 -11
  385. data/spec/server/commands/library_command_spec.rb +2 -2
  386. data/spec/server/doc_server_helper_spec.rb +4 -3
  387. data/spec/server/doc_server_serializer_spec.rb +3 -2
  388. data/spec/server/rack_adapter_spec.rb +3 -2
  389. data/spec/server/router_spec.rb +3 -2
  390. data/spec/server/spec_helper.rb +2 -2
  391. data/spec/server/static_caching_spec.rb +4 -3
  392. data/spec/server/webrick_servlet_spec.rb +5 -4
  393. data/spec/server_spec.rb +3 -3
  394. data/spec/spec_helper.rb +94 -21
  395. data/spec/tags/default_factory_spec.rb +10 -4
  396. data/spec/tags/default_tag_spec.rb +3 -3
  397. data/spec/tags/directives_spec.rb +12 -12
  398. data/spec/tags/library_spec.rb +16 -2
  399. data/spec/tags/overload_tag_spec.rb +4 -4
  400. data/spec/tags/ref_tag_list_spec.rb +3 -3
  401. data/spec/tags/types_explainer_spec.rb +200 -0
  402. data/spec/templates/class_spec.rb +2 -1
  403. data/spec/templates/constant_spec.rb +3 -2
  404. data/spec/templates/engine_spec.rb +4 -3
  405. data/spec/templates/examples/class001.html +0 -0
  406. data/spec/templates/examples/class001.txt +0 -0
  407. data/spec/templates/examples/class002.html +0 -0
  408. data/spec/templates/examples/constant001.txt +0 -0
  409. data/spec/templates/examples/constant002.txt +0 -0
  410. data/spec/templates/examples/constant003.txt +0 -0
  411. data/spec/templates/examples/method001.html +0 -0
  412. data/spec/templates/examples/method001.txt +0 -0
  413. data/spec/templates/examples/method002.html +0 -0
  414. data/spec/templates/examples/method002.txt +0 -0
  415. data/spec/templates/examples/method003.html +0 -0
  416. data/spec/templates/examples/method003.txt +0 -0
  417. data/spec/templates/examples/method004.html +0 -0
  418. data/spec/templates/examples/method004.txt +0 -0
  419. data/spec/templates/examples/method005.html +0 -0
  420. data/spec/templates/examples/method005.txt +0 -0
  421. data/spec/templates/examples/method006.html +108 -0
  422. data/spec/templates/examples/method006.txt +20 -0
  423. data/spec/templates/examples/module001.dot +0 -0
  424. data/spec/templates/examples/module001.html +0 -0
  425. data/spec/templates/examples/module001.txt +0 -0
  426. data/spec/templates/examples/module002.html +0 -0
  427. data/spec/templates/examples/module003.html +0 -0
  428. data/spec/templates/examples/module004.html +0 -0
  429. data/spec/templates/examples/tag001.txt +0 -0
  430. data/spec/templates/helpers/base_helper_spec.rb +5 -5
  431. data/spec/templates/helpers/html_helper_spec.rb +64 -60
  432. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +17 -6
  433. data/spec/templates/helpers/markup/rdoc_markup_spec.rb +11 -13
  434. data/spec/templates/helpers/markup_helper_spec.rb +2 -2
  435. data/spec/templates/helpers/method_helper_spec.rb +3 -3
  436. data/spec/templates/helpers/module_helper_spec.rb +2 -2
  437. data/spec/templates/helpers/shared_signature_examples.rb +2 -1
  438. data/spec/templates/helpers/text_helper_spec.rb +7 -6
  439. data/spec/templates/method_spec.rb +18 -2
  440. data/spec/templates/module_spec.rb +4 -3
  441. data/spec/templates/onefile_spec.rb +8 -6
  442. data/spec/templates/section_spec.rb +3 -2
  443. data/spec/templates/spec_helper.rb +5 -2
  444. data/spec/templates/tag_spec.rb +3 -2
  445. data/spec/templates/template_spec.rb +15 -14
  446. data/spec/verifier_spec.rb +3 -3
  447. data/templates/default/class/dot/setup.rb +2 -1
  448. data/templates/default/class/dot/superklass.erb +0 -0
  449. data/templates/default/class/html/constructor_details.erb +0 -0
  450. data/templates/default/class/html/setup.rb +2 -1
  451. data/templates/default/class/html/subclasses.erb +0 -0
  452. data/templates/default/class/setup.rb +6 -6
  453. data/templates/default/class/text/setup.rb +2 -1
  454. data/templates/default/class/text/subclasses.erb +0 -0
  455. data/templates/default/constant/text/header.erb +0 -0
  456. data/templates/default/constant/text/setup.rb +1 -0
  457. data/templates/default/docstring/html/abstract.erb +0 -0
  458. data/templates/default/docstring/html/deprecated.erb +0 -0
  459. data/templates/default/docstring/html/index.erb +0 -0
  460. data/templates/default/docstring/html/note.erb +0 -0
  461. data/templates/default/docstring/html/private.erb +0 -0
  462. data/templates/default/docstring/html/returns_void.erb +0 -0
  463. data/templates/default/docstring/html/text.erb +0 -0
  464. data/templates/default/docstring/html/todo.erb +0 -0
  465. data/templates/default/docstring/setup.rb +4 -3
  466. data/templates/default/docstring/text/abstract.erb +0 -0
  467. data/templates/default/docstring/text/deprecated.erb +0 -0
  468. data/templates/default/docstring/text/index.erb +0 -0
  469. data/templates/default/docstring/text/note.erb +0 -0
  470. data/templates/default/docstring/text/private.erb +0 -0
  471. data/templates/default/docstring/text/returns_void.erb +0 -0
  472. data/templates/default/docstring/text/text.erb +0 -0
  473. data/templates/default/docstring/text/todo.erb +0 -0
  474. data/templates/default/fulldoc/html/css/common.css +0 -0
  475. data/templates/default/fulldoc/html/css/full_list.css +0 -0
  476. data/templates/default/fulldoc/html/css/style.css +31 -20
  477. data/templates/default/fulldoc/html/frames.erb +0 -0
  478. data/templates/default/fulldoc/html/full_list.erb +2 -2
  479. data/templates/default/fulldoc/html/full_list_class.erb +0 -0
  480. data/templates/default/fulldoc/html/full_list_file.erb +0 -0
  481. data/templates/default/fulldoc/html/full_list_method.erb +0 -0
  482. data/templates/default/fulldoc/html/js/app.js +3 -3
  483. data/templates/default/fulldoc/html/js/full_list.js +0 -0
  484. data/templates/default/fulldoc/html/js/jquery.js +0 -0
  485. data/templates/default/fulldoc/html/setup.rb +22 -23
  486. data/templates/default/layout/dot/header.erb +0 -0
  487. data/templates/default/layout/dot/setup.rb +1 -0
  488. data/templates/default/layout/html/breadcrumb.erb +0 -0
  489. data/templates/default/layout/html/files.erb +0 -0
  490. data/templates/default/layout/html/footer.erb +0 -0
  491. data/templates/default/layout/html/headers.erb +2 -2
  492. data/templates/default/layout/html/index.erb +0 -0
  493. data/templates/default/layout/html/layout.erb +1 -3
  494. data/templates/default/layout/html/listing.erb +0 -0
  495. data/templates/default/layout/html/objects.erb +0 -0
  496. data/templates/default/layout/html/script_setup.erb +0 -0
  497. data/templates/default/layout/html/search.erb +0 -0
  498. data/templates/default/layout/html/setup.rb +21 -19
  499. data/templates/default/method/html/header.erb +0 -0
  500. data/templates/default/method/setup.rb +2 -1
  501. data/templates/default/method/text/header.erb +0 -0
  502. data/templates/default/method_details/html/header.erb +0 -0
  503. data/templates/default/method_details/html/method_signature.erb +0 -0
  504. data/templates/default/method_details/html/source.erb +0 -0
  505. data/templates/default/method_details/setup.rb +1 -0
  506. data/templates/default/method_details/text/header.erb +0 -0
  507. data/templates/default/method_details/text/method_signature.erb +0 -0
  508. data/templates/default/method_details/text/setup.rb +3 -2
  509. data/templates/default/module/dot/child.erb +0 -0
  510. data/templates/default/module/dot/dependencies.erb +0 -0
  511. data/templates/default/module/dot/header.erb +0 -0
  512. data/templates/default/module/dot/info.erb +0 -0
  513. data/templates/default/module/dot/setup.rb +2 -1
  514. data/templates/default/module/html/attribute_details.erb +0 -0
  515. data/templates/default/module/html/attribute_summary.erb +0 -0
  516. data/templates/default/module/html/box_info.erb +0 -0
  517. data/templates/default/module/html/children.erb +0 -0
  518. data/templates/default/module/html/constant_summary.erb +0 -0
  519. data/templates/default/module/html/defines.erb +0 -0
  520. data/templates/default/module/html/header.erb +0 -0
  521. data/templates/default/module/html/inherited_attributes.erb +0 -0
  522. data/templates/default/module/html/inherited_constants.erb +0 -0
  523. data/templates/default/module/html/inherited_methods.erb +0 -0
  524. data/templates/default/module/html/item_summary.erb +0 -0
  525. data/templates/default/module/html/method_details_list.erb +0 -0
  526. data/templates/default/module/html/method_summary.erb +0 -0
  527. data/templates/default/module/html/methodmissing.erb +0 -0
  528. data/templates/default/module/html/pre_docstring.erb +0 -0
  529. data/templates/default/module/setup.rb +24 -26
  530. data/templates/default/module/text/children.erb +0 -0
  531. data/templates/default/module/text/class_meths_list.erb +0 -0
  532. data/templates/default/module/text/extends.erb +0 -0
  533. data/templates/default/module/text/header.erb +0 -0
  534. data/templates/default/module/text/includes.erb +0 -0
  535. data/templates/default/module/text/instance_meths_list.erb +0 -0
  536. data/templates/default/module/text/setup.rb +2 -1
  537. data/templates/default/onefile/html/files.erb +0 -0
  538. data/templates/default/onefile/html/headers.erb +0 -0
  539. data/templates/default/onefile/html/layout.erb +3 -3
  540. data/templates/default/onefile/html/readme.erb +0 -0
  541. data/templates/default/onefile/html/setup.rb +9 -8
  542. data/templates/default/root/dot/child.erb +0 -0
  543. data/templates/default/root/dot/setup.rb +3 -2
  544. data/templates/default/root/html/setup.rb +2 -1
  545. data/templates/default/tags/html/example.erb +0 -0
  546. data/templates/default/tags/html/index.erb +0 -0
  547. data/templates/default/tags/html/option.erb +1 -1
  548. data/templates/default/tags/html/overload.erb +0 -0
  549. data/templates/default/tags/html/see.erb +0 -0
  550. data/templates/default/tags/html/tag.erb +1 -1
  551. data/templates/default/tags/setup.rb +7 -5
  552. data/templates/default/tags/text/example.erb +0 -0
  553. data/templates/default/tags/text/index.erb +0 -0
  554. data/templates/default/tags/text/option.erb +1 -1
  555. data/templates/default/tags/text/overload.erb +0 -0
  556. data/templates/default/tags/text/see.erb +0 -0
  557. data/templates/default/tags/text/tag.erb +2 -2
  558. data/templates/guide/class/html/setup.rb +1 -0
  559. data/templates/guide/docstring/html/setup.rb +1 -0
  560. data/templates/guide/fulldoc/html/css/style.css +0 -0
  561. data/templates/guide/fulldoc/html/js/app.js +0 -0
  562. data/templates/guide/fulldoc/html/setup.rb +7 -6
  563. data/templates/guide/layout/html/layout.erb +0 -0
  564. data/templates/guide/layout/html/setup.rb +2 -5
  565. data/templates/guide/method/html/header.erb +0 -0
  566. data/templates/guide/method/html/setup.rb +5 -4
  567. data/templates/guide/module/html/header.erb +0 -0
  568. data/templates/guide/module/html/method_list.erb +0 -0
  569. data/templates/guide/module/html/setup.rb +2 -1
  570. data/templates/guide/onefile/html/files.erb +0 -0
  571. data/templates/guide/onefile/html/setup.rb +1 -0
  572. data/templates/guide/onefile/html/toc.erb +0 -0
  573. data/templates/guide/tags/html/setup.rb +1 -0
  574. data/yard.gemspec +2 -1
  575. metadata +10 -2
data/lib/yard/logging.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'logger'
2
3
  require 'thread'
3
4
 
@@ -47,6 +48,7 @@ module YARD
47
48
  self.formatter = method(:format_log)
48
49
  @progress_indicator = 0
49
50
  @mutex = Mutex.new
51
+ @progress_msg = nil
50
52
  end
51
53
 
52
54
  # Changes the debug level to DEBUG if $DEBUG is set
@@ -65,7 +67,7 @@ module YARD
65
67
  # stream is not a TTY. Use +nil+ for no alternate logging.
66
68
  # @yield a block of arbitrary code to benchmark
67
69
  # @return [void]
68
- def capture(msg, nontty_log = :debug, &block)
70
+ def capture(msg, nontty_log = :debug)
69
71
  progress(msg, nontty_log)
70
72
  yield
71
73
  ensure
@@ -118,7 +120,7 @@ module YARD
118
120
  print("#{msg}\n")
119
121
  end
120
122
 
121
- alias_method :print_no_newline, :<<
123
+ alias print_no_newline <<
122
124
  private :print_no_newline
123
125
 
124
126
  # Displays an unformatted line to the logger output stream.
@@ -129,7 +131,7 @@ module YARD
129
131
  clear_line
130
132
  print_no_newline(msg)
131
133
  end
132
- alias_method :<<, :print
134
+ alias << print
133
135
 
134
136
  # Prints the backtrace +exc+ to the logger as error data.
135
137
  #
@@ -161,8 +163,9 @@ module YARD
161
163
  # @param [Fixnum] new_level the logger level for the duration of the block.
162
164
  # values can be found in Ruby's Logger class.
163
165
  # @yield the block with the logger temporarily set to +new_level+
164
- def enter_level(new_level = level, &block)
165
- old_level, self.level = level, new_level
166
+ def enter_level(new_level = level)
167
+ old_level = level
168
+ self.level = new_level
166
169
  yield
167
170
  ensure
168
171
  self.level = old_level
@@ -182,7 +185,7 @@ module YARD
182
185
  end
183
186
 
184
187
  # Log format (from Logger implementation). Used by Logger internally
185
- def format_log(sev, time, prog, msg)
188
+ def format_log(sev, _time, _prog, msg)
186
189
  "[#{sev.downcase}]: #{msg}\n"
187
190
  end
188
191
  end
data/lib/yard/options.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module YARD
2
3
  # Generalized options class for passing around large amounts of options between objects.
3
4
  #
@@ -139,7 +140,7 @@ module YARD
139
140
  # @yieldparam [Symbol] key the option key
140
141
  # @yieldparam [Object] value the option value
141
142
  # @return [void]
142
- def each(&block)
143
+ def each
143
144
  instance_variables.each do |ivar|
144
145
  name = ivar.to_s.sub(/^@/, '')
145
146
  yield(name.to_sym, send(name))
@@ -170,9 +171,9 @@ module YARD
170
171
  if meth.to_s =~ /^(.+)=$/
171
172
  log.debug "Attempting to set unregistered key #{$1} on #{self.class}"
172
173
  instance_variable_set("@#{$1}", args.first)
173
- elsif args.size == 0
174
+ elsif args.empty?
174
175
  log.debug "Attempting to access unregistered key #{meth} on #{self.class}"
175
- instance_variable_get("@#{meth}")
176
+ instance_variable_defined?("@#{meth}") ? instance_variable_get("@#{meth}") : nil
176
177
  else
177
178
  super
178
179
  end
@@ -187,7 +188,9 @@ module YARD
187
188
  def reset_defaults
188
189
  names_set = {}
189
190
  self.class.ancestors.each do |klass| # look at all ancestors
190
- defaults = klass.instance_variable_get("@defaults")
191
+ defaults =
192
+ klass.instance_variable_defined?("@defaults") &&
193
+ klass.instance_variable_get("@defaults")
191
194
  next unless defaults
192
195
  defaults.each do |key, value|
193
196
  next if names_set[key]
@@ -209,8 +212,6 @@ module YARD
209
212
  val
210
213
  end
211
214
 
212
- unless defined? tap() # only for 1.8.6
213
- def tap(&block) yield(self); self end
214
- end
215
+ def tap; yield(self); self end unless defined?(tap) # only for 1.8.6
215
216
  end
216
217
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module YARD
2
3
  module Parser
3
4
  # Represents the abstract base parser class that parses source code in
@@ -22,7 +23,7 @@ module YARD
22
23
  # storing the source contents and filename if they are required.
23
24
  # @param [String] source the source contents
24
25
  # @param [String] filename the name of the file if from disk
25
- def initialize(source, filename)
26
+ def initialize(source, filename) # rubocop:disable Lint/UnusedMethodArgument
26
27
  raise NotImplementedError, "invalid parser implementation"
27
28
  end
28
29
 
@@ -53,4 +54,4 @@ module YARD
53
54
  end
54
55
  end
55
56
  end
56
- end
57
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module YARD
2
3
  module Parser
3
4
  module C
@@ -86,42 +87,43 @@ module YARD
86
87
  end
87
88
  statement.source = @content[start..@index]
88
89
  statement.block = stmts
89
- statement.declaration = decl
90
+ statement.declaration = decl # rubocop:disable Lint/UselessSetterCall
90
91
  end
91
92
 
92
93
  def consume_body_statements
93
94
  stmts = []
94
95
  brace_level = 1
95
- while true
96
+ loop do
96
97
  strip_non_statement_data
97
- start, line = @index, @line
98
+ start = @index
99
+ line = @line
98
100
  consume_until(/[{};]/)
99
101
  brace_level += 1 if prevchar == '{'
100
102
  brace_level -= 1 if prevchar == '}'
101
103
 
102
104
  break if prevchar.empty? || (brace_level <= 0 && prevchar == '}')
103
- end_chr = @index
104
- end_chr -= 1 if prevchar == '}'
105
105
  src = @content[start...@index]
106
- if src && src !~ /\A\s*\Z|\A\}\Z/
107
- stmt = BodyStatement.new(src, @file, line)
108
- attach_comment(stmt)
109
- stmts << stmt
110
- end
106
+ next unless src && src !~ /\A\s*\Z|\A\}\Z/
107
+
108
+ stmt = BodyStatement.new(src, @file, line)
109
+ attach_comment(stmt)
110
+ stmts << stmt
111
111
  end
112
112
  stmts
113
113
  end
114
114
 
115
115
  def strip_non_statement_data
116
116
  start = @index
117
- begin
117
+ loop do
118
118
  start = @index
119
119
  case char
120
120
  when /\s/; consume_whitespace
121
121
  when '#'; consume_directive
122
122
  when '/'; consume_comment
123
123
  end
124
- end until start == @index
124
+
125
+ break if start == @index
126
+ end
125
127
  end
126
128
 
127
129
  def consume_whitespace
@@ -133,7 +135,7 @@ module YARD
133
135
  line = @line
134
136
  type = nextchar == '*' ? :multi : :line
135
137
  advance(2)
136
- comment = ""
138
+ comment = String.new("")
137
139
  advance_loop do
138
140
  comment << char
139
141
  if type == :multi
@@ -179,13 +181,12 @@ module YARD
179
181
  end
180
182
  @newline = false if chr !~ /\s/
181
183
 
182
- if chr =~ end_char && (chr == '{' || chr == '(')
183
- break
184
- elsif chr =~ end_char && bracket_level <= 0 && brace_level <= 0
185
- break
184
+ if chr =~ end_char
185
+ break if chr == '{' || chr == '('
186
+ break if bracket_level <= 0 && brace_level <= 0
186
187
  end
187
188
  end
188
- return @content[start...@index]
189
+ @content[start...@index]
189
190
  end
190
191
 
191
192
  def attach_comment(statement)
@@ -209,8 +210,8 @@ module YARD
209
210
  def advance(num = 1) @index += num end
210
211
  def back(num = 1) @index -= num end
211
212
 
212
- def advance_loop(&block)
213
- while @index <= @content.size; yield end
213
+ def advance_loop
214
+ yield while @index <= @content.size
214
215
  end
215
216
 
216
217
  def nextline
@@ -223,7 +224,7 @@ module YARD
223
224
  def nextchar(num = 1) @content[@index + 1, num] end
224
225
 
225
226
  def struct
226
- /struct\s[:alnum:]+\s\{/
227
+ /struct\s[a-zA-Z0-9]+\s\{/
227
228
  end
228
229
  end
229
230
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module YARD
2
3
  module Parser
3
4
  module C
@@ -56,9 +57,11 @@ module YARD
56
57
  signature, types = *line.split(/ [-=]> /)
57
58
  types = parse_types(types)
58
59
  if signature.sub!(/\[?\s*(\{(?:\s*\|(.+?)\|)?.*\})\s*\]?\s*$/, '') && $1
59
- blk, blkparams = $1, $2
60
+ blk = $1
61
+ blkparams = $2
60
62
  else
61
- blk, blkparams = nil, nil
63
+ blk = nil
64
+ blkparams = nil
62
65
  end
63
66
  case signature
64
67
  when /^(\w+)\s*=\s+(\w+)/
@@ -85,7 +88,7 @@ module YARD
85
88
  if types =~ /true or false/
86
89
  ["Boolean"]
87
90
  else
88
- (types||"").split(/,| or /).map do |t|
91
+ (types || "").split(/,| or /).map do |t|
89
92
  case t.strip.gsub(/^an?_/, '')
90
93
  when "class"; "Class"
91
94
  when "obj", "object", "anObject"; "Object"
@@ -121,9 +124,9 @@ module YARD
121
124
  end
122
125
 
123
126
  def remove_private_comments(comment)
124
- comment = comment.gsub(/\/?\*--\n(.*?)\/?\*\+\+/m, '')
125
- comment = comment.sub(/\/?\*--\n.*/m, '')
126
- comment
127
+ comment = comment.gsub(%r{/?\*--\n(.*?)/?\*\+\+}m, '')
128
+ comment = comment.sub(%r{/?\*--\n.*}m, '')
129
+ comment
127
130
  end
128
131
  end
129
132
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module YARD
2
3
  module Parser
3
4
  module C
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module YARD
2
3
  module Parser
3
4
  module Ruby
@@ -92,13 +93,13 @@ module YARD
92
93
 
93
94
  # List of all known keywords
94
95
  # @return [Hash]
95
- KEYWORDS = { :class => true, :alias => true, :lambda => true, :do_block => true,
96
+ KEYWORDS = {:class => true, :alias => true, :lambda => true, :do_block => true,
96
97
  :def => true, :defs => true, :begin => true, :rescue => true, :rescue_mod => true,
97
98
  :if => true, :if_mod => true, :else => true, :elsif => true, :case => true,
98
99
  :when => true, :next => true, :break => true, :retry => true, :redo => true,
99
100
  :return => true, :throw => true, :catch => true, :until => true, :until_mod => true,
100
101
  :while => true, :while_mod => true, :yield => true, :yield0 => true, :zsuper => true,
101
- :unless => true, :unless_mod => true, :for => true, :super => true, :return0 => true }
102
+ :unless => true, :unless_mod => true, :for => true, :super => true, :return0 => true}
102
103
 
103
104
  # @group Creating an AstNode
104
105
 
@@ -128,7 +129,7 @@ module YARD
128
129
  ReferenceNode
129
130
  elsif type.to_s =~ /_literal\Z/
130
131
  LiteralNode
131
- elsif KEYWORDS.has_key?(type)
132
+ elsif KEYWORDS.key?(type)
132
133
  KeywordNode
133
134
  else
134
135
  AstNode
@@ -157,13 +158,14 @@ module YARD
157
158
  @fallback_line = opts[:listline]
158
159
  @fallback_source = opts[:listchar]
159
160
  @token = true if opts[:token]
161
+ @docstring = nil
160
162
  end
161
163
 
162
164
  # @return [Boolean] whether the node is equal to another by checking
163
165
  # the list and type
164
166
  # @private
165
- def ==(ast)
166
- super && type == ast.type
167
+ def ==(other)
168
+ super && type == other.type
167
169
  end
168
170
 
169
171
  # @group Traversing a Node
@@ -207,7 +209,7 @@ module YARD
207
209
  nodes = [self]
208
210
  nodes.each.with_index do |node, index|
209
211
  yield node
210
- nodes.insert index+1, *node.children
212
+ nodes.insert index + 1, *node.children
211
213
  end
212
214
  end
213
215
 
@@ -285,18 +287,16 @@ module YARD
285
287
 
286
288
  # @return [nil] pretty prints the node
287
289
  def pretty_print(q)
288
- objs = self.dup + [:__last__]
290
+ objs = dup + [:__last__]
289
291
  objs.unshift(type) if type && type != :list
290
292
 
291
293
  options = []
292
- if @docstring
293
- options << ['docstring', docstring]
294
- end
294
+ options << ['docstring', docstring] if @docstring
295
295
  if @source_range || @line_range
296
296
  options << ['line', line_range]
297
297
  options << ['source', source_range]
298
298
  end
299
- objs.pop if options.size == 0
299
+ objs.pop if options.empty?
300
300
 
301
301
  q.group(3, 's(', ')') do
302
302
  q.seplist(objs, nil, :each) do |v|
@@ -341,8 +341,9 @@ module YARD
341
341
  if size == 0
342
342
  self.line_range = @fallback_line
343
343
  self.source_range = @fallback_source
344
- elsif children.size > 0
345
- f, l = children.first, children.last
344
+ elsif !children.empty?
345
+ f = children.first
346
+ l = children.last
346
347
  self.line_range = Range.new(f.line_range.first, l.line_range.last)
347
348
  self.source_range = Range.new(f.source_range.first, l.source_range.last)
348
349
  elsif @fallback_line || @fallback_source
@@ -410,7 +411,8 @@ module YARD
410
411
  end
411
412
 
412
413
  def double_splat_param
413
- YARD.ruby2? ? self[-2] : nil
414
+ return nil unless YARD.ruby2?
415
+ self[-2] if self[-2].is_a?(AstNode) && self[-2].type == :ident
414
416
  end
415
417
 
416
418
  def block_param
@@ -443,6 +445,7 @@ module YARD
443
445
  end
444
446
 
445
447
  def block_param; parameters.last end
448
+
446
449
  def block
447
450
  last.type == :do_block || last.type == :brace_block ? last : nil
448
451
  end
@@ -489,9 +492,8 @@ module YARD
489
492
  def then_block; self[1] end
490
493
 
491
494
  def else_block
492
- if self[2] && !cmod?
493
- self[2].type == :elsif ? self[2] : self[2][0]
494
- end
495
+ return unless self[2] && !cmod?
496
+ self[2].type == :elsif ? self[2] : self[2][0]
495
497
  end
496
498
 
497
499
  private
@@ -527,4 +529,4 @@ module YARD
527
529
  end
528
530
  end
529
531
  end
530
- end
532
+ end
@@ -99,14 +99,14 @@ module YARD
99
99
  class TkOPASGN < TkOp
100
100
  def initialize(line_no, char_no, op)
101
101
  super(line_no, char_no)
102
- op = TkReading2Token[op] unless op.kind_of?(Symbol)
102
+ op = TkReading2Token[op] unless op.is_a?(Symbol)
103
103
  @op = op
104
104
  end
105
105
  attr :op
106
106
  end
107
107
 
108
108
  class TkUnknownChar < Token
109
- def initialize(line_no, char_no, id)
109
+ def initialize(line_no, char_no, _id)
110
110
  super(line_no, char_no)
111
111
  @name = char_no > 255 ? '?' : char_no.chr
112
112
  end
@@ -123,11 +123,11 @@ module YARD
123
123
  end
124
124
 
125
125
  # @private
126
- def Token(token, value = nil)
126
+ def Token(token, value = nil) # rubocop:disable Style/MethodName
127
127
  tk = nil
128
128
  case token
129
129
  when String, Symbol
130
- source = token.kind_of?(String) ? TkReading2Token : TkSymbol2Token
130
+ source = token.is_a?(String) ? TkReading2Token : TkSymbol2Token
131
131
  if (tk = source[token]).nil?
132
132
  IRB.fail TkReading2TokenNoKey, token
133
133
  end
@@ -190,13 +190,11 @@ module YARD
190
190
  [:TklEND, TkKW, "END", EXPR_END],
191
191
  [:Tk__LINE__, TkKW, "__LINE__", EXPR_END],
192
192
  [:Tk__FILE__, TkKW, "__FILE__", EXPR_END],
193
-
194
193
  [:TkIDENTIFIER, TkId],
195
194
  [:TkFID, TkId],
196
195
  [:TkGVAR, TkId],
197
196
  [:TkIVAR, TkId],
198
197
  [:TkCONSTANT, TkId],
199
-
200
198
  [:TkINTEGER, TkVal],
201
199
  [:TkFLOAT, TkVal],
202
200
  [:TkSYMBOL, TkVal],
@@ -205,13 +203,11 @@ module YARD
205
203
  [:TkXSTRING, TkVal],
206
204
  [:TkREGEXP, TkVal],
207
205
  [:TkCOMMENT, TkVal],
208
-
209
206
  [:TkDSTRING, TkNode],
210
207
  [:TkDXSTRING, TkNode],
211
208
  [:TkDREGEXP, TkNode],
212
209
  [:TkNTH_REF, TkId],
213
210
  [:TkBACK_REF, TkId],
214
-
215
211
  [:TkUPLUS, TkOp, "+@"],
216
212
  [:TkUMINUS, TkOp, "-@"],
217
213
  [:TkPOW, TkOp, "**"],
@@ -233,17 +229,12 @@ module YARD
233
229
  [:TkRSHFT, TkOp, ">>"],
234
230
  [:TkCOLON2, TkOp],
235
231
  [:TkCOLON3, TkOp],
236
- [:OPASGN, TkOp], # +=, -= etc. #
232
+ [:OPASGN, TkOp], # +=, -= etc. #
237
233
  [:TkASSOC, TkOp, "=>"],
238
- [:TkQUESTION, TkOp, "?"], #?
239
- [:TkCOLON, TkOp, ":"], #:
240
-
241
- # [:TkfLPAREN], # func( #
242
- # [:TkfLBRACK], # func[ #
243
- # [:TkfLBRACE], # func{ #
234
+ [:TkQUESTION, TkOp, "?"], #?
235
+ [:TkCOLON, TkOp, ":"], #:
244
236
  [:TkSTAR], # *arg
245
237
  [:TkAMPER], # &arg #
246
- # [:TkSYMBOL, TkId], # :SYMBOL
247
238
  [:TkSYMBEG, TkId],
248
239
  [:TkGT, TkOp, ">"],
249
240
  [:TkLT, TkOp, "<"],
@@ -257,28 +248,23 @@ module YARD
257
248
  [:TkBITAND, TkOp, "&"],
258
249
  [:TkBITNOT, TkOp, "~"],
259
250
  [:TkNOTOP, TkOp, "!"],
260
-
261
251
  [:TkBACKQUOTE, TkOp, "`"],
262
-
263
252
  [:TkASSIGN, Token, "="],
264
253
  [:TkDOT, Token, "."],
265
- [:TkLPAREN, Token, "("], #(exp)
266
- [:TkLBRACK, Token, "["], #[arry]
267
- [:TkLBRACE, Token, "{"], #{hash}
254
+ [:TkLPAREN, Token, "("], # (exp)
255
+ [:TkLBRACK, Token, "["], # [arry]
256
+ [:TkLBRACE, Token, "{"], # {hash}
268
257
  [:TkRPAREN, Token, ")"],
269
258
  [:TkRBRACK, Token, "]"],
270
259
  [:TkRBRACE, Token, "}"],
271
260
  [:TkCOMMA, Token, ","],
272
261
  [:TkSEMICOLON, Token, ";"],
273
-
274
- # [:TkRD_COMMENT, TkVal],
275
262
  [:TkSPACE, TkWhitespace],
276
263
  [:TkNL, TkWhitespace],
277
264
  [:TkEND_OF_SCRIPT, TkWhitespace],
278
-
279
265
  [:TkBACKSLASH, TkUnknownChar, "\\"],
280
266
  [:TkAT, TkUnknownChar, "@"],
281
- [:TkDOLLAR, TkUnknownChar, "\$"], #"
267
+ [:TkDOLLAR, TkUnknownChar, "\$"]
282
268
  ]
283
269
 
284
270
  # { reading => token_class }
@@ -287,13 +273,13 @@ module YARD
287
273
  TkSymbol2Token = {}
288
274
 
289
275
  # @private
290
- def RubyToken.def_token(token_n, super_token = Token, reading = nil, *opts)
291
- token_n = token_n.id2name unless token_n.kind_of?(String)
276
+ def self.def_token(token_n, super_token = Token, reading = nil, *opts)
277
+ token_n = token_n.id2name unless token_n.is_a?(String)
292
278
  if RubyToken.const_defined?(token_n)
293
279
  # IRB.fail AlreadyDefinedToken, token_n
294
280
  end
295
281
 
296
- token_c = Class.new super_token
282
+ token_c = Class.new super_token
297
283
  RubyToken.const_set token_n, token_c
298
284
  # token_c.inspect
299
285
 
@@ -320,13 +306,10 @@ module YARD
320
306
  def_token(*defs)
321
307
  end
322
308
 
323
- NEWLINE_TOKEN = TkNL.new(0,0)
309
+ NEWLINE_TOKEN = TkNL.new(0, 0)
324
310
  NEWLINE_TOKEN.set_text("\n")
325
-
326
311
  end
327
312
 
328
-
329
-
330
313
  # Lexical analyzer for Ruby source
331
314
  # @private
332
315
  class RubyLex
@@ -359,19 +342,18 @@ module YARD
359
342
  #
360
343
  # @private
361
344
  class BufferedReader
362
-
363
345
  attr_reader :line_num
364
346
 
365
347
  def initialize(content)
366
348
  if /\t/ =~ content
367
349
  tab_width = 2
368
350
  content = content.split(/\n/).map do |line|
369
- 1 while line.gsub!(/\t+/) { ' ' * (tab_width*$&.length - $`.length % tab_width)} && $~ #`
351
+ 1 while line.gsub!(/\t+/) { ' ' * (tab_width * $&.length - $`.length % tab_width) } && $~ #`
370
352
  line
371
353
  end .join("\n")
372
354
  end
373
- @content = content
374
- @content << "\n" unless @content[-1,1] == "\n"
355
+ @content = String.new(content)
356
+ @content << "\n" unless @content[-1, 1] == "\n"
375
357
  @size = @content.size
376
358
  @offset = 0
377
359
  @hwm = 0
@@ -408,7 +390,7 @@ module YARD
408
390
  getc
409
391
  end
410
392
 
411
- def ungetc(ch)
393
+ def ungetc(_ch)
412
394
  raise "unget past beginning of file" if @offset <= 0
413
395
  @offset -= 1
414
396
  if @content[@offset] == ?\n
@@ -437,7 +419,7 @@ module YARD
437
419
 
438
420
  def divert_read_from(reserve)
439
421
  @content[@offset, 0] = reserve
440
- @size = @content.size
422
+ @size = @content.size
441
423
  end
442
424
  end
443
425
 
@@ -457,7 +439,7 @@ module YARD
457
439
  attr_reader :continue
458
440
  attr_reader :lex_state
459
441
 
460
- def RubyLex.debug?
442
+ def self.debug?
461
443
  false
462
444
  end
463
445
 
@@ -481,6 +463,8 @@ module YARD
481
463
  @skip_space = false
482
464
  @read_auto_clean_up = false
483
465
  @exception_on_syntax_error = true
466
+
467
+ @colonblock_seen = false
484
468
  end
485
469
 
486
470
  attr_accessor :skip_space
@@ -511,16 +495,15 @@ module YARD
511
495
  end
512
496
 
513
497
  def gets
514
- c = getc or return
498
+ (c = getc) || return
515
499
  l = ""
516
500
  begin
517
501
  l.concat c unless c == "\r"
518
502
  break if c == "\n"
519
- end while c = getc
503
+ end while c = getc # rubocop:disable Lint/Loop
520
504
  l
521
505
  end
522
506
 
523
-
524
507
  def ungetc(c = nil)
525
508
  @reader.ungetc(c)
526
509
  end
@@ -535,13 +518,13 @@ module YARD
535
518
 
536
519
  def lex
537
520
  catch(:eof) do
538
- until (((tk = token).kind_of?(TkNL) || tk.kind_of?(TkEND_OF_SCRIPT)) &&
539
- !@continue or
540
- tk.nil?)
521
+ until ((tk = token).is_a?(TkNL) || tk.is_a?(TkEND_OF_SCRIPT)) &&
522
+ !@continue ||
523
+ tk.nil?
541
524
  end
542
525
  line = get_read
543
526
 
544
- if line == "" and tk.kind_of?(TkEND_OF_SCRIPT) || tk.nil?
527
+ if line == "" && tk.is_a?(TkEND_OF_SCRIPT) || tk.nil?
545
528
  nil
546
529
  else
547
530
  line
@@ -555,12 +538,12 @@ module YARD
555
538
  begin
556
539
  begin
557
540
  tk = @OP.match(self)
558
- @space_seen = tk.kind_of?(TkSPACE)
541
+ @space_seen = tk.is_a?(TkSPACE)
559
542
  rescue SyntaxError
560
543
  abort if @exception_on_syntax_error
561
544
  tk = TkError.new(line_no, char_no)
562
545
  end
563
- end while @skip_space and tk.kind_of?(TkSPACE)
546
+ end while @skip_space && tk.is_a?(TkSPACE)
564
547
  if @read_auto_clean_up
565
548
  get_read
566
549
  end
@@ -573,11 +556,10 @@ module YARD
573
556
 
574
557
  ENINDENT_CLAUSE = [
575
558
  "case", "class", "def", "do", "for", "if",
576
- "module", "unless", "until", "while", "begin" #, "when"
577
- ]
559
+ "module", "unless", "until", "while", "begin"
560
+ ] #, "when"
578
561
  ACCEPTS_COLON = ["if", "for", "unless", "until", "while"]
579
- DEINDENT_CLAUSE = ["end" #, "when"
580
- ]
562
+ DEINDENT_CLAUSE = ["end"] #, "when"
581
563
 
582
564
  PERCENT_LTYPE = {
583
565
  "q" => "\'",
@@ -607,16 +589,16 @@ module YARD
607
589
  DLtype2Token = {
608
590
  "\"" => TkDSTRING,
609
591
  "\`" => TkDXSTRING,
610
- "/" => TkDREGEXP,
592
+ "/" => TkDREGEXP
611
593
  }
612
594
 
613
595
  def lex_init()
614
596
  @OP = SLex.new
615
- @OP.def_rules("\0", "\004", "\032") do |chars, io|
597
+ @OP.def_rules("\0", "\004", "\032") do |chars, _io|
616
598
  Token(TkEND_OF_SCRIPT).set_text(chars)
617
599
  end
618
600
 
619
- @OP.def_rules(" ", "\t", "\f", "\r", "\13") do |chars, io|
601
+ @OP.def_rules(" ", "\t", "\f", "\r", "\13") do |chars, _io|
620
602
  @space_seen = TRUE
621
603
  while (ch = getc) =~ /[ \t\f\r\13]/
622
604
  chars << ch
@@ -625,19 +607,16 @@ module YARD
625
607
  Token(TkSPACE).set_text(chars)
626
608
  end
627
609
 
628
- @OP.def_rule("#") do
629
- |op, io|
610
+ @OP.def_rule("#") do |_op, _io|
630
611
  identify_comment
631
612
  end
632
613
 
633
- @OP.def_rule("=begin", proc{@prev_char_no == 0 && peek(0) =~ /\s/}) do
634
- |op, io|
635
- str = op
614
+ @OP.def_rule("=begin", proc { @prev_char_no == 0 && peek(0) =~ /\s/ }) do |op, _io|
615
+ str = String.new(op)
636
616
  @ltype = "="
637
617
 
638
-
639
618
  begin
640
- line = ""
619
+ line = String.new
641
620
  begin
642
621
  ch = getc
643
622
  line << ch
@@ -676,17 +655,17 @@ module YARD
676
655
  "=", "==", "===",
677
656
  "=~", "<=>",
678
657
  "<", "<=",
679
- ">", ">=", ">>") do |op, io|
658
+ ">", ">=", ">>") do |op, _io|
680
659
  @lex_state = EXPR_BEG
681
660
  Token(op).set_text(op)
682
661
  end
683
662
 
684
- @OP.def_rules("<<") do |op, io|
663
+ @OP.def_rules("<<") do |op, _io|
685
664
  tk = nil
686
665
  if @lex_state != EXPR_END && @lex_state != EXPR_CLASS &&
687
666
  (@lex_state != EXPR_ARG || @space_seen)
688
667
  c = peek(0)
689
- tk = identify_here_document if /[-\w_\"\'\`]/ =~ c
668
+ tk = identify_here_document if /[-\w\"\'\`]/ =~ c
690
669
  end
691
670
  if !tk
692
671
  @lex_state = EXPR_BEG
@@ -695,11 +674,11 @@ module YARD
695
674
  tk
696
675
  end
697
676
 
698
- @OP.def_rules("'", '"') do |op, io|
677
+ @OP.def_rules("'", '"') do |op, _io|
699
678
  identify_string(op)
700
679
  end
701
680
 
702
- @OP.def_rules("`") do |op, io|
681
+ @OP.def_rules("`") do |op, _io|
703
682
  if @lex_state == EXPR_FNAME
704
683
  Token(op).set_text(op)
705
684
  else
@@ -707,7 +686,7 @@ module YARD
707
686
  end
708
687
  end
709
688
 
710
- @OP.def_rules('?') do |op, io|
689
+ @OP.def_rules('?') do |op, _io|
711
690
  if @lex_state == EXPR_END
712
691
  @lex_state = EXPR_BEG
713
692
  Token(TkQUESTION).set_text(op)
@@ -718,9 +697,9 @@ module YARD
718
697
  @lex_state = EXPR_BEG
719
698
  Token(TkQUESTION).set_text(op)
720
699
  else
721
- str = op
700
+ str = String.new(op)
722
701
  str << ch
723
- if (ch == '\\') #'
702
+ if ch == '\\' #'
724
703
  str << read_escape
725
704
  end
726
705
  @lex_state = EXPR_END
@@ -729,35 +708,35 @@ module YARD
729
708
  end
730
709
  end
731
710
 
732
- @OP.def_rules("&", "&&", "|", "||") do |op, io|
711
+ @OP.def_rules("&", "&&", "|", "||") do |op, _io|
733
712
  @lex_state = EXPR_BEG
734
713
  Token(op).set_text(op)
735
714
  end
736
715
 
737
716
  @OP.def_rules("+=", "-=", "*=", "**=",
738
- "&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do |op, io|
717
+ "&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do |op, _io|
739
718
  @lex_state = EXPR_BEG
740
719
  op =~ /^(.*)=$/
741
720
  Token(TkOPASGN, $1).set_text(op)
742
721
  end
743
722
 
744
- @OP.def_rule("+@", proc{@lex_state == EXPR_FNAME}) do |op, io|
723
+ @OP.def_rule("+@", proc { @lex_state == EXPR_FNAME }) do |op, _io|
745
724
  Token(TkUPLUS).set_text(op)
746
725
  end
747
726
 
748
- @OP.def_rule("-@", proc{@lex_state == EXPR_FNAME}) do |op, io|
727
+ @OP.def_rule("-@", proc { @lex_state == EXPR_FNAME }) do |op, _io|
749
728
  Token(TkUMINUS).set_text(op)
750
729
  end
751
730
 
752
- @OP.def_rules("+", "-") do |op, io|
731
+ @OP.def_rules("+", "-") do |op, _io|
753
732
  catch(:RET) do
754
733
  if @lex_state == EXPR_ARG
755
- if @space_seen and peek(0) =~ /[0-9]/
734
+ if @space_seen && peek(0) =~ /[0-9]/
756
735
  throw :RET, identify_number(op)
757
736
  else
758
737
  @lex_state = EXPR_BEG
759
738
  end
760
- elsif @lex_state != EXPR_END and peek(0) =~ /[0-9]/
739
+ elsif @lex_state != EXPR_END && peek(0) =~ /[0-9]/
761
740
  throw :RET, identify_number(op)
762
741
  else
763
742
  @lex_state = EXPR_BEG
@@ -778,7 +757,7 @@ module YARD
778
757
  end
779
758
  end
780
759
 
781
- @OP.def_rules("..", "...") do |op, io|
760
+ @OP.def_rules("..", "...") do |op, _io|
782
761
  @lex_state = EXPR_BEG
783
762
  Token(op).set_text(op)
784
763
  end
@@ -787,8 +766,7 @@ module YARD
787
766
  end
788
767
 
789
768
  def lex_int2
790
- @OP.def_rules("]", "}", ")") do
791
- |op, io|
769
+ @OP.def_rules("]", "}", ")") do |op, _io|
792
770
  @lex_state = EXPR_END
793
771
  @indent -= 1
794
772
  Token(op).set_text(op)
@@ -807,7 +785,7 @@ module YARD
807
785
 
808
786
  @OP.def_rule("::") do
809
787
  # p @lex_state.id2name, @space_seen
810
- if @lex_state == EXPR_BEG or @lex_state == EXPR_ARG && @space_seen
788
+ if @lex_state == EXPR_BEG || @lex_state == EXPR_ARG && @space_seen
811
789
  @lex_state = EXPR_BEG
812
790
  tk = Token(TkCOLON3)
813
791
  else
@@ -817,14 +795,14 @@ module YARD
817
795
  tk.set_text("::")
818
796
  end
819
797
 
820
- @OP.def_rule("/") do |op, io|
798
+ @OP.def_rule("/") do |op, _io|
821
799
  if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
822
800
  identify_string(op)
823
801
  elsif peek(0) == '='
824
802
  getc
825
803
  @lex_state = EXPR_BEG
826
804
  Token(TkOPASGN, :/).set_text("/=") #")
827
- elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
805
+ elsif @lex_state == EXPR_ARG && @space_seen && peek(0) !~ /\s/
828
806
  identify_string(op)
829
807
  else
830
808
  @lex_state = EXPR_BEG
@@ -842,7 +820,7 @@ module YARD
842
820
  # Token(TkOPASGN, :^)
843
821
  # end
844
822
 
845
- @OP.def_rules(",", ";") do |op, io|
823
+ @OP.def_rules(",", ";") do |op, _io|
846
824
  @colonblock_seen = false
847
825
  @lex_state = EXPR_BEG
848
826
  Token(op).set_text(op)
@@ -853,28 +831,28 @@ module YARD
853
831
  Token("~").set_text("~")
854
832
  end
855
833
 
856
- @OP.def_rule("~@", proc{@lex_state = EXPR_FNAME}) do
834
+ @OP.def_rule("~@", proc { @lex_state = EXPR_FNAME }) do
857
835
  @lex_state = EXPR_BEG
858
836
  Token("~").set_text("~@")
859
837
  end
860
838
 
861
839
  @OP.def_rule("(") do
862
840
  @indent += 1
863
- # if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
864
- # @lex_state = EXPR_BEG
865
- # tk = Token(TkfLPAREN)
866
- # else
841
+ # if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
842
+ # @lex_state = EXPR_BEG
843
+ # tk = Token(TkfLPAREN)
844
+ # else
867
845
  @lex_state = EXPR_BEG
868
846
  tk = Token(TkLPAREN)
869
847
  # end
870
848
  tk.set_text("(")
871
849
  end
872
850
 
873
- @OP.def_rule("[]", proc{@lex_state == EXPR_FNAME}) do
851
+ @OP.def_rule("[]", proc { @lex_state == EXPR_FNAME }) do
874
852
  Token("[]").set_text("[]")
875
853
  end
876
854
 
877
- @OP.def_rule("[]=", proc{@lex_state == EXPR_FNAME}) do
855
+ @OP.def_rule("[]=", proc { @lex_state == EXPR_FNAME }) do
878
856
  Token("[]=").set_text("[]=")
879
857
  end
880
858
 
@@ -907,25 +885,24 @@ module YARD
907
885
  t.set_text("{")
908
886
  end
909
887
 
910
- @OP.def_rule('\\') do #'
888
+ @OP.def_rule('\\') do #'
911
889
  if getc == "\n"
912
890
  @space_seen = true
913
891
  @continue = true
914
892
  Token(TkSPACE).set_text("\\\n")
915
893
  else
916
894
  ungetc
917
- Token("\\").set_text("\\") #"
895
+ Token("\\").set_text("\\") #"
918
896
  end
919
897
  end
920
898
 
921
- @OP.def_rule('%') do
922
- |op, io|
899
+ @OP.def_rule('%') do |_op, _io|
923
900
  if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
924
901
  identify_quotation('%')
925
902
  elsif peek(0) == '='
926
903
  getc
927
904
  Token(TkOPASGN, "%").set_text("%=")
928
- elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
905
+ elsif @lex_state == EXPR_ARG && @space_seen && peek(0) !~ /\s/
929
906
  identify_quotation('%')
930
907
  else
931
908
  @lex_state = EXPR_BEG
@@ -933,12 +910,12 @@ module YARD
933
910
  end
934
911
  end
935
912
 
936
- @OP.def_rule('$') do #'
913
+ @OP.def_rule('$') do #'
937
914
  identify_gvar
938
915
  end
939
916
 
940
917
  @OP.def_rule('@') do
941
- if peek(0) =~ /[@\w_]/
918
+ if peek(0) =~ /[@\w]/
942
919
  ungetc
943
920
  identify_identifier
944
921
  else
@@ -956,7 +933,7 @@ module YARD
956
933
  # # end
957
934
  # end
958
935
 
959
- @OP.def_rule("__END__", proc{@prev_char_no == 0 && peek(0) =~ /[\r\n]/}) do
936
+ @OP.def_rule("__END__", proc { @prev_char_no == 0 && peek(0) =~ /[\r\n]/ }) do
960
937
  throw :eof
961
938
  end
962
939
 
@@ -964,7 +941,7 @@ module YARD
964
941
  printf "MATCH: start %s: %s\n", op, io.inspect if RubyLex.debug?
965
942
  if peek(0) =~ /[0-9]/
966
943
  t = identify_number("")
967
- elsif peek(0) =~ /[\w_]/
944
+ elsif peek(0) =~ /[\w]/
968
945
  t = identify_identifier
969
946
  end
970
947
  printf "MATCH: end %s: %s\n", op, io.inspect if RubyLex.debug?
@@ -976,10 +953,10 @@ module YARD
976
953
 
977
954
  def identify_gvar
978
955
  @lex_state = EXPR_END
979
- str = "$"
956
+ str = String.new("$")
980
957
 
981
958
  tk = case ch = getc
982
- when /[~_*$?!@\/\\;,=:<>".]/ #"
959
+ when %r{[~_*$?!@/\\;,=:<>".]}
983
960
  str << ch
984
961
  Token(TkGVAR, str)
985
962
 
@@ -1020,7 +997,7 @@ module YARD
1020
997
  end
1021
998
  ungetc
1022
999
 
1023
- if ch == "!" or ch == "?"
1000
+ if ch == "!" || ch == "?"
1024
1001
  token.concat getc
1025
1002
  end
1026
1003
  # fix token
@@ -1042,9 +1019,9 @@ module YARD
1042
1019
  if token_c
1043
1020
  # reserved word?
1044
1021
 
1045
- if (@lex_state != EXPR_BEG &&
1046
- @lex_state != EXPR_FNAME &&
1047
- trans[1])
1022
+ if @lex_state != EXPR_BEG &&
1023
+ @lex_state != EXPR_FNAME &&
1024
+ trans[1]
1048
1025
  # modifiers
1049
1026
  token_c = TkSymbol2Token[trans[1]]
1050
1027
  @lex_state = trans[0]
@@ -1097,7 +1074,7 @@ module YARD
1097
1074
  ch = getc
1098
1075
  indent = true
1099
1076
  end
1100
- if /['"`]/ =~ ch # '
1077
+ if /['"`]/ =~ ch # '
1101
1078
  lt = ch
1102
1079
  quoted = ""
1103
1080
  while (c = getc) && c != lt
@@ -1113,11 +1090,11 @@ module YARD
1113
1090
  end
1114
1091
 
1115
1092
  ltback, @ltype = @ltype, lt
1116
- reserve = ""
1093
+ reserve = String.new
1117
1094
 
1118
1095
  while ch = getc
1119
1096
  reserve << ch
1120
- if ch == "\\" #"
1097
+ if ch == "\\" #"
1121
1098
  ch = getc
1122
1099
  reserve << ch
1123
1100
  elsif ch == "\n"
@@ -1125,7 +1102,7 @@ module YARD
1125
1102
  end
1126
1103
  end
1127
1104
 
1128
- str = ""
1105
+ str = String.new
1129
1106
  while (l = gets)
1130
1107
  l.chomp!
1131
1108
  l.strip! if indent
@@ -1162,7 +1139,7 @@ module YARD
1162
1139
  def identify_number(start)
1163
1140
  str = start.dup
1164
1141
 
1165
- if start == "+" or start == "-" or start == ""
1142
+ if start == "+" || start == "-" || start == ""
1166
1143
  start = getc
1167
1144
  str << start
1168
1145
  end
@@ -1221,14 +1198,14 @@ module YARD
1221
1198
  Token(type).set_text(str)
1222
1199
  end
1223
1200
 
1224
- def identify_string(ltype, quoted = ltype, opener=nil, initial_char = nil)
1201
+ def identify_string(ltype, quoted = ltype, opener = nil, initial_char = nil)
1225
1202
  @ltype = ltype
1226
1203
  @quoted = quoted
1227
1204
  subtype = nil
1228
1205
 
1229
- str = ""
1206
+ str = String.new
1230
1207
  str << initial_char if initial_char
1231
- str << (opener||quoted)
1208
+ str << (opener || quoted)
1232
1209
 
1233
1210
  nest = 0
1234
1211
  begin
@@ -1242,7 +1219,7 @@ module YARD
1242
1219
  end
1243
1220
  elsif opener == ch
1244
1221
  nest += 1
1245
- elsif @ltype != "'" && @ltype != "]" and ch == "#"
1222
+ elsif @ltype != "'" && @ltype != "]" && ch == "#"
1246
1223
  ch = getc
1247
1224
  if ch == "{"
1248
1225
  subtype = true
@@ -1272,12 +1249,12 @@ module YARD
1272
1249
  end
1273
1250
 
1274
1251
  def skip_inner_expression
1275
- res = ""
1252
+ res = String.new
1276
1253
  nest = 0
1277
1254
  while (ch = getc)
1278
1255
  res << ch
1279
1256
  if ch == '}'
1280
- break if nest.zero?
1257
+ break if nest == 0
1281
1258
  nest -= 1
1282
1259
  elsif ch == '{'
1283
1260
  nest += 1
@@ -1288,7 +1265,7 @@ module YARD
1288
1265
 
1289
1266
  def identify_comment
1290
1267
  @ltype = "#"
1291
- comment = "#"
1268
+ comment = String.new("#")
1292
1269
  while ch = getc
1293
1270
  if ch == "\\"
1294
1271
  ch = getc
@@ -1306,11 +1283,11 @@ module YARD
1306
1283
  end
1307
1284
  comment << ch
1308
1285
  end
1309
- return Token(TkCOMMENT).set_text(comment)
1286
+ Token(TkCOMMENT).set_text(comment)
1310
1287
  end
1311
1288
 
1312
1289
  def read_escape
1313
- res = ""
1290
+ res = String.new
1314
1291
  case ch = getc
1315
1292
  when /[0-7]/
1316
1293
  ungetc ch
@@ -1324,7 +1301,7 @@ module YARD
1324
1301
  break
1325
1302
  end
1326
1303
  res << ch
1327
- end
1304
+ end
1328
1305
 
1329
1306
  when "x"
1330
1307
  res << ch
@@ -1356,7 +1333,7 @@ module YARD
1356
1333
 
1357
1334
  when "C", "c" #, "^"
1358
1335
  res << ch
1359
- if ch == "C" and (ch = getc) != "-"
1336
+ if ch == "C" && (ch = getc) != "-"
1360
1337
  ungetc
1361
1338
  else
1362
1339
  res << ch