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