deg-yard 0.8.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +39 -0
- data/.yardopts +25 -0
- data/.yardopts_guide +19 -0
- data/.yardopts_i18n +22 -0
- data/Gemfile +35 -0
- data/LEGAL +66 -0
- data/LICENSE +22 -0
- data/README.md +609 -0
- data/Rakefile +66 -0
- data/benchmarks/builtins_vs_eval.rb +23 -0
- data/benchmarks/concat_vs_join.rb +12 -0
- data/benchmarks/erb_vs_erubis.rb +53 -0
- data/benchmarks/format_args.rb +46 -0
- data/benchmarks/generation.rb +37 -0
- data/benchmarks/marshal_vs_dbm.rb +63 -0
- data/benchmarks/parsing.rb +46 -0
- data/benchmarks/pathname_vs_string.rb +50 -0
- data/benchmarks/rdoc_vs_yardoc.rb +10 -0
- data/benchmarks/registry_store_types.rb +48 -0
- data/benchmarks/ri_vs_yri.rb +18 -0
- data/benchmarks/ripper_parser.rb +12 -0
- data/benchmarks/splat_vs_flatten.rb +12 -0
- data/benchmarks/template_erb.rb +22 -0
- data/benchmarks/template_format.rb +6 -0
- data/benchmarks/template_profile.rb +17 -0
- data/benchmarks/yri_cache.rb +19 -0
- data/bin/yard +12 -0
- data/bin/yardoc +12 -0
- data/bin/yri +12 -0
- data/docs/CodeObjects.md +115 -0
- data/docs/GettingStarted.md +592 -0
- data/docs/Handlers.md +152 -0
- data/docs/Overview.md +61 -0
- data/docs/Parser.md +191 -0
- data/docs/Tags.md +282 -0
- data/docs/TagsArch.md +123 -0
- data/docs/Templates.md +496 -0
- data/docs/WhatsNew.md +1244 -0
- data/docs/images/code-objects-class-diagram.png +0 -0
- data/docs/images/handlers-class-diagram.png +0 -0
- data/docs/images/overview-class-diagram.png +0 -0
- data/docs/images/parser-class-diagram.png +0 -0
- data/docs/images/tags-class-diagram.png +0 -0
- data/docs/templates/default/fulldoc/html/full_list_tag.erb +7 -0
- data/docs/templates/default/fulldoc/html/setup.rb +6 -0
- data/docs/templates/default/layout/html/setup.rb +8 -0
- data/docs/templates/default/layout/html/tag_list.erb +11 -0
- data/docs/templates/default/yard_tags/html/list.erb +18 -0
- data/docs/templates/default/yard_tags/html/setup.rb +27 -0
- data/docs/templates/plugin.rb +65 -0
- data/lib/rubygems_plugin.rb +4 -0
- data/lib/yard/autoload.rb +290 -0
- data/lib/yard/cli/command.rb +84 -0
- data/lib/yard/cli/command_parser.rb +92 -0
- data/lib/yard/cli/config.rb +136 -0
- data/lib/yard/cli/diff.rb +270 -0
- data/lib/yard/cli/display.rb +68 -0
- data/lib/yard/cli/gems.rb +83 -0
- data/lib/yard/cli/graph.rb +126 -0
- data/lib/yard/cli/help.rb +18 -0
- data/lib/yard/cli/i18n.rb +69 -0
- data/lib/yard/cli/list.rb +22 -0
- data/lib/yard/cli/markup_types.rb +33 -0
- data/lib/yard/cli/server.rb +253 -0
- data/lib/yard/cli/stats.rb +213 -0
- data/lib/yard/cli/yardoc.rb +752 -0
- data/lib/yard/cli/yardopts_command.rb +109 -0
- data/lib/yard/cli/yri.rb +214 -0
- data/lib/yard/code_objects/base.rb +585 -0
- data/lib/yard/code_objects/class_object.rb +143 -0
- data/lib/yard/code_objects/class_variable_object.rb +8 -0
- data/lib/yard/code_objects/constant_object.rb +13 -0
- data/lib/yard/code_objects/extended_method_object.rb +23 -0
- data/lib/yard/code_objects/extra_file_object.rb +128 -0
- data/lib/yard/code_objects/macro_object.rb +172 -0
- data/lib/yard/code_objects/method_object.rb +191 -0
- data/lib/yard/code_objects/module_object.rb +18 -0
- data/lib/yard/code_objects/namespace_object.rb +200 -0
- data/lib/yard/code_objects/proxy.rb +258 -0
- data/lib/yard/code_objects/root_object.rb +17 -0
- data/lib/yard/config.rb +269 -0
- data/lib/yard/core_ext/array.rb +15 -0
- data/lib/yard/core_ext/file.rb +65 -0
- data/lib/yard/core_ext/hash.rb +15 -0
- data/lib/yard/core_ext/insertion.rb +60 -0
- data/lib/yard/core_ext/module.rb +19 -0
- data/lib/yard/core_ext/string.rb +67 -0
- data/lib/yard/core_ext/symbol_hash.rb +73 -0
- data/lib/yard/docstring.rb +362 -0
- data/lib/yard/docstring_parser.rb +321 -0
- data/lib/yard/globals.rb +18 -0
- data/lib/yard/handlers/base.rb +597 -0
- data/lib/yard/handlers/c/alias_handler.rb +15 -0
- data/lib/yard/handlers/c/attribute_handler.rb +13 -0
- data/lib/yard/handlers/c/base.rb +110 -0
- data/lib/yard/handlers/c/class_handler.rb +26 -0
- data/lib/yard/handlers/c/constant_handler.rb +12 -0
- data/lib/yard/handlers/c/handler_methods.rb +166 -0
- data/lib/yard/handlers/c/init_handler.rb +18 -0
- data/lib/yard/handlers/c/method_handler.rb +35 -0
- data/lib/yard/handlers/c/mixin_handler.rb +13 -0
- data/lib/yard/handlers/c/module_handler.rb +16 -0
- data/lib/yard/handlers/c/override_comment_handler.rb +30 -0
- data/lib/yard/handlers/c/path_handler.rb +10 -0
- data/lib/yard/handlers/c/struct_handler.rb +12 -0
- data/lib/yard/handlers/c/symbol_handler.rb +7 -0
- data/lib/yard/handlers/processor.rb +201 -0
- data/lib/yard/handlers/ruby/alias_handler.rb +41 -0
- data/lib/yard/handlers/ruby/attribute_handler.rb +82 -0
- data/lib/yard/handlers/ruby/base.rb +164 -0
- data/lib/yard/handlers/ruby/class_condition_handler.rb +86 -0
- data/lib/yard/handlers/ruby/class_handler.rb +121 -0
- data/lib/yard/handlers/ruby/class_variable_handler.rb +16 -0
- data/lib/yard/handlers/ruby/comment_handler.rb +9 -0
- data/lib/yard/handlers/ruby/constant_handler.rb +45 -0
- data/lib/yard/handlers/ruby/dsl_handler.rb +14 -0
- data/lib/yard/handlers/ruby/dsl_handler_methods.rb +77 -0
- data/lib/yard/handlers/ruby/exception_handler.rb +26 -0
- data/lib/yard/handlers/ruby/extend_handler.rb +21 -0
- data/lib/yard/handlers/ruby/legacy/alias_handler.rb +34 -0
- data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +60 -0
- data/lib/yard/handlers/ruby/legacy/base.rb +250 -0
- data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +83 -0
- data/lib/yard/handlers/ruby/legacy/class_handler.rb +111 -0
- data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +14 -0
- data/lib/yard/handlers/ruby/legacy/comment_handler.rb +9 -0
- data/lib/yard/handlers/ruby/legacy/constant_handler.rb +28 -0
- data/lib/yard/handlers/ruby/legacy/dsl_handler.rb +16 -0
- data/lib/yard/handlers/ruby/legacy/exception_handler.rb +12 -0
- data/lib/yard/handlers/ruby/legacy/extend_handler.rb +20 -0
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +85 -0
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +39 -0
- data/lib/yard/handlers/ruby/legacy/module_function_handler.rb +18 -0
- data/lib/yard/handlers/ruby/legacy/module_handler.rb +11 -0
- data/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +21 -0
- data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +16 -0
- data/lib/yard/handlers/ruby/legacy/yield_handler.rb +28 -0
- data/lib/yard/handlers/ruby/method_condition_handler.rb +8 -0
- data/lib/yard/handlers/ruby/method_handler.rb +92 -0
- data/lib/yard/handlers/ruby/mixin_handler.rb +36 -0
- data/lib/yard/handlers/ruby/module_function_handler.rb +26 -0
- data/lib/yard/handlers/ruby/module_handler.rb +11 -0
- data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +141 -0
- data/lib/yard/handlers/ruby/visibility_handler.rb +24 -0
- data/lib/yard/handlers/ruby/yield_handler.rb +30 -0
- data/lib/yard/i18n/locale.rb +74 -0
- data/lib/yard/i18n/message.rb +56 -0
- data/lib/yard/i18n/messages.rb +55 -0
- data/lib/yard/i18n/pot_generator.rb +280 -0
- data/lib/yard/i18n/text.rb +173 -0
- data/lib/yard/logging.rb +190 -0
- data/lib/yard/options.rb +216 -0
- data/lib/yard/parser/base.rb +56 -0
- data/lib/yard/parser/c/c_parser.rb +231 -0
- data/lib/yard/parser/c/comment_parser.rb +131 -0
- data/lib/yard/parser/c/statement.rb +63 -0
- data/lib/yard/parser/ruby/ast_node.rb +496 -0
- data/lib/yard/parser/ruby/legacy/ruby_lex.rb +1378 -0
- data/lib/yard/parser/ruby/legacy/ruby_parser.rb +31 -0
- data/lib/yard/parser/ruby/legacy/statement.rb +65 -0
- data/lib/yard/parser/ruby/legacy/statement_list.rb +384 -0
- data/lib/yard/parser/ruby/legacy/token_list.rb +71 -0
- data/lib/yard/parser/ruby/ruby_parser.rb +625 -0
- data/lib/yard/parser/source_parser.rb +517 -0
- data/lib/yard/rake/yardoc_task.rb +74 -0
- data/lib/yard/registry.rb +438 -0
- data/lib/yard/registry_store.rb +319 -0
- data/lib/yard/rubygems/backports/LICENSE.txt +57 -0
- data/lib/yard/rubygems/backports/MIT.txt +20 -0
- data/lib/yard/rubygems/backports/gem.rb +9 -0
- data/lib/yard/rubygems/backports/source_index.rb +370 -0
- data/lib/yard/rubygems/backports.rb +8 -0
- data/lib/yard/rubygems/doc_manager.rb +88 -0
- data/lib/yard/rubygems/specification.rb +41 -0
- data/lib/yard/serializers/base.rb +80 -0
- data/lib/yard/serializers/file_system_serializer.rb +90 -0
- data/lib/yard/serializers/process_serializer.rb +24 -0
- data/lib/yard/serializers/stdout_serializer.rb +32 -0
- data/lib/yard/serializers/yardoc_serializer.rb +124 -0
- data/lib/yard/server/adapter.rb +100 -0
- data/lib/yard/server/commands/base.rb +192 -0
- data/lib/yard/server/commands/display_file_command.rb +24 -0
- data/lib/yard/server/commands/display_object_command.rb +58 -0
- data/lib/yard/server/commands/frames_command.rb +15 -0
- data/lib/yard/server/commands/library_command.rb +148 -0
- data/lib/yard/server/commands/library_index_command.rb +24 -0
- data/lib/yard/server/commands/list_command.rb +24 -0
- data/lib/yard/server/commands/search_command.rb +78 -0
- data/lib/yard/server/commands/static_file_command.rb +57 -0
- data/lib/yard/server/doc_server_helper.rb +76 -0
- data/lib/yard/server/doc_server_serializer.rb +33 -0
- data/lib/yard/server/library_version.rb +227 -0
- data/lib/yard/server/rack_adapter.rb +88 -0
- data/lib/yard/server/router.rb +176 -0
- data/lib/yard/server/static_caching.rb +45 -0
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +78 -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 +12 -0
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +46 -0
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +8 -0
- data/lib/yard/server/templates/default/layout/html/setup.rb +7 -0
- data/lib/yard/server/templates/default/method_details/html/permalink.erb +4 -0
- data/lib/yard/server/templates/default/method_details/html/setup.rb +4 -0
- data/lib/yard/server/templates/doc_server/library_list/html/contents.erb +13 -0
- data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +26 -0
- data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +12 -0
- data/lib/yard/server/templates/doc_server/library_list/html/setup.rb +3 -0
- data/lib/yard/server/templates/doc_server/library_list/html/title.erb +2 -0
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +51 -0
- data/lib/yard/server/templates/doc_server/processing/html/setup.rb +3 -0
- data/lib/yard/server/templates/doc_server/search/html/search.erb +18 -0
- data/lib/yard/server/templates/doc_server/search/html/setup.rb +8 -0
- data/lib/yard/server/webrick_adapter.rb +43 -0
- data/lib/yard/server.rb +11 -0
- data/lib/yard/tags/default_factory.rb +176 -0
- data/lib/yard/tags/default_tag.rb +12 -0
- data/lib/yard/tags/directives.rb +599 -0
- data/lib/yard/tags/library.rb +630 -0
- data/lib/yard/tags/option_tag.rb +12 -0
- data/lib/yard/tags/overload_tag.rb +66 -0
- data/lib/yard/tags/ref_tag.rb +7 -0
- data/lib/yard/tags/ref_tag_list.rb +27 -0
- data/lib/yard/tags/tag.rb +57 -0
- data/lib/yard/tags/tag_format_error.rb +6 -0
- data/lib/yard/templates/engine.rb +185 -0
- data/lib/yard/templates/erb_cache.rb +22 -0
- data/lib/yard/templates/helpers/base_helper.rb +212 -0
- data/lib/yard/templates/helpers/filter_helper.rb +26 -0
- data/lib/yard/templates/helpers/html_helper.rb +599 -0
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +59 -0
- data/lib/yard/templates/helpers/markup/rdoc_markdown.rb +22 -0
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +106 -0
- data/lib/yard/templates/helpers/markup_helper.rb +169 -0
- data/lib/yard/templates/helpers/method_helper.rb +74 -0
- data/lib/yard/templates/helpers/module_helper.rb +19 -0
- data/lib/yard/templates/helpers/text_helper.rb +95 -0
- data/lib/yard/templates/helpers/uml_helper.rb +46 -0
- data/lib/yard/templates/section.rb +106 -0
- data/lib/yard/templates/template.rb +407 -0
- data/lib/yard/templates/template_options.rb +88 -0
- data/lib/yard/verifier.rb +148 -0
- data/lib/yard/version.rb +3 -0
- data/lib/yard.rb +71 -0
- data/po/ja.po +31118 -0
- data/spec/cli/command_parser_spec.rb +43 -0
- data/spec/cli/command_spec.rb +36 -0
- data/spec/cli/config_spec.rb +92 -0
- data/spec/cli/diff_spec.rb +260 -0
- data/spec/cli/display_spec.rb +30 -0
- data/spec/cli/gems_spec.rb +81 -0
- data/spec/cli/graph_spec.rb +17 -0
- data/spec/cli/help_spec.rb +22 -0
- data/spec/cli/i18n_spec.rb +111 -0
- data/spec/cli/list_spec.rb +8 -0
- data/spec/cli/markup_types_spec.rb +22 -0
- data/spec/cli/server_spec.rb +327 -0
- data/spec/cli/stats_spec.rb +90 -0
- data/spec/cli/yardoc_spec.rb +804 -0
- data/spec/cli/yri_spec.rb +99 -0
- data/spec/code_objects/base_spec.rb +438 -0
- data/spec/code_objects/class_object_spec.rb +225 -0
- data/spec/code_objects/code_object_list_spec.rb +33 -0
- data/spec/code_objects/constants_spec.rb +82 -0
- data/spec/code_objects/extra_file_object_spec.rb +147 -0
- data/spec/code_objects/macro_object_spec.rb +148 -0
- data/spec/code_objects/method_object_spec.rb +175 -0
- data/spec/code_objects/module_object_spec.rb +141 -0
- data/spec/code_objects/namespace_object_spec.rb +170 -0
- data/spec/code_objects/proxy_spec.rb +140 -0
- data/spec/code_objects/spec_helper.rb +3 -0
- data/spec/config_spec.rb +176 -0
- data/spec/core_ext/array_spec.rb +14 -0
- data/spec/core_ext/file_spec.rb +68 -0
- data/spec/core_ext/hash_spec.rb +14 -0
- data/spec/core_ext/insertion_spec.rb +37 -0
- data/spec/core_ext/module_spec.rb +15 -0
- data/spec/core_ext/string_spec.rb +42 -0
- data/spec/core_ext/symbol_hash_spec.rb +86 -0
- data/spec/docstring_parser_spec.rb +228 -0
- data/spec/docstring_spec.rb +335 -0
- data/spec/handlers/alias_handler_spec.rb +80 -0
- data/spec/handlers/attribute_handler_spec.rb +94 -0
- data/spec/handlers/base_spec.rb +206 -0
- data/spec/handlers/c/alias_handler_spec.rb +33 -0
- data/spec/handlers/c/attribute_handler_spec.rb +40 -0
- data/spec/handlers/c/class_handler_spec.rb +63 -0
- data/spec/handlers/c/constant_handler_spec.rb +68 -0
- data/spec/handlers/c/init_handler_spec.rb +47 -0
- data/spec/handlers/c/method_handler_spec.rb +229 -0
- data/spec/handlers/c/mixin_handler_spec.rb +27 -0
- data/spec/handlers/c/module_handler_spec.rb +38 -0
- data/spec/handlers/c/override_comment_handler_spec.rb +46 -0
- data/spec/handlers/c/path_handler_spec.rb +35 -0
- data/spec/handlers/c/spec_helper.rb +13 -0
- data/spec/handlers/c/struct_handler_spec.rb +15 -0
- data/spec/handlers/class_condition_handler_spec.rb +67 -0
- data/spec/handlers/class_handler_spec.rb +246 -0
- data/spec/handlers/class_variable_handler_spec.rb +11 -0
- data/spec/handlers/constant_handler_spec.rb +64 -0
- data/spec/handlers/dsl_handler_spec.rb +197 -0
- data/spec/handlers/examples/alias_handler_001.rb.txt +44 -0
- data/spec/handlers/examples/attribute_handler_001.rb.txt +32 -0
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +69 -0
- data/spec/handlers/examples/class_handler_001.rb.txt +120 -0
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +10 -0
- data/spec/handlers/examples/constant_handler_001.rb.txt +25 -0
- data/spec/handlers/examples/dsl_handler_001.rb.txt +125 -0
- data/spec/handlers/examples/exception_handler_001.rb.txt +59 -0
- data/spec/handlers/examples/extend_handler_001.rb.txt +16 -0
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +10 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +126 -0
- data/spec/handlers/examples/mixin_handler_001.rb.txt +37 -0
- data/spec/handlers/examples/module_handler_001.rb.txt +29 -0
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +8 -0
- data/spec/handlers/examples/process_handler_001.rb.txt +11 -0
- data/spec/handlers/examples/visibility_handler_001.rb.txt +32 -0
- data/spec/handlers/examples/yield_handler_001.rb.txt +54 -0
- data/spec/handlers/exception_handler_spec.rb +48 -0
- data/spec/handlers/extend_handler_spec.rb +23 -0
- data/spec/handlers/legacy_base_spec.rb +128 -0
- data/spec/handlers/method_condition_handler_spec.rb +14 -0
- data/spec/handlers/method_handler_spec.rb +184 -0
- data/spec/handlers/mixin_handler_spec.rb +55 -0
- data/spec/handlers/module_function_handler_spec.rb +105 -0
- data/spec/handlers/module_handler_spec.rb +34 -0
- data/spec/handlers/private_constant_handler_spec.rb +24 -0
- data/spec/handlers/processor_spec.rb +34 -0
- data/spec/handlers/ruby/base_spec.rb +94 -0
- data/spec/handlers/ruby/legacy/base_spec.rb +82 -0
- data/spec/handlers/spec_helper.rb +33 -0
- data/spec/handlers/visibility_handler_spec.rb +39 -0
- data/spec/handlers/yield_handler_spec.rb +51 -0
- data/spec/i18n/locale_spec.rb +68 -0
- data/spec/i18n/message_spec.rb +52 -0
- data/spec/i18n/messages_spec.rb +67 -0
- data/spec/i18n/pot_generator_spec.rb +262 -0
- data/spec/i18n/text_spec.rb +180 -0
- data/spec/logging_spec.rb +35 -0
- data/spec/options_spec.rb +171 -0
- data/spec/parser/base_spec.rb +24 -0
- data/spec/parser/c_parser_spec.rb +171 -0
- data/spec/parser/examples/array.c.txt +3887 -0
- data/spec/parser/examples/example1.rb.txt +8 -0
- data/spec/parser/examples/extrafile.c.txt +8 -0
- data/spec/parser/examples/multifile.c.txt +22 -0
- data/spec/parser/examples/override.c.txt +424 -0
- data/spec/parser/examples/parse_in_order_001.rb.txt +2 -0
- data/spec/parser/examples/parse_in_order_002.rb.txt +2 -0
- data/spec/parser/examples/tag_handler_001.rb.txt +8 -0
- data/spec/parser/ruby/ast_node_spec.rb +33 -0
- data/spec/parser/ruby/legacy/statement_list_spec.rb +299 -0
- data/spec/parser/ruby/legacy/token_list_spec.rb +77 -0
- data/spec/parser/ruby/ruby_parser_spec.rb +334 -0
- data/spec/parser/source_parser_spec.rb +717 -0
- data/spec/parser/tag_parsing_spec.rb +18 -0
- data/spec/rake/yardoc_task_spec.rb +101 -0
- data/spec/registry_spec.rb +393 -0
- data/spec/registry_store_spec.rb +315 -0
- data/spec/rubygems/doc_manager_spec.rb +112 -0
- data/spec/serializers/data/serialized_yardoc/checksums +1 -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/Foo.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/root.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/proxy_types +2 -0
- data/spec/serializers/file_system_serializer_spec.rb +124 -0
- data/spec/serializers/spec_helper.rb +2 -0
- data/spec/serializers/yardoc_serializer_spec.rb +46 -0
- data/spec/server/adapter_spec.rb +38 -0
- data/spec/server/commands/base_spec.rb +87 -0
- data/spec/server/commands/library_command_spec.rb +39 -0
- data/spec/server/commands/static_file_command_spec.rb +84 -0
- data/spec/server/doc_server_helper_spec.rb +53 -0
- data/spec/server/doc_server_serializer_spec.rb +45 -0
- data/spec/server/rack_adapter_spec.rb +20 -0
- data/spec/server/router_spec.rb +122 -0
- data/spec/server/spec_helper.rb +17 -0
- data/spec/server/static_caching_spec.rb +39 -0
- data/spec/server/webrick_servlet_spec.rb +20 -0
- data/spec/server_spec.rb +10 -0
- data/spec/spec_helper.rb +128 -0
- data/spec/tags/default_factory_spec.rb +152 -0
- data/spec/tags/default_tag_spec.rb +11 -0
- data/spec/tags/directives_spec.rb +453 -0
- data/spec/tags/library_spec.rb +34 -0
- data/spec/tags/overload_tag_spec.rb +53 -0
- data/spec/tags/ref_tag_list_spec.rb +53 -0
- data/spec/templates/class_spec.rb +44 -0
- data/spec/templates/constant_spec.rb +40 -0
- data/spec/templates/engine_spec.rb +121 -0
- data/spec/templates/examples/class001.html +280 -0
- data/spec/templates/examples/class001.txt +36 -0
- data/spec/templates/examples/class002.html +35 -0
- data/spec/templates/examples/constant001.txt +25 -0
- data/spec/templates/examples/constant002.txt +7 -0
- data/spec/templates/examples/constant003.txt +11 -0
- data/spec/templates/examples/method001.html +130 -0
- data/spec/templates/examples/method001.txt +35 -0
- data/spec/templates/examples/method002.html +86 -0
- data/spec/templates/examples/method002.txt +20 -0
- data/spec/templates/examples/method003.html +159 -0
- data/spec/templates/examples/method003.txt +45 -0
- data/spec/templates/examples/method004.html +44 -0
- data/spec/templates/examples/method004.txt +10 -0
- data/spec/templates/examples/method005.html +99 -0
- data/spec/templates/examples/method005.txt +33 -0
- data/spec/templates/examples/module001.dot +33 -0
- data/spec/templates/examples/module001.html +825 -0
- data/spec/templates/examples/module001.txt +33 -0
- data/spec/templates/examples/module002.html +318 -0
- data/spec/templates/examples/module003.html +185 -0
- data/spec/templates/examples/module004.html +387 -0
- data/spec/templates/examples/tag001.txt +82 -0
- data/spec/templates/helpers/base_helper_spec.rb +175 -0
- data/spec/templates/helpers/html_helper_spec.rb +612 -0
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +48 -0
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +93 -0
- data/spec/templates/helpers/markup_helper_spec.rb +135 -0
- data/spec/templates/helpers/method_helper_spec.rb +82 -0
- data/spec/templates/helpers/shared_signature_examples.rb +123 -0
- data/spec/templates/helpers/text_helper_spec.rb +44 -0
- data/spec/templates/method_spec.rb +102 -0
- data/spec/templates/module_spec.rb +181 -0
- data/spec/templates/onefile_spec.rb +64 -0
- data/spec/templates/section_spec.rb +146 -0
- data/spec/templates/spec_helper.rb +73 -0
- data/spec/templates/tag_spec.rb +51 -0
- data/spec/templates/template_spec.rb +409 -0
- data/spec/verifier_spec.rb +106 -0
- data/templates/default/class/dot/setup.rb +6 -0
- data/templates/default/class/dot/superklass.erb +3 -0
- data/templates/default/class/html/constructor_details.erb +8 -0
- data/templates/default/class/html/setup.rb +1 -0
- data/templates/default/class/html/subclasses.erb +4 -0
- data/templates/default/class/setup.rb +36 -0
- data/templates/default/class/text/setup.rb +11 -0
- data/templates/default/class/text/subclasses.erb +5 -0
- data/templates/default/constant/text/header.erb +11 -0
- data/templates/default/constant/text/setup.rb +3 -0
- data/templates/default/docstring/html/abstract.erb +4 -0
- data/templates/default/docstring/html/deprecated.erb +1 -0
- data/templates/default/docstring/html/index.erb +5 -0
- data/templates/default/docstring/html/note.erb +6 -0
- data/templates/default/docstring/html/private.erb +4 -0
- data/templates/default/docstring/html/returns_void.erb +1 -0
- data/templates/default/docstring/html/text.erb +1 -0
- data/templates/default/docstring/html/todo.erb +6 -0
- data/templates/default/docstring/setup.rb +51 -0
- data/templates/default/docstring/text/abstract.erb +2 -0
- data/templates/default/docstring/text/deprecated.erb +2 -0
- data/templates/default/docstring/text/index.erb +2 -0
- data/templates/default/docstring/text/note.erb +4 -0
- data/templates/default/docstring/text/private.erb +2 -0
- data/templates/default/docstring/text/returns_void.erb +1 -0
- data/templates/default/docstring/text/text.erb +1 -0
- data/templates/default/docstring/text/todo.erb +4 -0
- data/templates/default/fulldoc/html/css/common.css +1 -0
- data/templates/default/fulldoc/html/css/full_list.css +57 -0
- data/templates/default/fulldoc/html/css/style.css +338 -0
- data/templates/default/fulldoc/html/frames.erb +28 -0
- data/templates/default/fulldoc/html/full_list.erb +40 -0
- data/templates/default/fulldoc/html/full_list_class.erb +2 -0
- data/templates/default/fulldoc/html/full_list_file.erb +5 -0
- data/templates/default/fulldoc/html/full_list_method.erb +8 -0
- data/templates/default/fulldoc/html/js/app.js +214 -0
- data/templates/default/fulldoc/html/js/full_list.js +178 -0
- data/templates/default/fulldoc/html/js/jquery.js +4 -0
- data/templates/default/fulldoc/html/setup.rb +199 -0
- data/templates/default/layout/dot/header.erb +6 -0
- data/templates/default/layout/dot/setup.rb +14 -0
- data/templates/default/layout/html/breadcrumb.erb +13 -0
- data/templates/default/layout/html/files.erb +11 -0
- data/templates/default/layout/html/footer.erb +5 -0
- data/templates/default/layout/html/headers.erb +14 -0
- data/templates/default/layout/html/index.erb +2 -0
- data/templates/default/layout/html/layout.erb +20 -0
- data/templates/default/layout/html/listing.erb +4 -0
- data/templates/default/layout/html/objects.erb +32 -0
- data/templates/default/layout/html/script_setup.erb +5 -0
- data/templates/default/layout/html/search.erb +8 -0
- data/templates/default/layout/html/setup.rb +71 -0
- data/templates/default/method/html/header.erb +16 -0
- data/templates/default/method/setup.rb +3 -0
- data/templates/default/method/text/header.erb +1 -0
- data/templates/default/method_details/html/header.erb +3 -0
- data/templates/default/method_details/html/method_signature.erb +25 -0
- data/templates/default/method_details/html/source.erb +10 -0
- data/templates/default/method_details/setup.rb +10 -0
- data/templates/default/method_details/text/header.erb +10 -0
- data/templates/default/method_details/text/method_signature.erb +12 -0
- data/templates/default/method_details/text/setup.rb +10 -0
- data/templates/default/module/dot/child.erb +1 -0
- data/templates/default/module/dot/dependencies.erb +3 -0
- data/templates/default/module/dot/header.erb +6 -0
- data/templates/default/module/dot/info.erb +14 -0
- data/templates/default/module/dot/setup.rb +14 -0
- data/templates/default/module/html/attribute_details.erb +10 -0
- data/templates/default/module/html/attribute_summary.erb +8 -0
- data/templates/default/module/html/box_info.erb +37 -0
- data/templates/default/module/html/children.erb +8 -0
- data/templates/default/module/html/constant_summary.erb +13 -0
- data/templates/default/module/html/defines.erb +3 -0
- data/templates/default/module/html/header.erb +5 -0
- data/templates/default/module/html/inherited_attributes.erb +14 -0
- data/templates/default/module/html/inherited_constants.erb +8 -0
- data/templates/default/module/html/inherited_methods.erb +19 -0
- data/templates/default/module/html/item_summary.erb +40 -0
- data/templates/default/module/html/method_details_list.erb +9 -0
- data/templates/default/module/html/method_summary.erb +14 -0
- data/templates/default/module/html/methodmissing.erb +12 -0
- data/templates/default/module/html/pre_docstring.erb +1 -0
- data/templates/default/module/setup.rb +164 -0
- data/templates/default/module/text/children.erb +10 -0
- data/templates/default/module/text/class_meths_list.erb +8 -0
- data/templates/default/module/text/extends.erb +8 -0
- data/templates/default/module/text/header.erb +7 -0
- data/templates/default/module/text/includes.erb +8 -0
- data/templates/default/module/text/instance_meths_list.erb +8 -0
- data/templates/default/module/text/setup.rb +12 -0
- data/templates/default/onefile/html/files.erb +5 -0
- data/templates/default/onefile/html/headers.erb +6 -0
- data/templates/default/onefile/html/layout.erb +17 -0
- data/templates/default/onefile/html/readme.erb +3 -0
- data/templates/default/onefile/html/setup.rb +61 -0
- data/templates/default/root/dot/child.erb +3 -0
- data/templates/default/root/dot/setup.rb +5 -0
- data/templates/default/root/html/setup.rb +1 -0
- data/templates/default/tags/html/example.erb +11 -0
- data/templates/default/tags/html/index.erb +3 -0
- data/templates/default/tags/html/option.erb +24 -0
- data/templates/default/tags/html/overload.erb +14 -0
- data/templates/default/tags/html/see.erb +8 -0
- data/templates/default/tags/html/tag.erb +20 -0
- data/templates/default/tags/setup.rb +55 -0
- data/templates/default/tags/text/example.erb +12 -0
- data/templates/default/tags/text/index.erb +1 -0
- data/templates/default/tags/text/option.erb +20 -0
- data/templates/default/tags/text/overload.erb +19 -0
- data/templates/default/tags/text/see.erb +11 -0
- data/templates/default/tags/text/tag.erb +13 -0
- 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 +108 -0
- data/templates/guide/fulldoc/html/js/app.js +33 -0
- data/templates/guide/fulldoc/html/setup.rb +73 -0
- data/templates/guide/layout/html/layout.erb +81 -0
- data/templates/guide/layout/html/setup.rb +28 -0
- data/templates/guide/method/html/header.erb +18 -0
- data/templates/guide/method/html/setup.rb +21 -0
- data/templates/guide/module/html/header.erb +7 -0
- data/templates/guide/module/html/method_list.erb +5 -0
- data/templates/guide/module/html/setup.rb +26 -0
- data/templates/guide/onefile/html/files.erb +4 -0
- data/templates/guide/onefile/html/setup.rb +5 -0
- data/templates/guide/onefile/html/toc.erb +3 -0
- data/templates/guide/tags/html/setup.rb +8 -0
- metadata +689 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
module YARD
|
|
2
|
+
# A documentation string, or "docstring" for short, encapsulates the
|
|
3
|
+
# comments and metadata, or "tags", of an object. Meta-data is expressed
|
|
4
|
+
# in the form +@tag VALUE+, where VALUE can span over multiple lines as
|
|
5
|
+
# long as they are indented. The following +@example+ tag shows how tags
|
|
6
|
+
# can be indented:
|
|
7
|
+
#
|
|
8
|
+
# # @example My example
|
|
9
|
+
# # a = "hello world"
|
|
10
|
+
# # a.reverse
|
|
11
|
+
# # @version 1.0
|
|
12
|
+
#
|
|
13
|
+
# Tags can be nested in a documentation string, though the {Tags::Tag}
|
|
14
|
+
# itself is responsible for parsing the inner tags.
|
|
15
|
+
class Docstring < String
|
|
16
|
+
class << self
|
|
17
|
+
# @note Plugin developers should make sure to reset this value
|
|
18
|
+
# after parsing finishes. This can be done via the
|
|
19
|
+
# {Parser::SourceParser.after_parse_list} callback. This will
|
|
20
|
+
# ensure that YARD can properly parse multiple projects in
|
|
21
|
+
# the same process.
|
|
22
|
+
# @return [Class<DocstringParser>] the parser class used to parse
|
|
23
|
+
# text and optional meta-data from docstrings. Defaults to
|
|
24
|
+
# {DocstringParser}.
|
|
25
|
+
# @see DocstringParser
|
|
26
|
+
# @see Parser::SourceParser.after_parse_list
|
|
27
|
+
attr_accessor :default_parser
|
|
28
|
+
|
|
29
|
+
# Creates a parser object using the current {default_parser}.
|
|
30
|
+
# Equivalent to:
|
|
31
|
+
# Docstring.default_parser.new(*args)
|
|
32
|
+
# @param args arguments are passed to the {DocstringParser}
|
|
33
|
+
# class. See {DocstringParser#initialize} for details on
|
|
34
|
+
# arguments.
|
|
35
|
+
# @return [DocstringParser] the parser object used to parse a
|
|
36
|
+
# docstring.
|
|
37
|
+
def parser(*args) default_parser.new(*args) end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
self.default_parser = DocstringParser
|
|
41
|
+
|
|
42
|
+
# @return [Array<Tags::RefTag>] the list of reference tags
|
|
43
|
+
attr_reader :ref_tags
|
|
44
|
+
|
|
45
|
+
# @return [CodeObjects::Base] the object that owns the docstring.
|
|
46
|
+
attr_accessor :object
|
|
47
|
+
|
|
48
|
+
# @return [Range] line range in the {#object}'s file where the docstring was parsed from
|
|
49
|
+
attr_accessor :line_range
|
|
50
|
+
|
|
51
|
+
# @return [String] the raw documentation (including raw tag text)
|
|
52
|
+
attr_reader :all
|
|
53
|
+
|
|
54
|
+
# @return [Boolean] whether the docstring was started with "##"
|
|
55
|
+
attr_reader :hash_flag
|
|
56
|
+
def hash_flag=(v) @hash_flag = v == nil ? false : v end
|
|
57
|
+
|
|
58
|
+
# Matches a tag at the start of a comment line
|
|
59
|
+
# @deprecated Use {DocstringParser::META_MATCH}
|
|
60
|
+
META_MATCH = DocstringParser::META_MATCH
|
|
61
|
+
|
|
62
|
+
# @group Creating a Docstring Object
|
|
63
|
+
|
|
64
|
+
# Creates a new docstring without performing any parsing through
|
|
65
|
+
# a {DocstringParser}. This method is called by +DocstringParser+
|
|
66
|
+
# when creating the new docstring object.
|
|
67
|
+
#
|
|
68
|
+
# @param [String] text the textual portion of the docstring
|
|
69
|
+
# @param [Array<Tag>] tags the list of tag objects in the docstring
|
|
70
|
+
# @param [CodeObjects::Base, nil] object the object associated with the
|
|
71
|
+
# docstring. May be nil.
|
|
72
|
+
# @param [String] raw_data the complete docstring, including all
|
|
73
|
+
# original formatting and any unparsed tags/directives.
|
|
74
|
+
# @param [CodeObjects::Base, nil] ref_object a reference object used for
|
|
75
|
+
# the base set of documentation / tag information.
|
|
76
|
+
def self.new!(text, tags = [], object = nil, raw_data = nil, ref_object = nil)
|
|
77
|
+
docstring = allocate
|
|
78
|
+
docstring.replace(text, false)
|
|
79
|
+
docstring.object = object
|
|
80
|
+
docstring.add_tag(*tags)
|
|
81
|
+
docstring.instance_variable_set("@unresolved_reference", ref_object)
|
|
82
|
+
docstring.instance_variable_set("@all", raw_data) if raw_data
|
|
83
|
+
docstring
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Creates a new docstring with the raw contents attached to an optional
|
|
87
|
+
# object. Parsing will be done by the {DocstringParser} class.
|
|
88
|
+
#
|
|
89
|
+
# @note To properly parse directives with proper parser context within
|
|
90
|
+
# handlers, you should not use this method to create a Docstring.
|
|
91
|
+
# Instead, use the {parser}, which takes a handler object that
|
|
92
|
+
# can pass parser state onto directives. If a Docstring is created
|
|
93
|
+
# with this method, directives do not have access to any parser
|
|
94
|
+
# state, and may not function as expected.
|
|
95
|
+
# @example
|
|
96
|
+
# Docstring.new("hello world\n@return Object return", someobj)
|
|
97
|
+
#
|
|
98
|
+
# @param [String] content the raw comments to be parsed into a docstring
|
|
99
|
+
# and associated meta-data.
|
|
100
|
+
# @param [CodeObjects::Base] object an object to associate the docstring
|
|
101
|
+
# with.
|
|
102
|
+
def initialize(content = '', object = nil)
|
|
103
|
+
@object = object
|
|
104
|
+
@summary = nil
|
|
105
|
+
@hash_flag = false
|
|
106
|
+
|
|
107
|
+
self.all = content
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Adds another {Docstring}, copying over tags.
|
|
111
|
+
#
|
|
112
|
+
# @param [Docstring, String] other the other docstring (or string) to
|
|
113
|
+
# add.
|
|
114
|
+
# @return [Docstring] a new docstring with both docstrings combines
|
|
115
|
+
def +(other)
|
|
116
|
+
case other
|
|
117
|
+
when Docstring
|
|
118
|
+
Docstring.new([all, other.all].join("\n"), object)
|
|
119
|
+
else
|
|
120
|
+
super
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def to_s
|
|
125
|
+
resolve_reference
|
|
126
|
+
super
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Replaces the docstring with new raw content. Called by {#all=}.
|
|
130
|
+
# @param [String] content the raw comments to be parsed
|
|
131
|
+
def replace(content, parse = true)
|
|
132
|
+
content = content.join("\n") if content.is_a?(Array)
|
|
133
|
+
@tags, @ref_tags = [], []
|
|
134
|
+
if parse
|
|
135
|
+
super(parse_comments(content))
|
|
136
|
+
else
|
|
137
|
+
@all = content
|
|
138
|
+
@unresolved_reference = nil
|
|
139
|
+
super(content)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
alias all= replace
|
|
143
|
+
|
|
144
|
+
# Deep-copies a docstring
|
|
145
|
+
#
|
|
146
|
+
# @note This method creates a new docstring with new tag lists, but does
|
|
147
|
+
# not create new individual tags. Modifying the tag objects will still
|
|
148
|
+
# affect the original tags.
|
|
149
|
+
# @return [Docstring] a new copied docstring
|
|
150
|
+
# @since 0.7.0
|
|
151
|
+
def dup
|
|
152
|
+
resolve_reference
|
|
153
|
+
obj = super
|
|
154
|
+
%w(all summary tags ref_tags).each do |name|
|
|
155
|
+
val = instance_variable_get("@#{name}")
|
|
156
|
+
obj.instance_variable_set("@#{name}", val ? val.dup : nil)
|
|
157
|
+
end
|
|
158
|
+
obj
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# @endgroup
|
|
162
|
+
|
|
163
|
+
# @return [Fixnum] the first line of the {#line_range}
|
|
164
|
+
# @return [nil] if there is no associated {#line_range}
|
|
165
|
+
def line
|
|
166
|
+
line_range ? line_range.first : nil
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Gets the first line of a docstring to the period or the first paragraph.
|
|
170
|
+
# @return [String] The first line or paragraph of the docstring; always ends with a period.
|
|
171
|
+
def summary
|
|
172
|
+
resolve_reference
|
|
173
|
+
return @summary if @summary
|
|
174
|
+
stripped = self.gsub(/<.+?>/m, '').gsub(/[\r\n](?![\r\n])/, ' ').strip
|
|
175
|
+
open_parens = ['{', '(', '[']
|
|
176
|
+
close_parens = ['}', ')', ']']
|
|
177
|
+
num_parens = 0
|
|
178
|
+
idx = length.times do |index|
|
|
179
|
+
case stripped[index, 1]
|
|
180
|
+
when ".", "\r", "\n"
|
|
181
|
+
next_char = stripped[index + 1, 1].to_s
|
|
182
|
+
if num_parens == 0 && next_char =~ /^\s*$/
|
|
183
|
+
break index - 1
|
|
184
|
+
end
|
|
185
|
+
when "{", "(", "["
|
|
186
|
+
num_parens += 1
|
|
187
|
+
when "}", ")", "]"
|
|
188
|
+
num_parens -= 1
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
@summary = stripped[0..idx]
|
|
192
|
+
if !@summary.empty? && @summary !~ /\A\s*\{include:.+\}\s*\Z/
|
|
193
|
+
@summary += '.'
|
|
194
|
+
end
|
|
195
|
+
@summary
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Reformats and returns a raw representation of the tag data using the
|
|
199
|
+
# current tag and docstring data, not the original text.
|
|
200
|
+
#
|
|
201
|
+
# @return [String] the updated raw formatted docstring data
|
|
202
|
+
# @since 0.7.0
|
|
203
|
+
# @todo Add Tags::Tag#to_raw and refactor
|
|
204
|
+
def to_raw
|
|
205
|
+
tag_data = tags.sort_by {|t| t.tag_name }.map do |tag|
|
|
206
|
+
case tag
|
|
207
|
+
when Tags::OverloadTag
|
|
208
|
+
tag_text = "@#{tag.tag_name} #{tag.signature}\n"
|
|
209
|
+
unless tag.docstring.blank?
|
|
210
|
+
tag_text += "\n" + tag.docstring.all.gsub(/\r?\n/, "\n ")
|
|
211
|
+
end
|
|
212
|
+
when Tags::OptionTag
|
|
213
|
+
tag_text = "@#{tag.tag_name} #{tag.name}"
|
|
214
|
+
tag_text += ' [' + tag.pair.types.join(', ') + ']' if tag.pair.types
|
|
215
|
+
tag_text += ' ' + tag.pair.name.to_s if tag.pair.name
|
|
216
|
+
tag_text += "\n " if tag.name && tag.text
|
|
217
|
+
tag_text += ' (' + tag.pair.defaults.join(', ') + ')' if tag.pair.defaults
|
|
218
|
+
tag_text += " " + tag.pair.text.strip.gsub(/\n/, "\n ") if tag.pair.text
|
|
219
|
+
else
|
|
220
|
+
tag_text = '@' + tag.tag_name
|
|
221
|
+
tag_text += ' [' + tag.types.join(', ') + ']' if tag.types
|
|
222
|
+
tag_text += ' ' + tag.name.to_s if tag.name
|
|
223
|
+
tag_text += "\n " if tag.name && tag.text
|
|
224
|
+
tag_text += ' ' + tag.text.strip.gsub(/\n/, "\n ") if tag.text
|
|
225
|
+
end
|
|
226
|
+
tag_text
|
|
227
|
+
end
|
|
228
|
+
[strip, tag_data.join("\n")].reject {|l| l.empty? }.compact.join("\n")
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
# @group Creating and Accessing Meta-data
|
|
232
|
+
|
|
233
|
+
# Adds a tag or reftag object to the tag list. If you want to parse
|
|
234
|
+
# tag data based on the {Tags::DefaultFactory} tag factory, use
|
|
235
|
+
# {DocstringParser} instead.
|
|
236
|
+
#
|
|
237
|
+
# @param [Tags::Tag, Tags::RefTag] tags list of tag objects to add
|
|
238
|
+
# @return [void]
|
|
239
|
+
def add_tag(*tags)
|
|
240
|
+
tags.each_with_index do |tag, i|
|
|
241
|
+
case tag
|
|
242
|
+
when Tags::Tag
|
|
243
|
+
tag.object = object
|
|
244
|
+
@tags << tag
|
|
245
|
+
when Tags::RefTag, Tags::RefTagList
|
|
246
|
+
@ref_tags << tag
|
|
247
|
+
else
|
|
248
|
+
raise ArgumentError, "expected Tag or RefTag, got #{tag.class} (at index #{i})"
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Convenience method to return the first tag
|
|
254
|
+
# object in the list of tag objects of that name
|
|
255
|
+
#
|
|
256
|
+
# @example
|
|
257
|
+
# doc = Docstring.new("@return zero when nil")
|
|
258
|
+
# doc.tag(:return).text # => "zero when nil"
|
|
259
|
+
#
|
|
260
|
+
# @param [#to_s] name the tag name to return data for
|
|
261
|
+
# @return [Tags::Tag] the first tag in the list of {#tags}
|
|
262
|
+
def tag(name)
|
|
263
|
+
tags.find {|tag| tag.tag_name.to_s == name.to_s }
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# Returns a list of tags specified by +name+ or all tags if +name+ is not specified.
|
|
267
|
+
#
|
|
268
|
+
# @param [#to_s] name the tag name to return data for, or nil for all tags
|
|
269
|
+
# @return [Array<Tags::Tag>] the list of tags by the specified tag name
|
|
270
|
+
def tags(name = nil)
|
|
271
|
+
list = @tags + convert_ref_tags
|
|
272
|
+
return list unless name
|
|
273
|
+
list.select {|tag| tag.tag_name.to_s == name.to_s }
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# Returns true if at least one tag by the name +name+ was declared
|
|
277
|
+
#
|
|
278
|
+
# @param [String] name the tag name to search for
|
|
279
|
+
# @return [Boolean] whether or not the tag +name+ was declared
|
|
280
|
+
def has_tag?(name)
|
|
281
|
+
tags.any? {|tag| tag.tag_name.to_s == name.to_s }
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Delete all tags with +name+
|
|
285
|
+
# @param [String] name the tag name
|
|
286
|
+
# @return [void]
|
|
287
|
+
# @since 0.7.0
|
|
288
|
+
def delete_tags(name)
|
|
289
|
+
delete_tag_if {|tag| tag.tag_name.to_s == name.to_s }
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
# Deletes all tags where the block returns true
|
|
293
|
+
# @yieldparam [Tags::Tag] tag the tag that is being tested
|
|
294
|
+
# @yieldreturn [Boolean] true if the tag should be deleted
|
|
295
|
+
# @return [void]
|
|
296
|
+
# @since 0.7.0
|
|
297
|
+
def delete_tag_if(&block)
|
|
298
|
+
@tags.delete_if(&block)
|
|
299
|
+
@ref_tags.delete_if(&block)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
# Returns true if the docstring has no content that is visible to a template.
|
|
303
|
+
#
|
|
304
|
+
# @param [Boolean] only_visible_tags whether only {Tags::Library.visible_tags}
|
|
305
|
+
# should be checked, or if all tags should be considered.
|
|
306
|
+
# @return [Boolean] whether or not the docstring has content
|
|
307
|
+
def blank?(only_visible_tags = true)
|
|
308
|
+
if only_visible_tags
|
|
309
|
+
empty? && !tags.any? {|tag| Tags::Library.visible_tags.include?(tag.tag_name.to_sym) }
|
|
310
|
+
else
|
|
311
|
+
empty? && @tags.empty? && @ref_tags.empty?
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# @endgroup
|
|
316
|
+
|
|
317
|
+
# Resolves unresolved other docstring reference if there is
|
|
318
|
+
# unresolved reference. Does nothing if there is no unresolved
|
|
319
|
+
# reference.
|
|
320
|
+
#
|
|
321
|
+
# Normally, you don't need to call this method
|
|
322
|
+
# explicitly. Resolving unresolved reference is done implicitly.
|
|
323
|
+
#
|
|
324
|
+
# @return [void]
|
|
325
|
+
def resolve_reference
|
|
326
|
+
loop do
|
|
327
|
+
return if @unresolved_reference.nil?
|
|
328
|
+
return if CodeObjects::Proxy === @unresolved_reference
|
|
329
|
+
|
|
330
|
+
reference, @unresolved_reference = @unresolved_reference, nil
|
|
331
|
+
self.all = [reference.docstring.all, @all].join("\n")
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
private
|
|
336
|
+
|
|
337
|
+
# Maps valid reference tags
|
|
338
|
+
#
|
|
339
|
+
# @return [Array<Tags::RefTag>] the list of valid reference tags
|
|
340
|
+
def convert_ref_tags
|
|
341
|
+
list = @ref_tags.reject {|t| CodeObjects::Proxy === t.owner }
|
|
342
|
+
list.map {|t| t.tags }.flatten
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
# Parses out comments split by newlines into a new code object
|
|
346
|
+
#
|
|
347
|
+
# @param [String] comments
|
|
348
|
+
# the newline delimited array of comments. If the comments
|
|
349
|
+
# are passed as a String, they will be split by newlines.
|
|
350
|
+
#
|
|
351
|
+
# @return [String] the non-metadata portion of the comments to
|
|
352
|
+
# be used as a docstring
|
|
353
|
+
def parse_comments(comments)
|
|
354
|
+
parser = self.class.parser
|
|
355
|
+
parser.parse(comments, object)
|
|
356
|
+
@all = parser.raw_text
|
|
357
|
+
@unresolved_reference = parser.reference
|
|
358
|
+
add_tag(*parser.tags)
|
|
359
|
+
parser.text
|
|
360
|
+
end
|
|
361
|
+
end
|
|
362
|
+
end
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
require 'ostruct'
|
|
2
|
+
|
|
3
|
+
module YARD
|
|
4
|
+
# Parses text and creates a {Docstring} object to represent documentation
|
|
5
|
+
# for a {CodeObjects::Base}. To create a new docstring, you should initialize
|
|
6
|
+
# the parser and call {#parse} followed by {#to_docstring}.
|
|
7
|
+
#
|
|
8
|
+
# == Subclassing Notes
|
|
9
|
+
#
|
|
10
|
+
# The DocstringParser can be subclassed and subtituted during parsing by
|
|
11
|
+
# setting the {Docstring.default_parser} attribute with the name of the
|
|
12
|
+
# subclass. This allows developers to change the way docstrings are
|
|
13
|
+
# parsed, allowing for completely different docstring syntaxes.
|
|
14
|
+
#
|
|
15
|
+
# @example Creating a Docstring with a DocstringParser
|
|
16
|
+
# DocstringParser.new.parse("text here").to_docstring
|
|
17
|
+
# @example Creating a Custom DocstringParser
|
|
18
|
+
# # Parses docstrings backwards!
|
|
19
|
+
# class ReverseDocstringParser
|
|
20
|
+
# def parse_content(content)
|
|
21
|
+
# super(content.reverse)
|
|
22
|
+
# end
|
|
23
|
+
# end
|
|
24
|
+
#
|
|
25
|
+
# # Set the parser as default when parsing
|
|
26
|
+
# YARD::Docstring.default_parser = ReverseDocstringParser
|
|
27
|
+
# @see #parse_content
|
|
28
|
+
# @since 0.8.0
|
|
29
|
+
class DocstringParser
|
|
30
|
+
# @return [String] the parsed text portion of the docstring,
|
|
31
|
+
# with tags removed.
|
|
32
|
+
attr_accessor :text
|
|
33
|
+
|
|
34
|
+
# @return [String] the complete input string to the parser.
|
|
35
|
+
attr_accessor :raw_text
|
|
36
|
+
|
|
37
|
+
# @return [Array<Tag>] the list of meta-data tags identified
|
|
38
|
+
# by the parser
|
|
39
|
+
attr_accessor :tags
|
|
40
|
+
|
|
41
|
+
# @return [Array<Directive>] a list of directives identified
|
|
42
|
+
# by the parser. This list will not be passed on to the
|
|
43
|
+
# Docstring object.
|
|
44
|
+
attr_accessor :directives
|
|
45
|
+
|
|
46
|
+
# @return [OpenStruct] any arbitrary state to be passed between
|
|
47
|
+
# tags during parsing. Mainly used by directives to coordinate
|
|
48
|
+
# behaviour (so that directives can be aware of other directives
|
|
49
|
+
# used in a docstring).
|
|
50
|
+
attr_accessor :state
|
|
51
|
+
|
|
52
|
+
# @return [CodeObjects::Base, nil] the object associated with
|
|
53
|
+
# the docstring being parsed. May be nil if the docstring is
|
|
54
|
+
# not attached to any object.
|
|
55
|
+
attr_accessor :object
|
|
56
|
+
|
|
57
|
+
# @return [CodeObjects::Base, nil] the object referenced by
|
|
58
|
+
# the docstring being parsed. May be nil if the docstring doesn't
|
|
59
|
+
# refer to any object.
|
|
60
|
+
attr_accessor :reference
|
|
61
|
+
|
|
62
|
+
# @return [Handlers::Base, nil] the handler parsing this
|
|
63
|
+
# docstring. May be nil if this docstring parser is not
|
|
64
|
+
# initialized through
|
|
65
|
+
attr_accessor :handler
|
|
66
|
+
|
|
67
|
+
# @return [Tags::Library] the tag library being used to
|
|
68
|
+
# identify registered tags in the docstring.
|
|
69
|
+
attr_accessor :library
|
|
70
|
+
|
|
71
|
+
# The regular expression to match the tag syntax
|
|
72
|
+
META_MATCH = /^@(!)?((?:\w\.?)+)(?:\s+(.*))?$/i
|
|
73
|
+
|
|
74
|
+
# @!group Creation and Conversion Methods
|
|
75
|
+
|
|
76
|
+
# Creates a new parser to parse docstring data
|
|
77
|
+
#
|
|
78
|
+
# @param [Tags::Library] library a tag library for recognizing
|
|
79
|
+
# tags.
|
|
80
|
+
def initialize(library = Tags::Library.instance)
|
|
81
|
+
@text = ""
|
|
82
|
+
@raw_text = ""
|
|
83
|
+
@tags = []
|
|
84
|
+
@directives = []
|
|
85
|
+
@library = library
|
|
86
|
+
@object = nil
|
|
87
|
+
@reference = nil
|
|
88
|
+
@handler = nil
|
|
89
|
+
@state = OpenStruct.new
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# @return [Docstring] translates parsed text into
|
|
93
|
+
# a Docstring object.
|
|
94
|
+
def to_docstring
|
|
95
|
+
Docstring.new!(text, tags, object, raw_text, reference)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# @!group Parsing Methods
|
|
99
|
+
|
|
100
|
+
# Parses all content and returns itself.
|
|
101
|
+
#
|
|
102
|
+
# @param [String] content the docstring text to parse
|
|
103
|
+
# @param [CodeObjects::Base] object the object that the docstring
|
|
104
|
+
# is attached to. Will be passed to directives to act on
|
|
105
|
+
# this object.
|
|
106
|
+
# @param [Handlers::Base, nil] handler the handler object that is
|
|
107
|
+
# parsing this object. May be nil if this parser is not being
|
|
108
|
+
# called from a {Parser::SourceParser} context.
|
|
109
|
+
# @return [self] the parser object. To get the docstring,
|
|
110
|
+
# call {#to_docstring}.
|
|
111
|
+
# @see #to_docstring
|
|
112
|
+
def parse(content, object = nil, handler = nil)
|
|
113
|
+
@object = object
|
|
114
|
+
@handler = handler
|
|
115
|
+
@reference, @raw_text = detect_reference(content)
|
|
116
|
+
text = parse_content(@raw_text)
|
|
117
|
+
# Remove trailing/leading whitespace / newlines
|
|
118
|
+
@text = text.gsub(/\A[\r\n\s]+|[\r\n\s]+\Z/, '')
|
|
119
|
+
call_directives_after_parse
|
|
120
|
+
call_after_parse_callbacks
|
|
121
|
+
self
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Parses a given block of text.
|
|
125
|
+
#
|
|
126
|
+
# @param [String] content the content to parse
|
|
127
|
+
# @note Subclasses can override this method to perform custom
|
|
128
|
+
# parsing of content data.
|
|
129
|
+
def parse_content(content)
|
|
130
|
+
content = content.split(/\r?\n/) if content.is_a?(String)
|
|
131
|
+
return '' if !content || content.empty?
|
|
132
|
+
docstring = ""
|
|
133
|
+
|
|
134
|
+
indent, last_indent = content.first[/^\s*/].length, 0
|
|
135
|
+
orig_indent = 0
|
|
136
|
+
directive = false
|
|
137
|
+
last_line = ""
|
|
138
|
+
tag_name, tag_klass, tag_buf = nil, nil, []
|
|
139
|
+
|
|
140
|
+
(content+['']).each_with_index do |line, index|
|
|
141
|
+
indent = line[/^\s*/].length
|
|
142
|
+
empty = (line =~ /^\s*$/ ? true : false)
|
|
143
|
+
done = content.size == index
|
|
144
|
+
|
|
145
|
+
if tag_name && (((indent < orig_indent && !empty) || done ||
|
|
146
|
+
(indent == 0 && !empty)) || (indent <= last_indent && line =~ META_MATCH))
|
|
147
|
+
buf = tag_buf.join("\n")
|
|
148
|
+
if directive || tag_is_directive?(tag_name)
|
|
149
|
+
directive = create_directive(tag_name, buf)
|
|
150
|
+
if directive
|
|
151
|
+
docstring << parse_content(directive.expanded_text).chomp
|
|
152
|
+
end
|
|
153
|
+
else
|
|
154
|
+
create_tag(tag_name, buf)
|
|
155
|
+
end
|
|
156
|
+
tag_name, tag_buf, directive = nil, [], false
|
|
157
|
+
orig_indent = 0
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Found a meta tag
|
|
161
|
+
if line =~ META_MATCH
|
|
162
|
+
directive, tag_name, tag_buf = $1, $2, [($3 || '')]
|
|
163
|
+
elsif tag_name && indent >= orig_indent && !empty
|
|
164
|
+
orig_indent = indent if orig_indent == 0
|
|
165
|
+
# Extra data added to the tag on the next line
|
|
166
|
+
last_empty = last_line =~ /^[ \t]*$/ ? true : false
|
|
167
|
+
|
|
168
|
+
tag_buf << '' if last_empty
|
|
169
|
+
tag_buf << line.gsub(/^[ \t]{#{orig_indent}}/, '')
|
|
170
|
+
elsif !tag_name
|
|
171
|
+
# Regular docstring text
|
|
172
|
+
docstring << line << "\n"
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
last_indent = indent
|
|
176
|
+
last_line = line
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
docstring
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# @!group Tag Manipulation Methods
|
|
183
|
+
|
|
184
|
+
# Creates a tag from the {Tags::DefaultFactory tag factory}.
|
|
185
|
+
#
|
|
186
|
+
# To add an already created tag object, append it to {#tags}.
|
|
187
|
+
#
|
|
188
|
+
# @param [String] tag_name the tag name
|
|
189
|
+
# @param [String] tag_buf the text attached to the tag with newlines removed.
|
|
190
|
+
# @return [Tags::Tag, Tags::RefTag] a tag
|
|
191
|
+
def create_tag(tag_name, tag_buf = '')
|
|
192
|
+
if tag_buf =~ /\A\s*(?:(\S+)\s+)?\(\s*see\s+(\S+)\s*\)\s*\Z/
|
|
193
|
+
return create_ref_tag(tag_name, $1, $2)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
if library.has_tag?(tag_name)
|
|
197
|
+
@tags += [library.tag_create(tag_name, tag_buf)].flatten
|
|
198
|
+
else
|
|
199
|
+
log.warn "Unknown tag @#{tag_name}" +
|
|
200
|
+
(object ? " in file `#{object.file}` near line #{object.line}" : "")
|
|
201
|
+
end
|
|
202
|
+
rescue Tags::TagFormatError
|
|
203
|
+
log.warn "Invalid tag format for @#{tag_name}" +
|
|
204
|
+
(object ? " in file `#{object.file}` near line #{object.line}" : "")
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Creates a {Tags::RefTag}
|
|
208
|
+
def create_ref_tag(tag_name, name, object_name)
|
|
209
|
+
@tags << Tags::RefTagList.new(tag_name, P(object, object_name), name)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Creates a new directive using the registered {#library}
|
|
213
|
+
# @return [Directive] the directive object that is created
|
|
214
|
+
def create_directive(tag_name, tag_buf)
|
|
215
|
+
if library.has_directive?(tag_name)
|
|
216
|
+
dir = library.directive_create(tag_name, tag_buf, self)
|
|
217
|
+
if dir.is_a?(Tags::Directive)
|
|
218
|
+
@directives << dir
|
|
219
|
+
dir
|
|
220
|
+
end
|
|
221
|
+
else
|
|
222
|
+
log.warn "Unknown directive @!#{tag_name}" +
|
|
223
|
+
(object ? " in file `#{object.file}` near line #{object.line}" : "")
|
|
224
|
+
nil
|
|
225
|
+
end
|
|
226
|
+
rescue Tags::TagFormatError
|
|
227
|
+
log.warn "Invalid directive format for @!#{tag_name}" +
|
|
228
|
+
(object ? " in file `#{object.file}` near line #{object.line}" : "")
|
|
229
|
+
nil
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Backward compatibility to detect old tags that should be specified
|
|
233
|
+
# as directives in 0.8 and onward.
|
|
234
|
+
def tag_is_directive?(tag_name)
|
|
235
|
+
list = %w(attribute endgroup group macro method scope visibility)
|
|
236
|
+
list.include?(tag_name)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
private
|
|
240
|
+
|
|
241
|
+
def namespace
|
|
242
|
+
if object
|
|
243
|
+
object.namespace
|
|
244
|
+
else
|
|
245
|
+
nil
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def detect_reference(content)
|
|
250
|
+
if content =~ /\A\s*\(see (\S+)\s*\)(?:\s|$)/
|
|
251
|
+
path, extra = $1, $'
|
|
252
|
+
[CodeObjects::Proxy.new(namespace, path), extra]
|
|
253
|
+
else
|
|
254
|
+
[nil, content]
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# @!group Parser Callback Methods
|
|
259
|
+
|
|
260
|
+
# Calls the {Directive#after_parse} callback on all the
|
|
261
|
+
# created directives.
|
|
262
|
+
def call_directives_after_parse
|
|
263
|
+
directives.each do |dir|
|
|
264
|
+
dir.after_parse
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# Calls all {after_parse} callbacks
|
|
269
|
+
def call_after_parse_callbacks
|
|
270
|
+
self.class.after_parse_callbacks.each do |cb|
|
|
271
|
+
cb.call(self)
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
public
|
|
276
|
+
|
|
277
|
+
# Creates a callback that is called after a docstring is successfully
|
|
278
|
+
# parsed. Use this method to perform sanity checks on a docstring's
|
|
279
|
+
# tag data, or add any extra tags automatically to a docstring.
|
|
280
|
+
#
|
|
281
|
+
# @yield [parser] a block to be called after a docstring is parsed
|
|
282
|
+
# @yieldparam [DocstringParser] parser the docstring parser object
|
|
283
|
+
# with all directives and tags created.
|
|
284
|
+
# @yieldreturn [void]
|
|
285
|
+
# @return [void]
|
|
286
|
+
def self.after_parse(&block)
|
|
287
|
+
self.after_parse_callbacks << block
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
# @return [Array<Proc>] the {after_parse} callback proc objects
|
|
291
|
+
def self.after_parse_callbacks
|
|
292
|
+
@after_parse_callbacks ||= []
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
# Define a callback to check that @param tags are properly named
|
|
296
|
+
after_parse do |parser|
|
|
297
|
+
next unless parser.object
|
|
298
|
+
next unless parser.object.is_a?(CodeObjects::MethodObject)
|
|
299
|
+
next if parser.object.parameters.empty? # method has no params or
|
|
300
|
+
# YARD couldn't detect any.
|
|
301
|
+
# but don't warn user (?)
|
|
302
|
+
names = parser.object.parameters.map {|l| l.first.gsub(/\W/, '') }
|
|
303
|
+
seen_names = []
|
|
304
|
+
infile_info = "\n in file `#{parser.object.file}' " +
|
|
305
|
+
"near line #{parser.object.line}"
|
|
306
|
+
parser.tags.each do |tag|
|
|
307
|
+
next if tag.is_a?(Tags::RefTagList) # we don't handle this yet
|
|
308
|
+
next unless tag.tag_name == "param"
|
|
309
|
+
if seen_names.include?(tag.name)
|
|
310
|
+
log.warn "@param tag has duplicate parameter name: " +
|
|
311
|
+
"#{tag.name} #{infile_info}"
|
|
312
|
+
elsif names.include?(tag.name)
|
|
313
|
+
seen_names << tag.name
|
|
314
|
+
else
|
|
315
|
+
log.warn "@param tag has unknown parameter name: " +
|
|
316
|
+
"#{tag.name} #{infile_info}"
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
end
|
data/lib/yard/globals.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @group Global Convenience Methods
|
|
2
|
+
|
|
3
|
+
# Shortcut for creating a YARD::CodeObjects::Proxy via a path
|
|
4
|
+
#
|
|
5
|
+
# @see YARD::CodeObjects::Proxy
|
|
6
|
+
# @see YARD::Registry.resolve
|
|
7
|
+
def P(namespace, name = nil, type = nil)
|
|
8
|
+
namespace, name = nil, namespace if name.nil?
|
|
9
|
+
YARD::Registry.resolve(namespace, name, false, true, type)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# The global {YARD::Logger} instance
|
|
13
|
+
#
|
|
14
|
+
# @return [YARD::Logger] the global {YARD::Logger} instance
|
|
15
|
+
# @see YARD::Logger
|
|
16
|
+
def log
|
|
17
|
+
YARD::Logger.instance
|
|
18
|
+
end
|