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.
- checksums.yaml +5 -5
- data/.yardopts +26 -26
- data/CHANGELOG.md +728 -728
- data/LEGAL +66 -66
- data/LICENSE +22 -22
- data/README.md +328 -328
- data/Rakefile +53 -47
- data/benchmarks/builtins_vs_eval.rb +24 -24
- data/benchmarks/concat_vs_join.rb +13 -13
- data/benchmarks/erb_vs_erubis.rb +54 -54
- data/benchmarks/format_args.rb +47 -47
- data/benchmarks/generation.rb +38 -38
- data/benchmarks/marshal_vs_dbm.rb +64 -64
- data/benchmarks/parsing.rb +46 -46
- data/benchmarks/pathname_vs_string.rb +50 -50
- data/benchmarks/rdoc_vs_yardoc.rb +11 -11
- data/benchmarks/registry_store_types.rb +49 -49
- data/benchmarks/ri_vs_yri.rb +19 -19
- data/benchmarks/ripper_parser.rb +13 -13
- data/benchmarks/splat_vs_flatten.rb +13 -13
- data/benchmarks/template_erb.rb +23 -23
- data/benchmarks/template_format.rb +7 -7
- data/benchmarks/template_profile.rb +18 -18
- data/benchmarks/yri_cache.rb +20 -20
- data/bin/yard +13 -13
- data/bin/yardoc +13 -13
- data/bin/yri +13 -13
- data/docs/CodeObjects.md +115 -115
- data/docs/GettingStarted.md +679 -679
- data/docs/Handlers.md +152 -152
- data/docs/Overview.md +61 -61
- data/docs/Parser.md +191 -191
- data/docs/Tags.md +283 -283
- data/docs/TagsArch.md +123 -123
- data/docs/Templates.md +496 -496
- data/docs/WhatsNew.md +1245 -1245
- data/docs/templates/default/fulldoc/html/full_list_tag.erb +8 -8
- data/docs/templates/default/fulldoc/html/setup.rb +6 -6
- data/docs/templates/default/layout/html/setup.rb +9 -9
- data/docs/templates/default/layout/html/tag_list.erb +11 -11
- data/docs/templates/default/yard_tags/html/list.erb +18 -18
- data/docs/templates/default/yard_tags/html/setup.rb +26 -26
- data/docs/templates/plugin.rb +70 -70
- data/lib/rubygems_plugin.rb +9 -9
- data/lib/yard.rb +69 -69
- data/lib/yard/autoload.rb +303 -303
- data/lib/yard/cli/command.rb +85 -85
- data/lib/yard/cli/command_parser.rb +93 -93
- data/lib/yard/cli/config.rb +198 -198
- data/lib/yard/cli/diff.rb +270 -270
- data/lib/yard/cli/display.rb +69 -69
- data/lib/yard/cli/gems.rb +84 -84
- data/lib/yard/cli/graph.rb +125 -125
- data/lib/yard/cli/help.rb +20 -20
- data/lib/yard/cli/i18n.rb +70 -70
- data/lib/yard/cli/list.rb +23 -23
- data/lib/yard/cli/markup_types.rb +32 -32
- data/lib/yard/cli/server.rb +257 -257
- data/lib/yard/cli/stats.rb +231 -231
- data/lib/yard/cli/yardoc.rb +788 -788
- data/lib/yard/cli/yardopts_command.rb +110 -110
- data/lib/yard/cli/yri.rb +215 -215
- data/lib/yard/code_objects/base.rb +615 -610
- data/lib/yard/code_objects/class_object.rb +146 -146
- data/lib/yard/code_objects/class_variable_object.rb +11 -11
- data/lib/yard/code_objects/constant_object.rb +16 -16
- data/lib/yard/code_objects/extended_method_object.rb +24 -24
- data/lib/yard/code_objects/extra_file_object.rb +131 -131
- data/lib/yard/code_objects/macro_object.rb +172 -172
- data/lib/yard/code_objects/method_object.rb +196 -196
- data/lib/yard/code_objects/module_object.rb +21 -21
- data/lib/yard/code_objects/namespace_mapper.rb +114 -114
- data/lib/yard/code_objects/namespace_object.rb +200 -200
- data/lib/yard/code_objects/proxy.rb +240 -240
- data/lib/yard/code_objects/root_object.rb +19 -19
- data/lib/yard/config.rb +270 -270
- data/lib/yard/core_ext/array.rb +16 -16
- data/lib/yard/core_ext/file.rb +69 -69
- data/lib/yard/core_ext/hash.rb +16 -16
- data/lib/yard/core_ext/insertion.rb +63 -63
- data/lib/yard/core_ext/module.rb +20 -20
- data/lib/yard/core_ext/string.rb +68 -68
- data/lib/yard/core_ext/symbol_hash.rb +75 -75
- data/lib/yard/docstring.rb +386 -378
- data/lib/yard/docstring_parser.rb +345 -345
- data/lib/yard/gem_index.rb +29 -29
- data/lib/yard/globals.rb +22 -22
- data/lib/yard/handlers/base.rb +595 -595
- data/lib/yard/handlers/c/alias_handler.rb +16 -16
- data/lib/yard/handlers/c/attribute_handler.rb +13 -13
- data/lib/yard/handlers/c/base.rb +129 -129
- data/lib/yard/handlers/c/class_handler.rb +27 -27
- data/lib/yard/handlers/c/constant_handler.rb +13 -13
- data/lib/yard/handlers/c/handler_methods.rb +211 -211
- data/lib/yard/handlers/c/init_handler.rb +20 -20
- data/lib/yard/handlers/c/method_handler.rb +45 -36
- data/lib/yard/handlers/c/mixin_handler.rb +21 -21
- data/lib/yard/handlers/c/module_handler.rb +17 -17
- data/lib/yard/handlers/c/override_comment_handler.rb +31 -31
- data/lib/yard/handlers/c/path_handler.rb +11 -11
- data/lib/yard/handlers/c/struct_handler.rb +13 -13
- data/lib/yard/handlers/c/symbol_handler.rb +8 -8
- data/lib/yard/handlers/processor.rb +200 -200
- data/lib/yard/handlers/ruby/alias_handler.rb +44 -44
- data/lib/yard/handlers/ruby/attribute_handler.rb +87 -87
- data/lib/yard/handlers/ruby/base.rb +165 -165
- data/lib/yard/handlers/ruby/class_condition_handler.rb +92 -92
- data/lib/yard/handlers/ruby/class_handler.rb +119 -119
- data/lib/yard/handlers/ruby/class_variable_handler.rb +17 -17
- data/lib/yard/handlers/ruby/comment_handler.rb +10 -10
- data/lib/yard/handlers/ruby/constant_handler.rb +59 -59
- data/lib/yard/handlers/ruby/decorator_handler_methods.rb +123 -123
- data/lib/yard/handlers/ruby/dsl_handler.rb +15 -15
- data/lib/yard/handlers/ruby/dsl_handler_methods.rb +96 -95
- data/lib/yard/handlers/ruby/exception_handler.rb +27 -27
- data/lib/yard/handlers/ruby/extend_handler.rb +22 -22
- data/lib/yard/handlers/ruby/legacy/alias_handler.rb +37 -37
- data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +65 -65
- data/lib/yard/handlers/ruby/legacy/base.rb +245 -245
- data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +83 -83
- data/lib/yard/handlers/ruby/legacy/class_handler.rb +113 -113
- data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +15 -15
- data/lib/yard/handlers/ruby/legacy/comment_handler.rb +10 -10
- data/lib/yard/handlers/ruby/legacy/constant_handler.rb +29 -29
- data/lib/yard/handlers/ruby/legacy/dsl_handler.rb +17 -17
- data/lib/yard/handlers/ruby/legacy/exception_handler.rb +13 -13
- data/lib/yard/handlers/ruby/legacy/extend_handler.rb +21 -21
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +90 -90
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +39 -39
- data/lib/yard/handlers/ruby/legacy/module_function_handler.rb +19 -19
- data/lib/yard/handlers/ruby/legacy/module_handler.rb +12 -12
- data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +22 -22
- data/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +22 -22
- data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +17 -17
- data/lib/yard/handlers/ruby/legacy/yield_handler.rb +29 -29
- data/lib/yard/handlers/ruby/method_condition_handler.rb +9 -9
- data/lib/yard/handlers/ruby/method_handler.rb +118 -118
- data/lib/yard/handlers/ruby/mixin_handler.rb +37 -37
- data/lib/yard/handlers/ruby/module_function_handler.rb +27 -27
- data/lib/yard/handlers/ruby/module_handler.rb +12 -12
- data/lib/yard/handlers/ruby/private_class_method_handler.rb +14 -14
- data/lib/yard/handlers/ruby/private_constant_handler.rb +43 -43
- data/lib/yard/handlers/ruby/public_class_method_handler.rb +14 -14
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +143 -143
- data/lib/yard/handlers/ruby/visibility_handler.rb +22 -22
- data/lib/yard/handlers/ruby/yield_handler.rb +31 -31
- data/lib/yard/i18n/locale.rb +67 -67
- data/lib/yard/i18n/message.rb +57 -57
- data/lib/yard/i18n/messages.rb +56 -56
- data/lib/yard/i18n/po_parser.rb +61 -61
- data/lib/yard/i18n/pot_generator.rb +290 -290
- data/lib/yard/i18n/text.rb +173 -173
- data/lib/yard/logging.rb +205 -205
- data/lib/yard/options.rb +217 -217
- data/lib/yard/parser/base.rb +57 -57
- data/lib/yard/parser/c/c_parser.rb +235 -235
- data/lib/yard/parser/c/comment_parser.rb +134 -134
- data/lib/yard/parser/c/statement.rb +64 -64
- data/lib/yard/parser/ruby/ast_node.rb +540 -540
- data/lib/yard/parser/ruby/legacy/ruby_lex.rb +1354 -1354
- data/lib/yard/parser/ruby/legacy/ruby_parser.rb +32 -32
- data/lib/yard/parser/ruby/legacy/statement.rb +66 -66
- data/lib/yard/parser/ruby/legacy/statement_list.rb +394 -394
- data/lib/yard/parser/ruby/legacy/token_list.rb +74 -74
- data/lib/yard/parser/ruby/ruby_parser.rb +687 -687
- data/lib/yard/parser/ruby/token_resolver.rb +156 -156
- data/lib/yard/parser/source_parser.rb +526 -526
- data/lib/yard/rake/yardoc_task.rb +81 -81
- data/lib/yard/registry.rb +439 -439
- data/lib/yard/registry_resolver.rb +189 -189
- data/lib/yard/registry_store.rb +337 -337
- data/lib/yard/rubygems/backports.rb +10 -10
- data/lib/yard/rubygems/backports/LICENSE.txt +57 -57
- data/lib/yard/rubygems/backports/MIT.txt +20 -20
- data/lib/yard/rubygems/backports/gem.rb +10 -10
- data/lib/yard/rubygems/backports/source_index.rb +365 -365
- data/lib/yard/rubygems/doc_manager.rb +90 -90
- data/lib/yard/rubygems/hook.rb +197 -197
- data/lib/yard/rubygems/specification.rb +50 -50
- data/lib/yard/serializers/base.rb +83 -83
- data/lib/yard/serializers/file_system_serializer.rb +123 -123
- data/lib/yard/serializers/process_serializer.rb +24 -24
- data/lib/yard/serializers/stdout_serializer.rb +34 -34
- data/lib/yard/serializers/yardoc_serializer.rb +152 -152
- data/lib/yard/server.rb +13 -13
- data/lib/yard/server/adapter.rb +100 -100
- data/lib/yard/server/commands/base.rb +209 -209
- data/lib/yard/server/commands/display_file_command.rb +29 -29
- data/lib/yard/server/commands/display_object_command.rb +65 -65
- data/lib/yard/server/commands/frames_command.rb +16 -16
- data/lib/yard/server/commands/library_command.rb +187 -187
- data/lib/yard/server/commands/library_index_command.rb +28 -28
- data/lib/yard/server/commands/list_command.rb +25 -25
- data/lib/yard/server/commands/root_request_command.rb +15 -15
- data/lib/yard/server/commands/search_command.rb +79 -79
- data/lib/yard/server/commands/static_file_command.rb +23 -23
- data/lib/yard/server/commands/static_file_helpers.rb +62 -62
- data/lib/yard/server/doc_server_helper.rb +91 -91
- data/lib/yard/server/doc_server_serializer.rb +39 -39
- data/lib/yard/server/library_version.rb +277 -277
- data/lib/yard/server/rack_adapter.rb +89 -89
- data/lib/yard/server/router.rb +187 -187
- data/lib/yard/server/static_caching.rb +46 -46
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +127 -127
- data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +11 -11
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +37 -37
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +7 -7
- data/lib/yard/server/templates/default/layout/html/setup.rb +8 -8
- data/lib/yard/server/templates/default/method_details/html/permalink.erb +4 -4
- data/lib/yard/server/templates/default/method_details/html/setup.rb +5 -5
- data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +8 -8
- data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +14 -14
- data/lib/yard/server/templates/doc_server/library_list/html/listing.erb +13 -13
- data/lib/yard/server/templates/doc_server/library_list/html/setup.rb +6 -6
- data/lib/yard/server/templates/doc_server/library_list/html/title.erb +2 -2
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +52 -52
- data/lib/yard/server/templates/doc_server/processing/html/setup.rb +4 -4
- data/lib/yard/server/templates/doc_server/search/html/search.erb +18 -18
- data/lib/yard/server/templates/doc_server/search/html/setup.rb +9 -9
- data/lib/yard/server/webrick_adapter.rb +45 -45
- data/lib/yard/tags/default_factory.rb +191 -191
- data/lib/yard/tags/default_tag.rb +13 -13
- data/lib/yard/tags/directives.rb +616 -616
- data/lib/yard/tags/library.rb +633 -633
- data/lib/yard/tags/option_tag.rb +13 -13
- data/lib/yard/tags/overload_tag.rb +71 -71
- data/lib/yard/tags/ref_tag.rb +8 -8
- data/lib/yard/tags/ref_tag_list.rb +28 -28
- data/lib/yard/tags/tag.rb +71 -71
- data/lib/yard/tags/tag_format_error.rb +7 -7
- data/lib/yard/tags/types_explainer.rb +162 -162
- data/lib/yard/templates/engine.rb +186 -186
- data/lib/yard/templates/erb_cache.rb +23 -23
- data/lib/yard/templates/helpers/base_helper.rb +215 -215
- data/lib/yard/templates/helpers/filter_helper.rb +27 -27
- data/lib/yard/templates/helpers/html_helper.rb +646 -642
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +78 -78
- data/lib/yard/templates/helpers/markup/rdoc_markdown.rb +23 -23
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +109 -109
- data/lib/yard/templates/helpers/markup_helper.rb +172 -172
- data/lib/yard/templates/helpers/method_helper.rb +75 -75
- data/lib/yard/templates/helpers/module_helper.rb +21 -21
- data/lib/yard/templates/helpers/text_helper.rb +112 -112
- data/lib/yard/templates/helpers/uml_helper.rb +47 -47
- data/lib/yard/templates/section.rb +105 -105
- data/lib/yard/templates/template.rb +418 -418
- data/lib/yard/templates/template_options.rb +92 -92
- data/lib/yard/verifier.rb +151 -151
- data/lib/yard/version.rb +3 -1
- data/spec/cli/command_parser_spec.rb +43 -43
- data/spec/cli/command_spec.rb +36 -36
- data/spec/cli/config_spec.rb +148 -148
- data/spec/cli/diff_spec.rb +254 -254
- data/spec/cli/display_spec.rb +30 -30
- data/spec/cli/gems_spec.rb +81 -81
- data/spec/cli/graph_spec.rb +18 -18
- data/spec/cli/help_spec.rb +22 -22
- data/spec/cli/i18n_spec.rb +107 -107
- data/spec/cli/list_spec.rb +8 -8
- data/spec/cli/markup_types_spec.rb +22 -22
- data/spec/cli/server_spec.rb +324 -324
- data/spec/cli/stats_spec.rb +96 -96
- data/spec/cli/yard_on_yard_spec.rb +38 -38
- data/spec/cli/yardoc_spec.rb +862 -849
- data/spec/cli/yri_spec.rb +101 -101
- data/spec/code_objects/base_spec.rb +470 -460
- data/spec/code_objects/class_object_spec.rb +226 -226
- data/spec/code_objects/code_object_list_spec.rb +36 -36
- data/spec/code_objects/constants_spec.rb +116 -116
- data/spec/code_objects/extra_file_object_spec.rb +160 -160
- data/spec/code_objects/macro_object_spec.rb +150 -150
- data/spec/code_objects/method_object_spec.rb +184 -184
- data/spec/code_objects/module_object_spec.rb +142 -142
- data/spec/code_objects/namespace_object_spec.rb +171 -171
- data/spec/code_objects/proxy_spec.rb +141 -141
- data/spec/code_objects/spec_helper.rb +3 -3
- data/spec/config_spec.rb +171 -171
- data/spec/core_ext/array_spec.rb +13 -13
- data/spec/core_ext/file_spec.rb +72 -72
- data/spec/core_ext/hash_spec.rb +14 -14
- data/spec/core_ext/insertion_spec.rb +37 -37
- data/spec/core_ext/module_spec.rb +15 -15
- data/spec/core_ext/string_spec.rb +42 -42
- data/spec/core_ext/symbol_hash_spec.rb +89 -89
- data/spec/docstring_parser_spec.rb +280 -262
- data/spec/docstring_spec.rb +373 -364
- data/spec/examples.txt +1875 -1871
- data/spec/handlers/alias_handler_spec.rb +82 -82
- data/spec/handlers/attribute_handler_spec.rb +96 -96
- data/spec/handlers/base_spec.rb +216 -216
- data/spec/handlers/c/alias_handler_spec.rb +34 -34
- data/spec/handlers/c/attribute_handler_spec.rb +41 -41
- data/spec/handlers/c/class_handler_spec.rb +78 -78
- data/spec/handlers/c/constant_handler_spec.rb +71 -71
- data/spec/handlers/c/init_handler_spec.rb +48 -48
- data/spec/handlers/c/method_handler_spec.rb +325 -325
- data/spec/handlers/c/mixin_handler_spec.rb +44 -44
- data/spec/handlers/c/module_handler_spec.rb +71 -71
- data/spec/handlers/c/override_comment_handler_spec.rb +47 -47
- data/spec/handlers/c/path_handler_spec.rb +36 -36
- data/spec/handlers/c/spec_helper.rb +23 -23
- data/spec/handlers/c/struct_handler_spec.rb +16 -16
- data/spec/handlers/class_condition_handler_spec.rb +87 -87
- data/spec/handlers/class_handler_spec.rb +247 -247
- data/spec/handlers/class_method_handler_shared_examples.rb +133 -133
- data/spec/handlers/class_variable_handler_spec.rb +12 -12
- data/spec/handlers/constant_handler_spec.rb +112 -112
- data/spec/handlers/decorator_handler_methods_spec.rb +393 -393
- data/spec/handlers/dsl_handler_spec.rb +219 -219
- data/spec/handlers/examples/alias_handler_001.rb.txt +45 -45
- data/spec/handlers/examples/attribute_handler_001.rb.txt +31 -31
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +68 -68
- data/spec/handlers/examples/class_handler_001.rb.txt +120 -120
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +9 -9
- data/spec/handlers/examples/constant_handler_001.rb.txt +35 -35
- data/spec/handlers/examples/dsl_handler_001.rb.txt +154 -154
- data/spec/handlers/examples/exception_handler_001.rb.txt +58 -58
- data/spec/handlers/examples/extend_handler_001.rb.txt +15 -15
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +9 -9
- data/spec/handlers/examples/method_handler_001.rb.txt +128 -128
- data/spec/handlers/examples/mixin_handler_001.rb.txt +37 -37
- data/spec/handlers/examples/module_handler_001.rb.txt +29 -29
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +8 -8
- data/spec/handlers/examples/process_handler_001.rb.txt +11 -11
- data/spec/handlers/examples/visibility_handler_001.rb.txt +35 -35
- data/spec/handlers/examples/yield_handler_001.rb.txt +54 -54
- data/spec/handlers/exception_handler_spec.rb +49 -49
- data/spec/handlers/extend_handler_spec.rb +24 -24
- data/spec/handlers/legacy_base_spec.rb +128 -128
- data/spec/handlers/method_condition_handler_spec.rb +15 -15
- data/spec/handlers/method_handler_spec.rb +190 -190
- data/spec/handlers/mixin_handler_spec.rb +56 -56
- data/spec/handlers/module_function_handler_spec.rb +106 -106
- data/spec/handlers/module_handler_spec.rb +35 -35
- data/spec/handlers/private_class_method_handler_spec.rb +11 -11
- data/spec/handlers/private_constant_handler_spec.rb +25 -25
- data/spec/handlers/processor_spec.rb +35 -35
- data/spec/handlers/public_class_method_handler_spec.rb +11 -11
- data/spec/handlers/ruby/base_spec.rb +95 -95
- data/spec/handlers/ruby/legacy/base_spec.rb +84 -84
- data/spec/handlers/spec_helper.rb +33 -33
- data/spec/handlers/visibility_handler_spec.rb +44 -44
- data/spec/handlers/yield_handler_spec.rb +52 -52
- data/spec/i18n/locale_spec.rb +81 -81
- data/spec/i18n/message_spec.rb +52 -52
- data/spec/i18n/messages_spec.rb +67 -67
- data/spec/i18n/pot_generator_spec.rb +295 -295
- data/spec/i18n/text_spec.rb +184 -184
- data/spec/logging_spec.rb +44 -44
- data/spec/options_spec.rb +171 -171
- data/spec/parser/base_spec.rb +24 -24
- data/spec/parser/c_parser_spec.rb +236 -223
- data/spec/parser/examples/array.c.txt +6267 -6267
- data/spec/parser/examples/example1.rb.txt +7 -7
- data/spec/parser/examples/extrafile.c.txt +8 -8
- data/spec/parser/examples/file.c.txt +28 -0
- data/spec/parser/examples/multifile.c.txt +22 -22
- data/spec/parser/examples/namespace.cpp.txt +68 -68
- data/spec/parser/examples/override.c.txt +424 -424
- data/spec/parser/examples/parse_in_order_001.rb.txt +2 -2
- data/spec/parser/examples/parse_in_order_002.rb.txt +1 -1
- data/spec/parser/examples/tag_handler_001.rb.txt +7 -7
- data/spec/parser/ruby/ast_node_spec.rb +33 -33
- data/spec/parser/ruby/legacy/statement_list_spec.rb +299 -299
- data/spec/parser/ruby/legacy/token_list_spec.rb +79 -79
- data/spec/parser/ruby/ruby_parser_spec.rb +508 -508
- data/spec/parser/ruby/token_resolver_spec.rb +165 -165
- data/spec/parser/source_parser_spec.rb +727 -727
- data/spec/parser/tag_parsing_spec.rb +17 -17
- data/spec/rake/yardoc_task_spec.rb +118 -118
- data/spec/registry_spec.rb +463 -463
- data/spec/registry_store_spec.rb +316 -316
- data/spec/rubygems/doc_manager_spec.rb +112 -112
- data/spec/serializers/data/serialized_yardoc/checksums +1 -1
- data/spec/serializers/file_system_serializer_spec.rb +145 -145
- data/spec/serializers/spec_helper.rb +2 -2
- data/spec/serializers/yardoc_serializer_spec.rb +78 -78
- data/spec/server/adapter_spec.rb +39 -39
- data/spec/server/commands/base_spec.rb +91 -91
- data/spec/server/commands/library_command_spec.rb +39 -39
- data/spec/server/doc_server_helper_spec.rb +72 -72
- data/spec/server/doc_server_serializer_spec.rb +60 -60
- data/spec/server/rack_adapter_spec.rb +21 -21
- data/spec/server/router_spec.rb +123 -123
- data/spec/server/spec_helper.rb +22 -22
- data/spec/server/static_caching_spec.rb +47 -47
- data/spec/server/webrick_servlet_spec.rb +20 -20
- data/spec/server_spec.rb +19 -19
- data/spec/spec_helper.rb +212 -212
- data/spec/tags/default_factory_spec.rb +168 -168
- data/spec/tags/default_tag_spec.rb +11 -11
- data/spec/tags/directives_spec.rb +463 -463
- data/spec/tags/library_spec.rb +48 -48
- data/spec/tags/overload_tag_spec.rb +53 -53
- data/spec/tags/ref_tag_list_spec.rb +53 -53
- data/spec/tags/types_explainer_spec.rb +203 -203
- data/spec/templates/class_spec.rb +45 -45
- data/spec/templates/constant_spec.rb +41 -41
- data/spec/templates/engine_spec.rb +131 -131
- data/spec/templates/examples/class001.html +308 -308
- data/spec/templates/examples/class001.txt +36 -36
- data/spec/templates/examples/class002.html +39 -39
- data/spec/templates/examples/constant001.txt +24 -24
- data/spec/templates/examples/constant002.txt +6 -6
- data/spec/templates/examples/constant003.txt +10 -10
- data/spec/templates/examples/method001.html +137 -137
- data/spec/templates/examples/method001.txt +35 -35
- data/spec/templates/examples/method002.html +91 -91
- data/spec/templates/examples/method002.txt +20 -20
- data/spec/templates/examples/method003.html +165 -165
- data/spec/templates/examples/method003.txt +45 -45
- data/spec/templates/examples/method004.html +48 -48
- data/spec/templates/examples/method004.txt +10 -10
- data/spec/templates/examples/method005.html +105 -105
- data/spec/templates/examples/method005.txt +33 -33
- data/spec/templates/examples/method006.html +107 -107
- data/spec/templates/examples/method006.txt +20 -20
- data/spec/templates/examples/module001.dot +33 -33
- data/spec/templates/examples/module001.html +833 -833
- data/spec/templates/examples/module001.txt +33 -33
- data/spec/templates/examples/module002.html +341 -341
- data/spec/templates/examples/module003.html +202 -202
- data/spec/templates/examples/module004.html +394 -394
- data/spec/templates/examples/module005.html +81 -81
- data/spec/templates/examples/tag001.txt +82 -82
- data/spec/templates/helpers/base_helper_spec.rb +171 -171
- data/spec/templates/helpers/html_helper_spec.rb +668 -653
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +65 -65
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +84 -84
- data/spec/templates/helpers/markup_helper_spec.rb +136 -136
- data/spec/templates/helpers/method_helper_spec.rb +107 -107
- data/spec/templates/helpers/module_helper_spec.rb +35 -35
- data/spec/templates/helpers/shared_signature_examples.rb +126 -126
- data/spec/templates/helpers/text_helper_spec.rb +65 -65
- data/spec/templates/method_spec.rb +118 -118
- data/spec/templates/module_spec.rb +203 -203
- data/spec/templates/onefile_spec.rb +66 -66
- data/spec/templates/section_spec.rb +144 -144
- data/spec/templates/spec_helper.rb +76 -76
- data/spec/templates/tag_spec.rb +52 -52
- data/spec/templates/template_spec.rb +410 -410
- data/spec/verifier_spec.rb +106 -106
- data/templates/default/class/dot/setup.rb +7 -7
- data/templates/default/class/dot/superklass.erb +2 -2
- data/templates/default/class/html/constructor_details.erb +8 -8
- data/templates/default/class/html/setup.rb +2 -2
- data/templates/default/class/html/subclasses.erb +4 -4
- data/templates/default/class/setup.rb +36 -36
- data/templates/default/class/text/setup.rb +12 -12
- data/templates/default/class/text/subclasses.erb +5 -5
- data/templates/default/constant/text/header.erb +11 -11
- data/templates/default/constant/text/setup.rb +4 -4
- data/templates/default/docstring/html/abstract.erb +4 -4
- data/templates/default/docstring/html/deprecated.erb +1 -1
- data/templates/default/docstring/html/index.erb +5 -5
- data/templates/default/docstring/html/note.erb +6 -6
- data/templates/default/docstring/html/private.erb +4 -4
- data/templates/default/docstring/html/text.erb +1 -1
- data/templates/default/docstring/html/todo.erb +6 -6
- data/templates/default/docstring/setup.rb +52 -52
- data/templates/default/docstring/text/abstract.erb +2 -2
- data/templates/default/docstring/text/deprecated.erb +2 -2
- data/templates/default/docstring/text/index.erb +2 -2
- data/templates/default/docstring/text/note.erb +3 -3
- data/templates/default/docstring/text/private.erb +2 -2
- data/templates/default/docstring/text/text.erb +1 -1
- data/templates/default/docstring/text/todo.erb +3 -3
- data/templates/default/fulldoc/html/css/full_list.css +58 -58
- data/templates/default/fulldoc/html/css/style.css +496 -496
- data/templates/default/fulldoc/html/frames.erb +17 -17
- data/templates/default/fulldoc/html/full_list.erb +37 -37
- data/templates/default/fulldoc/html/full_list_class.erb +2 -2
- data/templates/default/fulldoc/html/full_list_file.erb +7 -7
- data/templates/default/fulldoc/html/full_list_method.erb +10 -10
- data/templates/default/fulldoc/html/js/app.js +292 -292
- data/templates/default/fulldoc/html/js/full_list.js +216 -216
- data/templates/default/fulldoc/html/js/jquery.js +3 -3
- data/templates/default/fulldoc/html/setup.rb +241 -241
- data/templates/default/layout/dot/header.erb +5 -5
- data/templates/default/layout/dot/setup.rb +15 -15
- data/templates/default/layout/html/breadcrumb.erb +11 -11
- data/templates/default/layout/html/files.erb +11 -11
- data/templates/default/layout/html/footer.erb +5 -5
- data/templates/default/layout/html/headers.erb +15 -15
- data/templates/default/layout/html/index.erb +2 -2
- data/templates/default/layout/html/layout.erb +23 -23
- data/templates/default/layout/html/listing.erb +4 -4
- data/templates/default/layout/html/objects.erb +32 -32
- data/templates/default/layout/html/script_setup.erb +4 -4
- data/templates/default/layout/html/search.erb +12 -12
- data/templates/default/layout/html/setup.rb +89 -89
- data/templates/default/method/html/header.erb +16 -16
- data/templates/default/method/setup.rb +4 -4
- data/templates/default/method_details/html/header.erb +2 -2
- data/templates/default/method_details/html/method_signature.erb +24 -24
- data/templates/default/method_details/html/source.erb +9 -9
- data/templates/default/method_details/setup.rb +11 -11
- data/templates/default/method_details/text/header.erb +10 -10
- data/templates/default/method_details/text/method_signature.erb +12 -12
- data/templates/default/method_details/text/setup.rb +11 -11
- data/templates/default/module/dot/child.erb +1 -1
- data/templates/default/module/dot/dependencies.erb +2 -2
- data/templates/default/module/dot/header.erb +6 -6
- data/templates/default/module/dot/info.erb +13 -13
- data/templates/default/module/dot/setup.rb +15 -15
- data/templates/default/module/html/attribute_details.erb +10 -10
- data/templates/default/module/html/attribute_summary.erb +8 -8
- data/templates/default/module/html/box_info.erb +43 -43
- data/templates/default/module/html/children.erb +8 -8
- data/templates/default/module/html/constant_summary.erb +17 -17
- data/templates/default/module/html/defines.erb +2 -2
- data/templates/default/module/html/header.erb +5 -5
- data/templates/default/module/html/inherited_attributes.erb +14 -14
- data/templates/default/module/html/inherited_constants.erb +8 -8
- data/templates/default/module/html/inherited_methods.erb +18 -18
- data/templates/default/module/html/item_summary.erb +40 -40
- data/templates/default/module/html/method_details_list.erb +9 -9
- data/templates/default/module/html/method_summary.erb +13 -13
- data/templates/default/module/html/methodmissing.erb +12 -12
- data/templates/default/module/setup.rb +167 -167
- data/templates/default/module/text/children.erb +9 -9
- data/templates/default/module/text/class_meths_list.erb +7 -7
- data/templates/default/module/text/extends.erb +7 -7
- data/templates/default/module/text/header.erb +7 -7
- data/templates/default/module/text/includes.erb +7 -7
- data/templates/default/module/text/instance_meths_list.erb +7 -7
- data/templates/default/module/text/setup.rb +13 -13
- data/templates/default/onefile/html/files.erb +4 -4
- data/templates/default/onefile/html/headers.erb +6 -6
- data/templates/default/onefile/html/layout.erb +17 -17
- data/templates/default/onefile/html/readme.erb +2 -2
- data/templates/default/onefile/html/setup.rb +62 -62
- data/templates/default/root/dot/child.erb +2 -2
- data/templates/default/root/dot/setup.rb +6 -6
- data/templates/default/root/html/setup.rb +2 -2
- data/templates/default/tags/html/example.erb +10 -10
- data/templates/default/tags/html/index.erb +2 -2
- data/templates/default/tags/html/option.erb +24 -24
- data/templates/default/tags/html/overload.erb +13 -13
- data/templates/default/tags/html/see.erb +7 -7
- data/templates/default/tags/html/tag.erb +20 -20
- data/templates/default/tags/setup.rb +57 -57
- data/templates/default/tags/text/example.erb +12 -12
- data/templates/default/tags/text/index.erb +1 -1
- data/templates/default/tags/text/option.erb +20 -20
- data/templates/default/tags/text/overload.erb +19 -19
- data/templates/default/tags/text/see.erb +11 -11
- data/templates/default/tags/text/tag.erb +13 -13
- data/templates/guide/class/html/setup.rb +2 -2
- data/templates/guide/docstring/html/setup.rb +2 -2
- data/templates/guide/fulldoc/html/css/style.css +108 -108
- data/templates/guide/fulldoc/html/js/app.js +33 -33
- data/templates/guide/fulldoc/html/setup.rb +74 -74
- data/templates/guide/layout/html/layout.erb +81 -81
- data/templates/guide/layout/html/setup.rb +25 -25
- data/templates/guide/method/html/header.erb +17 -17
- data/templates/guide/method/html/setup.rb +22 -22
- data/templates/guide/module/html/header.erb +6 -6
- data/templates/guide/module/html/method_list.erb +4 -4
- data/templates/guide/module/html/setup.rb +27 -27
- data/templates/guide/onefile/html/files.erb +4 -4
- data/templates/guide/onefile/html/setup.rb +6 -6
- data/templates/guide/onefile/html/toc.erb +3 -3
- data/templates/guide/tags/html/setup.rb +9 -9
- data/yard.gemspec +43 -43
- metadata +4 -4
data/spec/cli/stats_spec.rb
CHANGED
@@ -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('— 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('— YARD-On-YARD')).to be >= 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end if ENV['CI'] || ENV['YY']
|
data/spec/cli/yardoc_spec.rb
CHANGED
@@ -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
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
it "
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
@yardoc.
|
216
|
-
|
217
|
-
@yardoc.
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
@yardoc.
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
expect(@yardoc
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
@yardoc.
|
254
|
-
end
|
255
|
-
|
256
|
-
it "
|
257
|
-
|
258
|
-
expect(
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
@yardoc.
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
@yardoc.
|
286
|
-
|
287
|
-
end
|
288
|
-
|
289
|
-
it "
|
290
|
-
expect(
|
291
|
-
@yardoc.run(*%w(--asset
|
292
|
-
expect(@yardoc.assets).to
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
expect(
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
expect(
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
class
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
end
|
379
|
-
|
380
|
-
it "allows --
|
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)
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
# @api
|
398
|
-
class
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
@yardoc.
|
404
|
-
|
405
|
-
|
406
|
-
end
|
407
|
-
|
408
|
-
it "
|
409
|
-
|
410
|
-
@
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
class Bar; end
|
436
|
-
class Baz; end
|
437
|
-
eof
|
438
|
-
@yardoc.run('--
|
439
|
-
expect(@yardoc.options.verifier.run(Registry.all).
|
440
|
-
sort_by(&:path)).to eq [P('Bar')]
|
441
|
-
end
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
expect(@yardoc.options.verifier.call(
|
497
|
-
end
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
@yardoc.
|
508
|
-
@yardoc.
|
509
|
-
@yardoc.
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
expect(
|
524
|
-
@yardoc.
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
expect(File).to receive(:read_binary).with("
|
531
|
-
@yardoc.
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
it "
|
543
|
-
|
544
|
-
@yardoc.
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
@yardoc.
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
@yardoc.
|
567
|
-
expect(@yardoc.options.verifier).to
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
expect(
|
578
|
-
expect(
|
579
|
-
@yardoc.parse_arguments(*%w(
|
580
|
-
expect(@yardoc.
|
581
|
-
expect(@yardoc.options.
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
expect(
|
589
|
-
|
590
|
-
expect(
|
591
|
-
expect(
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
expect(@yardoc.
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
expect(
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
expect(
|
616
|
-
@yardoc.
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
end
|
636
|
-
|
637
|
-
it "
|
638
|
-
expect(
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
expect(
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
it "
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
@yardoc.parse_arguments
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
expect(
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
expect(
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
@yardoc.parse_arguments('--tag', 'foo
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
end
|
705
|
-
|
706
|
-
it "
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
end
|
722
|
-
|
723
|
-
it "accepts --
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
@yardoc.
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
@yardoc.
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
it "
|
765
|
-
@yardoc.
|
766
|
-
@yardoc.
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
@yardoc.
|
772
|
-
|
773
|
-
end
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
@yardoc.
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
it "
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
@yardoc.run
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
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
|