yard 0.7.5 → 0.8.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 +10 -2
- data/ChangeLog +1263 -38
- data/LEGAL +5 -5
- data/LICENSE +1 -1
- data/README.md +91 -82
- data/Rakefile +6 -6
- data/benchmarks/builtins_vs_eval.rb +1 -1
- data/benchmarks/erb_vs_erubis.rb +4 -4
- data/benchmarks/generation.rb +5 -5
- data/benchmarks/parsing.rb +2 -2
- data/benchmarks/registry_store_types.rb +48 -0
- data/bin/yard +9 -1
- data/bin/yardoc +9 -1
- data/bin/yri +10 -2
- data/docs/CodeObjects.md +10 -10
- data/docs/GettingStarted.md +85 -83
- data/docs/Handlers.md +21 -21
- data/docs/Overview.md +7 -7
- data/docs/Parser.md +30 -30
- data/docs/Tags.md +250 -554
- data/docs/TagsArch.md +123 -0
- data/docs/Templates.md +58 -80
- data/docs/WhatsNew.md +378 -133
- 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/yard.rb +1 -10
- data/lib/yard/autoload.rb +75 -27
- data/lib/yard/cli/command.rb +5 -2
- data/lib/yard/cli/command_parser.rb +3 -2
- data/lib/yard/cli/diff.rb +1 -1
- data/lib/yard/cli/i18n.rb +69 -0
- data/lib/yard/cli/list.rb +1 -1
- data/lib/yard/cli/server.rb +30 -7
- data/lib/yard/cli/stats.rb +5 -6
- data/lib/yard/cli/yardoc.rb +95 -45
- data/lib/yard/cli/yri.rb +24 -3
- data/lib/yard/code_objects/base.rb +35 -4
- data/lib/yard/code_objects/extra_file_object.rb +1 -1
- data/lib/yard/code_objects/macro_object.rb +56 -99
- data/lib/yard/code_objects/method_object.rb +44 -6
- data/lib/yard/config.rb +18 -8
- data/lib/yard/core_ext/symbol_hash.rb +1 -1
- data/lib/yard/docstring.rb +45 -85
- data/lib/yard/docstring_parser.rb +269 -0
- data/lib/yard/handlers/base.rb +129 -118
- 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 +165 -0
- data/lib/yard/handlers/c/init_handler.rb +16 -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 +22 -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 +41 -30
- data/lib/yard/handlers/ruby/alias_handler.rb +0 -2
- data/lib/yard/handlers/ruby/attribute_handler.rb +16 -17
- data/lib/yard/handlers/ruby/base.rb +10 -6
- data/lib/yard/handlers/ruby/comment_handler.rb +9 -0
- data/lib/yard/handlers/ruby/dsl_handler.rb +14 -0
- data/lib/yard/handlers/ruby/dsl_handler_methods.rb +71 -0
- data/lib/yard/handlers/ruby/legacy/alias_handler.rb +0 -3
- data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +16 -17
- data/lib/yard/handlers/ruby/legacy/base.rb +28 -6
- data/lib/yard/handlers/ruby/legacy/comment_handler.rb +9 -0
- data/lib/yard/handlers/ruby/legacy/dsl_handler.rb +16 -0
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +0 -2
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +1 -1
- data/lib/yard/handlers/ruby/legacy/module_function_handler.rb +18 -0
- data/lib/yard/handlers/ruby/method_handler.rb +10 -15
- data/lib/yard/handlers/ruby/mixin_handler.rb +1 -1
- data/lib/yard/handlers/ruby/module_function_handler.rb +26 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +3 -2
- data/lib/yard/i18n/pot_generator.rb +281 -0
- data/lib/yard/i18n/text.rb +72 -0
- data/lib/yard/logging.rb +3 -7
- data/lib/yard/options.rb +216 -0
- data/lib/yard/parser/c/c_parser.rb +225 -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 +91 -1
- data/lib/yard/parser/ruby/legacy/ruby_parser.rb +1 -0
- data/lib/yard/parser/ruby/legacy/statement.rb +7 -2
- data/lib/yard/parser/ruby/legacy/statement_list.rb +13 -22
- data/lib/yard/parser/ruby/ruby_parser.rb +87 -26
- data/lib/yard/parser/source_parser.rb +89 -88
- data/lib/yard/rake/yardoc_task.rb +1 -1
- data/lib/yard/registry.rb +21 -10
- data/lib/yard/registry_store.rb +48 -0
- data/lib/yard/serializers/file_system_serializer.rb +18 -20
- data/lib/yard/serializers/yardoc_serializer.rb +1 -0
- data/lib/yard/server/adapter.rb +2 -2
- data/lib/yard/server/commands/base.rb +1 -1
- data/lib/yard/server/commands/display_object_command.rb +13 -6
- data/lib/yard/server/commands/frames_command.rb +4 -21
- data/lib/yard/server/commands/library_command.rb +57 -11
- data/lib/yard/server/commands/list_command.rb +10 -34
- data/lib/yard/server/commands/search_command.rb +8 -2
- data/lib/yard/server/doc_server_helper.rb +34 -0
- data/lib/yard/server/rack_adapter.rb +5 -1
- data/lib/yard/server/router.rb +4 -10
- data/lib/yard/server/static_caching.rb +2 -2
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +2 -2
- data/lib/yard/server/templates/default/fulldoc/html/js/live.js +0 -15
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +3 -3
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +8 -0
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +1 -1
- data/lib/yard/server/templates/doc_server/search/html/setup.rb +1 -1
- data/lib/yard/tags/default_factory.rb +31 -4
- data/lib/yard/tags/directives.rb +593 -0
- data/lib/yard/tags/library.rb +437 -35
- data/lib/yard/templates/engine.rb +17 -12
- data/lib/yard/templates/helpers/base_helper.rb +8 -2
- data/lib/yard/templates/helpers/html_helper.rb +57 -14
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +1 -1
- data/lib/yard/templates/helpers/markup_helper.rb +9 -9
- data/lib/yard/templates/helpers/text_helper.rb +2 -2
- data/lib/yard/templates/template.rb +42 -13
- data/lib/yard/templates/template_options.rb +81 -0
- data/spec/cli/command_parser_spec.rb +4 -4
- data/spec/cli/command_spec.rb +3 -3
- data/spec/cli/config_spec.rb +13 -13
- data/spec/cli/diff_spec.rb +13 -10
- data/spec/cli/gems_spec.rb +12 -12
- data/spec/cli/help_spec.rb +2 -2
- data/spec/cli/i18n_spec.rb +111 -0
- data/spec/cli/server_spec.rb +66 -18
- data/spec/cli/stats_spec.rb +15 -15
- data/spec/cli/yardoc_spec.rb +124 -97
- data/spec/cli/yri_spec.rb +14 -12
- data/spec/code_objects/base_spec.rb +104 -46
- data/spec/code_objects/class_object_spec.rb +33 -33
- data/spec/code_objects/code_object_list_spec.rb +5 -5
- data/spec/code_objects/constants_spec.rb +4 -3
- data/spec/code_objects/extra_file_object_spec.rb +19 -19
- data/spec/code_objects/macro_object_spec.rb +31 -37
- data/spec/code_objects/method_object_spec.rb +46 -23
- data/spec/code_objects/module_object_spec.rb +16 -16
- data/spec/code_objects/namespace_object_spec.rb +6 -6
- data/spec/code_objects/proxy_spec.rb +19 -19
- data/spec/config_spec.rb +33 -24
- data/spec/core_ext/array_spec.rb +1 -1
- data/spec/core_ext/file_spec.rb +8 -8
- data/spec/core_ext/hash_spec.rb +1 -1
- data/spec/core_ext/insertion_spec.rb +3 -3
- data/spec/core_ext/module_spec.rb +1 -1
- data/spec/core_ext/string_spec.rb +6 -6
- data/spec/core_ext/symbol_hash_spec.rb +11 -11
- data/spec/docstring_parser_spec.rb +207 -0
- data/spec/docstring_spec.rb +33 -146
- data/spec/handlers/alias_handler_spec.rb +14 -14
- data/spec/handlers/attribute_handler_spec.rb +20 -20
- data/spec/handlers/base_spec.rb +16 -16
- 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 +64 -0
- data/spec/handlers/c/constant_handler_spec.rb +68 -0
- data/spec/handlers/c/init_handler_spec.rb +36 -0
- data/spec/handlers/c/method_handler_spec.rb +228 -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 +43 -0
- data/spec/handlers/c/path_handler_spec.rb +35 -0
- data/spec/handlers/c/spec_helper.rb +11 -0
- data/spec/handlers/c/struct_handler_spec.rb +15 -0
- data/spec/handlers/class_condition_handler_spec.rb +10 -10
- data/spec/handlers/class_handler_spec.rb +38 -38
- data/spec/handlers/class_variable_handler_spec.rb +1 -1
- data/spec/handlers/constant_handler_spec.rb +7 -7
- data/spec/handlers/{macro_handler_spec.rb → dsl_handler_spec.rb} +72 -53
- data/spec/handlers/examples/alias_handler_001.rb.txt +5 -5
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +9 -9
- data/spec/handlers/examples/class_handler_001.rb.txt +1 -1
- data/spec/handlers/examples/dsl_handler_001.rb.txt +110 -0
- data/spec/handlers/examples/exception_handler_001.rb.txt +14 -14
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +2 -2
- data/spec/handlers/examples/method_handler_001.rb.txt +16 -16
- data/spec/handlers/examples/mixin_handler_001.rb.txt +8 -4
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +1 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +3 -3
- data/spec/handlers/examples/yield_handler_001.rb.txt +13 -14
- data/spec/handlers/exception_handler_spec.rb +9 -9
- data/spec/handlers/extend_handler_spec.rb +2 -2
- data/spec/handlers/legacy_base_spec.rb +34 -34
- data/spec/handlers/method_condition_handler_spec.rb +2 -2
- data/spec/handlers/method_handler_spec.rb +33 -33
- data/spec/handlers/mixin_handler_spec.rb +13 -9
- data/spec/handlers/module_function_handler_spec.rb +82 -0
- data/spec/handlers/module_handler_spec.rb +6 -6
- data/spec/handlers/private_constant_handler_spec.rb +3 -3
- data/spec/handlers/processor_spec.rb +5 -5
- data/spec/handlers/ruby/base_spec.rb +10 -6
- data/spec/handlers/ruby/legacy/base_spec.rb +11 -7
- data/spec/handlers/spec_helper.rb +2 -3
- data/spec/handlers/visibility_handler_spec.rb +6 -6
- data/spec/handlers/yield_handler_spec.rb +8 -8
- data/spec/i18n/pot_generator_spec.rb +244 -0
- data/spec/i18n/text_spec.rb +69 -0
- data/spec/options_spec.rb +160 -0
- data/spec/parser/base_spec.rb +3 -3
- data/spec/parser/c_parser_spec.rb +31 -257
- data/spec/parser/examples/array.c.txt +187 -187
- data/spec/parser/examples/extrafile.c.txt +1 -1
- data/spec/parser/examples/override.c.txt +1 -1
- data/spec/parser/ruby/ast_node_spec.rb +1 -1
- data/spec/parser/ruby/legacy/statement_list_spec.rb +24 -24
- data/spec/parser/ruby/legacy/token_list_spec.rb +7 -7
- data/spec/parser/ruby/ruby_parser_spec.rb +56 -34
- data/spec/parser/source_parser_spec.rb +125 -65
- data/spec/parser/tag_parsing_spec.rb +4 -4
- data/spec/rake/yardoc_task_spec.rb +10 -8
- data/spec/registry_spec.rb +65 -36
- data/spec/registry_store_spec.rb +90 -40
- data/spec/serializers/file_system_serializer_spec.rb +12 -12
- data/spec/serializers/yardoc_serializer_spec.rb +2 -2
- data/spec/server/adapter_spec.rb +3 -3
- data/spec/server/commands/base_spec.rb +8 -8
- data/spec/server/commands/library_command_spec.rb +3 -3
- data/spec/server/commands/static_file_command_spec.rb +7 -7
- data/spec/server/doc_server_helper_spec.rb +1 -1
- data/spec/server/doc_server_serializer_spec.rb +6 -6
- data/spec/server/rack_adapter_spec.rb +3 -3
- data/spec/server/router_spec.rb +19 -19
- data/spec/server/static_caching_spec.rb +4 -4
- data/spec/spec_helper.rb +7 -7
- data/spec/tags/default_factory_spec.rb +24 -16
- data/spec/tags/directives_spec.rb +422 -0
- data/spec/tags/library_spec.rb +15 -4
- data/spec/tags/overload_tag_spec.rb +6 -6
- data/spec/tags/ref_tag_list_spec.rb +8 -8
- data/spec/templates/class_spec.rb +7 -7
- data/spec/templates/constant_spec.rb +7 -7
- data/spec/templates/engine_spec.rb +28 -36
- data/spec/templates/examples/class001.html +108 -108
- data/spec/templates/examples/class002.html +17 -17
- data/spec/templates/examples/constant001.txt +1 -1
- data/spec/templates/examples/method001.html +45 -45
- data/spec/templates/examples/method002.html +25 -25
- data/spec/templates/examples/method003.html +60 -60
- data/spec/templates/examples/method004.html +7 -7
- data/spec/templates/examples/method005.html +28 -28
- data/spec/templates/examples/module001.html +321 -321
- data/spec/templates/examples/module001.txt +1 -1
- data/spec/templates/examples/module002.html +130 -130
- data/spec/templates/examples/module003.html +74 -74
- data/spec/templates/examples/module004.html +388 -0
- data/spec/templates/helpers/base_helper_spec.rb +32 -32
- data/spec/templates/helpers/html_helper_spec.rb +87 -68
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +9 -9
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +16 -16
- data/spec/templates/helpers/markup_helper_spec.rb +31 -28
- data/spec/templates/helpers/method_helper_spec.rb +7 -7
- data/spec/templates/helpers/shared_signature_examples.rb +9 -7
- data/spec/templates/helpers/text_helper_spec.rb +3 -3
- data/spec/templates/method_spec.rb +13 -13
- data/spec/templates/module_spec.rb +70 -24
- data/spec/templates/onefile_spec.rb +32 -15
- data/spec/templates/section_spec.rb +23 -23
- data/spec/templates/spec_helper.rb +31 -1
- data/spec/templates/tag_spec.rb +5 -5
- data/spec/templates/template_spec.rb +54 -46
- data/spec/verifier_spec.rb +5 -5
- data/templates/default/class/setup.rb +2 -2
- data/templates/default/docstring/html/abstract.erb +1 -1
- data/templates/default/docstring/html/note.erb +1 -1
- data/templates/default/docstring/html/private.erb +1 -1
- data/templates/default/docstring/html/todo.erb +1 -1
- data/templates/default/docstring/setup.rb +2 -2
- data/templates/default/fulldoc/html/css/full_list.css +4 -2
- data/templates/default/fulldoc/html/css/style.css +50 -44
- data/templates/default/fulldoc/html/frames.erb +21 -6
- data/templates/default/fulldoc/html/full_list.erb +5 -3
- data/templates/default/fulldoc/html/{full_list_files.erb → full_list_file.erb} +0 -0
- data/templates/default/fulldoc/html/js/app.js +29 -26
- data/templates/default/fulldoc/html/js/full_list.js +9 -9
- data/templates/default/fulldoc/html/js/jquery.js +4 -16
- data/templates/default/fulldoc/html/setup.rb +42 -38
- data/templates/default/layout/dot/header.erb +1 -1
- data/templates/default/layout/html/breadcrumb.erb +6 -6
- data/templates/default/layout/html/files.erb +1 -1
- data/templates/default/layout/html/footer.erb +1 -1
- data/templates/default/layout/html/headers.erb +3 -6
- data/templates/default/layout/html/index.erb +1 -1
- data/templates/default/layout/html/layout.erb +3 -7
- data/templates/default/layout/html/objects.erb +1 -1
- data/templates/default/layout/html/script_setup.erb +5 -0
- data/templates/default/layout/html/search.erb +4 -1
- data/templates/default/layout/html/setup.rb +8 -8
- data/templates/default/method_details/html/method_signature.erb +10 -3
- data/templates/default/method_details/setup.rb +1 -0
- data/templates/default/module/dot/info.erb +1 -1
- data/templates/default/module/dot/setup.rb +2 -2
- data/templates/default/module/html/attribute_details.erb +1 -1
- data/templates/default/module/html/children.erb +1 -1
- data/templates/default/module/html/defines.erb +1 -1
- data/templates/default/module/html/inherited_methods.erb +5 -4
- data/templates/default/module/html/item_summary.erb +15 -5
- data/templates/default/module/html/method_details_list.erb +2 -2
- data/templates/default/module/setup.rb +25 -12
- data/templates/default/module/text/setup.rb +1 -1
- data/templates/default/onefile/html/layout.erb +1 -1
- data/templates/default/onefile/html/setup.rb +2 -2
- data/templates/default/tags/html/example.erb +4 -2
- data/templates/default/tags/html/option.erb +1 -1
- data/templates/default/tags/html/overload.erb +1 -1
- data/templates/default/tags/html/see.erb +1 -1
- data/templates/default/tags/html/tag.erb +1 -1
- data/templates/default/tags/setup.rb +4 -3
- data/templates/guide/fulldoc/html/css/style.css +8 -8
- data/templates/guide/fulldoc/html/js/app.js +6 -6
- data/templates/guide/fulldoc/html/setup.rb +12 -12
- data/templates/guide/layout/html/layout.erb +11 -11
- data/templates/guide/layout/html/setup.rb +9 -9
- data/templates/guide/method/html/header.erb +2 -2
- data/templates/guide/method/html/setup.rb +1 -1
- metadata +68 -18
- data/bin/yard-graph +0 -4
- data/bin/yard-server +0 -4
- data/docs/Glossary.md +0 -12
- data/lib/yard/handlers/ruby/legacy/macro_handler.rb +0 -39
- data/lib/yard/handlers/ruby/macro_handler.rb +0 -40
- data/lib/yard/handlers/ruby/macro_handler_methods.rb +0 -131
- data/lib/yard/parser/c_parser.rb +0 -497
- data/lib/yard/server/templates/default/layout/html/headers.erb +0 -16
- data/lib/yard/server/templates/doc_server/frames/html/frames.erb +0 -13
- data/lib/yard/server/templates/doc_server/frames/html/setup.rb +0 -3
- data/lib/yard/server/templates/doc_server/full_list/html/full_list.erb +0 -34
- data/lib/yard/server/templates/doc_server/full_list/html/setup.rb +0 -20
- data/spec/handlers/examples/macro_handler_001.rb.txt +0 -83
@@ -2,11 +2,11 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MethodConditionHandler" do
|
4
4
|
before(:all) { parse_file :method_condition_handler_001, __FILE__ }
|
5
|
-
|
5
|
+
|
6
6
|
it "should not parse regular if blocks in methods" do
|
7
7
|
Registry.at('#b').should be_nil
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "should parse if/unless blocks in the form X if COND" do
|
11
11
|
Registry.at('#c').should_not be_nil
|
12
12
|
Registry.at('#d').should_not be_nil
|
@@ -3,45 +3,45 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MethodHandler" do
|
4
4
|
before(:all) do
|
5
5
|
log.enter_level(Logger::ERROR) do
|
6
|
-
parse_file :method_handler_001, __FILE__
|
6
|
+
parse_file :method_handler_001, __FILE__
|
7
7
|
end
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "should add methods to parent's #meths list" do
|
11
11
|
P(:Foo).meths.should include(P("Foo#method1"))
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "should parse/add class methods (self.method2)" do
|
15
15
|
P(:Foo).meths.should include(P("Foo.method2"))
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should parse/add class methods from other namespaces (String.hello)" do
|
19
19
|
P("String.hello").should be_instance_of(CodeObjects::MethodObject)
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
[:[], :[]=, :allowed?, :/, :=~, :==, :`, :|, :*, :&, :%, :'^', :-@, :+@, :'~@'].each do |name|
|
23
23
|
it "should allow valid method #{name}" do
|
24
24
|
Registry.at("Foo##{name}").should_not be_nil
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "should allow self.methname" do
|
29
29
|
Registry.at("Foo.new").should_not be_nil
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "should mark dynamic methods as such" do
|
33
33
|
P('Foo#dynamic').dynamic?.should == true
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it "should show that a method is explicitly defined (if it was originally defined implicitly by attribute)" do
|
37
37
|
P('Foo#method1').is_explicit?.should == true
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
it "should handle parameters" do
|
41
41
|
P('Foo#[]').parameters.should == [['key', "'default'"]]
|
42
42
|
P('Foo#/').parameters.should == [['x', "File.new('x', 'w')"], ['y', '2']]
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
it "should handle opts = {} as parameter" do
|
46
46
|
P('Foo#optsmeth').parameters.should == [['x', nil], ['opts', '{}']]
|
47
47
|
end
|
@@ -69,87 +69,87 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MethodHandler"
|
|
69
69
|
o3.docstring.should be_empty
|
70
70
|
o3.docstring.should be_blank
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
it "should set a return tag if not set on #initialize" do
|
74
74
|
meth = P('Foo#initialize')
|
75
|
-
|
75
|
+
|
76
76
|
meth.should have_tag(:return)
|
77
77
|
meth.tag(:return).types.should == ["Foo"]
|
78
78
|
meth.tag(:return).text.should == "a new instance of Foo"
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
%w(inherited included method_added method_removed method_undefined).each do |meth|
|
82
82
|
it "should set @private tag on #{meth} callback method if no docstring is set" do
|
83
83
|
P('Foo.' + meth).should have_tag(:private)
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
it "should not set @private tag on extended callback method since docstring is set" do
|
88
88
|
P('Foo.extended').should_not have_tag(:private)
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
it "should add @return [Boolean] tag to methods ending in ? without return types" do
|
92
92
|
meth = P('Foo#boolean?')
|
93
93
|
meth.should have_tag(:return)
|
94
94
|
meth.tag(:return).types.should == ['Boolean']
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
it "should add Boolean type to return tag without types" do
|
98
98
|
meth = P('Foo#boolean2?')
|
99
99
|
meth.should have_tag(:return)
|
100
100
|
meth.tag(:return).types.should == ['Boolean']
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
it "should not change return type for method ending in ? with return types set" do
|
104
104
|
meth = P('Foo#boolean3?')
|
105
105
|
meth.should have_tag(:return)
|
106
106
|
meth.tag(:return).types.should == ['NotBoolean', 'nil']
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
it "should not change return type for method ending in ? with return types set by @overload" do
|
110
110
|
meth = P('Foo#rainy?')
|
111
111
|
meth.should have_tag(:overload)
|
112
112
|
meth.tag(:overload).should have_tag(:return)
|
113
113
|
meth.should_not have_tag(:return)
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
it "should add method writer to existing attribute" do
|
117
117
|
Registry.at('Foo#attr_name').should be_reader
|
118
118
|
Registry.at('Foo#attr_name=').should be_writer
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
it "should add method reader to existing attribute" do
|
122
122
|
Registry.at('Foo#attr_name2').should be_reader
|
123
123
|
Registry.at('Foo#attr_name2=').should be_writer
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
it "should generate an options parameter if @option refers to an undocumented parameter" do
|
127
127
|
meth = P('Foo#auto_opts')
|
128
128
|
meth.should have_tag(:param)
|
129
129
|
meth.tag(:param).name.should == "opts"
|
130
130
|
meth.tag(:param).types.should == ["Hash"]
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
it "should raise an undocumentable error when a method is defined on an object instance" do
|
134
134
|
undoc_error "error = Foo; def error.at(foo) end"
|
135
135
|
Registry.at('error').should be_nil
|
136
136
|
end
|
137
|
-
|
137
|
+
|
138
138
|
it "should allow class method to be defined on constant reference object" do
|
139
139
|
Registry.at('Foo.meth_on_const').should_not be_nil
|
140
140
|
Registry.at('Foo.meth2_on_const').should_not be_nil
|
141
141
|
end
|
142
|
-
|
142
|
+
|
143
143
|
it "should copy alias information on method (re-)definition to new method" do
|
144
144
|
Registry.at('D').aliases.should be_empty
|
145
145
|
Registry.at('D#b').is_alias?.should == false
|
146
146
|
Registry.at('D#a').is_alias?.should == false
|
147
147
|
end
|
148
|
-
|
148
|
+
|
149
149
|
it "should add macros for class methods" do
|
150
150
|
macro = CodeObjects::MacroObject.find('prop')
|
151
151
|
macro.should_not be_nil
|
152
|
-
macro.macro_data.should == "
|
152
|
+
macro.macro_data.should == "@!method $1(value)\n$3\n@return [$2]"
|
153
153
|
macro.method_object.should == Registry.at('E.property')
|
154
154
|
macro.should be_attached
|
155
155
|
obj = Registry.at('E#foo')
|
@@ -158,22 +158,22 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MethodHandler"
|
|
158
158
|
obj.signature.should == 'def foo(value)'
|
159
159
|
obj.tag(:return).types.should == ['String']
|
160
160
|
end
|
161
|
-
|
161
|
+
|
162
162
|
it "should handle macros on any object" do
|
163
163
|
macro = CodeObjects::MacroObject.find('xyz')
|
164
164
|
macro.should_not be_nil
|
165
|
-
macro.macro_data.should == '
|
165
|
+
macro.macro_data.should == '@!method $1'
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
it "should skip macros on instance methods" do
|
169
169
|
Registry.at('E#a').should be_nil
|
170
170
|
end
|
171
|
-
|
171
|
+
|
172
172
|
it "should warn if the macro name is invalid" do
|
173
|
-
log.should_receive(:warn).with(/Invalid
|
174
|
-
YARD.parse_string "class Foo\n#
|
173
|
+
log.should_receive(:warn).with(/Invalid directive.*@!macro/)
|
174
|
+
YARD.parse_string "class Foo\n# @!macro\ndef self.foo; end\nend"
|
175
175
|
end
|
176
|
-
|
176
|
+
|
177
177
|
it "should handle 'def end' methods" do
|
178
178
|
obj = Registry.at('F::A#foo')
|
179
179
|
obj.should_not be_nil
|
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MixinHandler" do
|
4
4
|
before(:all) { parse_file :mixin_handler_001, __FILE__ }
|
5
|
-
|
5
|
+
|
6
6
|
it "should handle includes from classes or modules" do
|
7
7
|
Registry.at(:X).instance_mixins.should include(P(:A))
|
8
8
|
Registry.at(:Y).instance_mixins.should include(P(:A))
|
@@ -11,38 +11,42 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MixinHandler"
|
|
11
11
|
it "should handle includes in class << self" do
|
12
12
|
Registry.at(:Y).class_mixins.should include(P(:A))
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should handle includes for modules that don't yet exist" do
|
16
16
|
Registry.at(:X).instance_mixins.should include(P(nil, :NOTEXIST))
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "should set the type of non-existing modules to :module" do
|
20
20
|
P(:NOTEXIST).type.should == :module
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should handle includes with multiple parameters" do
|
24
24
|
Registry.at(:X).should_not be_nil
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
it "should handle complex include statements" do
|
28
28
|
P(:Y).instance_mixins.should include(P('B::C'))
|
29
29
|
P(:Y).instance_mixins.should include(P(:B))
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "should treat a mixed in Constant by taking its value as the real object name" do
|
33
33
|
P(:Y).instance_mixins.should include(Registry.at('B::D'))
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
|
+
it "should add includes in the correct order when include is given multiple arguments" do
|
37
|
+
P(:Z).instance_mixins.should == [P(:A), P(:B)]
|
38
|
+
end
|
39
|
+
|
36
40
|
it "should avoid including self for unresolved mixins of the same name" do
|
37
41
|
P("ABC::DEF::FOO").mixins.should == [P("ABC::FOO")]
|
38
42
|
P("ABC::DEF::BAR").mixins.should == [P("ABC::BAR")]
|
39
43
|
end
|
40
|
-
|
44
|
+
|
41
45
|
it "should raise undocumentable error if argument is variable" do
|
42
46
|
undoc_error "module X; include invalid; end"
|
43
47
|
Registry.at('X').mixins.should == []
|
44
48
|
end
|
45
|
-
|
49
|
+
|
46
50
|
it "should parse all other arguments before erroring out on undocumentable error" do
|
47
51
|
undoc_error "module X; include invalid, Y; end"
|
48
52
|
Registry.at('X').mixins.should == [P('Y')]
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}VisibilityHandler" do
|
4
|
+
after { Registry.clear }
|
5
|
+
|
6
|
+
def assert_module_function(namespace, name)
|
7
|
+
klass = Registry.at("#{namespace}.#{name}")
|
8
|
+
instance = Registry.at("#{namespace}##{name}")
|
9
|
+
klass.should_not be_nil
|
10
|
+
instance.should_not be_nil
|
11
|
+
klass.should be_module_function
|
12
|
+
instance.should_not be_module_function
|
13
|
+
klass.visibility.should == :public
|
14
|
+
instance.visibility.should == :private
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be able to create a module function with parameters" do
|
18
|
+
YARD.parse_string <<-eof
|
19
|
+
module Foo
|
20
|
+
def bar; end
|
21
|
+
def baz; end
|
22
|
+
|
23
|
+
module_function :bar, :baz
|
24
|
+
end
|
25
|
+
eof
|
26
|
+
assert_module_function('Foo', 'bar')
|
27
|
+
assert_module_function('Foo', 'baz')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be able to set scope for duration of block without params" do
|
31
|
+
YARD.parse_string <<-eof
|
32
|
+
module Foo
|
33
|
+
def qux; end
|
34
|
+
|
35
|
+
module_function
|
36
|
+
|
37
|
+
def bar; end
|
38
|
+
def baz; end
|
39
|
+
end
|
40
|
+
eof
|
41
|
+
Registry.at('Foo.qux').should be_nil
|
42
|
+
assert_module_function('Foo', 'bar')
|
43
|
+
assert_module_function('Foo', 'baz')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should handle all method names in parameters" do
|
47
|
+
YARD.parse_string <<-eof
|
48
|
+
module Foo
|
49
|
+
def -(t); end
|
50
|
+
def ==(other); end
|
51
|
+
def a?; end
|
52
|
+
module_function :-, '==', :a?
|
53
|
+
end
|
54
|
+
eof
|
55
|
+
assert_module_function('Foo', '-')
|
56
|
+
assert_module_function('Foo', '==')
|
57
|
+
assert_module_function('Foo', 'a?')
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should only accept strings and symbols" do
|
61
|
+
YARD.parse_string <<-eof
|
62
|
+
module Foo
|
63
|
+
module_function name
|
64
|
+
module_function *argument
|
65
|
+
module_function *(method_call)
|
66
|
+
end
|
67
|
+
eof
|
68
|
+
Registry.at('Foo#name').should be_nil
|
69
|
+
Registry.at('Foo#argument').should be_nil
|
70
|
+
Registry.at('Foo#method_call').should be_nil
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should handle constants passed in as symbols" do
|
74
|
+
YARD.parse_string <<-eof
|
75
|
+
module Foo
|
76
|
+
def Foo; end
|
77
|
+
module_function :Foo
|
78
|
+
end
|
79
|
+
eof
|
80
|
+
assert_module_function('Foo', 'Foo')
|
81
|
+
end
|
82
|
+
end
|
@@ -7,27 +7,27 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ModuleHandler"
|
|
7
7
|
Registry.at(:ModName).should_not == nil
|
8
8
|
Registry.at("ModName::OtherModName").should_not == nil
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "should attach docstring" do
|
12
12
|
Registry.at("ModName::OtherModName").docstring.should == "Docstring"
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should handle any formatting" do
|
16
16
|
Registry.at(:StressTest).should_not == nil
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "should handle complex module names" do
|
20
20
|
Registry.at("A::B").should_not == nil
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should handle modules in the form ::ModName" do
|
24
24
|
Registry.at("Kernel").should_not be_nil
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
it "should list mixins in proper order" do
|
28
28
|
Registry.at('D').mixins.should == [P(:C), P(:B), P(:A)]
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
it "should create proper module when constant is in namespace" do
|
32
32
|
Registry.at('Q::FOO::A').should_not be_nil
|
33
33
|
end
|
@@ -8,16 +8,16 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}PrivateConstan
|
|
8
8
|
Registry.at('A::B').visibility.should == :private
|
9
9
|
Registry.at('A::C').visibility.should == :private
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should make all other constants public" do
|
13
13
|
Registry.at('A::D').visibility.should == :public
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should fail if parameter is not String, Symbol or Constant" do
|
17
17
|
undoc_error 'class Foo; private_constant x; end'
|
18
18
|
undoc_error 'class Foo; X = 1; private_constant X.new("hi"); end'
|
19
19
|
end unless LEGACY_PARSER
|
20
|
-
|
20
|
+
|
21
21
|
it "should fail if constant can't be recognized" do
|
22
22
|
undoc_error 'class Foo2; private_constant :X end'
|
23
23
|
end
|
@@ -2,21 +2,21 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
|
3
3
|
describe YARD::Handlers::Processor do
|
4
4
|
before do
|
5
|
-
@proc = Handlers::Processor.new
|
5
|
+
@proc = Handlers::Processor.new(OpenStruct.new(:parser_type => :ruby))
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should start with public visibility" do
|
9
9
|
@proc.visibility.should == :public
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should start in instance scope" do
|
13
13
|
@proc.scope.should == :instance
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should start in root namespace" do
|
17
17
|
@proc.namespace.should == Registry.root
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should have a globals structure" do
|
21
21
|
@proc.globals.should be_a(OpenStruct)
|
22
22
|
end
|
@@ -5,13 +5,17 @@ describe YARD::Handlers::Ruby::Base, '#valid_handler?' do
|
|
5
5
|
|
6
6
|
before do
|
7
7
|
Handlers::Ruby::Base.stub!(:inherited)
|
8
|
-
@processor = Handlers::Processor.new(
|
8
|
+
@processor = Handlers::Processor.new(OpenStruct.new(:parser_type => :ruby))
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
Handlers::Base.clear_subclasses
|
13
|
+
end
|
14
|
+
|
11
15
|
def valid(handler, stmt)
|
12
16
|
@processor.find_handlers(stmt).should include(handler)
|
13
17
|
end
|
14
|
-
|
18
|
+
|
15
19
|
def invalid(handler, stmt)
|
16
20
|
@processor.find_handlers(stmt).should_not include(handler)
|
17
21
|
end
|
@@ -36,7 +40,7 @@ describe YARD::Handlers::Ruby::Base, '#valid_handler?' do
|
|
36
40
|
valid StringHandler, ast[0][0][0]
|
37
41
|
invalid StringHandler, ast[0][1]
|
38
42
|
end
|
39
|
-
|
43
|
+
|
40
44
|
it "should handle symbol input (matches AstNode#type)" do
|
41
45
|
class SymbolHandler < Handlers::Ruby::Base
|
42
46
|
handles :myNodeType
|
@@ -64,7 +68,7 @@ describe YARD::Handlers::Ruby::Base, '#valid_handler?' do
|
|
64
68
|
valid ASTHandler, s(:vcall, s(:ident, "hello_world"))
|
65
69
|
invalid ASTHandler, s(:vcall, s(:ident, "NOTHELLOWORLD"))
|
66
70
|
end
|
67
|
-
|
71
|
+
|
68
72
|
it "should handle #method_call(:methname) on a valid AST" do
|
69
73
|
class MethCallHandler < Handlers::Ruby::Base
|
70
74
|
handles method_call(:meth)
|
@@ -87,4 +91,4 @@ describe YARD::Handlers::Ruby::Base, '#valid_handler?' do
|
|
87
91
|
end
|
88
92
|
invalid MethCallHandler, ast[9]
|
89
93
|
end
|
90
|
-
end if HAVE_RIPPER
|
94
|
+
end if HAVE_RIPPER
|