yard 0.9.16 → 0.9.17

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 (566) hide show
  1. checksums.yaml +5 -5
  2. data/.yardopts +26 -26
  3. data/CHANGELOG.md +728 -728
  4. data/LEGAL +66 -66
  5. data/LICENSE +22 -22
  6. data/README.md +328 -328
  7. data/Rakefile +53 -47
  8. data/benchmarks/builtins_vs_eval.rb +24 -24
  9. data/benchmarks/concat_vs_join.rb +13 -13
  10. data/benchmarks/erb_vs_erubis.rb +54 -54
  11. data/benchmarks/format_args.rb +47 -47
  12. data/benchmarks/generation.rb +38 -38
  13. data/benchmarks/marshal_vs_dbm.rb +64 -64
  14. data/benchmarks/parsing.rb +46 -46
  15. data/benchmarks/pathname_vs_string.rb +50 -50
  16. data/benchmarks/rdoc_vs_yardoc.rb +11 -11
  17. data/benchmarks/registry_store_types.rb +49 -49
  18. data/benchmarks/ri_vs_yri.rb +19 -19
  19. data/benchmarks/ripper_parser.rb +13 -13
  20. data/benchmarks/splat_vs_flatten.rb +13 -13
  21. data/benchmarks/template_erb.rb +23 -23
  22. data/benchmarks/template_format.rb +7 -7
  23. data/benchmarks/template_profile.rb +18 -18
  24. data/benchmarks/yri_cache.rb +20 -20
  25. data/bin/yard +13 -13
  26. data/bin/yardoc +13 -13
  27. data/bin/yri +13 -13
  28. data/docs/CodeObjects.md +115 -115
  29. data/docs/GettingStarted.md +679 -679
  30. data/docs/Handlers.md +152 -152
  31. data/docs/Overview.md +61 -61
  32. data/docs/Parser.md +191 -191
  33. data/docs/Tags.md +283 -283
  34. data/docs/TagsArch.md +123 -123
  35. data/docs/Templates.md +496 -496
  36. data/docs/WhatsNew.md +1245 -1245
  37. data/docs/templates/default/fulldoc/html/full_list_tag.erb +8 -8
  38. data/docs/templates/default/fulldoc/html/setup.rb +6 -6
  39. data/docs/templates/default/layout/html/setup.rb +9 -9
  40. data/docs/templates/default/layout/html/tag_list.erb +11 -11
  41. data/docs/templates/default/yard_tags/html/list.erb +18 -18
  42. data/docs/templates/default/yard_tags/html/setup.rb +26 -26
  43. data/docs/templates/plugin.rb +70 -70
  44. data/lib/rubygems_plugin.rb +9 -9
  45. data/lib/yard.rb +69 -69
  46. data/lib/yard/autoload.rb +303 -303
  47. data/lib/yard/cli/command.rb +85 -85
  48. data/lib/yard/cli/command_parser.rb +93 -93
  49. data/lib/yard/cli/config.rb +198 -198
  50. data/lib/yard/cli/diff.rb +270 -270
  51. data/lib/yard/cli/display.rb +69 -69
  52. data/lib/yard/cli/gems.rb +84 -84
  53. data/lib/yard/cli/graph.rb +125 -125
  54. data/lib/yard/cli/help.rb +20 -20
  55. data/lib/yard/cli/i18n.rb +70 -70
  56. data/lib/yard/cli/list.rb +23 -23
  57. data/lib/yard/cli/markup_types.rb +32 -32
  58. data/lib/yard/cli/server.rb +257 -257
  59. data/lib/yard/cli/stats.rb +231 -231
  60. data/lib/yard/cli/yardoc.rb +788 -788
  61. data/lib/yard/cli/yardopts_command.rb +110 -110
  62. data/lib/yard/cli/yri.rb +215 -215
  63. data/lib/yard/code_objects/base.rb +615 -610
  64. data/lib/yard/code_objects/class_object.rb +146 -146
  65. data/lib/yard/code_objects/class_variable_object.rb +11 -11
  66. data/lib/yard/code_objects/constant_object.rb +16 -16
  67. data/lib/yard/code_objects/extended_method_object.rb +24 -24
  68. data/lib/yard/code_objects/extra_file_object.rb +131 -131
  69. data/lib/yard/code_objects/macro_object.rb +172 -172
  70. data/lib/yard/code_objects/method_object.rb +196 -196
  71. data/lib/yard/code_objects/module_object.rb +21 -21
  72. data/lib/yard/code_objects/namespace_mapper.rb +114 -114
  73. data/lib/yard/code_objects/namespace_object.rb +200 -200
  74. data/lib/yard/code_objects/proxy.rb +240 -240
  75. data/lib/yard/code_objects/root_object.rb +19 -19
  76. data/lib/yard/config.rb +270 -270
  77. data/lib/yard/core_ext/array.rb +16 -16
  78. data/lib/yard/core_ext/file.rb +69 -69
  79. data/lib/yard/core_ext/hash.rb +16 -16
  80. data/lib/yard/core_ext/insertion.rb +63 -63
  81. data/lib/yard/core_ext/module.rb +20 -20
  82. data/lib/yard/core_ext/string.rb +68 -68
  83. data/lib/yard/core_ext/symbol_hash.rb +75 -75
  84. data/lib/yard/docstring.rb +386 -378
  85. data/lib/yard/docstring_parser.rb +345 -345
  86. data/lib/yard/gem_index.rb +29 -29
  87. data/lib/yard/globals.rb +22 -22
  88. data/lib/yard/handlers/base.rb +595 -595
  89. data/lib/yard/handlers/c/alias_handler.rb +16 -16
  90. data/lib/yard/handlers/c/attribute_handler.rb +13 -13
  91. data/lib/yard/handlers/c/base.rb +129 -129
  92. data/lib/yard/handlers/c/class_handler.rb +27 -27
  93. data/lib/yard/handlers/c/constant_handler.rb +13 -13
  94. data/lib/yard/handlers/c/handler_methods.rb +211 -211
  95. data/lib/yard/handlers/c/init_handler.rb +20 -20
  96. data/lib/yard/handlers/c/method_handler.rb +45 -36
  97. data/lib/yard/handlers/c/mixin_handler.rb +21 -21
  98. data/lib/yard/handlers/c/module_handler.rb +17 -17
  99. data/lib/yard/handlers/c/override_comment_handler.rb +31 -31
  100. data/lib/yard/handlers/c/path_handler.rb +11 -11
  101. data/lib/yard/handlers/c/struct_handler.rb +13 -13
  102. data/lib/yard/handlers/c/symbol_handler.rb +8 -8
  103. data/lib/yard/handlers/processor.rb +200 -200
  104. data/lib/yard/handlers/ruby/alias_handler.rb +44 -44
  105. data/lib/yard/handlers/ruby/attribute_handler.rb +87 -87
  106. data/lib/yard/handlers/ruby/base.rb +165 -165
  107. data/lib/yard/handlers/ruby/class_condition_handler.rb +92 -92
  108. data/lib/yard/handlers/ruby/class_handler.rb +119 -119
  109. data/lib/yard/handlers/ruby/class_variable_handler.rb +17 -17
  110. data/lib/yard/handlers/ruby/comment_handler.rb +10 -10
  111. data/lib/yard/handlers/ruby/constant_handler.rb +59 -59
  112. data/lib/yard/handlers/ruby/decorator_handler_methods.rb +123 -123
  113. data/lib/yard/handlers/ruby/dsl_handler.rb +15 -15
  114. data/lib/yard/handlers/ruby/dsl_handler_methods.rb +96 -95
  115. data/lib/yard/handlers/ruby/exception_handler.rb +27 -27
  116. data/lib/yard/handlers/ruby/extend_handler.rb +22 -22
  117. data/lib/yard/handlers/ruby/legacy/alias_handler.rb +37 -37
  118. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +65 -65
  119. data/lib/yard/handlers/ruby/legacy/base.rb +245 -245
  120. data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +83 -83
  121. data/lib/yard/handlers/ruby/legacy/class_handler.rb +113 -113
  122. data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +15 -15
  123. data/lib/yard/handlers/ruby/legacy/comment_handler.rb +10 -10
  124. data/lib/yard/handlers/ruby/legacy/constant_handler.rb +29 -29
  125. data/lib/yard/handlers/ruby/legacy/dsl_handler.rb +17 -17
  126. data/lib/yard/handlers/ruby/legacy/exception_handler.rb +13 -13
  127. data/lib/yard/handlers/ruby/legacy/extend_handler.rb +21 -21
  128. data/lib/yard/handlers/ruby/legacy/method_handler.rb +90 -90
  129. data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +39 -39
  130. data/lib/yard/handlers/ruby/legacy/module_function_handler.rb +19 -19
  131. data/lib/yard/handlers/ruby/legacy/module_handler.rb +12 -12
  132. data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +22 -22
  133. data/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +22 -22
  134. data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +17 -17
  135. data/lib/yard/handlers/ruby/legacy/yield_handler.rb +29 -29
  136. data/lib/yard/handlers/ruby/method_condition_handler.rb +9 -9
  137. data/lib/yard/handlers/ruby/method_handler.rb +118 -118
  138. data/lib/yard/handlers/ruby/mixin_handler.rb +37 -37
  139. data/lib/yard/handlers/ruby/module_function_handler.rb +27 -27
  140. data/lib/yard/handlers/ruby/module_handler.rb +12 -12
  141. data/lib/yard/handlers/ruby/private_class_method_handler.rb +14 -14
  142. data/lib/yard/handlers/ruby/private_constant_handler.rb +43 -43
  143. data/lib/yard/handlers/ruby/public_class_method_handler.rb +14 -14
  144. data/lib/yard/handlers/ruby/struct_handler_methods.rb +143 -143
  145. data/lib/yard/handlers/ruby/visibility_handler.rb +22 -22
  146. data/lib/yard/handlers/ruby/yield_handler.rb +31 -31
  147. data/lib/yard/i18n/locale.rb +67 -67
  148. data/lib/yard/i18n/message.rb +57 -57
  149. data/lib/yard/i18n/messages.rb +56 -56
  150. data/lib/yard/i18n/po_parser.rb +61 -61
  151. data/lib/yard/i18n/pot_generator.rb +290 -290
  152. data/lib/yard/i18n/text.rb +173 -173
  153. data/lib/yard/logging.rb +205 -205
  154. data/lib/yard/options.rb +217 -217
  155. data/lib/yard/parser/base.rb +57 -57
  156. data/lib/yard/parser/c/c_parser.rb +235 -235
  157. data/lib/yard/parser/c/comment_parser.rb +134 -134
  158. data/lib/yard/parser/c/statement.rb +64 -64
  159. data/lib/yard/parser/ruby/ast_node.rb +540 -540
  160. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +1354 -1354
  161. data/lib/yard/parser/ruby/legacy/ruby_parser.rb +32 -32
  162. data/lib/yard/parser/ruby/legacy/statement.rb +66 -66
  163. data/lib/yard/parser/ruby/legacy/statement_list.rb +394 -394
  164. data/lib/yard/parser/ruby/legacy/token_list.rb +74 -74
  165. data/lib/yard/parser/ruby/ruby_parser.rb +687 -687
  166. data/lib/yard/parser/ruby/token_resolver.rb +156 -156
  167. data/lib/yard/parser/source_parser.rb +526 -526
  168. data/lib/yard/rake/yardoc_task.rb +81 -81
  169. data/lib/yard/registry.rb +439 -439
  170. data/lib/yard/registry_resolver.rb +189 -189
  171. data/lib/yard/registry_store.rb +337 -337
  172. data/lib/yard/rubygems/backports.rb +10 -10
  173. data/lib/yard/rubygems/backports/LICENSE.txt +57 -57
  174. data/lib/yard/rubygems/backports/MIT.txt +20 -20
  175. data/lib/yard/rubygems/backports/gem.rb +10 -10
  176. data/lib/yard/rubygems/backports/source_index.rb +365 -365
  177. data/lib/yard/rubygems/doc_manager.rb +90 -90
  178. data/lib/yard/rubygems/hook.rb +197 -197
  179. data/lib/yard/rubygems/specification.rb +50 -50
  180. data/lib/yard/serializers/base.rb +83 -83
  181. data/lib/yard/serializers/file_system_serializer.rb +123 -123
  182. data/lib/yard/serializers/process_serializer.rb +24 -24
  183. data/lib/yard/serializers/stdout_serializer.rb +34 -34
  184. data/lib/yard/serializers/yardoc_serializer.rb +152 -152
  185. data/lib/yard/server.rb +13 -13
  186. data/lib/yard/server/adapter.rb +100 -100
  187. data/lib/yard/server/commands/base.rb +209 -209
  188. data/lib/yard/server/commands/display_file_command.rb +29 -29
  189. data/lib/yard/server/commands/display_object_command.rb +65 -65
  190. data/lib/yard/server/commands/frames_command.rb +16 -16
  191. data/lib/yard/server/commands/library_command.rb +187 -187
  192. data/lib/yard/server/commands/library_index_command.rb +28 -28
  193. data/lib/yard/server/commands/list_command.rb +25 -25
  194. data/lib/yard/server/commands/root_request_command.rb +15 -15
  195. data/lib/yard/server/commands/search_command.rb +79 -79
  196. data/lib/yard/server/commands/static_file_command.rb +23 -23
  197. data/lib/yard/server/commands/static_file_helpers.rb +62 -62
  198. data/lib/yard/server/doc_server_helper.rb +91 -91
  199. data/lib/yard/server/doc_server_serializer.rb +39 -39
  200. data/lib/yard/server/library_version.rb +277 -277
  201. data/lib/yard/server/rack_adapter.rb +89 -89
  202. data/lib/yard/server/router.rb +187 -187
  203. data/lib/yard/server/static_caching.rb +46 -46
  204. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +127 -127
  205. data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +11 -11
  206. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +37 -37
  207. data/lib/yard/server/templates/default/layout/html/script_setup.erb +7 -7
  208. data/lib/yard/server/templates/default/layout/html/setup.rb +8 -8
  209. data/lib/yard/server/templates/default/method_details/html/permalink.erb +4 -4
  210. data/lib/yard/server/templates/default/method_details/html/setup.rb +5 -5
  211. data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +8 -8
  212. data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +14 -14
  213. data/lib/yard/server/templates/doc_server/library_list/html/listing.erb +13 -13
  214. data/lib/yard/server/templates/doc_server/library_list/html/setup.rb +6 -6
  215. data/lib/yard/server/templates/doc_server/library_list/html/title.erb +2 -2
  216. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +52 -52
  217. data/lib/yard/server/templates/doc_server/processing/html/setup.rb +4 -4
  218. data/lib/yard/server/templates/doc_server/search/html/search.erb +18 -18
  219. data/lib/yard/server/templates/doc_server/search/html/setup.rb +9 -9
  220. data/lib/yard/server/webrick_adapter.rb +45 -45
  221. data/lib/yard/tags/default_factory.rb +191 -191
  222. data/lib/yard/tags/default_tag.rb +13 -13
  223. data/lib/yard/tags/directives.rb +616 -616
  224. data/lib/yard/tags/library.rb +633 -633
  225. data/lib/yard/tags/option_tag.rb +13 -13
  226. data/lib/yard/tags/overload_tag.rb +71 -71
  227. data/lib/yard/tags/ref_tag.rb +8 -8
  228. data/lib/yard/tags/ref_tag_list.rb +28 -28
  229. data/lib/yard/tags/tag.rb +71 -71
  230. data/lib/yard/tags/tag_format_error.rb +7 -7
  231. data/lib/yard/tags/types_explainer.rb +162 -162
  232. data/lib/yard/templates/engine.rb +186 -186
  233. data/lib/yard/templates/erb_cache.rb +23 -23
  234. data/lib/yard/templates/helpers/base_helper.rb +215 -215
  235. data/lib/yard/templates/helpers/filter_helper.rb +27 -27
  236. data/lib/yard/templates/helpers/html_helper.rb +646 -642
  237. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +78 -78
  238. data/lib/yard/templates/helpers/markup/rdoc_markdown.rb +23 -23
  239. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +109 -109
  240. data/lib/yard/templates/helpers/markup_helper.rb +172 -172
  241. data/lib/yard/templates/helpers/method_helper.rb +75 -75
  242. data/lib/yard/templates/helpers/module_helper.rb +21 -21
  243. data/lib/yard/templates/helpers/text_helper.rb +112 -112
  244. data/lib/yard/templates/helpers/uml_helper.rb +47 -47
  245. data/lib/yard/templates/section.rb +105 -105
  246. data/lib/yard/templates/template.rb +418 -418
  247. data/lib/yard/templates/template_options.rb +92 -92
  248. data/lib/yard/verifier.rb +151 -151
  249. data/lib/yard/version.rb +3 -1
  250. data/spec/cli/command_parser_spec.rb +43 -43
  251. data/spec/cli/command_spec.rb +36 -36
  252. data/spec/cli/config_spec.rb +148 -148
  253. data/spec/cli/diff_spec.rb +254 -254
  254. data/spec/cli/display_spec.rb +30 -30
  255. data/spec/cli/gems_spec.rb +81 -81
  256. data/spec/cli/graph_spec.rb +18 -18
  257. data/spec/cli/help_spec.rb +22 -22
  258. data/spec/cli/i18n_spec.rb +107 -107
  259. data/spec/cli/list_spec.rb +8 -8
  260. data/spec/cli/markup_types_spec.rb +22 -22
  261. data/spec/cli/server_spec.rb +324 -324
  262. data/spec/cli/stats_spec.rb +96 -96
  263. data/spec/cli/yard_on_yard_spec.rb +38 -38
  264. data/spec/cli/yardoc_spec.rb +862 -849
  265. data/spec/cli/yri_spec.rb +101 -101
  266. data/spec/code_objects/base_spec.rb +470 -460
  267. data/spec/code_objects/class_object_spec.rb +226 -226
  268. data/spec/code_objects/code_object_list_spec.rb +36 -36
  269. data/spec/code_objects/constants_spec.rb +116 -116
  270. data/spec/code_objects/extra_file_object_spec.rb +160 -160
  271. data/spec/code_objects/macro_object_spec.rb +150 -150
  272. data/spec/code_objects/method_object_spec.rb +184 -184
  273. data/spec/code_objects/module_object_spec.rb +142 -142
  274. data/spec/code_objects/namespace_object_spec.rb +171 -171
  275. data/spec/code_objects/proxy_spec.rb +141 -141
  276. data/spec/code_objects/spec_helper.rb +3 -3
  277. data/spec/config_spec.rb +171 -171
  278. data/spec/core_ext/array_spec.rb +13 -13
  279. data/spec/core_ext/file_spec.rb +72 -72
  280. data/spec/core_ext/hash_spec.rb +14 -14
  281. data/spec/core_ext/insertion_spec.rb +37 -37
  282. data/spec/core_ext/module_spec.rb +15 -15
  283. data/spec/core_ext/string_spec.rb +42 -42
  284. data/spec/core_ext/symbol_hash_spec.rb +89 -89
  285. data/spec/docstring_parser_spec.rb +280 -262
  286. data/spec/docstring_spec.rb +373 -364
  287. data/spec/examples.txt +1875 -1871
  288. data/spec/handlers/alias_handler_spec.rb +82 -82
  289. data/spec/handlers/attribute_handler_spec.rb +96 -96
  290. data/spec/handlers/base_spec.rb +216 -216
  291. data/spec/handlers/c/alias_handler_spec.rb +34 -34
  292. data/spec/handlers/c/attribute_handler_spec.rb +41 -41
  293. data/spec/handlers/c/class_handler_spec.rb +78 -78
  294. data/spec/handlers/c/constant_handler_spec.rb +71 -71
  295. data/spec/handlers/c/init_handler_spec.rb +48 -48
  296. data/spec/handlers/c/method_handler_spec.rb +325 -325
  297. data/spec/handlers/c/mixin_handler_spec.rb +44 -44
  298. data/spec/handlers/c/module_handler_spec.rb +71 -71
  299. data/spec/handlers/c/override_comment_handler_spec.rb +47 -47
  300. data/spec/handlers/c/path_handler_spec.rb +36 -36
  301. data/spec/handlers/c/spec_helper.rb +23 -23
  302. data/spec/handlers/c/struct_handler_spec.rb +16 -16
  303. data/spec/handlers/class_condition_handler_spec.rb +87 -87
  304. data/spec/handlers/class_handler_spec.rb +247 -247
  305. data/spec/handlers/class_method_handler_shared_examples.rb +133 -133
  306. data/spec/handlers/class_variable_handler_spec.rb +12 -12
  307. data/spec/handlers/constant_handler_spec.rb +112 -112
  308. data/spec/handlers/decorator_handler_methods_spec.rb +393 -393
  309. data/spec/handlers/dsl_handler_spec.rb +219 -219
  310. data/spec/handlers/examples/alias_handler_001.rb.txt +45 -45
  311. data/spec/handlers/examples/attribute_handler_001.rb.txt +31 -31
  312. data/spec/handlers/examples/class_condition_handler_001.rb.txt +68 -68
  313. data/spec/handlers/examples/class_handler_001.rb.txt +120 -120
  314. data/spec/handlers/examples/class_variable_handler_001.rb.txt +9 -9
  315. data/spec/handlers/examples/constant_handler_001.rb.txt +35 -35
  316. data/spec/handlers/examples/dsl_handler_001.rb.txt +154 -154
  317. data/spec/handlers/examples/exception_handler_001.rb.txt +58 -58
  318. data/spec/handlers/examples/extend_handler_001.rb.txt +15 -15
  319. data/spec/handlers/examples/method_condition_handler_001.rb.txt +9 -9
  320. data/spec/handlers/examples/method_handler_001.rb.txt +128 -128
  321. data/spec/handlers/examples/mixin_handler_001.rb.txt +37 -37
  322. data/spec/handlers/examples/module_handler_001.rb.txt +29 -29
  323. data/spec/handlers/examples/private_constant_handler_001.rb.txt +8 -8
  324. data/spec/handlers/examples/process_handler_001.rb.txt +11 -11
  325. data/spec/handlers/examples/visibility_handler_001.rb.txt +35 -35
  326. data/spec/handlers/examples/yield_handler_001.rb.txt +54 -54
  327. data/spec/handlers/exception_handler_spec.rb +49 -49
  328. data/spec/handlers/extend_handler_spec.rb +24 -24
  329. data/spec/handlers/legacy_base_spec.rb +128 -128
  330. data/spec/handlers/method_condition_handler_spec.rb +15 -15
  331. data/spec/handlers/method_handler_spec.rb +190 -190
  332. data/spec/handlers/mixin_handler_spec.rb +56 -56
  333. data/spec/handlers/module_function_handler_spec.rb +106 -106
  334. data/spec/handlers/module_handler_spec.rb +35 -35
  335. data/spec/handlers/private_class_method_handler_spec.rb +11 -11
  336. data/spec/handlers/private_constant_handler_spec.rb +25 -25
  337. data/spec/handlers/processor_spec.rb +35 -35
  338. data/spec/handlers/public_class_method_handler_spec.rb +11 -11
  339. data/spec/handlers/ruby/base_spec.rb +95 -95
  340. data/spec/handlers/ruby/legacy/base_spec.rb +84 -84
  341. data/spec/handlers/spec_helper.rb +33 -33
  342. data/spec/handlers/visibility_handler_spec.rb +44 -44
  343. data/spec/handlers/yield_handler_spec.rb +52 -52
  344. data/spec/i18n/locale_spec.rb +81 -81
  345. data/spec/i18n/message_spec.rb +52 -52
  346. data/spec/i18n/messages_spec.rb +67 -67
  347. data/spec/i18n/pot_generator_spec.rb +295 -295
  348. data/spec/i18n/text_spec.rb +184 -184
  349. data/spec/logging_spec.rb +44 -44
  350. data/spec/options_spec.rb +171 -171
  351. data/spec/parser/base_spec.rb +24 -24
  352. data/spec/parser/c_parser_spec.rb +236 -223
  353. data/spec/parser/examples/array.c.txt +6267 -6267
  354. data/spec/parser/examples/example1.rb.txt +7 -7
  355. data/spec/parser/examples/extrafile.c.txt +8 -8
  356. data/spec/parser/examples/file.c.txt +28 -0
  357. data/spec/parser/examples/multifile.c.txt +22 -22
  358. data/spec/parser/examples/namespace.cpp.txt +68 -68
  359. data/spec/parser/examples/override.c.txt +424 -424
  360. data/spec/parser/examples/parse_in_order_001.rb.txt +2 -2
  361. data/spec/parser/examples/parse_in_order_002.rb.txt +1 -1
  362. data/spec/parser/examples/tag_handler_001.rb.txt +7 -7
  363. data/spec/parser/ruby/ast_node_spec.rb +33 -33
  364. data/spec/parser/ruby/legacy/statement_list_spec.rb +299 -299
  365. data/spec/parser/ruby/legacy/token_list_spec.rb +79 -79
  366. data/spec/parser/ruby/ruby_parser_spec.rb +508 -508
  367. data/spec/parser/ruby/token_resolver_spec.rb +165 -165
  368. data/spec/parser/source_parser_spec.rb +727 -727
  369. data/spec/parser/tag_parsing_spec.rb +17 -17
  370. data/spec/rake/yardoc_task_spec.rb +118 -118
  371. data/spec/registry_spec.rb +463 -463
  372. data/spec/registry_store_spec.rb +316 -316
  373. data/spec/rubygems/doc_manager_spec.rb +112 -112
  374. data/spec/serializers/data/serialized_yardoc/checksums +1 -1
  375. data/spec/serializers/file_system_serializer_spec.rb +145 -145
  376. data/spec/serializers/spec_helper.rb +2 -2
  377. data/spec/serializers/yardoc_serializer_spec.rb +78 -78
  378. data/spec/server/adapter_spec.rb +39 -39
  379. data/spec/server/commands/base_spec.rb +91 -91
  380. data/spec/server/commands/library_command_spec.rb +39 -39
  381. data/spec/server/doc_server_helper_spec.rb +72 -72
  382. data/spec/server/doc_server_serializer_spec.rb +60 -60
  383. data/spec/server/rack_adapter_spec.rb +21 -21
  384. data/spec/server/router_spec.rb +123 -123
  385. data/spec/server/spec_helper.rb +22 -22
  386. data/spec/server/static_caching_spec.rb +47 -47
  387. data/spec/server/webrick_servlet_spec.rb +20 -20
  388. data/spec/server_spec.rb +19 -19
  389. data/spec/spec_helper.rb +212 -212
  390. data/spec/tags/default_factory_spec.rb +168 -168
  391. data/spec/tags/default_tag_spec.rb +11 -11
  392. data/spec/tags/directives_spec.rb +463 -463
  393. data/spec/tags/library_spec.rb +48 -48
  394. data/spec/tags/overload_tag_spec.rb +53 -53
  395. data/spec/tags/ref_tag_list_spec.rb +53 -53
  396. data/spec/tags/types_explainer_spec.rb +203 -203
  397. data/spec/templates/class_spec.rb +45 -45
  398. data/spec/templates/constant_spec.rb +41 -41
  399. data/spec/templates/engine_spec.rb +131 -131
  400. data/spec/templates/examples/class001.html +308 -308
  401. data/spec/templates/examples/class001.txt +36 -36
  402. data/spec/templates/examples/class002.html +39 -39
  403. data/spec/templates/examples/constant001.txt +24 -24
  404. data/spec/templates/examples/constant002.txt +6 -6
  405. data/spec/templates/examples/constant003.txt +10 -10
  406. data/spec/templates/examples/method001.html +137 -137
  407. data/spec/templates/examples/method001.txt +35 -35
  408. data/spec/templates/examples/method002.html +91 -91
  409. data/spec/templates/examples/method002.txt +20 -20
  410. data/spec/templates/examples/method003.html +165 -165
  411. data/spec/templates/examples/method003.txt +45 -45
  412. data/spec/templates/examples/method004.html +48 -48
  413. data/spec/templates/examples/method004.txt +10 -10
  414. data/spec/templates/examples/method005.html +105 -105
  415. data/spec/templates/examples/method005.txt +33 -33
  416. data/spec/templates/examples/method006.html +107 -107
  417. data/spec/templates/examples/method006.txt +20 -20
  418. data/spec/templates/examples/module001.dot +33 -33
  419. data/spec/templates/examples/module001.html +833 -833
  420. data/spec/templates/examples/module001.txt +33 -33
  421. data/spec/templates/examples/module002.html +341 -341
  422. data/spec/templates/examples/module003.html +202 -202
  423. data/spec/templates/examples/module004.html +394 -394
  424. data/spec/templates/examples/module005.html +81 -81
  425. data/spec/templates/examples/tag001.txt +82 -82
  426. data/spec/templates/helpers/base_helper_spec.rb +171 -171
  427. data/spec/templates/helpers/html_helper_spec.rb +668 -653
  428. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +65 -65
  429. data/spec/templates/helpers/markup/rdoc_markup_spec.rb +84 -84
  430. data/spec/templates/helpers/markup_helper_spec.rb +136 -136
  431. data/spec/templates/helpers/method_helper_spec.rb +107 -107
  432. data/spec/templates/helpers/module_helper_spec.rb +35 -35
  433. data/spec/templates/helpers/shared_signature_examples.rb +126 -126
  434. data/spec/templates/helpers/text_helper_spec.rb +65 -65
  435. data/spec/templates/method_spec.rb +118 -118
  436. data/spec/templates/module_spec.rb +203 -203
  437. data/spec/templates/onefile_spec.rb +66 -66
  438. data/spec/templates/section_spec.rb +144 -144
  439. data/spec/templates/spec_helper.rb +76 -76
  440. data/spec/templates/tag_spec.rb +52 -52
  441. data/spec/templates/template_spec.rb +410 -410
  442. data/spec/verifier_spec.rb +106 -106
  443. data/templates/default/class/dot/setup.rb +7 -7
  444. data/templates/default/class/dot/superklass.erb +2 -2
  445. data/templates/default/class/html/constructor_details.erb +8 -8
  446. data/templates/default/class/html/setup.rb +2 -2
  447. data/templates/default/class/html/subclasses.erb +4 -4
  448. data/templates/default/class/setup.rb +36 -36
  449. data/templates/default/class/text/setup.rb +12 -12
  450. data/templates/default/class/text/subclasses.erb +5 -5
  451. data/templates/default/constant/text/header.erb +11 -11
  452. data/templates/default/constant/text/setup.rb +4 -4
  453. data/templates/default/docstring/html/abstract.erb +4 -4
  454. data/templates/default/docstring/html/deprecated.erb +1 -1
  455. data/templates/default/docstring/html/index.erb +5 -5
  456. data/templates/default/docstring/html/note.erb +6 -6
  457. data/templates/default/docstring/html/private.erb +4 -4
  458. data/templates/default/docstring/html/text.erb +1 -1
  459. data/templates/default/docstring/html/todo.erb +6 -6
  460. data/templates/default/docstring/setup.rb +52 -52
  461. data/templates/default/docstring/text/abstract.erb +2 -2
  462. data/templates/default/docstring/text/deprecated.erb +2 -2
  463. data/templates/default/docstring/text/index.erb +2 -2
  464. data/templates/default/docstring/text/note.erb +3 -3
  465. data/templates/default/docstring/text/private.erb +2 -2
  466. data/templates/default/docstring/text/text.erb +1 -1
  467. data/templates/default/docstring/text/todo.erb +3 -3
  468. data/templates/default/fulldoc/html/css/full_list.css +58 -58
  469. data/templates/default/fulldoc/html/css/style.css +496 -496
  470. data/templates/default/fulldoc/html/frames.erb +17 -17
  471. data/templates/default/fulldoc/html/full_list.erb +37 -37
  472. data/templates/default/fulldoc/html/full_list_class.erb +2 -2
  473. data/templates/default/fulldoc/html/full_list_file.erb +7 -7
  474. data/templates/default/fulldoc/html/full_list_method.erb +10 -10
  475. data/templates/default/fulldoc/html/js/app.js +292 -292
  476. data/templates/default/fulldoc/html/js/full_list.js +216 -216
  477. data/templates/default/fulldoc/html/js/jquery.js +3 -3
  478. data/templates/default/fulldoc/html/setup.rb +241 -241
  479. data/templates/default/layout/dot/header.erb +5 -5
  480. data/templates/default/layout/dot/setup.rb +15 -15
  481. data/templates/default/layout/html/breadcrumb.erb +11 -11
  482. data/templates/default/layout/html/files.erb +11 -11
  483. data/templates/default/layout/html/footer.erb +5 -5
  484. data/templates/default/layout/html/headers.erb +15 -15
  485. data/templates/default/layout/html/index.erb +2 -2
  486. data/templates/default/layout/html/layout.erb +23 -23
  487. data/templates/default/layout/html/listing.erb +4 -4
  488. data/templates/default/layout/html/objects.erb +32 -32
  489. data/templates/default/layout/html/script_setup.erb +4 -4
  490. data/templates/default/layout/html/search.erb +12 -12
  491. data/templates/default/layout/html/setup.rb +89 -89
  492. data/templates/default/method/html/header.erb +16 -16
  493. data/templates/default/method/setup.rb +4 -4
  494. data/templates/default/method_details/html/header.erb +2 -2
  495. data/templates/default/method_details/html/method_signature.erb +24 -24
  496. data/templates/default/method_details/html/source.erb +9 -9
  497. data/templates/default/method_details/setup.rb +11 -11
  498. data/templates/default/method_details/text/header.erb +10 -10
  499. data/templates/default/method_details/text/method_signature.erb +12 -12
  500. data/templates/default/method_details/text/setup.rb +11 -11
  501. data/templates/default/module/dot/child.erb +1 -1
  502. data/templates/default/module/dot/dependencies.erb +2 -2
  503. data/templates/default/module/dot/header.erb +6 -6
  504. data/templates/default/module/dot/info.erb +13 -13
  505. data/templates/default/module/dot/setup.rb +15 -15
  506. data/templates/default/module/html/attribute_details.erb +10 -10
  507. data/templates/default/module/html/attribute_summary.erb +8 -8
  508. data/templates/default/module/html/box_info.erb +43 -43
  509. data/templates/default/module/html/children.erb +8 -8
  510. data/templates/default/module/html/constant_summary.erb +17 -17
  511. data/templates/default/module/html/defines.erb +2 -2
  512. data/templates/default/module/html/header.erb +5 -5
  513. data/templates/default/module/html/inherited_attributes.erb +14 -14
  514. data/templates/default/module/html/inherited_constants.erb +8 -8
  515. data/templates/default/module/html/inherited_methods.erb +18 -18
  516. data/templates/default/module/html/item_summary.erb +40 -40
  517. data/templates/default/module/html/method_details_list.erb +9 -9
  518. data/templates/default/module/html/method_summary.erb +13 -13
  519. data/templates/default/module/html/methodmissing.erb +12 -12
  520. data/templates/default/module/setup.rb +167 -167
  521. data/templates/default/module/text/children.erb +9 -9
  522. data/templates/default/module/text/class_meths_list.erb +7 -7
  523. data/templates/default/module/text/extends.erb +7 -7
  524. data/templates/default/module/text/header.erb +7 -7
  525. data/templates/default/module/text/includes.erb +7 -7
  526. data/templates/default/module/text/instance_meths_list.erb +7 -7
  527. data/templates/default/module/text/setup.rb +13 -13
  528. data/templates/default/onefile/html/files.erb +4 -4
  529. data/templates/default/onefile/html/headers.erb +6 -6
  530. data/templates/default/onefile/html/layout.erb +17 -17
  531. data/templates/default/onefile/html/readme.erb +2 -2
  532. data/templates/default/onefile/html/setup.rb +62 -62
  533. data/templates/default/root/dot/child.erb +2 -2
  534. data/templates/default/root/dot/setup.rb +6 -6
  535. data/templates/default/root/html/setup.rb +2 -2
  536. data/templates/default/tags/html/example.erb +10 -10
  537. data/templates/default/tags/html/index.erb +2 -2
  538. data/templates/default/tags/html/option.erb +24 -24
  539. data/templates/default/tags/html/overload.erb +13 -13
  540. data/templates/default/tags/html/see.erb +7 -7
  541. data/templates/default/tags/html/tag.erb +20 -20
  542. data/templates/default/tags/setup.rb +57 -57
  543. data/templates/default/tags/text/example.erb +12 -12
  544. data/templates/default/tags/text/index.erb +1 -1
  545. data/templates/default/tags/text/option.erb +20 -20
  546. data/templates/default/tags/text/overload.erb +19 -19
  547. data/templates/default/tags/text/see.erb +11 -11
  548. data/templates/default/tags/text/tag.erb +13 -13
  549. data/templates/guide/class/html/setup.rb +2 -2
  550. data/templates/guide/docstring/html/setup.rb +2 -2
  551. data/templates/guide/fulldoc/html/css/style.css +108 -108
  552. data/templates/guide/fulldoc/html/js/app.js +33 -33
  553. data/templates/guide/fulldoc/html/setup.rb +74 -74
  554. data/templates/guide/layout/html/layout.erb +81 -81
  555. data/templates/guide/layout/html/setup.rb +25 -25
  556. data/templates/guide/method/html/header.erb +17 -17
  557. data/templates/guide/method/html/setup.rb +22 -22
  558. data/templates/guide/module/html/header.erb +6 -6
  559. data/templates/guide/module/html/method_list.erb +4 -4
  560. data/templates/guide/module/html/setup.rb +27 -27
  561. data/templates/guide/onefile/html/files.erb +4 -4
  562. data/templates/guide/onefile/html/setup.rb +6 -6
  563. data/templates/guide/onefile/html/toc.erb +3 -3
  564. data/templates/guide/tags/html/setup.rb +9 -9
  565. data/yard.gemspec +43 -43
  566. metadata +4 -4
