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
data/lib/yard/logging.rb
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
require 'logger'
|
|
2
|
+
require 'thread'
|
|
3
|
+
|
|
4
|
+
module YARD
|
|
5
|
+
# Handles console logging for info, warnings and errors.
|
|
6
|
+
# Uses the stdlib Logger class in Ruby for all the backend logic.
|
|
7
|
+
class Logger < ::Logger
|
|
8
|
+
# The list of characters displayed beside the progress bar to indicate
|
|
9
|
+
# "movement".
|
|
10
|
+
# @since 0.8.2
|
|
11
|
+
PROGRESS_INDICATORS = ["\u230C", "\u230D", "\u230E", "\u230F"]
|
|
12
|
+
|
|
13
|
+
# @return [IO] the IO object being logged to
|
|
14
|
+
# @since 0.8.2
|
|
15
|
+
def io; @logdev end
|
|
16
|
+
def io=(pipe) @logdev = pipe end
|
|
17
|
+
|
|
18
|
+
# @return [Boolean] whether backtraces should be shown (by default
|
|
19
|
+
# this is on).
|
|
20
|
+
def show_backtraces; @show_backtraces || level == DEBUG end
|
|
21
|
+
attr_writer :show_backtraces
|
|
22
|
+
|
|
23
|
+
# @return [Boolean] whether progress indicators should be shown when
|
|
24
|
+
# logging CLIs (by default this is off).
|
|
25
|
+
def show_progress
|
|
26
|
+
return false if YARD.ruby18? # threading is too ineffective for progress support
|
|
27
|
+
return false if YARD.windows? # windows has poor ANSI support
|
|
28
|
+
return false unless io.tty? # no TTY support on IO
|
|
29
|
+
return false if level > WARN # no progress in verbose/debug modes
|
|
30
|
+
@show_progress
|
|
31
|
+
end
|
|
32
|
+
attr_writer :show_progress
|
|
33
|
+
|
|
34
|
+
# The logger instance
|
|
35
|
+
# @return [Logger] the logger instance
|
|
36
|
+
def self.instance(pipe = STDOUT)
|
|
37
|
+
@logger ||= new(pipe)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Creates a new logger
|
|
41
|
+
def initialize(pipe, *args)
|
|
42
|
+
super(pipe, *args)
|
|
43
|
+
self.io = pipe
|
|
44
|
+
self.show_backtraces = true
|
|
45
|
+
self.show_progress = false
|
|
46
|
+
self.level = WARN
|
|
47
|
+
self.formatter = method(:format_log)
|
|
48
|
+
@progress_indicator = 0
|
|
49
|
+
@mutex = Mutex.new
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Changes the debug level to DEBUG if $DEBUG is set
|
|
53
|
+
# and writes a debugging message.
|
|
54
|
+
def debug(*args)
|
|
55
|
+
self.level = DEBUG if $DEBUG
|
|
56
|
+
super
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Captures the duration of a block of code for benchmark analysis. Also
|
|
60
|
+
# calls {#progress} on the message to display it to the user.
|
|
61
|
+
#
|
|
62
|
+
# @todo Implement capture storage for reporting of benchmarks
|
|
63
|
+
# @param [String] msg the message to display
|
|
64
|
+
# @param [Symbol, nil] nontty_log the level to log as if the output
|
|
65
|
+
# stream is not a TTY. Use +nil+ for no alternate logging.
|
|
66
|
+
# @yield a block of arbitrary code to benchmark
|
|
67
|
+
# @return [void]
|
|
68
|
+
def capture(msg, nontty_log = :debug, &block)
|
|
69
|
+
progress(msg, nontty_log)
|
|
70
|
+
yield
|
|
71
|
+
ensure
|
|
72
|
+
clear_progress
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Displays a progress indicator for a given message. This progress report
|
|
76
|
+
# is only displayed on TTY displays, otherwise the message is passed to
|
|
77
|
+
# the +nontty_log+ level.
|
|
78
|
+
#
|
|
79
|
+
# @param [String] msg the message to log
|
|
80
|
+
# @param [Symbol, nil] nontty_log the level to log as if the output
|
|
81
|
+
# stream is not a TTY. Use +nil+ for no alternate logging.
|
|
82
|
+
# @return [void]
|
|
83
|
+
# @since 0.8.2
|
|
84
|
+
def progress(msg, nontty_log = :debug)
|
|
85
|
+
send(nontty_log, msg) if nontty_log
|
|
86
|
+
return unless show_progress
|
|
87
|
+
icon = ""
|
|
88
|
+
if defined?(::Encoding)
|
|
89
|
+
icon = PROGRESS_INDICATORS[@progress_indicator] + " "
|
|
90
|
+
end
|
|
91
|
+
print("\e[2K\e[?25l\e[1m#{icon}#{msg}\e[0m\r")
|
|
92
|
+
@mutex.synchronize do
|
|
93
|
+
@progress_msg = msg
|
|
94
|
+
@progress_indicator += 1
|
|
95
|
+
@progress_indicator %= PROGRESS_INDICATORS.size
|
|
96
|
+
end
|
|
97
|
+
Thread.new do
|
|
98
|
+
sleep(0.05)
|
|
99
|
+
@mutex.synchronize do
|
|
100
|
+
progress(msg + ".", nil) if @progress_msg == msg
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Clears the progress indicator in the TTY display.
|
|
106
|
+
# @return [void]
|
|
107
|
+
# @since 0.8.2
|
|
108
|
+
def clear_progress
|
|
109
|
+
return unless show_progress
|
|
110
|
+
print_no_newline("\e[?25h\e[2K")
|
|
111
|
+
@progress_msg = nil
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Displays an unformatted line to the logger output stream, adding
|
|
115
|
+
# a newline.
|
|
116
|
+
# @param [String] msg the message to display
|
|
117
|
+
# @return [void]
|
|
118
|
+
# @since 0.8.2
|
|
119
|
+
def puts(msg = '')
|
|
120
|
+
print("#{msg}\n")
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
alias_method :print_no_newline, :<<
|
|
124
|
+
private :print_no_newline
|
|
125
|
+
|
|
126
|
+
# Displays an unformatted line to the logger output stream.
|
|
127
|
+
# @param [String] msg the message to display
|
|
128
|
+
# @return [void]
|
|
129
|
+
# @since 0.8.2
|
|
130
|
+
def print(msg = '')
|
|
131
|
+
clear_line
|
|
132
|
+
print_no_newline(msg)
|
|
133
|
+
end
|
|
134
|
+
alias_method :<<, :print
|
|
135
|
+
|
|
136
|
+
# Prints the backtrace +exc+ to the logger as error data.
|
|
137
|
+
#
|
|
138
|
+
# @param [Array<String>] exc the backtrace list
|
|
139
|
+
# @param [Symbol] level_meth the level to log backtrace at
|
|
140
|
+
# @return [void]
|
|
141
|
+
def backtrace(exc, level_meth = :error)
|
|
142
|
+
return unless show_backtraces
|
|
143
|
+
send(level_meth, "#{exc.class.class_name}: #{exc.message}")
|
|
144
|
+
send(level_meth, "Stack trace:" +
|
|
145
|
+
exc.backtrace[0..5].map {|x| "\n\t#{x}" }.join + "\n")
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Warns that the Ruby environment does not support continuations. Applies
|
|
149
|
+
# to JRuby, Rubinius and MacRuby. This warning will only display once
|
|
150
|
+
# per Ruby process.
|
|
151
|
+
#
|
|
152
|
+
# @deprecated Continuations are no longer needed by YARD 0.8.0+.
|
|
153
|
+
# @return [void]
|
|
154
|
+
def warn_no_continuations
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Sets the logger level for the duration of the block
|
|
158
|
+
#
|
|
159
|
+
# @example
|
|
160
|
+
# log.enter_level(Logger::ERROR) do
|
|
161
|
+
# YARD.parse_string "def x; end"
|
|
162
|
+
# end
|
|
163
|
+
# @param [Fixnum] new_level the logger level for the duration of the block.
|
|
164
|
+
# values can be found in Ruby's Logger class.
|
|
165
|
+
# @yield the block with the logger temporarily set to +new_level+
|
|
166
|
+
def enter_level(new_level = level, &block)
|
|
167
|
+
old_level, self.level = level, new_level
|
|
168
|
+
yield
|
|
169
|
+
self.level = old_level
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
private
|
|
173
|
+
|
|
174
|
+
# Override this internal Logger method to clear line
|
|
175
|
+
def add(*args)
|
|
176
|
+
clear_line
|
|
177
|
+
super(*args)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def clear_line
|
|
181
|
+
return unless @progress_msg
|
|
182
|
+
print_no_newline("\e[2K\r")
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Log format (from Logger implementation). Used by Logger internally
|
|
186
|
+
def format_log(sev, time, prog, msg)
|
|
187
|
+
"[#{sev.downcase}]: #{msg}\n"
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
data/lib/yard/options.rb
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
module YARD
|
|
2
|
+
# Generalized options class for passing around large amounts of options between objects.
|
|
3
|
+
#
|
|
4
|
+
# The options class exists for better visibility and documentability of options being
|
|
5
|
+
# passed through to other objects. Because YARD has parser and template architectures
|
|
6
|
+
# that are heavily reliant on options, it is necessary to make these option keys easily
|
|
7
|
+
# visible and understood by developers. Since the options class is more than just a
|
|
8
|
+
# basic Hash, the subclass can provide aliasing and convenience methods to simplify
|
|
9
|
+
# option property access, and, if needed, support backward-compatibility for deprecated
|
|
10
|
+
# key names.
|
|
11
|
+
#
|
|
12
|
+
# == Hash and OpenStruct-like Access
|
|
13
|
+
#
|
|
14
|
+
# Although the options class allows for Hash-like access (<tt>opts[:key]</tt>), the recommended
|
|
15
|
+
# mechanism for accessing an option key will be via standard method calls on attributes
|
|
16
|
+
#
|
|
17
|
+
# The options class can also act as an open ended key value storage structure (like a
|
|
18
|
+
# Hash or OpenStruct), and allows for setting and getting of unregistered option keys.
|
|
19
|
+
# This methodology is not recommended, however, and is only supported for backward
|
|
20
|
+
# compatibility inside YARD. Whenever possible, developers should define all keys used
|
|
21
|
+
# by an options class.
|
|
22
|
+
#
|
|
23
|
+
# == Declaring Default Values
|
|
24
|
+
#
|
|
25
|
+
# Note that the options class can contain default value definitions for certain options,
|
|
26
|
+
# but to initialize these defaults, {#reset_defaults} must be called manually after
|
|
27
|
+
# initialization; the options object is always created empty until defaults are applied.
|
|
28
|
+
#
|
|
29
|
+
# @abstract Subclasses should define (and document) custom attributes that are expected
|
|
30
|
+
# to be made available as option keys.
|
|
31
|
+
# @example Defining an Options class with custom option keys
|
|
32
|
+
# class TemplateOptions < YARD::Options
|
|
33
|
+
# # @return [Symbol] the output format to generate templates in
|
|
34
|
+
# attr_accessor :format
|
|
35
|
+
#
|
|
36
|
+
# # @return [Symbol] the template to use when generating output
|
|
37
|
+
# attr_accessor :template
|
|
38
|
+
# end
|
|
39
|
+
# @example Initializing default option values
|
|
40
|
+
# class TemplateOptions < YARD::Options
|
|
41
|
+
# def reset_defaults
|
|
42
|
+
# super
|
|
43
|
+
# self.format = :html
|
|
44
|
+
# self.template = :default
|
|
45
|
+
# self.highlight = true
|
|
46
|
+
# # ...
|
|
47
|
+
# end
|
|
48
|
+
# end
|
|
49
|
+
# @example Using +default_attr+ to create default attributes
|
|
50
|
+
# class TemplateOptions < YARD::Options
|
|
51
|
+
# default_attr :format, :html
|
|
52
|
+
# default_attr :template, :default
|
|
53
|
+
# default_attr :highlight, true
|
|
54
|
+
# end
|
|
55
|
+
# @example Deprecating an option while still supporting it
|
|
56
|
+
# class TemplateOptions < YARD::Options
|
|
57
|
+
# # @return [Boolean] if syntax highlighting should be performed on code blocks.
|
|
58
|
+
# # Defaults to true.
|
|
59
|
+
# attr_accessor :highlight
|
|
60
|
+
#
|
|
61
|
+
# # @deprecated Use {#highlight} instead.
|
|
62
|
+
# # @return [Boolean] if no syntax highlighting should be performs on code blocks.
|
|
63
|
+
# # Defaults to false.
|
|
64
|
+
# attr_accessor :no_highlight
|
|
65
|
+
# def no_highlight=(value) @highlight = !value end
|
|
66
|
+
# def no_highlight; !highlight end
|
|
67
|
+
# end
|
|
68
|
+
class Options
|
|
69
|
+
# @!macro [attach] yard.default_attr
|
|
70
|
+
# @!attribute $1
|
|
71
|
+
# Defines an attribute named +key+ and sets a default value for it
|
|
72
|
+
#
|
|
73
|
+
# @example Defining a default option key
|
|
74
|
+
# default_attr :name, 'Default Name'
|
|
75
|
+
# default_attr :time, lambda { Time.now }
|
|
76
|
+
# @param [Symbol] key the option key name
|
|
77
|
+
# @param [Object, Proc] default the default object value. If the default
|
|
78
|
+
# value is a proc, it is executed upon initialization.
|
|
79
|
+
def self.default_attr(key, default)
|
|
80
|
+
(@defaults ||= {})[key] = default
|
|
81
|
+
attr_accessor(key)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Delegates calls with Hash syntax to actual method with key name
|
|
85
|
+
#
|
|
86
|
+
# @example Calling on an option key with Hash syntax
|
|
87
|
+
# options[:format] # equivalent to: options.format
|
|
88
|
+
# @param [Symbol, String] key the option name to access
|
|
89
|
+
# @return the value of the option named +key+
|
|
90
|
+
def [](key) send(key) end
|
|
91
|
+
|
|
92
|
+
# Delegates setter calls with Hash syntax to the attribute setter with the key name
|
|
93
|
+
#
|
|
94
|
+
# @example Setting an option with Hash syntax
|
|
95
|
+
# options[:format] = :html # equivalent to: options.format = :html
|
|
96
|
+
# @param [Symbol, String] key the optin to set
|
|
97
|
+
# @param [Object] value the value to set for the option
|
|
98
|
+
# @return [Object] the value being set
|
|
99
|
+
def []=(key, value) send("#{key}=", value) end
|
|
100
|
+
|
|
101
|
+
# Updates values from an options hash or options object on this object.
|
|
102
|
+
# All keys passed should be key names defined by attributes on the class.
|
|
103
|
+
#
|
|
104
|
+
# @example Updating a set of options on an Options object
|
|
105
|
+
# opts.update(:template => :guide, :type => :fulldoc)
|
|
106
|
+
# @param [Hash, Options] opts
|
|
107
|
+
# @return [self]
|
|
108
|
+
def update(opts)
|
|
109
|
+
opts = opts.to_hash if Options === opts
|
|
110
|
+
opts.each do |key, value|
|
|
111
|
+
self[key] = value
|
|
112
|
+
end
|
|
113
|
+
self
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Creates a new options object and sets options hash or object value
|
|
117
|
+
# onto that object.
|
|
118
|
+
#
|
|
119
|
+
# @param [Options, Hash] opts
|
|
120
|
+
# @return [Options] the newly created options object
|
|
121
|
+
# @see #update
|
|
122
|
+
def merge(opts)
|
|
123
|
+
dup.update(opts)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# @return [Hash] Converts options object to an options hash. All keys
|
|
127
|
+
# will be symbolized.
|
|
128
|
+
def to_hash
|
|
129
|
+
opts = {}
|
|
130
|
+
instance_variables.each do |ivar|
|
|
131
|
+
name = ivar.to_s.sub(/^@/, '')
|
|
132
|
+
opts[name.to_sym] = send(name)
|
|
133
|
+
end
|
|
134
|
+
opts
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Yields over every option key and value
|
|
138
|
+
# @yield [key, value] every option key and value
|
|
139
|
+
# @yieldparam [Symbol] key the option key
|
|
140
|
+
# @yieldparam [Object] value the option value
|
|
141
|
+
# @return [void]
|
|
142
|
+
def each(&block)
|
|
143
|
+
instance_variables.each do |ivar|
|
|
144
|
+
name = ivar.to_s.sub(/^@/, '')
|
|
145
|
+
yield(name.to_sym, send(name))
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Inspects the object
|
|
150
|
+
def inspect
|
|
151
|
+
"<#{self.class}: #{to_hash.inspect}>"
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# @return [Boolean] whether another Options object equals the
|
|
155
|
+
# keys and values of this options object
|
|
156
|
+
def ==(other)
|
|
157
|
+
case other
|
|
158
|
+
when Options; to_hash == other.to_hash
|
|
159
|
+
when Hash; to_hash == other
|
|
160
|
+
else false
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Handles setting and accessing of unregistered keys similar
|
|
165
|
+
# to an OpenStruct object.
|
|
166
|
+
#
|
|
167
|
+
# @note It is not recommended to set and access unregistered keys on
|
|
168
|
+
# an Options object. Instead, register the attribute before using it.
|
|
169
|
+
def method_missing(meth, *args, &block)
|
|
170
|
+
if meth.to_s =~ /^(.+)=$/
|
|
171
|
+
log.debug "Attempting to set unregistered key #{$1} on #{self.class}"
|
|
172
|
+
instance_variable_set("@#{$1}", args.first)
|
|
173
|
+
elsif args.size == 0
|
|
174
|
+
log.debug "Attempting to access unregistered key #{meth} on #{self.class}"
|
|
175
|
+
instance_variable_get("@#{meth}")
|
|
176
|
+
else
|
|
177
|
+
super
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Resets all values to their defaults.
|
|
182
|
+
#
|
|
183
|
+
# @abstract Subclasses should override this method to perform custom
|
|
184
|
+
# value initialization if not using {default_attr}. Be sure to call
|
|
185
|
+
# +super+ so that default initialization can take place.
|
|
186
|
+
# @return [void]
|
|
187
|
+
def reset_defaults
|
|
188
|
+
names_set = {}
|
|
189
|
+
self.class.ancestors.each do |klass| # look at all ancestors
|
|
190
|
+
defaults = klass.instance_variable_get("@defaults")
|
|
191
|
+
next unless defaults
|
|
192
|
+
defaults.each do |key, value|
|
|
193
|
+
next if names_set[key]
|
|
194
|
+
names_set[key] = true
|
|
195
|
+
self[key] = Proc === value ? value.call : value
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# Deletes an option value for +key+
|
|
201
|
+
#
|
|
202
|
+
# @param [Symbol, String] key the key to delete a value for
|
|
203
|
+
# @return [Object] the value that was deleted
|
|
204
|
+
def delete(key)
|
|
205
|
+
val = self[key]
|
|
206
|
+
if instance_variable_defined?("@#{key}")
|
|
207
|
+
remove_instance_variable("@#{key}")
|
|
208
|
+
end
|
|
209
|
+
val
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
unless defined? tap() # only for 1.8.6
|
|
213
|
+
def tap(&block) yield(self); self end
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module YARD
|
|
2
|
+
module Parser
|
|
3
|
+
# Represents the abstract base parser class that parses source code in
|
|
4
|
+
# a specific way. A parser should implement {#parse}, {#tokenize} and
|
|
5
|
+
# {#enumerator}.
|
|
6
|
+
#
|
|
7
|
+
# == Registering a Custom Parser
|
|
8
|
+
# To register a parser, see {SourceParser.register_parser_type}
|
|
9
|
+
#
|
|
10
|
+
# @abstract
|
|
11
|
+
# @see #parse
|
|
12
|
+
# @see #tokenize
|
|
13
|
+
# @see #enumerator
|
|
14
|
+
# @since 0.5.6
|
|
15
|
+
class Base
|
|
16
|
+
# Convenience method to create a new parser and {#parse}
|
|
17
|
+
def self.parse(source, filename = nil)
|
|
18
|
+
new(source, filename).parse
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# This default constructor does nothing. The subclass is responsible for
|
|
22
|
+
# storing the source contents and filename if they are required.
|
|
23
|
+
# @param [String] source the source contents
|
|
24
|
+
# @param [String] filename the name of the file if from disk
|
|
25
|
+
def initialize(source, filename)
|
|
26
|
+
raise NotImplementedError, "invalid parser implementation"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# This method should be implemented to parse the source and return itself.
|
|
30
|
+
# @abstract
|
|
31
|
+
# @return [Base] this method should return itself
|
|
32
|
+
def parse
|
|
33
|
+
raise NotImplementedError, "#{self.class} must implement #parse"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# This method should be implemented to tokenize given source
|
|
37
|
+
# @abstract
|
|
38
|
+
# @return [Array] a list/tree of lexical tokens
|
|
39
|
+
def tokenize
|
|
40
|
+
raise NotImplementedError, "#{self.class} does not support tokenization"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# This method should be implemented to return a list of semantic tokens
|
|
44
|
+
# representing the source code to be post-processed. Otherwise the method
|
|
45
|
+
# should return nil.
|
|
46
|
+
#
|
|
47
|
+
# @abstract
|
|
48
|
+
# @return [Array] a list of semantic tokens representing the source code
|
|
49
|
+
# to be post-processed
|
|
50
|
+
# @return [nil] if no post-processing should be done
|
|
51
|
+
def enumerator
|
|
52
|
+
nil
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
module YARD
|
|
2
|
+
module Parser
|
|
3
|
+
module C
|
|
4
|
+
class CParser < Base
|
|
5
|
+
def initialize(source, file = '(stdin)')
|
|
6
|
+
@file = file
|
|
7
|
+
@namespaces = {}
|
|
8
|
+
@content = source
|
|
9
|
+
@index = 0
|
|
10
|
+
@line = 1
|
|
11
|
+
@state = nil
|
|
12
|
+
@newline = true
|
|
13
|
+
@statements = []
|
|
14
|
+
@last_comment = nil
|
|
15
|
+
@last_statement = nil
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def parse
|
|
19
|
+
parse_toplevel
|
|
20
|
+
enumerator
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def enumerator
|
|
24
|
+
@statements
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def tokenize
|
|
28
|
+
raise NotImplementedError, "no tokenization support for C/C++ files"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def parse_toplevel
|
|
34
|
+
advance_loop do
|
|
35
|
+
case char
|
|
36
|
+
when /['"]/; consume_quote(char)
|
|
37
|
+
when '#'; consume_directive
|
|
38
|
+
when '/'; consume_comment
|
|
39
|
+
when /\s/; consume_whitespace
|
|
40
|
+
else consume_toplevel_statement
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def consume_quote(type = '"')
|
|
46
|
+
advance
|
|
47
|
+
advance_loop do
|
|
48
|
+
case char
|
|
49
|
+
when "\n"; advance; nextline
|
|
50
|
+
when '\\'; advance(2)
|
|
51
|
+
when type; advance; return
|
|
52
|
+
else advance
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def consume_directive
|
|
58
|
+
return(advance) unless @newline
|
|
59
|
+
@last_comment = nil
|
|
60
|
+
@last_statement = nil
|
|
61
|
+
advance_loop do
|
|
62
|
+
if char == '\\' && nextchar =~ /[\r\n]/
|
|
63
|
+
advance_loop { advance; break(nextline) if char == "\n" }
|
|
64
|
+
elsif char == "\n"
|
|
65
|
+
return
|
|
66
|
+
end
|
|
67
|
+
advance
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def consume_toplevel_statement
|
|
72
|
+
@newline = false
|
|
73
|
+
start = @index
|
|
74
|
+
line = @line
|
|
75
|
+
decl = consume_until(/[{;]/)
|
|
76
|
+
return nil if decl =~ /\A\s*\Z/
|
|
77
|
+
statement = ToplevelStatement.new(nil, @file, line)
|
|
78
|
+
@statements << statement
|
|
79
|
+
attach_comment(statement)
|
|
80
|
+
stmts = nil
|
|
81
|
+
if prevchar == '{'
|
|
82
|
+
stmts = consume_body_statements
|
|
83
|
+
if decl =~ /\A(typedef|enum|class|#{struct}|union)/
|
|
84
|
+
consume_until(';')
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
statement.source = @content[start..@index]
|
|
88
|
+
statement.block = stmts
|
|
89
|
+
statement.declaration = decl
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def consume_body_statements
|
|
93
|
+
stmts = []
|
|
94
|
+
brace_level = 1
|
|
95
|
+
while true
|
|
96
|
+
strip_non_statement_data
|
|
97
|
+
start, line = @index, @line
|
|
98
|
+
consume_until(/[{};]/)
|
|
99
|
+
brace_level += 1 if prevchar == '{'
|
|
100
|
+
brace_level -= 1 if prevchar == '}'
|
|
101
|
+
|
|
102
|
+
break if prevchar.empty? || (brace_level <= 0 && prevchar == '}')
|
|
103
|
+
end_chr = @index
|
|
104
|
+
end_chr -= 1 if prevchar == '}'
|
|
105
|
+
src = @content[start...@index]
|
|
106
|
+
if src && src !~ /\A\s*\Z|\A\}\Z/
|
|
107
|
+
stmt = BodyStatement.new(src, @file, line)
|
|
108
|
+
attach_comment(stmt)
|
|
109
|
+
stmts << stmt
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
stmts
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def strip_non_statement_data
|
|
116
|
+
start = @index
|
|
117
|
+
begin
|
|
118
|
+
start = @index
|
|
119
|
+
case char
|
|
120
|
+
when /\s/; consume_whitespace
|
|
121
|
+
when '#'; consume_directive
|
|
122
|
+
when '/'; consume_comment
|
|
123
|
+
end
|
|
124
|
+
end until start == @index
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def consume_whitespace
|
|
128
|
+
advance_loop { nextline if char == "\n"; break if char =~ /\S/; advance }
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def consume_comment(add_comment = true)
|
|
132
|
+
return(advance) unless nextchar == '*' || nextchar == '/'
|
|
133
|
+
line = @line
|
|
134
|
+
type = nextchar == '*' ? :multi : :line
|
|
135
|
+
advance(2)
|
|
136
|
+
comment = ""
|
|
137
|
+
advance_loop do
|
|
138
|
+
comment << char
|
|
139
|
+
if type == :multi
|
|
140
|
+
nextline if char == "\n"
|
|
141
|
+
if char(2) == '*/'
|
|
142
|
+
if add_comment
|
|
143
|
+
comment << '/'
|
|
144
|
+
stmt = Comment.new(comment, @file, line)
|
|
145
|
+
stmt.type = type
|
|
146
|
+
attach_comment(stmt)
|
|
147
|
+
@statements << stmt
|
|
148
|
+
end
|
|
149
|
+
return advance(2)
|
|
150
|
+
end
|
|
151
|
+
elsif char == "\n"
|
|
152
|
+
if add_comment
|
|
153
|
+
stmt = Comment.new(comment[0...-1], @file, line)
|
|
154
|
+
stmt.type = type
|
|
155
|
+
attach_comment(stmt)
|
|
156
|
+
@statements << stmt
|
|
157
|
+
end
|
|
158
|
+
return
|
|
159
|
+
end
|
|
160
|
+
advance
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def consume_until(end_char, bracket_level = 0, brace_level = 0, add_comment = true)
|
|
165
|
+
end_char = /#{end_char}/ if end_char.is_a?(String)
|
|
166
|
+
start = @index
|
|
167
|
+
advance_loop do
|
|
168
|
+
chr = char
|
|
169
|
+
case chr
|
|
170
|
+
when /\s/; consume_whitespace
|
|
171
|
+
when /['"]/; consume_quote(char)
|
|
172
|
+
when '#'; consume_directive
|
|
173
|
+
when '/'; consume_comment(add_comment)
|
|
174
|
+
when '{'; advance; brace_level += 1
|
|
175
|
+
when '}'; advance; brace_level -= 1
|
|
176
|
+
when '('; advance; bracket_level += 1
|
|
177
|
+
when ')'; advance; bracket_level -= 1
|
|
178
|
+
else advance
|
|
179
|
+
end
|
|
180
|
+
@newline = false if chr !~ /\s/
|
|
181
|
+
|
|
182
|
+
if chr =~ end_char && (chr == '{' || chr == '(')
|
|
183
|
+
break
|
|
184
|
+
elsif chr =~ end_char && bracket_level <= 0 && brace_level <= 0
|
|
185
|
+
break
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
return @content[start...@index]
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def attach_comment(statement)
|
|
192
|
+
if Comment === statement
|
|
193
|
+
if @last_statement && @last_statement.line == statement.line
|
|
194
|
+
@last_statement.comments = statement
|
|
195
|
+
statement.statement = @last_statement
|
|
196
|
+
end
|
|
197
|
+
@last_comment = statement
|
|
198
|
+
@last_statement = nil
|
|
199
|
+
else
|
|
200
|
+
if @last_comment
|
|
201
|
+
statement.comments = @last_comment
|
|
202
|
+
@last_comment.statement = statement
|
|
203
|
+
end
|
|
204
|
+
@last_statement = statement
|
|
205
|
+
@last_comment = nil
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def advance(num = 1) @index += num end
|
|
210
|
+
def back(num = 1) @index -= num end
|
|
211
|
+
|
|
212
|
+
def advance_loop(&block)
|
|
213
|
+
while @index <= @content.size; yield end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def nextline
|
|
217
|
+
@line += 1
|
|
218
|
+
@newline = true
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def char(num = 1) @content[@index, num] end
|
|
222
|
+
def prevchar(num = 1) @content[@index - 1, num] end
|
|
223
|
+
def nextchar(num = 1) @content[@index + 1, num] end
|
|
224
|
+
|
|
225
|
+
def struct
|
|
226
|
+
/struct\s[:alnum:]+\s\{/
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
end
|