yard 0.2.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- data/.yardopts +12 -10
- data/ChangeLog +5686 -0
- data/{README.markdown → README.md} +65 -11
- data/Rakefile +25 -13
- data/benchmarks/concat_vs_join.rb +12 -0
- data/benchmarks/erb_vs_erubis.rb +14 -14
- data/benchmarks/marshal_vs_dbm.rb +1 -1
- data/benchmarks/pathname_vs_string.rb +50 -0
- data/benchmarks/template_erb.rb +22 -0
- data/benchmarks/template_format.rb +6 -0
- data/benchmarks/template_profile.rb +17 -0
- data/bin/yri +16 -7
- data/docs/{CODE_OBJECTS.markdown → CodeObjects.md} +0 -0
- data/docs/{GETTING_STARTED.markdown → GettingStarted.md} +49 -11
- data/docs/{GLOSSARY.markdown → Glossary.md} +0 -0
- data/docs/{HANDLERS.markdown → Handlers.md} +5 -5
- data/docs/{OVERVIEW.markdown → Overview.md} +9 -13
- data/docs/{PARSER.markdown → Parser.md} +1 -1
- data/docs/{TAGS.markdown → Tags.md} +1 -1
- data/docs/Templates.md +286 -0
- data/docs/{WHATSNEW.markdown → WhatsNew.md} +82 -2
- data/lib/rubygems_plugin.rb +17 -20
- data/lib/yard.rb +47 -1
- data/lib/yard/autoload.rb +38 -47
- data/lib/yard/cli/yard_graph.rb +36 -13
- data/lib/yard/cli/yardoc.rb +74 -12
- data/lib/yard/code_objects/base.rb +182 -14
- data/lib/yard/code_objects/class_object.rb +39 -2
- data/lib/yard/code_objects/class_variable_object.rb +4 -0
- data/lib/yard/code_objects/constant_object.rb +8 -0
- data/lib/yard/code_objects/extended_method_object.rb +14 -0
- data/lib/yard/code_objects/method_object.rb +60 -2
- data/lib/yard/code_objects/module_object.rb +6 -0
- data/lib/yard/code_objects/namespace_object.rb +99 -2
- data/lib/yard/code_objects/proxy.rb +53 -6
- data/lib/yard/code_objects/root_object.rb +2 -0
- data/lib/yard/core_ext/array.rb +61 -0
- data/lib/yard/core_ext/file.rb +21 -4
- data/lib/yard/core_ext/module.rb +11 -1
- data/lib/yard/core_ext/string.rb +13 -2
- data/lib/yard/core_ext/symbol_hash.rb +51 -3
- data/lib/yard/docstring.rb +68 -19
- data/lib/yard/globals.rb +5 -2
- data/lib/yard/handlers/base.rb +13 -3
- data/lib/yard/handlers/processor.rb +64 -2
- data/lib/yard/handlers/ruby/class_handler.rb +1 -1
- data/lib/yard/handlers/ruby/class_variable_handler.rb +5 -1
- data/lib/yard/handlers/ruby/constant_handler.rb +38 -4
- data/lib/yard/handlers/ruby/exception_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/base.rb +2 -2
- data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +6 -3
- data/lib/yard/handlers/ruby/legacy/constant_handler.rb +21 -2
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +10 -0
- data/lib/yard/handlers/ruby/legacy/yield_handler.rb +2 -1
- data/lib/yard/handlers/ruby/method_handler.rb +10 -0
- data/lib/yard/handlers/ruby/yield_handler.rb +2 -1
- data/lib/yard/logging.rb +17 -0
- data/lib/yard/parser/ruby/ast_node.rb +101 -0
- data/lib/yard/parser/ruby/legacy/ruby_lex.rb +2 -2
- data/lib/yard/parser/ruby/legacy/statement_list.rb +10 -9
- data/lib/yard/parser/ruby/ruby_parser.rb +32 -3
- data/lib/yard/parser/source_parser.rb +82 -5
- data/lib/yard/rake/yardoc_task.rb +38 -3
- data/lib/yard/registry.rb +112 -2
- data/lib/yard/serializers/base.rb +48 -1
- data/lib/yard/serializers/file_system_serializer.rb +23 -2
- data/lib/yard/serializers/process_serializer.rb +10 -0
- data/lib/yard/serializers/stdout_serializer.rb +11 -0
- data/lib/yard/tags/library.rb +4 -1
- data/lib/yard/tags/overload_tag.rb +3 -12
- data/lib/yard/templates/engine.rb +162 -0
- data/lib/yard/{generators → templates}/helpers/base_helper.rb +14 -13
- data/lib/yard/{generators → templates}/helpers/filter_helper.rb +1 -1
- data/lib/yard/templates/helpers/html_helper.rb +287 -0
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +29 -0
- data/lib/yard/templates/helpers/html_syntax_highlight_helper18.rb +27 -0
- data/lib/yard/{generators → templates}/helpers/markup_helper.rb +15 -11
- data/lib/yard/{generators → templates}/helpers/method_helper.rb +8 -1
- data/lib/yard/templates/helpers/module_helper.rb +15 -0
- data/lib/yard/templates/helpers/text_helper.rb +60 -0
- data/lib/yard/templates/helpers/uml_helper.rb +33 -0
- data/lib/yard/templates/template.rb +355 -0
- data/lib/yard/verifier.rb +110 -0
- data/spec/cli/yardoc_spec.rb +23 -1
- data/spec/code_objects/base_spec.rb +8 -0
- data/spec/code_objects/class_object_spec.rb +166 -156
- data/spec/code_objects/method_object_spec.rb +2 -2
- data/spec/code_objects/module_object_spec.rb +112 -110
- data/spec/code_objects/proxy_spec.rb +9 -0
- data/spec/core_ext/array_spec.rb +33 -0
- data/spec/core_ext/file_spec.rb +40 -12
- data/spec/core_ext/module_spec.rb +15 -0
- data/spec/core_ext/string_spec.rb +10 -2
- data/spec/docstring_spec.rb +157 -135
- data/spec/handlers/class_handler_spec.rb +3 -0
- data/spec/handlers/class_variable_handler_spec.rb +3 -1
- data/spec/handlers/constant_handler_spec.rb +38 -0
- data/spec/handlers/examples/class_handler_001.rb.txt +14 -1
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +1 -0
- data/spec/handlers/examples/constant_handler_001.rb.txt +10 -1
- data/spec/handlers/examples/exception_handler_001.rb.txt +5 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +15 -0
- data/spec/handlers/examples/mixin_handler_001.rb.txt +13 -0
- data/spec/handlers/exception_handler_spec.rb +4 -0
- data/spec/handlers/method_handler_spec.rb +22 -0
- data/spec/handlers/mixin_handler_spec.rb +5 -3
- data/spec/handlers/yield_handler_spec.rb +1 -1
- data/spec/parser/ruby/ast_node_spec.rb +16 -0
- data/spec/parser/ruby/legacy/statement_list_spec.rb +36 -0
- data/spec/parser/ruby/ruby_parser_spec.rb +80 -0
- data/spec/parser/source_parser_spec.rb +48 -2
- data/spec/rake/yardoc_task_spec.rb +62 -25
- data/spec/serializers/file_system_serializer_spec.rb +1 -1
- data/spec/templates/class_spec.rb +34 -0
- data/spec/templates/engine_spec.rb +121 -0
- data/spec/templates/examples/class001.html +271 -0
- data/spec/templates/examples/class001.txt +31 -0
- data/spec/templates/examples/method001.html +96 -0
- data/spec/templates/examples/method001.txt +28 -0
- data/spec/templates/examples/method002.html +81 -0
- data/spec/templates/examples/method002.txt +20 -0
- data/spec/templates/examples/method003.html +137 -0
- data/spec/templates/examples/method003.txt +45 -0
- data/spec/templates/examples/module001.dot +31 -0
- data/spec/templates/examples/module001.html +294 -0
- data/spec/templates/examples/module001.txt +33 -0
- data/spec/templates/examples/tag001.txt +82 -0
- data/spec/templates/helpers/base_helper_spec.rb +129 -0
- data/spec/{generators → templates}/helpers/html_helper_spec.rb +73 -16
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +39 -0
- data/spec/{generators → templates}/helpers/markup_helper_spec.rb +6 -7
- data/spec/templates/method_spec.rb +75 -0
- data/spec/templates/module_spec.rb +50 -0
- data/spec/templates/spec_helper.rb +33 -0
- data/spec/templates/tag_spec.rb +39 -0
- data/spec/templates/template_spec.rb +398 -0
- data/spec/verifier_spec.rb +51 -0
- data/spec/yard_spec.rb +46 -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 +29 -0
- data/templates/default/class/text/setup.rb +11 -0
- data/templates/default/class/text/subclasses.erb +5 -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/text.erb +1 -0
- data/templates/default/docstring/html/todo.erb +6 -0
- data/templates/default/docstring/setup.rb +39 -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/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 +23 -0
- data/templates/default/fulldoc/html/css/style.css +261 -0
- data/templates/default/fulldoc/html/full_list.erb +36 -0
- data/templates/default/fulldoc/html/js/app.js +91 -0
- data/templates/default/fulldoc/html/js/full_list.js +39 -0
- data/templates/default/fulldoc/html/js/jquery.js +19 -0
- data/templates/default/fulldoc/html/setup.rb +86 -0
- data/templates/default/{uml → layout}/dot/header.erb +2 -2
- data/templates/default/layout/dot/setup.rb +14 -0
- data/templates/default/layout/html/breadcrumb.erb +11 -0
- data/templates/default/layout/html/footer.erb +5 -0
- data/templates/default/layout/html/headers.erb +13 -0
- data/templates/default/layout/html/index.erb +49 -0
- data/templates/default/layout/html/layout.erb +20 -0
- data/templates/default/layout/html/search.erb +5 -0
- data/templates/default/layout/html/setup.rb +58 -0
- data/templates/default/method/html/header.erb +14 -3
- data/templates/default/method/setup.rb +3 -0
- data/templates/default/method/text/header.erb +1 -1
- data/templates/default/method_details/html/header.erb +3 -0
- data/templates/default/method_details/html/method_signature.erb +17 -0
- data/templates/default/method_details/html/source.erb +10 -0
- data/templates/default/method_details/setup.rb +8 -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/{uml/dot/subgraph.erb → module/dot/header.erb} +3 -3
- data/templates/default/{uml → module}/dot/info.erb +4 -4
- data/templates/default/module/dot/setup.rb +14 -0
- data/templates/default/module/html/attribute_details.erb +11 -0
- data/templates/default/module/html/attribute_summary.erb +8 -0
- data/templates/default/module/html/box_info.erb +32 -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 +4 -4
- data/templates/default/module/html/inherited_constants.erb +8 -0
- data/templates/default/module/html/inherited_methods.erb +9 -0
- data/templates/default/module/html/item_summary.erb +20 -0
- data/templates/default/module/html/method_details_list.erb +8 -0
- data/templates/default/module/html/method_summary.erb +8 -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 +83 -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/root/dot/child.erb +3 -0
- data/templates/default/root/dot/setup.rb +5 -0
- data/templates/default/tags/html/example.erb +5 -16
- data/templates/default/tags/html/index.erb +3 -0
- data/templates/default/tags/html/option.erb +17 -20
- data/templates/default/tags/html/overload.erb +13 -0
- data/templates/default/tags/html/see.erb +5 -10
- data/templates/default/tags/html/tag.erb +20 -0
- data/templates/default/tags/setup.rb +50 -0
- data/templates/default/tags/text/example.erb +8 -10
- data/templates/default/tags/text/index.erb +1 -0
- data/templates/default/tags/text/option.erb +18 -3
- data/templates/default/tags/text/overload.erb +19 -0
- data/templates/default/tags/text/see.erb +8 -2
- data/templates/default/tags/text/tag.erb +13 -0
- metadata +142 -158
- data/bin/view_generator +0 -17
- data/docs/FAQ.markdown +0 -34
- data/docs/GENERATORS.markdown +0 -211
- data/lib/yard/generators/attributes_generator.rb +0 -22
- data/lib/yard/generators/base.rb +0 -305
- data/lib/yard/generators/class_generator.rb +0 -27
- data/lib/yard/generators/constants_generator.rb +0 -74
- data/lib/yard/generators/constructor_generator.rb +0 -25
- data/lib/yard/generators/deprecated_generator.rb +0 -15
- data/lib/yard/generators/docstring_generator.rb +0 -15
- data/lib/yard/generators/full_doc_generator.rb +0 -127
- data/lib/yard/generators/helpers/html_helper.rb +0 -196
- data/lib/yard/generators/helpers/html_syntax_highlight_helper.rb +0 -49
- data/lib/yard/generators/helpers/uml_helper.rb +0 -16
- data/lib/yard/generators/inheritance_generator.rb +0 -16
- data/lib/yard/generators/method_details_generator.rb +0 -18
- data/lib/yard/generators/method_generator.rb +0 -43
- data/lib/yard/generators/method_listing_generator.rb +0 -105
- data/lib/yard/generators/method_missing_generator.rb +0 -25
- data/lib/yard/generators/method_signature_generator.rb +0 -19
- data/lib/yard/generators/method_summary_generator.rb +0 -21
- data/lib/yard/generators/mixins_generator.rb +0 -21
- data/lib/yard/generators/module_generator.rb +0 -23
- data/lib/yard/generators/overloads_generator.rb +0 -20
- data/lib/yard/generators/quick_doc_generator.rb +0 -25
- data/lib/yard/generators/root_generator.rb +0 -32
- data/lib/yard/generators/source_generator.rb +0 -11
- data/lib/yard/generators/tags_generator.rb +0 -99
- data/lib/yard/generators/uml_generator.rb +0 -102
- data/lib/yard/generators/visibility_group_generator.rb +0 -26
- data/spec/generators/base_spec.rb +0 -64
- data/spec/generators/full_doc_generator_spec.rb +0 -29
- data/spec/generators/helpers/base_helper_spec.rb +0 -15
- data/spec/generators/quick_doc_generator_spec.rb +0 -13
- data/templates/default/attributes/html/header.erb +0 -47
- data/templates/default/attributes/text/header.erb +0 -10
- data/templates/default/class/html/header.erb +0 -4
- data/templates/default/constants/html/constants.erb +0 -9
- data/templates/default/constants/html/header.erb +0 -3
- data/templates/default/constants/html/included.erb +0 -9
- data/templates/default/constants/html/inherited.erb +0 -9
- data/templates/default/constructor/html/header.erb +0 -10
- data/templates/default/deprecated/html/main.erb +0 -6
- data/templates/default/deprecated/text/main.erb +0 -3
- data/templates/default/docstring/html/main.erb +0 -3
- data/templates/default/docstring/text/main.erb +0 -3
- data/templates/default/fulldoc/html/all_files.erb +0 -19
- data/templates/default/fulldoc/html/all_methods.erb +0 -26
- data/templates/default/fulldoc/html/all_namespaces.erb +0 -22
- data/templates/default/fulldoc/html/app.js +0 -18
- data/templates/default/fulldoc/html/custom.css +0 -1
- data/templates/default/fulldoc/html/file.erb +0 -16
- data/templates/default/fulldoc/html/footer.erb +0 -5
- data/templates/default/fulldoc/html/header.erb +0 -16
- data/templates/default/fulldoc/html/html_head.erb +0 -4
- data/templates/default/fulldoc/html/index.erb +0 -19
- data/templates/default/fulldoc/html/jquery.js +0 -11
- data/templates/default/fulldoc/html/style.css +0 -81
- data/templates/default/fulldoc/html/syntax_highlight.css +0 -24
- data/templates/default/inheritance/html/header.erb +0 -8
- data/templates/default/inheritance/text/header.erb +0 -3
- data/templates/default/method/html/aliases.erb +0 -6
- data/templates/default/method/html/title.erb +0 -3
- data/templates/default/method/text/title.erb +0 -1
- data/templates/default/methoddetails/html/header.erb +0 -8
- data/templates/default/methoddetails/html/method_header.erb +0 -3
- data/templates/default/methodmissing/html/header.erb +0 -12
- data/templates/default/methodsignature/html/main.erb +0 -10
- data/templates/default/methodsignature/text/main.erb +0 -8
- data/templates/default/methodsummary/html/header.erb +0 -5
- data/templates/default/methodsummary/html/included.erb +0 -9
- data/templates/default/methodsummary/html/inherited.erb +0 -9
- data/templates/default/methodsummary/html/summary.erb +0 -29
- data/templates/default/methodsummary/text/header.erb +0 -5
- data/templates/default/methodsummary/text/included.erb +0 -0
- data/templates/default/methodsummary/text/inherited.erb +0 -0
- data/templates/default/methodsummary/text/summary.erb +0 -6
- data/templates/default/mixins/html/header.erb +0 -4
- data/templates/default/overloads/html/header.erb +0 -8
- data/templates/default/overloads/text/header.erb +0 -8
- data/templates/default/quickdoc/html/header.erb +0 -15
- data/templates/default/quickdoc/text/header.erb +0 -12
- data/templates/default/root/html/header.erb +0 -4
- data/templates/default/source/html/main.erb +0 -15
- data/templates/default/source/text/main.erb +0 -4
- data/templates/default/tags/html/header.erb +0 -4
- data/templates/default/tags/html/param.erb +0 -21
- data/templates/default/tags/html/tags.erb +0 -23
- data/templates/default/tags/html/todo.erb +0 -8
- data/templates/default/tags/text/header.erb +0 -3
- data/templates/default/tags/text/param.erb +0 -9
- data/templates/default/tags/text/tags.erb +0 -7
- data/templates/default/uml/dot/child.erb +0 -1
- data/templates/default/uml/dot/dependencies.erb +0 -10
- data/templates/default/uml/dot/superclasses.erb +0 -9
- data/templates/default/uml/dot/unknown.erb +0 -3
- data/templates/default/uml/dot/unknown_child.erb +0 -1
- data/templates/default/visibilitygroup/html/header.erb +0 -6
- data/templates/javadoc/attributes/html/header.erb +0 -16
- data/templates/javadoc/class/html/header.erb +0 -4
- data/templates/javadoc/constants/html/constants.erb +0 -9
- data/templates/javadoc/constants/html/header.erb +0 -3
- data/templates/javadoc/constants/html/included.erb +0 -12
- data/templates/javadoc/constants/html/inherited.erb +0 -12
- data/templates/javadoc/constructor/html/header.erb +0 -10
- data/templates/javadoc/deprecated/html/main.erb +0 -0
- data/templates/javadoc/docstring/html/main.erb +0 -6
- data/templates/javadoc/fulldoc/html/all_methods.erb +0 -25
- data/templates/javadoc/fulldoc/html/all_namespaces.erb +0 -19
- data/templates/javadoc/fulldoc/html/app.js +0 -18
- data/templates/javadoc/fulldoc/html/header.erb +0 -15
- data/templates/javadoc/fulldoc/html/html_head.erb +0 -3
- data/templates/javadoc/fulldoc/html/index.erb +0 -18
- data/templates/javadoc/fulldoc/html/jquery.js +0 -11
- data/templates/javadoc/fulldoc/html/readme.erb +0 -15
- data/templates/javadoc/fulldoc/html/style.css +0 -22
- data/templates/javadoc/fulldoc/html/syntax_highlight.css +0 -21
- data/templates/javadoc/inheritance/html/header.erb +0 -6
- data/templates/javadoc/method/html/aliases.erb +0 -6
- data/templates/javadoc/method/html/header.erb +0 -4
- data/templates/javadoc/method/html/title.erb +0 -4
- data/templates/javadoc/methoddetails/html/header.erb +0 -8
- data/templates/javadoc/methoddetails/html/method_header.erb +0 -0
- data/templates/javadoc/methodmissing/html/header.erb +0 -12
- data/templates/javadoc/methodsignature/html/main.erb +0 -8
- data/templates/javadoc/methodsummary/html/header.erb +0 -5
- data/templates/javadoc/methodsummary/html/included.erb +0 -12
- data/templates/javadoc/methodsummary/html/inherited.erb +0 -12
- data/templates/javadoc/methodsummary/html/summary.erb +0 -25
- data/templates/javadoc/mixins/html/header.erb +0 -5
- data/templates/javadoc/module/html/header.erb +0 -4
- data/templates/javadoc/source/html/main.erb +0 -15
- data/templates/javadoc/tags/html/header.erb +0 -5
- data/templates/javadoc/tags/html/see.erb +0 -8
- data/templates/javadoc/tags/html/tags.erb +0 -19
- data/templates/javadoc/visibilitygroup/html/header.erb +0 -5
@@ -106,4 +106,7 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ClassHandler" do
|
|
106
106
|
Registry.at(:RT).superclass.should == P('XX::RT')
|
107
107
|
end
|
108
108
|
|
109
|
+
it "should not overwrite docstring with an empty one" do
|
110
|
+
Registry.at(:Zebra).docstring.should == "Docstring 2"
|
111
|
+
end
|
109
112
|
end
|
@@ -4,6 +4,8 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ClassVariableHandler"
|
|
4
4
|
before(:all) { parse_file :class_variable_handler_001, __FILE__ }
|
5
5
|
|
6
6
|
it "should not parse class variables inside methods" do
|
7
|
-
Registry.at("A::B::@@somevar")
|
7
|
+
obj = Registry.at("A::B::@@somevar")
|
8
|
+
obj.source.should == "@@somevar = \"hello\""
|
9
|
+
obj.value.should == '"hello"'
|
8
10
|
end
|
9
11
|
end
|
@@ -10,4 +10,42 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ConstantHandler" do
|
|
10
10
|
it "should only parse valid constants" do
|
11
11
|
Registry.at("A::B::notaconstant").should be_nil
|
12
12
|
end
|
13
|
+
|
14
|
+
it "should maintain newlines" do
|
15
|
+
Registry.at("A::B::MYCONSTANT").value.should == "A +\nB +\nC +\nD"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should turn Const = Struct.new(:sym) into class Const with attr :sym" do
|
19
|
+
obj = Registry.at("MyClass")
|
20
|
+
obj.should be_kind_of(CodeObjects::ClassObject)
|
21
|
+
attrs = obj.attributes[:instance]
|
22
|
+
[:a, :b, :c].each do |key|
|
23
|
+
attrs.should have_key(key)
|
24
|
+
attrs[key][:read].should_not be_nil
|
25
|
+
attrs[key][:write].should_not be_nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should turn Const = Struct.new('Name', :sym) into class Const with attr :sym" do
|
30
|
+
obj = Registry.at("NotMyClass")
|
31
|
+
obj.should be_kind_of(CodeObjects::ClassObject)
|
32
|
+
attrs = obj.attributes[:instance]
|
33
|
+
[:b, :c].each do |key|
|
34
|
+
attrs.should have_key(key)
|
35
|
+
attrs[key][:read].should_not be_nil
|
36
|
+
attrs[key][:write].should_not be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
Registry.at("NotMyClass2").should be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should turn Const = Struct.new into empty struct" do
|
43
|
+
obj = Registry.at("MyEmptyStruct")
|
44
|
+
obj.should_not be_nil
|
45
|
+
obj.attributes[:instance].should be_empty
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should raise undocumentable error in 1.9 parser for Struct.new assignment to non-const" do
|
49
|
+
undoc_error "nonconst = Struct.new"
|
50
|
+
end if RUBY19
|
13
51
|
end
|
@@ -1,4 +1,17 @@
|
|
1
1
|
class Foo
|
2
|
+
class << self
|
3
|
+
def inherited; end
|
4
|
+
def included; end
|
5
|
+
# docstring
|
6
|
+
def extended; end
|
7
|
+
def method_added; end
|
8
|
+
def method_removed; end
|
9
|
+
def method_undefined; end
|
10
|
+
end
|
11
|
+
|
12
|
+
# A docstring but no return type
|
13
|
+
def initialize; end
|
14
|
+
|
2
15
|
def ==(other)
|
3
16
|
'hello'
|
4
17
|
end
|
@@ -14,6 +27,8 @@ class Foo
|
|
14
27
|
|
15
28
|
# Docstring
|
16
29
|
def String :: hello; "" end
|
30
|
+
|
31
|
+
def self.new() end
|
17
32
|
|
18
33
|
def [](key = 'default') puts key end
|
19
34
|
def []=(key, value) end
|
@@ -32,4 +32,8 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ExceptionHandler" do
|
|
32
32
|
it "should handle complex class names" do
|
33
33
|
P('Testing#mymethod5').tag(:raise).types.should == ['YARD::Parser::UndocumentableError']
|
34
34
|
end
|
35
|
+
|
36
|
+
it "should ignore any raise calls on a receiver" do
|
37
|
+
P('Testing#mymethod9').tag(:raise).should be_nil
|
38
|
+
end
|
35
39
|
end
|
@@ -25,6 +25,10 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}MethodHandler" do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
it "should allow self.methname" do
|
29
|
+
Registry.at("Foo.new").should_not be_nil
|
30
|
+
end
|
31
|
+
|
28
32
|
it "should mark dynamic methods as such" do
|
29
33
|
P('Foo#dynamic').dynamic?.should == true
|
30
34
|
end
|
@@ -65,4 +69,22 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}MethodHandler" do
|
|
65
69
|
o3.docstring.should be_empty
|
66
70
|
o3.docstring.should be_blank
|
67
71
|
end
|
72
|
+
|
73
|
+
it "should set a return tag if not set on #initialize" do
|
74
|
+
meth = P('Foo#initialize')
|
75
|
+
|
76
|
+
meth.should have_tag(:return)
|
77
|
+
meth.tag(:return).types.should == ["Foo"]
|
78
|
+
meth.tag(:return).text.should == "a new instance of +Foo+"
|
79
|
+
end
|
80
|
+
|
81
|
+
%w(inherited included method_added method_removed method_undefined).each do |meth|
|
82
|
+
it "should set @private tag on #{meth} callback method if no docstring is set" do
|
83
|
+
P('Foo.' + meth).should have_tag(:private)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should not set @private tag on extended callback method since docstring is set" do
|
88
|
+
P('Foo.extended').should_not have_tag(:private)
|
89
|
+
end
|
68
90
|
end
|
@@ -12,9 +12,6 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}MixinHandler" do
|
|
12
12
|
Registry.at(:Y).class_mixins.should include(P(:A))
|
13
13
|
end
|
14
14
|
|
15
|
-
it "should handle includes for complex namespaces" do
|
16
|
-
end
|
17
|
-
|
18
15
|
it "should handle includes for modules that don't yet exist" do
|
19
16
|
Registry.at(:X).instance_mixins.should include(P(nil, :NOTEXIST))
|
20
17
|
end
|
@@ -35,4 +32,9 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}MixinHandler" do
|
|
35
32
|
it "should treat a mixed in Constant by taking its value as the real object name" do
|
36
33
|
P(:Y).instance_mixins.should include(Registry.at('B::D'))
|
37
34
|
end
|
35
|
+
|
36
|
+
it "should avoid including self for unresolved mixins of the same name" do
|
37
|
+
P("ABC::DEF::FOO").mixins.should == [P("ABC::FOO")]
|
38
|
+
P("ABC::DEF::BAR").mixins.should == [P("ABC::BAR")]
|
39
|
+
end
|
38
40
|
end
|
@@ -9,7 +9,7 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}YieldHandler" do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should handle an empty yield statement" do
|
12
|
-
P('Testing#mymethod').tag(:yield).
|
12
|
+
P('Testing#mymethod').tag(:yield).should be_nil
|
13
13
|
P('Testing#mymethod').tag(:yieldparam).should be_nil
|
14
14
|
end
|
15
15
|
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
|
2
|
+
require 'pp'
|
3
|
+
require 'stringio'
|
2
4
|
|
3
5
|
include YARD::Parser::Ruby
|
4
6
|
|
@@ -15,5 +17,19 @@ if RUBY19
|
|
15
17
|
ast.jump(:params).object_id.should == ast.object_id
|
16
18
|
end
|
17
19
|
end
|
20
|
+
|
21
|
+
describe '#pretty_print' do
|
22
|
+
it "should show a list of nodes" do
|
23
|
+
obj = YARD::Parser::Ruby::RubyParser.parse("# x\nbye", "x").ast
|
24
|
+
out = StringIO.new
|
25
|
+
PP.pp(obj, out)
|
26
|
+
out.rewind
|
27
|
+
out.read.should == "s(s(:var_ref,\n" +
|
28
|
+
" s(:ident, \"bye\", line: 2..2, source: 4..6),\n" +
|
29
|
+
" docstring: \"x\",\n" +
|
30
|
+
" line: 2..2,\n" +
|
31
|
+
" source: 4..6))\n"
|
32
|
+
end
|
33
|
+
end
|
18
34
|
end
|
19
35
|
end
|
@@ -220,4 +220,40 @@ eof
|
|
220
220
|
s.comments.should == ["comment"]
|
221
221
|
s.comments_range.should == (1..1)
|
222
222
|
end
|
223
|
+
|
224
|
+
it "should only look up to two lines back for comments" do
|
225
|
+
s = stmt <<-eof
|
226
|
+
# comments
|
227
|
+
|
228
|
+
# comments
|
229
|
+
|
230
|
+
def method; end
|
231
|
+
eof
|
232
|
+
s.comments.should == ["comments"]
|
233
|
+
|
234
|
+
s = stmt <<-eof
|
235
|
+
# comments
|
236
|
+
|
237
|
+
|
238
|
+
def method; end
|
239
|
+
eof
|
240
|
+
s.comments.should == nil
|
241
|
+
|
242
|
+
ss = stmts <<-eof
|
243
|
+
# comments
|
244
|
+
|
245
|
+
|
246
|
+
def method; end
|
247
|
+
|
248
|
+
# hello
|
249
|
+
def method2; end
|
250
|
+
eof
|
251
|
+
ss[0].comments.should == nil
|
252
|
+
ss[1].comments.should == ['hello']
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should handle CRLF (Windows) newlines" do
|
256
|
+
s = stmts("require 'foo'\r\n\r\n# Test Test\r\n# \r\n# Example:\r\n# example code\r\ndef test\r\nend\r\n")
|
257
|
+
s[1].comments.should == ['Test Test', '', 'Example:', ' example code']
|
258
|
+
end
|
223
259
|
end
|
@@ -6,6 +6,10 @@ if RUBY19
|
|
6
6
|
YARD::Parser::Ruby::RubyParser.new(stmt, nil).parse.root.first
|
7
7
|
end
|
8
8
|
|
9
|
+
def stmts(stmts)
|
10
|
+
YARD::Parser::Ruby::RubyParser.new(stmts, nil).parse.root
|
11
|
+
end
|
12
|
+
|
9
13
|
describe '#parse' do
|
10
14
|
it "should get comment line numbers" do
|
11
15
|
s = stmt <<-eof
|
@@ -49,6 +53,37 @@ if RUBY19
|
|
49
53
|
s.comments_range.should == (1..1)
|
50
54
|
end
|
51
55
|
|
56
|
+
it "should only look up to two lines back for comments" do
|
57
|
+
s = stmt <<-eof
|
58
|
+
# comments
|
59
|
+
|
60
|
+
# comments
|
61
|
+
|
62
|
+
def method; end
|
63
|
+
eof
|
64
|
+
s.comments.should == "comments"
|
65
|
+
|
66
|
+
s = stmt <<-eof
|
67
|
+
# comments
|
68
|
+
|
69
|
+
|
70
|
+
def method; end
|
71
|
+
eof
|
72
|
+
s.comments.should == nil
|
73
|
+
|
74
|
+
ss = stmts <<-eof
|
75
|
+
# comments
|
76
|
+
|
77
|
+
|
78
|
+
def method; end
|
79
|
+
|
80
|
+
# hello
|
81
|
+
def method2; end
|
82
|
+
eof
|
83
|
+
ss[0].comments.should == nil
|
84
|
+
ss[1].comments.should == 'hello'
|
85
|
+
end
|
86
|
+
|
52
87
|
it "should handle 1.9 lambda syntax with args" do
|
53
88
|
src = "->(a,b,c=1,*args,&block) { hello_world }"
|
54
89
|
stmt(src).source.should == src
|
@@ -90,6 +125,51 @@ if RUBY19
|
|
90
125
|
ast[0].should == "a"
|
91
126
|
ast.source.should == "a:"
|
92
127
|
end
|
128
|
+
|
129
|
+
it "should handle begin/rescue blocks" do
|
130
|
+
ast = stmt("begin; X; rescue => e; Y end").jump(:rescue)
|
131
|
+
ast.source.should == "rescue => e; Y end"
|
132
|
+
|
133
|
+
ast = stmt("begin; X; rescue A => e; Y end").jump(:rescue)
|
134
|
+
ast.source.should == "rescue A => e; Y end"
|
135
|
+
|
136
|
+
ast = stmt("begin; X; rescue A, B => e; Y end").jump(:rescue)
|
137
|
+
ast.source.should == "rescue A, B => e; Y end"
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should handle method rescue blocks" do
|
141
|
+
ast = stmt("def x; A; rescue Y; B end")
|
142
|
+
ast.source.should == "def x; A; rescue Y; B end"
|
143
|
+
ast.jump(:rescue).source.should == "rescue Y; B end"
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should handle defs with keywords as method name" do
|
147
|
+
ast = stmt("# docstring\nclass A;\ndef class; end\nend")
|
148
|
+
ast.jump(:class).docstring.should == "docstring"
|
149
|
+
ast.jump(:class).line_range.should == (2..4)
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should end source properly on array reference" do
|
153
|
+
ast = stmt("AS[0, 1 ] ")
|
154
|
+
ast.source.should == 'AS[0, 1 ]'
|
155
|
+
|
156
|
+
ast = stmt("def x(a = S[1]) end").jump(:default_arg)
|
157
|
+
ast.source.should == 'a = S[1]'
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should end source properly on if/unless mod" do
|
161
|
+
%w(if unless while).each do |mod|
|
162
|
+
stmt("A=1 #{mod} true").source.should == "A=1 #{mod} true"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should show proper source for assignment" do
|
167
|
+
stmt("A=1").jump(:assign).source.should == "A=1"
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should sho" do
|
171
|
+
p stmt("A = Struct.new :a, :b")[1].parameters
|
172
|
+
end
|
93
173
|
end
|
94
174
|
end
|
95
175
|
end
|
@@ -7,7 +7,7 @@ describe YARD::Parser::SourceParser do
|
|
7
7
|
|
8
8
|
describe '#parse_string' do
|
9
9
|
it "should parse basic Ruby code" do
|
10
|
-
|
10
|
+
YARD.parse_string(<<-eof)
|
11
11
|
module Hello
|
12
12
|
class Hi
|
13
13
|
# Docstring
|
@@ -21,6 +21,46 @@ describe YARD::Parser::SourceParser do
|
|
21
21
|
Registry.at("Hello::Hi#me").docstring.should == "Docstring\nDocstring2"
|
22
22
|
Registry.at("Hello::Hi#me").docstring.line_range.should == (3..4)
|
23
23
|
end
|
24
|
+
|
25
|
+
it "should only use prepended comments for an object" do
|
26
|
+
YARD.parse_string(<<-eof)
|
27
|
+
# Test
|
28
|
+
|
29
|
+
# PASS
|
30
|
+
module Hello
|
31
|
+
end # FAIL
|
32
|
+
eof
|
33
|
+
Registry.at(:Hello).docstring.should == "PASS"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should add comments appended to an object's first line" do
|
37
|
+
YARD.parse_string <<-eof
|
38
|
+
module Hello # PASS
|
39
|
+
HELLO
|
40
|
+
end
|
41
|
+
module Hello2
|
42
|
+
end # FAIL
|
43
|
+
|
44
|
+
|
45
|
+
module Hello3 # PASS
|
46
|
+
# CANNOT DIFFERENTIATE
|
47
|
+
def x; end
|
48
|
+
end
|
49
|
+
eof
|
50
|
+
|
51
|
+
# TODO: unify behaviour
|
52
|
+
if RUBY18
|
53
|
+
Registry.at(:Hello).docstring.should == ""
|
54
|
+
Registry.at(:Hello2).docstring.should == "FAIL"
|
55
|
+
Registry.at(:Hello3).docstring.should == ""
|
56
|
+
Registry.at('Hello3#x').docstring.should == "CANNOT DIFFERENTIATE"
|
57
|
+
else
|
58
|
+
Registry.at(:Hello).docstring.should == "PASS"
|
59
|
+
Registry.at(:Hello2).docstring.should == ""
|
60
|
+
Registry.at(:Hello3).docstring.should == ""
|
61
|
+
Registry.at('Hello3#x').docstring.should == "PASS\nCANNOT DIFFERENTIATE"
|
62
|
+
end
|
63
|
+
end
|
24
64
|
end
|
25
65
|
|
26
66
|
describe '#parse' do
|
@@ -65,7 +105,13 @@ describe YARD::Parser::SourceParser do
|
|
65
105
|
msgs[2].should =~ /Missing object MyModule/
|
66
106
|
msgs[3].should =~ /Processing .+parse_in_order_002.+/
|
67
107
|
msgs[4].should =~ /Re-processing .+parse_in_order_001.+/
|
68
|
-
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should attempt to order files by length (process toplevel files first)" do
|
111
|
+
%w(a a/b a/b/c).each do |file|
|
112
|
+
IO.should_receive(:read).with(file).ordered.and_return('')
|
113
|
+
end
|
114
|
+
YARD.parse %w(a/b/c a/b a)
|
69
115
|
end
|
70
116
|
end
|
71
117
|
|