@@ -1,96 +1,96 @@
1
- # frozen_string_literal: true
2
- require 'stringio'
3
-
4
- RSpec.describe YARD::CLI::Stats do
5
- before do
6
- Registry.clear
7
- YARD.parse_string <<-eof
8
- class A
9
- CONST = 1
10
-
11
- def foo; end
12
-
13
- attr_reader :fooattr
14
-
15
- # Documented
16
- def bar; end
17
- end
18
- module B; end
19
- eof
20
-
21
- @main_stats =
22
- "Files: 1\n" \
23
- "Modules: 1 ( 1 undocumented)\n" \
24
- "Classes: 1 ( 1 undocumented)\n" \
25
- "Constants: 1 ( 1 undocumented)\n" \
26
- "Attributes: 1 ( 0 undocumented)\n" \
27
- "Methods: 2 ( 1 undocumented)\n" \
28
- " 33.33% documented\n"
29
-
30
- @output = StringIO.new
31
- @stats = CLI::Stats.new(false)
32
- allow(@stats).to receive(:support_rdoc_document_file!).and_return([])
33
- allow(@stats).to receive(:yardopts).and_return([])
34
- allow(log).to receive(:puts) {|*args| @output << args.join("\n") << "\n" }
35
- end
36
-
37
- it "lists undocumented objects with --list-undoc when there are undocumented objects" do
38
- @stats.run('--list-undoc')
39
- expect(@output.string).to eq <<-eof
40
- #{@main_stats}
41
- Undocumented Objects:
42
-
43
- (in file: (stdin))
44
- A
45
- A#foo
46
- A::CONST
47
- B
48
- eof
49
- end
50
-
51
- it "lists no undocumented objects with --list-undoc when there is nothing undocumented" do
52
- Registry.clear
53
- YARD.parse_string <<-eof
54
- # documentation
55
- def foo; end
56
- eof
57
- @stats.run('--list-undoc')
58
- expect(@output.string).to eq "Files: 1\n" \
59
- "Modules: 0 ( 0 undocumented)\n" \
60
- "Classes: 0 ( 0 undocumented)\n" \
61
- "Constants: 0 ( 0 undocumented)\n" \
62
- "Attributes: 0 ( 0 undocumented)\n" \
63
- "Methods: 1 ( 0 undocumented)\n" \
64
- " 100.00% documented\n"
65
- end
66
-
67
- it "lists undocumented objects in compact mode with --list-undoc --compact" do
68
- @stats.run('--list-undoc', '--compact')
69
- expect(@output.string).to eq <<-eof
70
- #{@main_stats}
71
- Undocumented Objects:
72
- A ((stdin):1)
73
- A#foo ((stdin):4)
74
- A::CONST ((stdin):2)
75
- B ((stdin):11)
76
- eof
77
- end
78
-
79
- it "still lists stats with --quiet" do
80
- @stats.run('--quiet')
81
- expect(@output.string).to eq @main_stats
82
- end
83
-
84
- it "ignores everything with --no-public" do
85
- @stats.run('--no-public')
86
- expect(@output.string).to eq(
87
- "Files: 0\n" \
88
- "Modules: 0 ( 0 undocumented)\n" \
89
- "Classes: 0 ( 0 undocumented)\n" \
90
- "Constants: 0 ( 0 undocumented)\n" \
91
- "Attributes: 0 ( 0 undocumented)\n" \
92
- "Methods: 0 ( 0 undocumented)\n" \
93
- " 100.00% documented\n"
94
- )
95
- end
96
- end
1
+ # frozen_string_literal: true
2
+ require 'stringio'
3
+
4
+ RSpec.describe YARD::CLI::Stats do
5
+ before do
6
+ Registry.clear
7
+ YARD.parse_string <<-eof
8
+ class A
9
+ CONST = 1
10
+
11
+ def foo; end
12
+
13
+ attr_reader :fooattr
14
+
15
+ # Documented
16
+ def bar; end
17
+ end
18
+ module B; end
19
+ eof
20
+
21
+ @main_stats =
22
+ "Files: 1\n" \
23
+ "Modules: 1 ( 1 undocumented)\n" \
24
+ "Classes: 1 ( 1 undocumented)\n" \
25
+ "Constants: 1 ( 1 undocumented)\n" \
26
+ "Attributes: 1 ( 0 undocumented)\n" \
27
+ "Methods: 2 ( 1 undocumented)\n" \
28
+ " 33.33% documented\n"
29
+
30
+ @output = StringIO.new
31
+ @stats = CLI::Stats.new(false)
32
+ allow(@stats).to receive(:support_rdoc_document_file!).and_return([])
33
+ allow(@stats).to receive(:yardopts).and_return([])
34
+ allow(log).to receive(:puts) {|*args| @output << args.join("\n") << "\n" }
35
+ end
36
+
37
+ it "lists undocumented objects with --list-undoc when there are undocumented objects" do
38
+ @stats.run('--list-undoc')
39
+ expect(@output.string).to eq <<-eof
40
+ #{@main_stats}
41
+ Undocumented Objects:
42
+
43
+ (in file: (stdin))
44
+ A
45
+ A#foo
46
+ A::CONST
47
+ B
48
+ eof
49
+ end
50
+
51
+ it "lists no undocumented objects with --list-undoc when there is nothing undocumented" do
52
+ Registry.clear
53
+ YARD.parse_string <<-eof
54
+ # documentation
55
+ def foo; end
56
+ eof
57
+ @stats.run('--list-undoc')
58
+ expect(@output.string).to eq "Files: 1\n" \
59
+ "Modules: 0 ( 0 undocumented)\n" \
60
+ "Classes: 0 ( 0 undocumented)\n" \
61
+ "Constants: 0 ( 0 undocumented)\n" \
62
+ "Attributes: 0 ( 0 undocumented)\n" \
63
+ "Methods: 1 ( 0 undocumented)\n" \
64
+ " 100.00% documented\n"
65
+ end
66
+
67
+ it "lists undocumented objects in compact mode with --list-undoc --compact" do
68
+ @stats.run('--list-undoc', '--compact')
69
+ expect(@output.string).to eq <<-eof
70
+ #{@main_stats}
71
+ Undocumented Objects:
72
+ A ((stdin):1)
73
+ A#foo ((stdin):4)
74
+ A::CONST ((stdin):2)
75
+ B ((stdin):11)
76
+ eof
77
+ end
78
+
79
+ it "still lists stats with --quiet" do
80
+ @stats.run('--quiet')
81
+ expect(@output.string).to eq @main_stats
82
+ end
83
+
84
+ it "ignores everything with --no-public" do
85
+ @stats.run('--no-public')
86
+ expect(@output.string).to eq(
87
+ "Files: 0\n" \
88
+ "Modules: 0 ( 0 undocumented)\n" \
89
+ "Classes: 0 ( 0 undocumented)\n" \
90
+ "Constants: 0 ( 0 undocumented)\n" \
91
+ "Attributes: 0 ( 0 undocumented)\n" \
92
+ "Methods: 0 ( 0 undocumented)\n" \
93
+ " 100.00% documented\n"
94
+ )
95
+ end
96
+ end
@@ -1,38 +1,38 @@
1
- # frozen_string_literal: true
2
-
3
- $TOPDIR = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
4
-
5
- require 'fileutils'
6
-
7
- RSpec.describe YARD::CLI::Yardoc do
8
- include FileUtils
9
-
10
- context 'building the documentation of YARD itself' do
11
- before(:context) do
12
- rm_rf File.join($TOPDIR, 'doc')
13
- rm_rf File.join($TOPDIR, '.yardoc')
14
-
15
- # Note: as this is very time consuming, we do it only once
16
- Dir.chdir($TOPDIR) do
17
- @res = YARD::CLI::Yardoc.new.run('--title', 'YARD-On-YARD')
18
- end
19
- end
20
-
21
- it 'succeeds and creates doc/ and .yardoc/' do
22
- expect(@res).to be true
23
- expect(Dir.exist?('doc')).to be true
24
- expect(Dir.exist?('.yardoc')).to be true
25
- end
26
-
27
- it 'writes the given title in each documentation file' do
28
- Dir.glob(File.join($TOPDIR, 'doc/**/*.html')) do |htmlfile|
29
- next if %w(
30
- frames file_list class_list method_list tag_list _index
31
- ).include?(File.basename(htmlfile, '.html'))
32
- html = File.read(htmlfile)
33
-
34
- expect(html.index('&mdash; YARD-On-YARD')).to be >= 0
35
- end
36
- end
37
- end
38
- end if ENV['CI'] || ENV['YY']
1
+ # frozen_string_literal: true
2
+
3
+ $TOPDIR = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
4
+
5
+ require 'fileutils'
6
+
7
+ RSpec.describe YARD::CLI::Yardoc do
8
+ include FileUtils
9
+
10
+ context 'building the documentation of YARD itself' do
11
+ before(:context) do
12
+ rm_rf File.join($TOPDIR, 'doc')
13
+ rm_rf File.join($TOPDIR, '.yardoc')
14
+
15
+ # Note: as this is very time consuming, we do it only once
16
+ Dir.chdir($TOPDIR) do
17
+ @res = YARD::CLI::Yardoc.new.run('--title', 'YARD-On-YARD')
18
+ end
19
+ end
20
+
21
+ it 'succeeds and creates doc/ and .yardoc/' do
22
+ expect(@res).to be true
23
+ expect(Dir.exist?('doc')).to be true
24
+ expect(Dir.exist?('.yardoc')).to be true
25
+ end
26
+
27
+ it 'writes the given title in each documentation file' do
28
+ Dir.glob(File.join($TOPDIR, 'doc/**/*.html')) do |htmlfile|
29
+ next if %w(
30
+ frames file_list class_list method_list tag_list _index
31
+ ).include?(File.basename(htmlfile, '.html'))
32
+ html = File.read(htmlfile)
33
+
34
+ expect(html.index('&mdash; YARD-On-YARD')).to be >= 0
35
+ end
36
+ end
37
+ end
38
+ end if ENV['CI'] || ENV['YY']
@@ -1,849 +1,862 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe YARD::CLI::Yardoc do
4
- before do
5
- @yardoc = YARD::CLI::Yardoc.new
6
- @yardoc.statistics = false
7
- @yardoc.use_document_file = false
8
- @yardoc.use_yardopts_file = false
9
- @yardoc.generate = false
10
- allow(Templates::Engine).to receive(:render)
11
- allow(Templates::Engine).to receive(:generate)
12
- allow(YARD).to receive(:parse)
13
- allow(Registry).to receive(:load)
14
- allow(Registry).to receive(:save)
15
- allow(File).to receive(:open!)
16
- end
17
-
18
- describe "Defaults" do
19
- before do
20
- @yardoc = CLI::Yardoc.new
21
- allow(@yardoc).to receive(:yardopts).and_return([])
22
- allow(@yardoc).to receive(:support_rdoc_document_file!).and_return([])
23
- @yardoc.parse_arguments
24
- end
25
-
26
- it "does not use cache by default" do
27
- expect(@yardoc.use_cache).to be false
28
- end
29
-
30
- it "prints statistics by default" do
31
- expect(@yardoc.statistics).to be true
32
- end
33
-
34
- it "generates output by default" do
35
- expect(@yardoc.generate).to be true
36
- end
37
-
38
- it "reads .yardopts by default" do
39
- expect(@yardoc.use_yardopts_file).to be true
40
- end
41
-
42
- it "reads .document by default" do
43
- expect(@yardoc.use_document_file).to be true
44
- end
45
-
46
- it "uses lib, app, and ext as default file glob paths" do
47
- expect(@yardoc.files).to eq Parser::SourceParser::DEFAULT_PATH_GLOB
48
- end
49
-
50
- it "uses rdoc as default markup type (but falls back on none)" do
51
- expect(@yardoc.options.markup).to eq :rdoc
52
- end
53
-
54
- it "uses default as default template" do
55
- expect(@yardoc.options.template).to eq :default
56
- end
57
-
58
- it "uses HTML as default format" do
59
- expect(@yardoc.options.format).to eq :html
60
- end
61
-
62
- it "uses 'Object' as default return type" do
63
- expect(@yardoc.options.default_return).to eq 'Object'
64
- end
65
-
66
- it "does not hide void return types by default" do
67
- expect(@yardoc.options.hide_void_return).to be false
68
- end
69
-
70
- it "only shows public visibility by default" do
71
- expect(@yardoc.visibilities).to eq [:public]
72
- end
73
-
74
- it "does not list objects by default" do
75
- expect(@yardoc.list).to be false
76
- end
77
-
78
- it "does not embed mixins by default" do
79
- expect(@yardoc.options.embed_mixins).to be_empty
80
- end
81
-
82
- it "does not set any locale by default" do
83
- expect(@yardoc.options.locale).to be nil
84
- end
85
- end
86
-
87
- describe "General options" do
88
- def self.should_accept(*args, &block)
89
- @counter ||= 0
90
- @counter += 1
91
- counter = @counter
92
- define_method("test_options_#{@counter}", &block)
93
- args.each do |arg|
94
- it("accepts #{arg}") { send("test_options_#{counter}", arg) }
95
- end
96
- end
97
-
98
- should_accept('--single-db') do |arg|
99
- @yardoc.parse_arguments(arg)
100
- expect(Registry.single_object_db).to be true
101
- Registry.single_object_db = nil
102
- end
103
-
104
- should_accept('--no-single-db') do |arg|
105
- @yardoc.parse_arguments(arg)
106
- expect(Registry.single_object_db).to be false
107
- Registry.single_object_db = nil
108
- end
109
-
110
- should_accept('-c', '--use-cache') do |arg|
111
- @yardoc.parse_arguments(arg)
112
- expect(@yardoc.use_cache).to be true
113
- end
114
-
115
- should_accept('--no-cache') do |arg|
116
- @yardoc.parse_arguments(arg)
117
- expect(@yardoc.use_cache).to be false
118
- end
119
-
120
- should_accept('--yardopts') do |arg|
121
- @yardoc = CLI::Yardoc.new
122
- @yardoc.use_document_file = false
123
- expect(@yardoc).to receive(:yardopts).at_least(1).times.and_return([])
124
- @yardoc.parse_arguments(arg)
125
- expect(@yardoc.use_yardopts_file).to be true
126
- @yardoc.parse_arguments('--no-yardopts', arg)
127
- expect(@yardoc.use_yardopts_file).to be true
128
- end
129
-
130
- should_accept('--yardopts with filename') do |_arg|
131
- @yardoc = CLI::Yardoc.new
132
- expect(File).to receive(:read_binary).with('.foobar').and_return('')
133
- @yardoc.use_document_file = false
134
- @yardoc.parse_arguments('--yardopts', '.foobar')
135
- expect(@yardoc.use_yardopts_file).to be true
136
- expect(@yardoc.options_file).to eq '.foobar'
137
- end
138
-
139
- should_accept('--no-yardopts') do |arg|
140
- @yardoc = CLI::Yardoc.new
141
- @yardoc.use_document_file = false
142
- expect(@yardoc).not_to receive(:yardopts)
143
- @yardoc.parse_arguments(arg)
144
- expect(@yardoc.use_yardopts_file).to be false
145
- @yardoc.parse_arguments('--yardopts', arg)
146
- expect(@yardoc.use_yardopts_file).to be false
147
- end
148
-
149
- should_accept('--document') do |arg|
150
- @yardoc = CLI::Yardoc.new
151
- @yardoc.use_yardopts_file = false
152
- expect(@yardoc).to receive(:support_rdoc_document_file!).and_return([])
153
- @yardoc.parse_arguments('--no-document', arg)
154
- expect(@yardoc.use_document_file).to be true
155
- end
156
-
157
- should_accept('--no-document') do |arg|
158
- @yardoc = CLI::Yardoc.new
159
- @yardoc.use_yardopts_file = false
160
- expect(@yardoc).not_to receive(:support_rdoc_document_file!)
161
- @yardoc.parse_arguments('--document', arg)
162
- expect(@yardoc.use_document_file).to be false
163
- end
164
-
165
- should_accept('-b', '--db') do |arg|
166
- @yardoc.parse_arguments(arg, 'test')
167
- expect(Registry.yardoc_file).to eq 'test'
168
- Registry.yardoc_file = '.yardoc'
169
- end
170
-
171
- should_accept('-n', '--no-output') do |arg|
172
- expect(Templates::Engine).not_to receive(:generate)
173
- @yardoc.run(arg)
174
- end
175
-
176
- should_accept('--exclude') do |arg|
177
- expect(YARD).to receive(:parse).with(['a'], ['nota', 'b'])
178
- @yardoc.run(arg, 'nota', arg, 'b', 'a')
179
- end
180
-
181
- should_accept('--no-save') do |arg|
182
- expect(YARD).to receive(:parse)
183
- expect(Registry).not_to receive(:save)
184
- @yardoc.run(arg)
185
- end
186
-
187
- should_accept('--fail-on-warning') do |arg|
188
- expect(YARD).to receive(:parse)
189
- @yardoc.run(arg)
190
- end
191
- end
192
-
193
- describe "Output options" do
194
- it "accepts --title" do
195
- @yardoc.parse_arguments('--title', 'hello world')
196
- expect(@yardoc.options.title).to eq 'hello world'
197
- end
198
-
199
- it "allows --title to have multiple spaces in .yardopts" do
200
- expect(File).to receive(:read_binary).with("test").and_return("--title \"Foo Bar\"")
201
- @yardoc.options_file = "test"
202
- @yardoc.use_yardopts_file = true
203
- @yardoc.run
204
- expect(@yardoc.options.title).to eq "Foo Bar"
205
- end
206
-
207
- it "aliases --main to the --readme flag" do
208
- Dir.chdir(File.join(File.dirname(__FILE__), '..', '..')) do
209
- @yardoc.parse_arguments('--main', 'README.md')
210
- expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('README.md', '')
211
- end
212
- end
213
-
214
- it "selects a markup provider when --markup-provider or -mp is set" do
215
- @yardoc.parse_arguments("-M", "test")
216
- expect(@yardoc.options.markup_provider).to eq :test
217
- @yardoc.parse_arguments("--markup-provider", "test2")
218
- expect(@yardoc.options.markup_provider).to eq :test2
219
- end
220
-
221
- it "selects a markup format when -m is set" do
222
- expect(@yardoc).to receive(:verify_markup_options).and_return(true)
223
- @yardoc.generate = true
224
- @yardoc.parse_arguments('-m', 'markdown')
225
- expect(@yardoc.options.markup).to eq :markdown
226
- end
227
-
228
- it "accepts --default-return" do
229
- @yardoc.parse_arguments(*%w(--default-return XYZ))
230
- expect(@yardoc.options.default_return).to eq "XYZ"
231
- end
232
-
233
- it "allows --hide-void-return to be set" do
234
- @yardoc.parse_arguments(*%w(--hide-void-return))
235
- expect(@yardoc.options.hide_void_return).to be true
236
- end
237
-
238
- it "accepts --embed-mixins" do
239
- @yardoc.parse_arguments(*%w(--embed-mixins))
240
- expect(@yardoc.options.embed_mixins).to eq ['*']
241
- end
242
-
243
- it "accepts --embed-mixin MODULE" do
244
- @yardoc.parse_arguments(*%w(--embed-mixin MyModule))
245
- expect(@yardoc.options.embed_mixins).to eq ['MyModule']
246
- end
247
-
248
- it "generates all objects with --use-cache" do
249
- expect(YARD).to receive(:parse)
250
- expect(Registry).to receive(:load)
251
- expect(Registry).to receive(:load_all)
252
- allow(@yardoc).to receive(:generate).and_return(true)
253
- @yardoc.run(*%w(--use-cache))
254
- end
255
-
256
- it "does not print statistics with --no-stats" do
257
- allow(@yardoc).to receive(:statistics).and_return(false)
258
- expect(CLI::Stats).not_to receive(:new)
259
- @yardoc.run(*%w(--no-stats))
260
- end
261
-
262
- it "disables progress bar with --no-progress" do
263
- old = log.show_progress
264
- log.show_progress = true
265
- @yardoc.run(*%w(--no-progress))
266
- expect(log.show_progress).to eq false
267
- log.show_progress = old
268
- end
269
-
270
- describe "--asset" do
271
- before do
272
- @yardoc.generate = true
273
- allow(@yardoc).to receive(:run_generate)
274
- end
275
-
276
- it "copies assets to output directory" do
277
- expect(FileUtils).to receive(:cp_r).with('a', 'doc/a')
278
- @yardoc.run(*%w(--asset a))
279
- expect(@yardoc.assets).to eq('a' => 'a')
280
- end
281
-
282
- it "allows multiple --asset options" do
283
- expect(FileUtils).to receive(:cp_r).with('a', 'doc/a')
284
- expect(FileUtils).to receive(:cp_r).with('b', 'doc/b')
285
- @yardoc.run(*%w(--asset a --asset b))
286
- expect(@yardoc.assets).to eq('a' => 'a', 'b' => 'b')
287
- end
288
-
289
- it "does not allow from or to to refer to a path above current path" do
290
- expect(log).to receive(:warn).exactly(4).times.with(/invalid/i)
291
- @yardoc.run(*%w(--asset ../../../etc/passwd))
292
- expect(@yardoc.assets).to be_empty
293
- @yardoc.run(*%w(--asset a/b/c/d/../../../../../../etc/passwd))
294
- expect(@yardoc.assets).to be_empty
295
- @yardoc.run(*%w(--asset /etc/passwd))
296
- expect(@yardoc.assets).to be_empty
297
- @yardoc.run(*%w(--asset normal:/etc/passwd))
298
- expect(@yardoc.assets).to be_empty
299
- end
300
-
301
- it "allows from:to syntax" do
302
- expect(FileUtils).to receive(:cp_r).with(%r{foo(\/\.)?}, 'doc/bar')
303
- @yardoc.run(*%w(--asset foo:bar))
304
- expect(@yardoc.assets).to eq('foo' => 'bar')
305
- end
306
-
307
- it "does not put from inside of to/ if from is a directory" do
308
- begin
309
- from = 'tmp_foo'
310
- to = 'tmp_bar'
311
- full_to = File.join(File.dirname(__FILE__), to)
312
- FileUtils.mkdir_p(from)
313
- @yardoc.options.serializer.basepath = File.dirname(__FILE__)
314
- @yardoc.run("--asset", "#{from}:#{to}")
315
- @yardoc.run("--asset", "#{from}:#{to}")
316
- expect(File.directory?(full_to)).to be true
317
- expect(File.directory?(File.join(full_to, 'tmp_foo'))).to be false
318
- ensure
319
- FileUtils.rm_rf(from)
320
- FileUtils.rm_rf(full_to)
321
- end
322
- end
323
- end
324
-
325
- describe "--locale" do
326
- it "applies specified locale to all extra file objects" do
327
- allow(File).to receive(:read).with('extra_file1').and_return('')
328
- allow(File).to receive(:read).with('extra_file2').and_return('')
329
-
330
- extra_file_object1 = CodeObjects::ExtraFileObject.new('extra_file1')
331
- extra_file_object2 = CodeObjects::ExtraFileObject.new('extra_file2')
332
- expect(extra_file_object1).to receive(:locale=).with('fr')
333
- expect(extra_file_object2).to receive(:locale=).with('fr')
334
-
335
- allow(CodeObjects::ExtraFileObject).to receive(:new).with('extra_file1').and_return(extra_file_object1)
336
- allow(CodeObjects::ExtraFileObject).to receive(:new).with('extra_file2').and_return(extra_file_object2)
337
- allow(Dir).to receive(:glob).with('README{,*[^~]}').and_return([])
338
- allow(File).to receive(:file?).with('extra_file1').and_return(true)
339
- allow(File).to receive(:file?).with('extra_file2').and_return(true)
340
- @yardoc.run('--locale=fr', '-', 'extra_file1', 'extra_file2')
341
- end
342
- end
343
-
344
- describe "--po-dir" do
345
- it "sets Registry.po_dir" do
346
- expect(Registry).to receive(:po_dir=).with("locale")
347
- @yardoc.run('--po-dir=locale')
348
- end
349
- end
350
- end
351
-
352
- describe "--[no-]api" do
353
- before { Registry.clear }
354
-
355
- it "allows --api name" do
356
- YARD.parse_string <<-eof
357
- # @api private
358
- class Foo; end
359
- # @api public
360
- class Bar; end
361
- class Baz; end
362
- eof
363
- @yardoc.run('--api', 'private')
364
- expect(@yardoc.options.verifier.run(Registry.all)).to eq [P('Foo')]
365
- end
366
-
367
- it "allows multiple --api's to all be shown" do
368
- YARD.parse_string <<-eof
369
- # @api private
370
- class Foo; end
371
- # @api public
372
- class Bar; end
373
- class Baz; end
374
- eof
375
- @yardoc.run('--api', 'private', '--api', 'public')
376
- expect(@yardoc.options.verifier.run(Registry.all).
377
- sort_by(&:path)).to eq [P('Bar'), P('Foo')]
378
- end
379
-
380
- it "allows --no-api to specify objects with no @api tag" do
381
- YARD.parse_string <<-eof
382
- # @api private
383
- class Foo; end
384
- # @api public
385
- class Bar; end
386
- class Baz; end
387
- eof
388
- @yardoc.run('--api', '')
389
- expect(@yardoc.options.verifier.run(Registry.all)).to eq [P('Baz')]
390
- @yardoc.options.verifier = Verifier.new
391
- @yardoc.run('--no-api')
392
- expect(@yardoc.options.verifier.run(Registry.all)).to eq [P('Baz')]
393
- end
394
-
395
- it "allows --no-api to work with other --api switches" do
396
- YARD.parse_string <<-eof
397
- # @api private
398
- class Foo; end
399
- # @api public
400
- class Bar; end
401
- class Baz; end
402
- eof
403
- @yardoc.run('--no-api', '--api', 'public')
404
- expect(@yardoc.options.verifier.run(Registry.all).
405
- sort_by(&:path)).to eq [P('Bar'), P('Baz')]
406
- end
407
-
408
- it "ensures Ruby code cannot be used" do
409
- [':symbol', '42', '"; exit'].each do |ruby|
410
- @yardoc.options.verifier.expressions = []
411
- @yardoc.run('--api', ruby)
412
- expect(@yardoc.options.verifier.expressions[1]).to include(ruby.inspect)
413
- end
414
- end
415
- end
416
-
417
- describe "--hide-api option" do
418
- it "allows --hide-api to hide objects with api tags" do
419
- YARD.parse_string <<-eof
420
- # @api private
421
- class Foo; end
422
- class Bar; end
423
- class Baz; end
424
- eof
425
- @yardoc.run('--hide-api', 'private')
426
- expect(@yardoc.options.verifier.run(Registry.all).
427
- sort_by(&:path)).to eq [P('Bar'), P('Baz')]
428
- end
429
-
430
- it "allows --hide-api to work with --api" do
431
- YARD.parse_string <<-eof
432
- # @api private
433
- class Foo; end
434
- # @api public
435
- class Bar; end
436
- class Baz; end
437
- eof
438
- @yardoc.run('--api', 'public', '--hide-api', 'private')
439
- expect(@yardoc.options.verifier.run(Registry.all).
440
- sort_by(&:path)).to eq [P('Bar')]
441
- end
442
- end
443
-
444
- describe "--no-private option" do
445
- it "accepts --no-private" do
446
- obj = double(:object)
447
- expect(obj).to receive(:tag).ordered.with(:private).and_return(true)
448
- @yardoc.parse_arguments(*%w(--no-private))
449
- expect(@yardoc.options.verifier.call(obj)).to be false
450
- end
451
-
452
- it "hides object if namespace is @private with --no-private" do
453
- ns = double(:namespace, :type => :module)
454
- expect(ns).to receive(:tag).with(:private).and_return(true)
455
- obj = double(:object, :namespace => ns)
456
- expect(obj).to receive(:tag).with(:private).and_return(false)
457
- @yardoc.parse_arguments(*%w(--no-private))
458
- expect(@yardoc.options.verifier.call(obj)).to be false
459
- end
460
-
461
- it "does not call #tag on namespace if namespace is proxy with --no-private" do
462
- ns = double(:namespace)
463
- expect(ns).to receive(:is_a?).with(CodeObjects::Proxy).and_return(true)
464
- expect(ns).not_to receive(:tag)
465
- obj = double(:object, :type => :class, :namespace => ns, :visibility => :public)
466
- expect(obj).to receive(:tag).ordered.with(:private).and_return(false)
467
- @yardoc.parse_arguments(*%w(--no-private))
468
- expect(@yardoc.options.verifier.call(obj)).to be true
469
- end
470
-
471
- # @bug gh-197
472
- it "does not call #tag on namespace if namespace is proxy with --no-private" do
473
- Registry.clear
474
- YARD.parse_string "module Qux; class Foo::Bar; end; end"
475
- foobar = Registry.at('Foo::Bar')
476
- foobar.namespace.type = :module
477
- @yardoc.parse_arguments(*%w(--no-private))
478
- expect(@yardoc.options.verifier.call(foobar)).to be true
479
- end
480
-
481
- it "does not call #tag on proxy object" do # @bug gh-197
482
- @yardoc.parse_arguments(*%w(--no-private))
483
- expect(@yardoc.options.verifier.call(P('ProxyClass'))).to be true
484
- end
485
-
486
- it "hides methods inside a 'private' class/module with --no-private" do
487
- Registry.clear
488
- YARD.parse_string <<-eof
489
- # @private
490
- class ABC
491
- def foo; end
492
- end
493
- eof
494
- @yardoc.parse_arguments(*%w(--no-private))
495
- expect(@yardoc.options.verifier.call(Registry.at('ABC'))).to be false
496
- expect(@yardoc.options.verifier.call(Registry.at('ABC#foo'))).to be false
497
- end
498
- end
499
-
500
- describe ".yardopts and .document handling" do
501
- before do
502
- @yardoc.use_yardopts_file = true
503
- end
504
-
505
- it "searches for and uses yardopts file specified by #options_file" do
506
- expect(File).to receive(:read_binary).with("test").and_return("-o \n\nMYPATH\nFILE1 FILE2")
507
- @yardoc.use_document_file = false
508
- @yardoc.options_file = "test"
509
- @yardoc.run
510
- expect(@yardoc.options.serializer.options[:basepath]).to eq "MYPATH"
511
- expect(@yardoc.files).to eq ["FILE1", "FILE2"]
512
- end
513
-
514
- it "uses String#shell_split to split .yardopts tokens" do
515
- optsdata = String.new("foo bar")
516
- expect(optsdata).to receive(:shell_split)
517
- expect(File).to receive(:read_binary).with("test").and_return(optsdata)
518
- @yardoc.options_file = "test"
519
- @yardoc.run
520
- end
521
-
522
- it "allows opts specified in command line to override yardopts file" do
523
- expect(File).to receive(:read_binary).with(".yardopts").and_return("-o NOTMYPATH")
524
- @yardoc.run("-o", "MYPATH", "FILE")
525
- expect(@yardoc.options.serializer.options[:basepath]).to eq "MYPATH"
526
- expect(@yardoc.files).to eq ["FILE"]
527
- end
528
-
529
- it "loads the RDoc .document file if found" do
530
- expect(File).to receive(:read_binary).with(".yardopts").and_return("-o NOTMYPATH")
531
- @yardoc.use_document_file = true
532
- allow(@yardoc).to receive(:support_rdoc_document_file!).and_return(["FILE2", "FILE3"])
533
- @yardoc.run("-o", "MYPATH", "FILE1")
534
- expect(@yardoc.options.serializer.options[:basepath]).to eq "MYPATH"
535
- expect(@yardoc.files).to eq ["FILE2", "FILE3", "FILE1"]
536
- end
537
- end
538
-
539
- describe "Query options" do
540
- after { Registry.clear }
541
-
542
- it "hides private constants in with default visibilities" do
543
- classobj = CodeObjects::ClassObject.new(:root, :Foo) {|o| o.visibility = :private }
544
- @yardoc.run
545
- expect(@yardoc.options.verifier.run([classobj])).to eq []
546
- end
547
-
548
- it "sets up visibility rules as verifier" do
549
- methobj = CodeObjects::MethodObject.new(:root, :test) {|o| o.visibility = :private }
550
- expect(File).to receive(:read_binary).with("test").and_return("--private")
551
- @yardoc.use_yardopts_file = true
552
- @yardoc.options_file = "test"
553
- @yardoc.run
554
- expect(@yardoc.options.verifier.call(methobj)).to be true
555
- end
556
-
557
- it "accepts a --query" do
558
- @yardoc.parse_arguments(*%w(--query @return))
559
- expect(@yardoc.options.verifier).to be_a(Verifier)
560
- end
561
-
562
- it "accepts multiple --query arguments" do
563
- obj = double(:object)
564
- expect(obj).to receive(:tag).ordered.with('return').and_return(true)
565
- expect(obj).to receive(:tag).ordered.with('tag').and_return(false)
566
- @yardoc.parse_arguments(*%w(--query @return --query @tag))
567
- expect(@yardoc.options.verifier).to be_a(Verifier)
568
- expect(@yardoc.options.verifier.call(obj)).to be false
569
- end
570
- end
571
-
572
- describe "Extra file arguments" do
573
- it "accepts extra files if specified after '-' with source files" do
574
- expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return([])
575
- expect(File).to receive(:file?).with('extra_file1').and_return(true)
576
- expect(File).to receive(:file?).with('extra_file2').and_return(true)
577
- expect(File).to receive(:read).with('extra_file1').and_return('')
578
- expect(File).to receive(:read).with('extra_file2').and_return('')
579
- @yardoc.parse_arguments(*%w(file1 file2 - extra_file1 extra_file2))
580
- expect(@yardoc.files).to eq %w(file1 file2)
581
- expect(@yardoc.options.files).to eq(
582
- [CodeObjects::ExtraFileObject.new('extra_file1', ''),
583
- CodeObjects::ExtraFileObject.new('extra_file2', '')]
584
- )
585
- end
586
-
587
- it "accepts files section only containing extra files" do
588
- expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return([])
589
- @yardoc.parse_arguments(*%w(- LICENSE))
590
- expect(@yardoc.files).to eq Parser::SourceParser::DEFAULT_PATH_GLOB
591
- expect(@yardoc.options.files).to eq [CodeObjects::ExtraFileObject.new('LICENSE', '')]
592
- end
593
-
594
- it "accepts globs as extra files" do
595
- expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return []
596
- expect(Dir).to receive(:glob).with('*.txt').and_return ['a.txt', 'b.txt']
597
- expect(File).to receive(:read).with('a.txt').and_return('')
598
- expect(File).to receive(:read).with('b.txt').and_return('')
599
- expect(File).to receive(:file?).with('a.txt').and_return(true)
600
- expect(File).to receive(:file?).with('b.txt').and_return(true)
601
- @yardoc.parse_arguments(*%w(file1 file2 - *.txt))
602
- expect(@yardoc.files).to eq %w(file1 file2)
603
- expect(@yardoc.options.files).to eq(
604
- [CodeObjects::ExtraFileObject.new('a.txt', ''),
605
- CodeObjects::ExtraFileObject.new('b.txt', '')]
606
- )
607
- end
608
-
609
- it "warns if extra file is not found" do
610
- expect(log).to receive(:warn).with(/Could not find file: UNKNOWN/)
611
- @yardoc.parse_arguments(*%w(- UNKNOWN))
612
- end
613
-
614
- it "warns if readme file is not found" do
615
- expect(log).to receive(:warn).with(/Could not find file: UNKNOWN/)
616
- @yardoc.parse_arguments(*%w(-r UNKNOWN))
617
- end
618
-
619
- it "warns on absolute paths in extra files" do
620
- expect(log).to receive(:warn).with(%r{Invalid file: /path/to/file})
621
- @yardoc.parse_arguments(*%w(- /path/to/file))
622
- end
623
-
624
- it "warns on absolute paths in readme" do
625
- expect(log).to receive(:warn).with(%r{Invalid file: /path/to/file})
626
- @yardoc.parse_arguments(*%w(-r /path/to/file))
627
- end
628
-
629
- it "uses first file as readme if no readme is specified when using --one-file" do
630
- expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return []
631
- expect(Dir).to receive(:glob).with('lib/*.rb').and_return(['lib/foo.rb'])
632
- expect(File).to receive(:read).with('lib/foo.rb').and_return('')
633
- @yardoc.parse_arguments(*%w(--one-file lib/*.rb))
634
- expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('lib/foo.rb', '')
635
- end
636
-
637
- it "uses readme it exists when using --one-file" do
638
- expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return ['README']
639
- expect(File).to receive(:read).with('README').and_return('')
640
- @yardoc.parse_arguments(*%w(--one-file lib/*.rb))
641
- expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('README', '')
642
- end
643
-
644
- it "does not allow US-ASCII charset when using --one-file" do
645
- ienc = Encoding.default_internal
646
- eenc = Encoding.default_external
647
- expect(log).to receive(:warn).with(/not compatible with US-ASCII.*using ASCII-8BIT/)
648
- @yardoc.parse_arguments(*%w(--one-file --charset us-ascii))
649
- expect(Encoding.default_internal.name).to eq 'ASCII-8BIT'
650
- expect(Encoding.default_external.name).to eq 'ASCII-8BIT'
651
- Encoding.default_internal = ienc
652
- Encoding.default_external = eenc
653
- end if defined?(::Encoding)
654
- end
655
-
656
- describe "Source file arguments" do
657
- it "accepts no params and parse {lib,app}/**/*.rb ext/**/*.c" do
658
- @yardoc.parse_arguments
659
- expect(@yardoc.files).to eq Parser::SourceParser::DEFAULT_PATH_GLOB
660
- end
661
- end
662
-
663
- describe "Tags options" do
664
- def tag_created(switch, factory_method)
665
- visible_tags = double(:visible_tags)
666
- expect(visible_tags).to receive(:|).ordered.with([:foo])
667
- expect(visible_tags).to receive(:-).ordered.with([]).and_return(visible_tags)
668
- expect(Tags::Library).to receive(:define_tag).with('Foo', :foo, factory_method)
669
- allow(Tags::Library).to receive(:visible_tags=)
670
- expect(Tags::Library).to receive(:visible_tags).at_least(1).times.and_return(visible_tags)
671
- @yardoc.parse_arguments("--#{switch}-tag", 'foo')
672
- end
673
-
674
- def tag_hidden(tag)
675
- visible_tags = double(:visible_tags)
676
- expect(visible_tags).to receive(:|).ordered.with([tag])
677
- expect(visible_tags).to receive(:-).ordered.with([tag]).and_return([])
678
- expect(Tags::Library).to receive(:define_tag).with(tag.to_s.capitalize, tag, nil)
679
- allow(Tags::Library).to receive(:visible_tags=)
680
- expect(Tags::Library).to receive(:visible_tags).at_least(1).times.and_return(visible_tags)
681
- end
682
-
683
- it "accepts --tag" do
684
- expect(Tags::Library).to receive(:define_tag).with('Title of Foo', :foo, nil)
685
- @yardoc.parse_arguments('--tag', 'foo:Title of Foo')
686
- end
687
-
688
- it "accepts --tag without title (and default to capitalized tag name)" do
689
- expect(Tags::Library).to receive(:define_tag).with('Foo', :foo, nil)
690
- @yardoc.parse_arguments('--tag', 'foo')
691
- end
692
-
693
- it "only lists tag once if declared twice" do
694
- visible_tags = []
695
- allow(Tags::Library).to receive(:define_tag)
696
- allow(Tags::Library).to receive(:visible_tags).and_return([:foo])
697
- allow(Tags::Library).to receive(:visible_tags=) {|value| visible_tags = value }
698
- @yardoc.parse_arguments('--tag', 'foo', '--tag', 'foo')
699
- expect(visible_tags).to eq [:foo]
700
- end
701
-
702
- it "accepts --type-tag" do
703
- tag_created 'type', :with_types
704
- end
705
-
706
- it "accepts --type-name-tag" do
707
- tag_created 'type-name', :with_types_and_name
708
- end
709
-
710
- it "accepts --name-tag" do
711
- tag_created 'name', :with_name
712
- end
713
-
714
- it "accepts --title-tag" do
715
- tag_created 'title', :with_title_and_text
716
- end
717
-
718
- it "accepts --hide-tag before tag is listed" do
719
- tag_hidden(:anewfoo)
720
- @yardoc.parse_arguments('--hide-tag', 'anewfoo', '--tag', 'anewfoo')
721
- end
722
-
723
- it "accepts --hide-tag after tag is listed" do
724
- tag_hidden(:anewfoo2)
725
- @yardoc.parse_arguments('--tag', 'anewfoo2', '--hide-tag', 'anewfoo2')
726
- end
727
-
728
- it "accepts --transitive-tag" do
729
- @yardoc.parse_arguments('--transitive-tag', 'foo')
730
- expect(Tags::Library.transitive_tags).to include(:foo)
731
- end
732
-
733
- it "accepts --non-transitive-tag" do
734
- Tags::Library.transitive_tags |= [:foo]
735
- @yardoc.parse_arguments('--non-transitive-tag', 'foo')
736
- expect(Tags::Library.transitive_tags).not_to include(:foo)
737
- end
738
- end
739
-
740
- describe "Safe mode" do
741
- before do
742
- allow(YARD::Config).to receive(:options).and_return(:safe_mode => true)
743
- end
744
-
745
- it "does not allow --load or -e in safe mode" do
746
- expect(@yardoc).not_to receive(:require)
747
- @yardoc.run('--load', 'foo')
748
- @yardoc.run('-e', 'foo')
749
- end
750
-
751
- it "does not allow --query in safe mode" do
752
- @yardoc.run('--query', 'foo')
753
- expect(@yardoc.options.verifier.expressions).not_to include("foo")
754
- end
755
-
756
- it "does not allow modifying the template paths" do
757
- expect(YARD::Templates::Engine).not_to receive(:register_template_path)
758
- @yardoc.run('-p', 'foo')
759
- @yardoc.run('--template-path', 'foo')
760
- end
761
- end
762
-
763
- describe "Markup Loading" do
764
- it "loads rdoc markup if no markup is provided" do
765
- @yardoc.generate = true
766
- @yardoc.run
767
- expect(@yardoc.options.markup).to eq :rdoc
768
- end
769
-
770
- it "loads rdoc markup even when no output is specified" do
771
- @yardoc.parse_arguments('--no-output')
772
- expect(@yardoc.options.markup).to eq :rdoc
773
- end
774
-
775
- it "warns if rdoc cannot be loaded and fallback to :none" do
776
- mod = YARD::Templates::Helpers::MarkupHelper
777
- mod.clear_markup_cache
778
- expect(mod.const_get(:MARKUP_PROVIDERS)).to receive(:[]).with(:rdoc).and_return([{:lib => 'INVALID'}])
779
- expect(log).to receive(:warn).with(/Could not load default RDoc formatter/)
780
- allow(@yardoc).to receive(:generate) { @yardoc.options.files = []; true }
781
- @yardoc.run
782
- expect(@yardoc.options.markup).to eq :none
783
- mod.clear_markup_cache
784
- end
785
-
786
- it "returns an error immediately if markup for any files are missing" do
787
- mod = YARD::Templates::Helpers::MarkupHelper
788
- mod.clear_markup_cache
789
- expect(mod.const_get(:MARKUP_PROVIDERS)).to receive(:[]).with(:markdown).and_return([{:lib => 'INVALID'}])
790
- expect(log).to receive(:error).with(/Missing 'INVALID' gem for Markdown formatting/)
791
- files = [CodeObjects::ExtraFileObject.new('test.md', '')]
792
- allow(@yardoc).to receive(:generate) { @yardoc.options.files = files; true }
793
- @yardoc.run
794
- mod.clear_markup_cache
795
- end
796
-
797
- it "returns an error immediately if markup for any files are missing (file markup specified in attributes)" do
798
- mod = YARD::Templates::Helpers::MarkupHelper
799
- mod.clear_markup_cache
800
- expect(mod.const_get(:MARKUP_PROVIDERS)).to receive(:[]).with(:markdown).and_return([{:lib => 'INVALID'}])
801
- expect(log).to receive(:error).with(/Missing 'INVALID' gem for Markdown formatting/)
802
- files = [CodeObjects::ExtraFileObject.new('test', '# @markup markdown')]
803
- allow(@yardoc).to receive(:generate) { @yardoc.options.files = files; true }
804
- @yardoc.run
805
- mod.clear_markup_cache
806
- end
807
- end
808
-
809
- describe "#run" do
810
- it "parses arguments if run() is called" do
811
- expect(@yardoc).to receive(:parse_arguments)
812
- @yardoc.run
813
- end
814
-
815
- it "parses arguments if run(arg1, arg2, ...) is called" do
816
- expect(@yardoc).to receive(:parse_arguments)
817
- @yardoc.run('--private', '-p', 'foo')
818
- end
819
-
820
- it "does not parse arguments if run(nil) is called" do
821
- expect(@yardoc).not_to receive(:parse_arguments)
822
- @yardoc.run(nil)
823
- end
824
-
825
- it "creates processing lock if saving" do
826
- expect(Registry).to receive(:lock_for_writing).and_yield
827
- @yardoc.run
828
- end
829
-
830
- it "does not create processing lock if not saving" do
831
- expect(Registry).not_to receive(:lock_for_writing)
832
- @yardoc.run('--no-save')
833
- end
834
-
835
- context "with --fail-on-warning" do
836
- it "exits with error status code if a warning occurs" do
837
- allow(log).to receive(:warned).and_return(true)
838
- expect { @yardoc.run("--fail-on-warning") }.to raise_error(SystemExit) do |error|
839
- expect(error).not_to be_success
840
- end
841
- end
842
-
843
- it "does not exit if a warning does not occur" do
844
- allow(log).to receive(:warned).and_return(false)
845
- expect { @yardoc.run("--fail-on-warning") }.not_to raise_error
846
- end
847
- end
848
- end
849
- end
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe YARD::CLI::Yardoc do
4
+ before do
5
+ @yardoc = YARD::CLI::Yardoc.new
6
+ @yardoc.statistics = false
7
+ @yardoc.use_document_file = false
8
+ @yardoc.use_yardopts_file = false
9
+ @yardoc.generate = false
10
+ allow(Templates::Engine).to receive(:render)
11
+ allow(Templates::Engine).to receive(:generate)
12
+ allow(YARD).to receive(:parse)
13
+ allow(Registry).to receive(:load)
14
+ allow(Registry).to receive(:save)
15
+ allow(File).to receive(:open!)
16
+ end
17
+
18
+ describe "Defaults" do
19
+ before do
20
+ @yardoc = CLI::Yardoc.new
21
+ allow(@yardoc).to receive(:yardopts).and_return([])
22
+ allow(@yardoc).to receive(:support_rdoc_document_file!).and_return([])
23
+ @yardoc.parse_arguments
24
+ end
25
+
26
+ it "does not use cache by default" do
27
+ expect(@yardoc.use_cache).to be false
28
+ end
29
+
30
+ it "prints statistics by default" do
31
+ expect(@yardoc.statistics).to be true
32
+ end
33
+
34
+ it "generates output by default" do
35
+ expect(@yardoc.generate).to be true
36
+ end
37
+
38
+ it "reads .yardopts by default" do
39
+ expect(@yardoc.use_yardopts_file).to be true
40
+ end
41
+
42
+ it "reads .document by default" do
43
+ expect(@yardoc.use_document_file).to be true
44
+ end
45
+
46
+ it "uses lib, app, and ext as default file glob paths" do
47
+ expect(@yardoc.files).to eq Parser::SourceParser::DEFAULT_PATH_GLOB
48
+ end
49
+
50
+ it "uses rdoc as default markup type (but falls back on none)" do
51
+ expect(@yardoc.options.markup).to eq :rdoc
52
+ end
53
+
54
+ it "uses default as default template" do
55
+ expect(@yardoc.options.template).to eq :default
56
+ end
57
+
58
+ it "uses HTML as default format" do
59
+ expect(@yardoc.options.format).to eq :html
60
+ end
61
+
62
+ it "uses 'Object' as default return type" do
63
+ expect(@yardoc.options.default_return).to eq 'Object'
64
+ end
65
+
66
+ it "does not hide void return types by default" do
67
+ expect(@yardoc.options.hide_void_return).to be false
68
+ end
69
+
70
+ it "only shows public visibility by default" do
71
+ expect(@yardoc.visibilities).to eq [:public]
72
+ end
73
+
74
+ it "does not list objects by default" do
75
+ expect(@yardoc.list).to be false
76
+ end
77
+
78
+ it "does not embed mixins by default" do
79
+ expect(@yardoc.options.embed_mixins).to be_empty
80
+ end
81
+
82
+ it "does not set any locale by default" do
83
+ expect(@yardoc.options.locale).to be nil
84
+ end
85
+ end
86
+
87
+ describe "General options" do
88
+ def self.should_accept(*args, &block)
89
+ @counter ||= 0
90
+ @counter += 1
91
+ counter = @counter
92
+ define_method("test_options_#{@counter}", &block)
93
+ args.each do |arg|
94
+ it("accepts #{arg}") { send("test_options_#{counter}", arg) }
95
+ end
96
+ end
97
+
98
+ should_accept('--single-db') do |arg|
99
+ @yardoc.parse_arguments(arg)
100
+ expect(Registry.single_object_db).to be true
101
+ Registry.single_object_db = nil
102
+ end
103
+
104
+ should_accept('--no-single-db') do |arg|
105
+ @yardoc.parse_arguments(arg)
106
+ expect(Registry.single_object_db).to be false
107
+ Registry.single_object_db = nil
108
+ end
109
+
110
+ should_accept('-c', '--use-cache') do |arg|
111
+ @yardoc.parse_arguments(arg)
112
+ expect(@yardoc.use_cache).to be true
113
+ end
114
+
115
+ should_accept('--no-cache') do |arg|
116
+ @yardoc.parse_arguments(arg)
117
+ expect(@yardoc.use_cache).to be false
118
+ end
119
+
120
+ should_accept('--yardopts') do |arg|
121
+ @yardoc = CLI::Yardoc.new
122
+ @yardoc.use_document_file = false
123
+ expect(@yardoc).to receive(:yardopts).at_least(1).times.and_return([])
124
+ @yardoc.parse_arguments(arg)
125
+ expect(@yardoc.use_yardopts_file).to be true
126
+ @yardoc.parse_arguments('--no-yardopts', arg)
127
+ expect(@yardoc.use_yardopts_file).to be true
128
+ end
129
+
130
+ should_accept('--yardopts with filename') do |_arg|
131
+ @yardoc = CLI::Yardoc.new
132
+ expect(File).to receive(:read_binary).with('.foobar').and_return('')
133
+ @yardoc.use_document_file = false
134
+ @yardoc.parse_arguments('--yardopts', '.foobar')
135
+ expect(@yardoc.use_yardopts_file).to be true
136
+ expect(@yardoc.options_file).to eq '.foobar'
137
+ end
138
+
139
+ should_accept('--no-yardopts') do |arg|
140
+ @yardoc = CLI::Yardoc.new
141
+ @yardoc.use_document_file = false
142
+ expect(@yardoc).not_to receive(:yardopts)
143
+ @yardoc.parse_arguments(arg)
144
+ expect(@yardoc.use_yardopts_file).to be false
145
+ @yardoc.parse_arguments('--yardopts', arg)
146
+ expect(@yardoc.use_yardopts_file).to be false
147
+ end
148
+
149
+ should_accept('--document') do |arg|
150
+ @yardoc = CLI::Yardoc.new
151
+ @yardoc.use_yardopts_file = false
152
+ expect(@yardoc).to receive(:support_rdoc_document_file!).and_return([])
153
+ @yardoc.parse_arguments('--no-document', arg)
154
+ expect(@yardoc.use_document_file).to be true
155
+ end
156
+
157
+ should_accept('--no-document') do |arg|
158
+ @yardoc = CLI::Yardoc.new
159
+ @yardoc.use_yardopts_file = false
160
+ expect(@yardoc).not_to receive(:support_rdoc_document_file!)
161
+ @yardoc.parse_arguments('--document', arg)
162
+ expect(@yardoc.use_document_file).to be false
163
+ end
164
+
165
+ should_accept('-b', '--db') do |arg|
166
+ @yardoc.parse_arguments(arg, 'test')
167
+ expect(Registry.yardoc_file).to eq 'test'
168
+ Registry.yardoc_file = '.yardoc'
169
+ end
170
+
171
+ should_accept('-n', '--no-output') do |arg|
172
+ expect(Templates::Engine).not_to receive(:generate)
173
+ @yardoc.run(arg)
174
+ end
175
+
176
+ should_accept('--exclude') do |arg|
177
+ expect(YARD).to receive(:parse).with(['a'], ['nota', 'b'])
178
+ @yardoc.run(arg, 'nota', arg, 'b', 'a')
179
+ end
180
+
181
+ should_accept('--no-save') do |arg|
182
+ expect(YARD).to receive(:parse)
183
+ expect(Registry).not_to receive(:save)
184
+ @yardoc.run(arg)
185
+ end
186
+
187
+ # This example relies on processing Yard's own documentation, and with
188
+ # --fail-on-warning option on, will raise a SystemExit error if building
189
+ # that documentation produces any one warning.
190
+ #
191
+ # Unless handled, it will cause immediate and abnormal process exit,
192
+ # without running remaining tests, and with non-successful exit status.
193
+ #
194
+ # While suppressing exceptions is generally a bad practice and against this
195
+ # project's style guide, here it is well advocated,
196
+ # hence Lint/HandleExceptions cop is disabled.
197
+ should_accept('--fail-on-warning') do |arg|
198
+ expect(YARD).to receive(:parse)
199
+ begin
200
+ @yardoc.run(arg)
201
+ rescue SystemExit # rubocop:disable Lint/HandleExceptions
202
+ end
203
+ end
204
+ end
205
+
206
+ describe "Output options" do
207
+ it "accepts --title" do
208
+ @yardoc.parse_arguments('--title', 'hello world')
209
+ expect(@yardoc.options.title).to eq 'hello world'
210
+ end
211
+
212
+ it "allows --title to have multiple spaces in .yardopts" do
213
+ expect(File).to receive(:read_binary).with("test").and_return("--title \"Foo Bar\"")
214
+ @yardoc.options_file = "test"
215
+ @yardoc.use_yardopts_file = true
216
+ @yardoc.run
217
+ expect(@yardoc.options.title).to eq "Foo Bar"
218
+ end
219
+
220
+ it "aliases --main to the --readme flag" do
221
+ Dir.chdir(File.join(File.dirname(__FILE__), '..', '..')) do
222
+ @yardoc.parse_arguments('--main', 'README.md')
223
+ expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('README.md', '')
224
+ end
225
+ end
226
+
227
+ it "selects a markup provider when --markup-provider or -mp is set" do
228
+ @yardoc.parse_arguments("-M", "test")
229
+ expect(@yardoc.options.markup_provider).to eq :test
230
+ @yardoc.parse_arguments("--markup-provider", "test2")
231
+ expect(@yardoc.options.markup_provider).to eq :test2
232
+ end
233
+
234
+ it "selects a markup format when -m is set" do
235
+ expect(@yardoc).to receive(:verify_markup_options).and_return(true)
236
+ @yardoc.generate = true
237
+ @yardoc.parse_arguments('-m', 'markdown')
238
+ expect(@yardoc.options.markup).to eq :markdown
239
+ end
240
+
241
+ it "accepts --default-return" do
242
+ @yardoc.parse_arguments(*%w(--default-return XYZ))
243
+ expect(@yardoc.options.default_return).to eq "XYZ"
244
+ end
245
+
246
+ it "allows --hide-void-return to be set" do
247
+ @yardoc.parse_arguments(*%w(--hide-void-return))
248
+ expect(@yardoc.options.hide_void_return).to be true
249
+ end
250
+
251
+ it "accepts --embed-mixins" do
252
+ @yardoc.parse_arguments(*%w(--embed-mixins))
253
+ expect(@yardoc.options.embed_mixins).to eq ['*']
254
+ end
255
+
256
+ it "accepts --embed-mixin MODULE" do
257
+ @yardoc.parse_arguments(*%w(--embed-mixin MyModule))
258
+ expect(@yardoc.options.embed_mixins).to eq ['MyModule']
259
+ end
260
+
261
+ it "generates all objects with --use-cache" do
262
+ expect(YARD).to receive(:parse)
263
+ expect(Registry).to receive(:load)
264
+ expect(Registry).to receive(:load_all)
265
+ allow(@yardoc).to receive(:generate).and_return(true)
266
+ @yardoc.run(*%w(--use-cache))
267
+ end
268
+
269
+ it "does not print statistics with --no-stats" do
270
+ allow(@yardoc).to receive(:statistics).and_return(false)
271
+ expect(CLI::Stats).not_to receive(:new)
272
+ @yardoc.run(*%w(--no-stats))
273
+ end
274
+
275
+ it "disables progress bar with --no-progress" do
276
+ old = log.show_progress
277
+ log.show_progress = true
278
+ @yardoc.run(*%w(--no-progress))
279
+ expect(log.show_progress).to eq false
280
+ log.show_progress = old
281
+ end
282
+
283
+ describe "--asset" do
284
+ before do
285
+ @yardoc.generate = true
286
+ allow(@yardoc).to receive(:run_generate)
287
+ end
288
+
289
+ it "copies assets to output directory" do
290
+ expect(FileUtils).to receive(:cp_r).with('a', 'doc/a')
291
+ @yardoc.run(*%w(--asset a))
292
+ expect(@yardoc.assets).to eq('a' => 'a')
293
+ end
294
+
295
+ it "allows multiple --asset options" do
296
+ expect(FileUtils).to receive(:cp_r).with('a', 'doc/a')
297
+ expect(FileUtils).to receive(:cp_r).with('b', 'doc/b')
298
+ @yardoc.run(*%w(--asset a --asset b))
299
+ expect(@yardoc.assets).to eq('a' => 'a', 'b' => 'b')
300
+ end
301
+
302
+ it "does not allow from or to to refer to a path above current path" do
303
+ expect(log).to receive(:warn).exactly(4).times.with(/invalid/i)
304
+ @yardoc.run(*%w(--asset ../../../etc/passwd))
305
+ expect(@yardoc.assets).to be_empty
306
+ @yardoc.run(*%w(--asset a/b/c/d/../../../../../../etc/passwd))
307
+ expect(@yardoc.assets).to be_empty
308
+ @yardoc.run(*%w(--asset /etc/passwd))
309
+ expect(@yardoc.assets).to be_empty
310
+ @yardoc.run(*%w(--asset normal:/etc/passwd))
311
+ expect(@yardoc.assets).to be_empty
312
+ end
313
+
314
+ it "allows from:to syntax" do
315
+ expect(FileUtils).to receive(:cp_r).with(%r{foo(\/\.)?}, 'doc/bar')
316
+ @yardoc.run(*%w(--asset foo:bar))
317
+ expect(@yardoc.assets).to eq('foo' => 'bar')
318
+ end
319
+
320
+ it "does not put from inside of to/ if from is a directory" do
321
+ begin
322
+ from = 'tmp_foo'
323
+ to = 'tmp_bar'
324
+ full_to = File.join(File.dirname(__FILE__), to)
325
+ FileUtils.mkdir_p(from)
326
+ @yardoc.options.serializer.basepath = File.dirname(__FILE__)
327
+ @yardoc.run("--asset", "#{from}:#{to}")
328
+ @yardoc.run("--asset", "#{from}:#{to}")
329
+ expect(File.directory?(full_to)).to be true
330
+ expect(File.directory?(File.join(full_to, 'tmp_foo'))).to be false
331
+ ensure
332
+ FileUtils.rm_rf(from)
333
+ FileUtils.rm_rf(full_to)
334
+ end
335
+ end
336
+ end
337
+
338
+ describe "--locale" do
339
+ it "applies specified locale to all extra file objects" do
340
+ allow(File).to receive(:read).with('extra_file1').and_return('')
341
+ allow(File).to receive(:read).with('extra_file2').and_return('')
342
+
343
+ extra_file_object1 = CodeObjects::ExtraFileObject.new('extra_file1')
344
+ extra_file_object2 = CodeObjects::ExtraFileObject.new('extra_file2')
345
+ expect(extra_file_object1).to receive(:locale=).with('fr')
346
+ expect(extra_file_object2).to receive(:locale=).with('fr')
347
+
348
+ allow(CodeObjects::ExtraFileObject).to receive(:new).with('extra_file1').and_return(extra_file_object1)
349
+ allow(CodeObjects::ExtraFileObject).to receive(:new).with('extra_file2').and_return(extra_file_object2)
350
+ allow(Dir).to receive(:glob).with('README{,*[^~]}').and_return([])
351
+ allow(File).to receive(:file?).with('extra_file1').and_return(true)
352
+ allow(File).to receive(:file?).with('extra_file2').and_return(true)
353
+ @yardoc.run('--locale=fr', '-', 'extra_file1', 'extra_file2')
354
+ end
355
+ end
356
+
357
+ describe "--po-dir" do
358
+ it "sets Registry.po_dir" do
359
+ expect(Registry).to receive(:po_dir=).with("locale")
360
+ @yardoc.run('--po-dir=locale')
361
+ end
362
+ end
363
+ end
364
+
365
+ describe "--[no-]api" do
366
+ before { Registry.clear }
367
+
368
+ it "allows --api name" do
369
+ YARD.parse_string <<-eof
370
+ # @api private
371
+ class Foo; end
372
+ # @api public
373
+ class Bar; end
374
+ class Baz; end
375
+ eof
376
+ @yardoc.run('--api', 'private')
377
+ expect(@yardoc.options.verifier.run(Registry.all)).to eq [P('Foo')]
378
+ end
379
+
380
+ it "allows multiple --api's to all be shown" do
381
+ YARD.parse_string <<-eof
382
+ # @api private
383
+ class Foo; end
384
+ # @api public
385
+ class Bar; end
386
+ class Baz; end
387
+ eof
388
+ @yardoc.run('--api', 'private', '--api', 'public')
389
+ expect(@yardoc.options.verifier.run(Registry.all).
390
+ sort_by(&:path)).to eq [P('Bar'), P('Foo')]
391
+ end
392
+
393
+ it "allows --no-api to specify objects with no @api tag" do
394
+ YARD.parse_string <<-eof
395
+ # @api private
396
+ class Foo; end
397
+ # @api public
398
+ class Bar; end
399
+ class Baz; end
400
+ eof
401
+ @yardoc.run('--api', '')
402
+ expect(@yardoc.options.verifier.run(Registry.all)).to eq [P('Baz')]
403
+ @yardoc.options.verifier = Verifier.new
404
+ @yardoc.run('--no-api')
405
+ expect(@yardoc.options.verifier.run(Registry.all)).to eq [P('Baz')]
406
+ end
407
+
408
+ it "allows --no-api to work with other --api switches" do
409
+ YARD.parse_string <<-eof
410
+ # @api private
411
+ class Foo; end
412
+ # @api public
413
+ class Bar; end
414
+ class Baz; end
415
+ eof
416
+ @yardoc.run('--no-api', '--api', 'public')
417
+ expect(@yardoc.options.verifier.run(Registry.all).
418
+ sort_by(&:path)).to eq [P('Bar'), P('Baz')]
419
+ end
420
+
421
+ it "ensures Ruby code cannot be used" do
422
+ [':symbol', '42', '"; exit'].each do |ruby|
423
+ @yardoc.options.verifier.expressions = []
424
+ @yardoc.run('--api', ruby)
425
+ expect(@yardoc.options.verifier.expressions[1]).to include(ruby.inspect)
426
+ end
427
+ end
428
+ end
429
+
430
+ describe "--hide-api option" do
431
+ it "allows --hide-api to hide objects with api tags" do
432
+ YARD.parse_string <<-eof
433
+ # @api private
434
+ class Foo; end
435
+ class Bar; end
436
+ class Baz; end
437
+ eof
438
+ @yardoc.run('--hide-api', 'private')
439
+ expect(@yardoc.options.verifier.run(Registry.all).
440
+ sort_by(&:path)).to eq [P('Bar'), P('Baz')]
441
+ end
442
+
443
+ it "allows --hide-api to work with --api" do
444
+ YARD.parse_string <<-eof
445
+ # @api private
446
+ class Foo; end
447
+ # @api public
448
+ class Bar; end
449
+ class Baz; end
450
+ eof
451
+ @yardoc.run('--api', 'public', '--hide-api', 'private')
452
+ expect(@yardoc.options.verifier.run(Registry.all).
453
+ sort_by(&:path)).to eq [P('Bar')]
454
+ end
455
+ end
456
+
457
+ describe "--no-private option" do
458
+ it "accepts --no-private" do
459
+ obj = double(:object)
460
+ expect(obj).to receive(:tag).ordered.with(:private).and_return(true)
461
+ @yardoc.parse_arguments(*%w(--no-private))
462
+ expect(@yardoc.options.verifier.call(obj)).to be false
463
+ end
464
+
465
+ it "hides object if namespace is @private with --no-private" do
466
+ ns = double(:namespace, :type => :module)
467
+ expect(ns).to receive(:tag).with(:private).and_return(true)
468
+ obj = double(:object, :namespace => ns)
469
+ expect(obj).to receive(:tag).with(:private).and_return(false)
470
+ @yardoc.parse_arguments(*%w(--no-private))
471
+ expect(@yardoc.options.verifier.call(obj)).to be false
472
+ end
473
+
474
+ it "does not call #tag on namespace if namespace is proxy with --no-private" do
475
+ ns = double(:namespace)
476
+ expect(ns).to receive(:is_a?).with(CodeObjects::Proxy).and_return(true)
477
+ expect(ns).not_to receive(:tag)
478
+ obj = double(:object, :type => :class, :namespace => ns, :visibility => :public)
479
+ expect(obj).to receive(:tag).ordered.with(:private).and_return(false)
480
+ @yardoc.parse_arguments(*%w(--no-private))
481
+ expect(@yardoc.options.verifier.call(obj)).to be true
482
+ end
483
+
484
+ # @bug gh-197
485
+ it "does not call #tag on namespace if namespace is proxy with --no-private" do
486
+ Registry.clear
487
+ YARD.parse_string "module Qux; class Foo::Bar; end; end"
488
+ foobar = Registry.at('Foo::Bar')
489
+ foobar.namespace.type = :module
490
+ @yardoc.parse_arguments(*%w(--no-private))
491
+ expect(@yardoc.options.verifier.call(foobar)).to be true
492
+ end
493
+
494
+ it "does not call #tag on proxy object" do # @bug gh-197
495
+ @yardoc.parse_arguments(*%w(--no-private))
496
+ expect(@yardoc.options.verifier.call(P('ProxyClass'))).to be true
497
+ end
498
+
499
+ it "hides methods inside a 'private' class/module with --no-private" do
500
+ Registry.clear
501
+ YARD.parse_string <<-eof
502
+ # @private
503
+ class ABC
504
+ def foo; end
505
+ end
506
+ eof
507
+ @yardoc.parse_arguments(*%w(--no-private))
508
+ expect(@yardoc.options.verifier.call(Registry.at('ABC'))).to be false
509
+ expect(@yardoc.options.verifier.call(Registry.at('ABC#foo'))).to be false
510
+ end
511
+ end
512
+
513
+ describe ".yardopts and .document handling" do
514
+ before do
515
+ @yardoc.use_yardopts_file = true
516
+ end
517
+
518
+ it "searches for and uses yardopts file specified by #options_file" do
519
+ expect(File).to receive(:read_binary).with("test").and_return("-o \n\nMYPATH\nFILE1 FILE2")
520
+ @yardoc.use_document_file = false
521
+ @yardoc.options_file = "test"
522
+ @yardoc.run
523
+ expect(@yardoc.options.serializer.options[:basepath]).to eq "MYPATH"
524
+ expect(@yardoc.files).to eq ["FILE1", "FILE2"]
525
+ end
526
+
527
+ it "uses String#shell_split to split .yardopts tokens" do
528
+ optsdata = String.new("foo bar")
529
+ expect(optsdata).to receive(:shell_split)
530
+ expect(File).to receive(:read_binary).with("test").and_return(optsdata)
531
+ @yardoc.options_file = "test"
532
+ @yardoc.run
533
+ end
534
+
535
+ it "allows opts specified in command line to override yardopts file" do
536
+ expect(File).to receive(:read_binary).with(".yardopts").and_return("-o NOTMYPATH")
537
+ @yardoc.run("-o", "MYPATH", "FILE")
538
+ expect(@yardoc.options.serializer.options[:basepath]).to eq "MYPATH"
539
+ expect(@yardoc.files).to eq ["FILE"]
540
+ end
541
+
542
+ it "loads the RDoc .document file if found" do
543
+ expect(File).to receive(:read_binary).with(".yardopts").and_return("-o NOTMYPATH")
544
+ @yardoc.use_document_file = true
545
+ allow(@yardoc).to receive(:support_rdoc_document_file!).and_return(["FILE2", "FILE3"])
546
+ @yardoc.run("-o", "MYPATH", "FILE1")
547
+ expect(@yardoc.options.serializer.options[:basepath]).to eq "MYPATH"
548
+ expect(@yardoc.files).to eq ["FILE2", "FILE3", "FILE1"]
549
+ end
550
+ end
551
+
552
+ describe "Query options" do
553
+ after { Registry.clear }
554
+
555
+ it "hides private constants in with default visibilities" do
556
+ classobj = CodeObjects::ClassObject.new(:root, :Foo) {|o| o.visibility = :private }
557
+ @yardoc.run
558
+ expect(@yardoc.options.verifier.run([classobj])).to eq []
559
+ end
560
+
561
+ it "sets up visibility rules as verifier" do
562
+ methobj = CodeObjects::MethodObject.new(:root, :test) {|o| o.visibility = :private }
563
+ expect(File).to receive(:read_binary).with("test").and_return("--private")
564
+ @yardoc.use_yardopts_file = true
565
+ @yardoc.options_file = "test"
566
+ @yardoc.run
567
+ expect(@yardoc.options.verifier.call(methobj)).to be true
568
+ end
569
+
570
+ it "accepts a --query" do
571
+ @yardoc.parse_arguments(*%w(--query @return))
572
+ expect(@yardoc.options.verifier).to be_a(Verifier)
573
+ end
574
+
575
+ it "accepts multiple --query arguments" do
576
+ obj = double(:object)
577
+ expect(obj).to receive(:tag).ordered.with('return').and_return(true)
578
+ expect(obj).to receive(:tag).ordered.with('tag').and_return(false)
579
+ @yardoc.parse_arguments(*%w(--query @return --query @tag))
580
+ expect(@yardoc.options.verifier).to be_a(Verifier)
581
+ expect(@yardoc.options.verifier.call(obj)).to be false
582
+ end
583
+ end
584
+
585
+ describe "Extra file arguments" do
586
+ it "accepts extra files if specified after '-' with source files" do
587
+ expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return([])
588
+ expect(File).to receive(:file?).with('extra_file1').and_return(true)
589
+ expect(File).to receive(:file?).with('extra_file2').and_return(true)
590
+ expect(File).to receive(:read).with('extra_file1').and_return('')
591
+ expect(File).to receive(:read).with('extra_file2').and_return('')
592
+ @yardoc.parse_arguments(*%w(file1 file2 - extra_file1 extra_file2))
593
+ expect(@yardoc.files).to eq %w(file1 file2)
594
+ expect(@yardoc.options.files).to eq(
595
+ [CodeObjects::ExtraFileObject.new('extra_file1', ''),
596
+ CodeObjects::ExtraFileObject.new('extra_file2', '')]
597
+ )
598
+ end
599
+
600
+ it "accepts files section only containing extra files" do
601
+ expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return([])
602
+ @yardoc.parse_arguments(*%w(- LICENSE))
603
+ expect(@yardoc.files).to eq Parser::SourceParser::DEFAULT_PATH_GLOB
604
+ expect(@yardoc.options.files).to eq [CodeObjects::ExtraFileObject.new('LICENSE', '')]
605
+ end
606
+
607
+ it "accepts globs as extra files" do
608
+ expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return []
609
+ expect(Dir).to receive(:glob).with('*.txt').and_return ['a.txt', 'b.txt']
610
+ expect(File).to receive(:read).with('a.txt').and_return('')
611
+ expect(File).to receive(:read).with('b.txt').and_return('')
612
+ expect(File).to receive(:file?).with('a.txt').and_return(true)
613
+ expect(File).to receive(:file?).with('b.txt').and_return(true)
614
+ @yardoc.parse_arguments(*%w(file1 file2 - *.txt))
615
+ expect(@yardoc.files).to eq %w(file1 file2)
616
+ expect(@yardoc.options.files).to eq(
617
+ [CodeObjects::ExtraFileObject.new('a.txt', ''),
618
+ CodeObjects::ExtraFileObject.new('b.txt', '')]
619
+ )
620
+ end
621
+
622
+ it "warns if extra file is not found" do
623
+ expect(log).to receive(:warn).with(/Could not find file: UNKNOWN/)
624
+ @yardoc.parse_arguments(*%w(- UNKNOWN))
625
+ end
626
+
627
+ it "warns if readme file is not found" do
628
+ expect(log).to receive(:warn).with(/Could not find file: UNKNOWN/)
629
+ @yardoc.parse_arguments(*%w(-r UNKNOWN))
630
+ end
631
+
632
+ it "warns on absolute paths in extra files" do
633
+ expect(log).to receive(:warn).with(%r{Invalid file: /path/to/file})
634
+ @yardoc.parse_arguments(*%w(- /path/to/file))
635
+ end
636
+
637
+ it "warns on absolute paths in readme" do
638
+ expect(log).to receive(:warn).with(%r{Invalid file: /path/to/file})
639
+ @yardoc.parse_arguments(*%w(-r /path/to/file))
640
+ end
641
+
642
+ it "uses first file as readme if no readme is specified when using --one-file" do
643
+ expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return []
644
+ expect(Dir).to receive(:glob).with('lib/*.rb').and_return(['lib/foo.rb'])
645
+ expect(File).to receive(:read).with('lib/foo.rb').and_return('')
646
+ @yardoc.parse_arguments(*%w(--one-file lib/*.rb))
647
+ expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('lib/foo.rb', '')
648
+ end
649
+
650
+ it "uses readme it exists when using --one-file" do
651
+ expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return ['README']
652
+ expect(File).to receive(:read).with('README').and_return('')
653
+ @yardoc.parse_arguments(*%w(--one-file lib/*.rb))
654
+ expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('README', '')
655
+ end
656
+
657
+ it "does not allow US-ASCII charset when using --one-file" do
658
+ ienc = Encoding.default_internal
659
+ eenc = Encoding.default_external
660
+ expect(log).to receive(:warn).with(/not compatible with US-ASCII.*using ASCII-8BIT/)
661
+ @yardoc.parse_arguments(*%w(--one-file --charset us-ascii))
662
+ expect(Encoding.default_internal.name).to eq 'ASCII-8BIT'
663
+ expect(Encoding.default_external.name).to eq 'ASCII-8BIT'
664
+ Encoding.default_internal = ienc
665
+ Encoding.default_external = eenc
666
+ end if defined?(::Encoding)
667
+ end
668
+
669
+ describe "Source file arguments" do
670
+ it "accepts no params and parse {lib,app}/**/*.rb ext/**/*.c" do
671
+ @yardoc.parse_arguments
672
+ expect(@yardoc.files).to eq Parser::SourceParser::DEFAULT_PATH_GLOB
673
+ end
674
+ end
675
+
676
+ describe "Tags options" do
677
+ def tag_created(switch, factory_method)
678
+ visible_tags = double(:visible_tags)
679
+ expect(visible_tags).to receive(:|).ordered.with([:foo])
680
+ expect(visible_tags).to receive(:-).ordered.with([]).and_return(visible_tags)
681
+ expect(Tags::Library).to receive(:define_tag).with('Foo', :foo, factory_method)
682
+ allow(Tags::Library).to receive(:visible_tags=)
683
+ expect(Tags::Library).to receive(:visible_tags).at_least(1).times.and_return(visible_tags)
684
+ @yardoc.parse_arguments("--#{switch}-tag", 'foo')
685
+ end
686
+
687
+ def tag_hidden(tag)
688
+ visible_tags = double(:visible_tags)
689
+ expect(visible_tags).to receive(:|).ordered.with([tag])
690
+ expect(visible_tags).to receive(:-).ordered.with([tag]).and_return([])
691
+ expect(Tags::Library).to receive(:define_tag).with(tag.to_s.capitalize, tag, nil)
692
+ allow(Tags::Library).to receive(:visible_tags=)
693
+ expect(Tags::Library).to receive(:visible_tags).at_least(1).times.and_return(visible_tags)
694
+ end
695
+
696
+ it "accepts --tag" do
697
+ expect(Tags::Library).to receive(:define_tag).with('Title of Foo', :foo, nil)
698
+ @yardoc.parse_arguments('--tag', 'foo:Title of Foo')
699
+ end
700
+
701
+ it "accepts --tag without title (and default to capitalized tag name)" do
702
+ expect(Tags::Library).to receive(:define_tag).with('Foo', :foo, nil)
703
+ @yardoc.parse_arguments('--tag', 'foo')
704
+ end
705
+
706
+ it "only lists tag once if declared twice" do
707
+ visible_tags = []
708
+ allow(Tags::Library).to receive(:define_tag)
709
+ allow(Tags::Library).to receive(:visible_tags).and_return([:foo])
710
+ allow(Tags::Library).to receive(:visible_tags=) {|value| visible_tags = value }
711
+ @yardoc.parse_arguments('--tag', 'foo', '--tag', 'foo')
712
+ expect(visible_tags).to eq [:foo]
713
+ end
714
+
715
+ it "accepts --type-tag" do
716
+ tag_created 'type', :with_types
717
+ end
718
+
719
+ it "accepts --type-name-tag" do
720
+ tag_created 'type-name', :with_types_and_name
721
+ end
722
+
723
+ it "accepts --name-tag" do
724
+ tag_created 'name', :with_name
725
+ end
726
+
727
+ it "accepts --title-tag" do
728
+ tag_created 'title', :with_title_and_text
729
+ end
730
+
731
+ it "accepts --hide-tag before tag is listed" do
732
+ tag_hidden(:anewfoo)
733
+ @yardoc.parse_arguments('--hide-tag', 'anewfoo', '--tag', 'anewfoo')
734
+ end
735
+
736
+ it "accepts --hide-tag after tag is listed" do
737
+ tag_hidden(:anewfoo2)
738
+ @yardoc.parse_arguments('--tag', 'anewfoo2', '--hide-tag', 'anewfoo2')
739
+ end
740
+
741
+ it "accepts --transitive-tag" do
742
+ @yardoc.parse_arguments('--transitive-tag', 'foo')
743
+ expect(Tags::Library.transitive_tags).to include(:foo)
744
+ end
745
+
746
+ it "accepts --non-transitive-tag" do
747
+ Tags::Library.transitive_tags |= [:foo]
748
+ @yardoc.parse_arguments('--non-transitive-tag', 'foo')
749
+ expect(Tags::Library.transitive_tags).not_to include(:foo)
750
+ end
751
+ end
752
+
753
+ describe "Safe mode" do
754
+ before do
755
+ allow(YARD::Config).to receive(:options).and_return(:safe_mode => true)
756
+ end
757
+
758
+ it "does not allow --load or -e in safe mode" do
759
+ expect(@yardoc).not_to receive(:require)
760
+ @yardoc.run('--load', 'foo')
761
+ @yardoc.run('-e', 'foo')
762
+ end
763
+
764
+ it "does not allow --query in safe mode" do
765
+ @yardoc.run('--query', 'foo')
766
+ expect(@yardoc.options.verifier.expressions).not_to include("foo")
767
+ end
768
+
769
+ it "does not allow modifying the template paths" do
770
+ expect(YARD::Templates::Engine).not_to receive(:register_template_path)
771
+ @yardoc.run('-p', 'foo')
772
+ @yardoc.run('--template-path', 'foo')
773
+ end
774
+ end
775
+
776
+ describe "Markup Loading" do
777
+ it "loads rdoc markup if no markup is provided" do
778
+ @yardoc.generate = true
779
+ @yardoc.run
780
+ expect(@yardoc.options.markup).to eq :rdoc
781
+ end
782
+
783
+ it "loads rdoc markup even when no output is specified" do
784
+ @yardoc.parse_arguments('--no-output')
785
+ expect(@yardoc.options.markup).to eq :rdoc
786
+ end
787
+
788
+ it "warns if rdoc cannot be loaded and fallback to :none" do
789
+ mod = YARD::Templates::Helpers::MarkupHelper
790
+ mod.clear_markup_cache
791
+ expect(mod.const_get(:MARKUP_PROVIDERS)).to receive(:[]).with(:rdoc).and_return([{:lib => 'INVALID'}])
792
+ expect(log).to receive(:warn).with(/Could not load default RDoc formatter/)
793
+ allow(@yardoc).to receive(:generate) { @yardoc.options.files = []; true }
794
+ @yardoc.run
795
+ expect(@yardoc.options.markup).to eq :none
796
+ mod.clear_markup_cache
797
+ end
798
+
799
+ it "returns an error immediately if markup for any files are missing" do
800
+ mod = YARD::Templates::Helpers::MarkupHelper
801
+ mod.clear_markup_cache
802
+ expect(mod.const_get(:MARKUP_PROVIDERS)).to receive(:[]).with(:markdown).and_return([{:lib => 'INVALID'}])
803
+ expect(log).to receive(:error).with(/Missing 'INVALID' gem for Markdown formatting/)
804
+ files = [CodeObjects::ExtraFileObject.new('test.md', '')]
805
+ allow(@yardoc).to receive(:generate) { @yardoc.options.files = files; true }
806
+ @yardoc.run
807
+ mod.clear_markup_cache
808
+ end
809
+
810
+ it "returns an error immediately if markup for any files are missing (file markup specified in attributes)" do
811
+ mod = YARD::Templates::Helpers::MarkupHelper
812
+ mod.clear_markup_cache
813
+ expect(mod.const_get(:MARKUP_PROVIDERS)).to receive(:[]).with(:markdown).and_return([{:lib => 'INVALID'}])
814
+ expect(log).to receive(:error).with(/Missing 'INVALID' gem for Markdown formatting/)
815
+ files = [CodeObjects::ExtraFileObject.new('test', '# @markup markdown')]
816
+ allow(@yardoc).to receive(:generate) { @yardoc.options.files = files; true }
817
+ @yardoc.run
818
+ mod.clear_markup_cache
819
+ end
820
+ end
821
+
822
+ describe "#run" do
823
+ it "parses arguments if run() is called" do
824
+ expect(@yardoc).to receive(:parse_arguments)
825
+ @yardoc.run
826
+ end
827
+
828
+ it "parses arguments if run(arg1, arg2, ...) is called" do
829
+ expect(@yardoc).to receive(:parse_arguments)
830
+ @yardoc.run('--private', '-p', 'foo')
831
+ end
832
+
833
+ it "does not parse arguments if run(nil) is called" do
834
+ expect(@yardoc).not_to receive(:parse_arguments)
835
+ @yardoc.run(nil)
836
+ end
837
+
838
+ it "creates processing lock if saving" do
839
+ expect(Registry).to receive(:lock_for_writing).and_yield
840
+ @yardoc.run
841
+ end
842
+
843
+ it "does not create processing lock if not saving" do
844
+ expect(Registry).not_to receive(:lock_for_writing)
845
+ @yardoc.run('--no-save')
846
+ end
847
+
848
+ context "with --fail-on-warning" do
849
+ it "exits with error status code if a warning occurs" do
850
+ allow(log).to receive(:warned).and_return(true)
851
+ expect { @yardoc.run("--fail-on-warning") }.to raise_error(SystemExit) do |error|
852
+ expect(error).not_to be_success
853
+ end
854
+ end
855
+
856
+ it "does not exit if a warning does not occur" do
857
+ allow(log).to receive(:warned).and_return(false)
858
+ expect { @yardoc.run("--fail-on-warning") }.not_to raise_error
859
+ end
860
+ end
861
+ end
862
+ end