yard 0.8.7.6 → 0.9.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/LICENSE +2 -2
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/bin/yard +0 -0
- data/bin/yardoc +0 -0
- data/bin/yri +0 -0
- data/docs/GettingStarted.md +88 -6
- 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/templates/default/fulldoc/html/full_list_tag.erb +6 -4
- data/lib/yard/autoload.rb +3 -0
- data/lib/yard/cli/yardoc.rb +1 -1
- data/lib/yard/code_objects/base.rb +4 -1
- data/lib/yard/code_objects/extra_file_object.rb +3 -1
- data/lib/yard/code_objects/proxy.rb +2 -2
- data/lib/yard/docstring.rb +11 -6
- data/lib/yard/handlers/base.rb +1 -2
- data/lib/yard/handlers/c/base.rb +19 -0
- data/lib/yard/handlers/c/handler_methods.rb +42 -8
- data/lib/yard/handlers/c/init_handler.rb +1 -1
- data/lib/yard/handlers/c/method_handler.rb +3 -3
- data/lib/yard/handlers/ruby/decorator_handler_methods.rb +132 -0
- data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +1 -1
- data/lib/yard/handlers/ruby/private_class_method_handler.rb +6 -39
- data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -30
- data/lib/yard/handlers/ruby/public_class_method_handler.rb +13 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +1 -0
- data/lib/yard/handlers/ruby/visibility_handler.rb +5 -8
- data/lib/yard/logging.rb +1 -0
- data/lib/yard/parser/ruby/ruby_parser.rb +2 -2
- data/lib/yard/parser/source_parser.rb +6 -6
- data/lib/yard/rake/yardoc_task.rb +2 -2
- data/lib/yard/serializers/file_system_serializer.rb +33 -1
- data/lib/yard/server/commands/display_file_command.rb +8 -3
- data/lib/yard/server/commands/display_object_command.rb +7 -3
- data/lib/yard/server/doc_server_helper.rb +2 -8
- data/lib/yard/server/doc_server_serializer.rb +2 -4
- data/lib/yard/server/router.rb +1 -1
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +57 -8
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -10
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +1 -2
- data/lib/yard/server/templates/default/method_details/html/permalink.erb +3 -3
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
- data/lib/yard/tags/directives.rb +1 -0
- data/lib/yard/tags/library.rb +9 -7
- data/lib/yard/tags/overload_tag.rb +4 -1
- data/lib/yard/templates/helpers/html_helper.rb +4 -3
- data/lib/yard/templates/template_options.rb +3 -0
- data/lib/yard/version.rb +1 -1
- data/spec/cli/command_parser_spec.rb +14 -14
- data/spec/cli/command_spec.rb +11 -11
- data/spec/cli/config_spec.rb +32 -32
- data/spec/cli/diff_spec.rb +86 -90
- data/spec/cli/display_spec.rb +6 -6
- data/spec/cli/gems_spec.rb +28 -28
- data/spec/cli/graph_spec.rb +8 -8
- data/spec/cli/help_spec.rb +8 -8
- data/spec/cli/i18n_spec.rb +33 -37
- data/spec/cli/list_spec.rb +2 -2
- data/spec/cli/markup_types_spec.rb +3 -3
- data/spec/cli/server_spec.rb +74 -88
- data/spec/cli/stats_spec.rb +14 -14
- data/spec/cli/yardoc_spec.rb +316 -321
- data/spec/cli/yri_spec.rb +45 -45
- data/spec/code_objects/base_spec.rb +174 -173
- data/spec/code_objects/class_object_spec.rb +65 -65
- data/spec/code_objects/code_object_list_spec.rb +13 -11
- data/spec/code_objects/constants_spec.rb +68 -58
- data/spec/code_objects/extra_file_object_spec.rb +71 -59
- data/spec/code_objects/macro_object_spec.rb +64 -64
- data/spec/code_objects/method_object_spec.rb +80 -72
- data/spec/code_objects/module_object_spec.rb +47 -47
- data/spec/code_objects/namespace_object_spec.rb +51 -51
- data/spec/code_objects/proxy_spec.rb +54 -54
- data/spec/config_spec.rb +104 -104
- data/spec/core_ext/array_spec.rb +5 -5
- data/spec/core_ext/file_spec.rb +33 -33
- data/spec/core_ext/hash_spec.rb +5 -5
- data/spec/core_ext/insertion_spec.rb +18 -18
- data/spec/core_ext/module_spec.rb +6 -6
- data/spec/core_ext/string_spec.rb +17 -17
- data/spec/core_ext/symbol_hash_spec.rb +42 -39
- data/spec/docstring_parser_spec.rb +65 -65
- data/spec/docstring_spec.rb +137 -130
- data/spec/handlers/alias_handler_spec.rb +39 -39
- data/spec/handlers/attribute_handler_spec.rb +35 -35
- data/spec/handlers/base_spec.rb +60 -51
- data/spec/handlers/c/alias_handler_spec.rb +6 -6
- data/spec/handlers/c/attribute_handler_spec.rb +12 -12
- data/spec/handlers/c/class_handler_spec.rb +35 -22
- data/spec/handlers/c/constant_handler_spec.rb +24 -22
- data/spec/handlers/c/init_handler_spec.rb +10 -10
- data/spec/handlers/c/method_handler_spec.rb +150 -65
- data/spec/handlers/c/mixin_handler_spec.rb +5 -5
- data/spec/handlers/c/module_handler_spec.rb +27 -15
- data/spec/handlers/c/override_comment_handler_spec.rb +14 -14
- data/spec/handlers/c/path_handler_spec.rb +8 -8
- data/spec/handlers/c/spec_helper.rb +10 -0
- data/spec/handlers/c/struct_handler_spec.rb +3 -3
- data/spec/handlers/class_condition_handler_spec.rb +18 -18
- data/spec/handlers/class_handler_spec.rb +97 -97
- data/spec/handlers/class_method_handler_shared_examples.rb +132 -0
- data/spec/handlers/class_variable_handler_spec.rb +3 -3
- data/spec/handlers/constant_handler_spec.rb +32 -29
- data/spec/handlers/decorator_handler_methods_spec.rb +405 -0
- data/spec/handlers/dsl_handler_spec.rb +108 -109
- data/spec/handlers/examples/constant_handler_001.rb.txt +4 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
- data/spec/handlers/exception_handler_spec.rb +23 -23
- data/spec/handlers/extend_handler_spec.rb +9 -9
- data/spec/handlers/legacy_base_spec.rb +60 -60
- data/spec/handlers/method_condition_handler_spec.rb +5 -5
- data/spec/handlers/method_handler_spec.rb +92 -92
- data/spec/handlers/mixin_handler_spec.rb +25 -25
- data/spec/handlers/module_function_handler_spec.rb +24 -24
- data/spec/handlers/module_handler_spec.rb +15 -15
- data/spec/handlers/private_class_method_handler_spec.rb +4 -48
- data/spec/handlers/private_constant_handler_spec.rb +8 -8
- data/spec/handlers/processor_spec.rb +12 -12
- data/spec/handlers/public_class_method_handler_spec.rb +10 -0
- data/spec/handlers/ruby/base_spec.rb +16 -16
- data/spec/handlers/ruby/legacy/base_spec.rb +20 -18
- data/spec/handlers/spec_helper.rb +1 -1
- data/spec/handlers/visibility_handler_spec.rb +25 -21
- data/spec/handlers/yield_handler_spec.rb +28 -28
- data/spec/i18n/locale_spec.rb +16 -16
- data/spec/i18n/message_spec.rb +8 -8
- data/spec/i18n/messages_spec.rb +14 -14
- data/spec/i18n/pot_generator_spec.rb +32 -32
- data/spec/i18n/text_spec.rb +22 -22
- data/spec/logging_spec.rb +12 -12
- data/spec/options_spec.rb +56 -56
- data/spec/parser/base_spec.rb +9 -9
- data/spec/parser/c_parser_spec.rb +50 -50
- data/spec/parser/ruby/ast_node_spec.rb +7 -7
- data/spec/parser/ruby/legacy/statement_list_spec.rb +106 -106
- data/spec/parser/ruby/legacy/token_list_spec.rb +27 -27
- data/spec/parser/ruby/ruby_parser_spec.rb +123 -113
- data/spec/parser/source_parser_spec.rb +224 -224
- data/spec/parser/tag_parsing_spec.rb +6 -7
- data/spec/rake/yardoc_task_spec.rb +38 -48
- data/spec/registry_spec.rb +143 -143
- data/spec/registry_store_spec.rb +165 -165
- data/spec/rubygems/doc_manager_spec.rb +38 -38
- data/spec/serializers/file_system_serializer_spec.rb +53 -33
- data/spec/serializers/yardoc_serializer_spec.rb +15 -15
- data/spec/server/adapter_spec.rb +15 -15
- data/spec/server/commands/base_spec.rb +29 -29
- data/spec/server/commands/library_command_spec.rb +12 -12
- data/spec/server/commands/static_file_command_spec.rb +28 -28
- data/spec/server/doc_server_helper_spec.rb +8 -8
- data/spec/server/doc_server_serializer_spec.rb +23 -18
- data/spec/server/rack_adapter_spec.rb +6 -6
- data/spec/server/router_spec.rb +39 -39
- data/spec/server/static_caching_spec.rb +16 -16
- data/spec/server/webrick_servlet_spec.rb +6 -7
- data/spec/server_spec.rb +3 -3
- data/spec/spec_helper.rb +11 -2
- data/spec/tags/default_factory_spec.rb +64 -64
- data/spec/tags/default_tag_spec.rb +5 -5
- data/spec/tags/directives_spec.rb +121 -121
- data/spec/tags/library_spec.rb +14 -14
- data/spec/tags/overload_tag_spec.rb +24 -24
- data/spec/tags/ref_tag_list_spec.rb +12 -12
- data/spec/templates/class_spec.rb +3 -3
- data/spec/templates/constant_spec.rb +4 -4
- data/spec/templates/engine_spec.rb +47 -48
- data/spec/templates/examples/class001.html +129 -101
- data/spec/templates/examples/class002.html +31 -27
- data/spec/templates/examples/method001.html +54 -47
- data/spec/templates/examples/method002.html +33 -28
- data/spec/templates/examples/method003.html +70 -64
- data/spec/templates/examples/method004.html +13 -9
- data/spec/templates/examples/method005.html +38 -32
- data/spec/templates/examples/module001.html +343 -339
- data/spec/templates/examples/module002.html +147 -124
- data/spec/templates/examples/module003.html +94 -81
- data/spec/templates/examples/module004.html +40 -33
- data/spec/templates/helpers/base_helper_spec.rb +91 -95
- data/spec/templates/helpers/html_helper_spec.rb +276 -279
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +16 -15
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +27 -34
- data/spec/templates/helpers/markup_helper_spec.rb +57 -57
- data/spec/templates/helpers/method_helper_spec.rb +20 -20
- data/spec/templates/helpers/shared_signature_examples.rb +33 -31
- data/spec/templates/helpers/text_helper_spec.rb +6 -6
- data/spec/templates/method_spec.rb +7 -7
- data/spec/templates/module_spec.rb +7 -7
- data/spec/templates/onefile_spec.rb +7 -7
- data/spec/templates/section_spec.rb +66 -69
- data/spec/templates/spec_helper.rb +1 -1
- data/spec/templates/tag_spec.rb +5 -5
- data/spec/templates/template_spec.rb +158 -158
- data/spec/verifier_spec.rb +52 -52
- data/templates/default/fulldoc/html/css/full_list.css +32 -31
- data/templates/default/fulldoc/html/css/style.css +212 -77
- data/templates/default/fulldoc/html/frames.erb +6 -15
- data/templates/default/fulldoc/html/full_list.erb +14 -21
- data/templates/default/fulldoc/html/full_list_class.erb +1 -1
- data/templates/default/fulldoc/html/full_list_file.erb +6 -4
- data/templates/default/fulldoc/html/full_list_method.erb +8 -6
- data/templates/default/fulldoc/html/js/app.js +100 -76
- data/templates/default/fulldoc/html/js/full_list.js +170 -135
- data/templates/default/fulldoc/html/setup.rb +50 -7
- data/templates/default/layout/html/breadcrumb.erb +0 -2
- data/templates/default/layout/html/headers.erb +2 -1
- data/templates/default/layout/html/layout.erb +16 -10
- data/templates/default/layout/html/script_setup.erb +1 -2
- data/templates/default/layout/html/search.erb +7 -2
- data/templates/default/layout/html/setup.rb +16 -0
- data/templates/default/method/html/header.erb +7 -6
- data/templates/default/module/html/attribute_summary.erb +1 -1
- data/templates/default/module/html/box_info.erb +24 -18
- data/templates/default/module/html/constant_summary.erb +9 -11
- data/templates/default/module/html/item_summary.erb +1 -1
- data/templates/default/module/html/method_summary.erb +1 -1
- data/templates/guide/fulldoc/html/setup.rb +1 -1
- data/yard.gemspec +1 -2
- metadata +10 -7
- data/spec/handlers/examples/private_class_method_handler_001.rb.txt +0 -9
- data/spec/handlers/examples/private_class_method_handler_002.rb.txt +0 -18
- data/spec/handlers/examples/private_class_method_handler_003.rb.txt +0 -11
@@ -3,12 +3,12 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
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
|
-
it "
|
7
|
-
Registry.at('#b').
|
6
|
+
it "does not parse regular if blocks in methods" do
|
7
|
+
expect(Registry.at('#b')).to be nil
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
11
|
-
Registry.at('#c').
|
12
|
-
Registry.at('#d').
|
10
|
+
it "parses if/unless blocks in the form X if COND" do
|
11
|
+
expect(Registry.at('#c')).not_to be nil
|
12
|
+
expect(Registry.at('#d')).not_to be nil
|
13
13
|
end
|
14
14
|
end
|
@@ -7,178 +7,178 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MethodHandler"
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
11
|
-
P(:Foo).meths.
|
10
|
+
it "adds methods to parent's #meths list" do
|
11
|
+
expect(P(:Foo).meths).to include(P("Foo#method1"))
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
15
|
-
P(:Foo).meths.
|
14
|
+
it "parses and adds class methods (self.method2)" do
|
15
|
+
expect(P(:Foo).meths).to include(P("Foo.method2"))
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
19
|
-
P("String.hello").
|
18
|
+
it "parses and adds class methods from other namespaces (String.hello)" do
|
19
|
+
expect(P("String.hello")).to be_instance_of(CodeObjects::MethodObject)
|
20
20
|
end
|
21
21
|
|
22
22
|
[:[], :[]=, :allowed?, :/, :=~, :==, :`, :|, :*, :&, :%, :'^', :-@, :+@, :'~@'].each do |name|
|
23
|
-
it "
|
24
|
-
Registry.at("Foo##{name}").
|
23
|
+
it "allows valid method #{name}" do
|
24
|
+
expect(Registry.at("Foo##{name}")).not_to be nil
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
29
|
-
Registry.at("Foo.new").
|
28
|
+
it "allows self.methname" do
|
29
|
+
expect(Registry.at("Foo.new")).not_to be nil
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
33
|
-
P('Foo#dynamic').dynamic
|
32
|
+
it "marks dynamic methods as such" do
|
33
|
+
expect(P('Foo#dynamic').dynamic?).to be true
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
37
|
-
P('Foo#method1').is_explicit
|
36
|
+
it "shows that a method is explicitly defined (if it was originally defined implicitly by attribute)" do
|
37
|
+
expect(P('Foo#method1').is_explicit?).to be true
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
41
|
-
P('Foo#[]').parameters.
|
42
|
-
P('Foo#/').parameters.
|
40
|
+
it "handles parameters" do
|
41
|
+
expect(P('Foo#[]').parameters).to eq [['key', "'default'"]]
|
42
|
+
expect(P('Foo#/').parameters).to eq [['x', "File.new('x', 'w')"], ['y', '2']]
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
46
|
-
P('Foo#optsmeth').parameters.
|
45
|
+
it "handles opts = {} as parameter" do
|
46
|
+
expect(P('Foo#optsmeth').parameters).to eq [['x', nil], ['opts', '{}']]
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
50
|
-
P('Foo#blockmeth').parameters.
|
49
|
+
it "handles &block as parameter" do
|
50
|
+
expect(P('Foo#blockmeth').parameters).to eq [['x', nil], ['&block', nil]]
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "handles overloads" do
|
54
54
|
meth = P('Foo#foo')
|
55
55
|
|
56
56
|
o1 = meth.tags(:overload).first
|
57
|
-
o1.name.
|
58
|
-
o1.parameters.
|
59
|
-
o1.tag(:return).type.
|
57
|
+
expect(o1.name).to eq :bar
|
58
|
+
expect(o1.parameters).to eq [['a', nil], ['b', "1"]]
|
59
|
+
expect(o1.tag(:return).type).to eq "String"
|
60
60
|
|
61
61
|
o2 = meth.tags(:overload)[1]
|
62
|
-
o2.name.
|
63
|
-
o2.parameters.
|
64
|
-
o2.tag(:return).type.
|
62
|
+
expect(o2.name).to eq :baz
|
63
|
+
expect(o2.parameters).to eq [['b', nil], ['c', nil]]
|
64
|
+
expect(o2.tag(:return).type).to eq "Fixnum"
|
65
65
|
|
66
66
|
o3 = meth.tags(:overload)[2]
|
67
|
-
o3.name.
|
68
|
-
o3.parameters.
|
69
|
-
o3.docstring.
|
70
|
-
o3.docstring.
|
67
|
+
expect(o3.name).to eq :bang
|
68
|
+
expect(o3.parameters).to eq [['d', nil], ['e', nil]]
|
69
|
+
expect(o3.docstring).to be_empty
|
70
|
+
expect(o3.docstring).to be_blank
|
71
71
|
end
|
72
72
|
|
73
|
-
it "
|
73
|
+
it "sets a return tag if not set on #initialize" do
|
74
74
|
meth = P('Foo#initialize')
|
75
75
|
|
76
|
-
meth.
|
77
|
-
meth.tag(:return).types.
|
78
|
-
meth.tag(:return).text.
|
76
|
+
expect(meth).to have_tag(:return)
|
77
|
+
expect(meth.tag(:return).types).to eq ["Foo"]
|
78
|
+
expect(meth.tag(:return).text).to eq "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
|
-
it "
|
83
|
-
P('Foo.' + meth).
|
82
|
+
it "sets @private tag on #{meth} callback method if no docstring is set" do
|
83
|
+
expect(P('Foo.' + meth)).to have_tag(:private)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
88
|
-
P('Foo.extended').
|
87
|
+
it "does not set @private tag on extended callback method since docstring is set" do
|
88
|
+
expect(P('Foo.extended')).not_to have_tag(:private)
|
89
89
|
end
|
90
90
|
|
91
|
-
it "
|
91
|
+
it "adds @return [Boolean] tag to methods ending in ? without return types" do
|
92
92
|
meth = P('Foo#boolean?')
|
93
|
-
meth.
|
94
|
-
meth.tag(:return).types.
|
93
|
+
expect(meth).to have_tag(:return)
|
94
|
+
expect(meth.tag(:return).types).to eq ['Boolean']
|
95
95
|
end
|
96
96
|
|
97
|
-
it "
|
97
|
+
it "adds Boolean type to return tag without types" do
|
98
98
|
meth = P('Foo#boolean2?')
|
99
|
-
meth.
|
100
|
-
meth.tag(:return).types.
|
99
|
+
expect(meth).to have_tag(:return)
|
100
|
+
expect(meth.tag(:return).types).to eq ['Boolean']
|
101
101
|
end
|
102
102
|
|
103
|
-
it "
|
103
|
+
it "does not change return type for method ending in ? with return types set" do
|
104
104
|
meth = P('Foo#boolean3?')
|
105
|
-
meth.
|
106
|
-
meth.tag(:return).types.
|
105
|
+
expect(meth).to have_tag(:return)
|
106
|
+
expect(meth.tag(:return).types).to eq ['NotBoolean', 'nil']
|
107
107
|
end
|
108
108
|
|
109
|
-
it "
|
109
|
+
it "does not change return type for method ending in ? with return types set by @overload" do
|
110
110
|
meth = P('Foo#rainy?')
|
111
|
-
meth.
|
112
|
-
meth.tag(:overload).
|
113
|
-
meth.
|
111
|
+
expect(meth).to have_tag(:overload)
|
112
|
+
expect(meth.tag(:overload)).to have_tag(:return)
|
113
|
+
expect(meth).not_to have_tag(:return)
|
114
114
|
end
|
115
115
|
|
116
|
-
it "
|
117
|
-
Registry.at('Foo#attr_name').
|
118
|
-
Registry.at('Foo#attr_name=').
|
116
|
+
it "adds method writer to existing attribute" do
|
117
|
+
expect(Registry.at('Foo#attr_name')).to be_reader
|
118
|
+
expect(Registry.at('Foo#attr_name=')).to be_writer
|
119
119
|
end
|
120
120
|
|
121
|
-
it "
|
122
|
-
Registry.at('Foo#attr_name2').
|
123
|
-
Registry.at('Foo#attr_name2=').
|
121
|
+
it "adds method reader to existing attribute" do
|
122
|
+
expect(Registry.at('Foo#attr_name2')).to be_reader
|
123
|
+
expect(Registry.at('Foo#attr_name2=')).to be_writer
|
124
124
|
end
|
125
125
|
|
126
|
-
it "
|
126
|
+
it "generates an options parameter if @option refers to an undocumented parameter" do
|
127
127
|
meth = P('Foo#auto_opts')
|
128
|
-
meth.
|
129
|
-
meth.tag(:param).name.
|
130
|
-
meth.tag(:param).types.
|
128
|
+
expect(meth).to have_tag(:param)
|
129
|
+
expect(meth.tag(:param).name).to eq "opts"
|
130
|
+
expect(meth.tag(:param).types).to eq ["Hash"]
|
131
131
|
end
|
132
132
|
|
133
|
-
it "
|
133
|
+
it "raises 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
|
-
Registry.at('error').
|
135
|
+
expect(Registry.at('error')).to be nil
|
136
136
|
end
|
137
137
|
|
138
|
-
it "
|
139
|
-
Registry.at('Foo.meth_on_const').
|
140
|
-
Registry.at('Foo.meth2_on_const').
|
138
|
+
it "allows class method to be defined on constant reference object" do
|
139
|
+
expect(Registry.at('Foo.meth_on_const')).not_to be nil
|
140
|
+
expect(Registry.at('Foo.meth2_on_const')).not_to be nil
|
141
141
|
end
|
142
142
|
|
143
|
-
it "
|
144
|
-
Registry.at('D').aliases.
|
145
|
-
Registry.at('D#b').is_alias
|
146
|
-
Registry.at('D#a').is_alias
|
143
|
+
it "copies alias information on method (re-)definition to new method" do
|
144
|
+
expect(Registry.at('D').aliases).to be_empty
|
145
|
+
expect(Registry.at('D#b').is_alias?).to be false
|
146
|
+
expect(Registry.at('D#a').is_alias?).to be false
|
147
147
|
end
|
148
148
|
|
149
|
-
it "
|
149
|
+
it "adds macros for class methods" do
|
150
150
|
macro = CodeObjects::MacroObject.find('prop')
|
151
|
-
macro.
|
152
|
-
macro.macro_data.
|
153
|
-
macro.method_object.
|
154
|
-
macro.
|
151
|
+
expect(macro).not_to be nil
|
152
|
+
expect(macro.macro_data).to eq "@!method $1(value)\n$3\n@return [$2]"
|
153
|
+
expect(macro.method_object).to eq Registry.at('E.property')
|
154
|
+
expect(macro).to be_attached
|
155
155
|
obj = Registry.at('E#foo')
|
156
|
-
obj.
|
157
|
-
obj.docstring.
|
158
|
-
obj.signature.
|
159
|
-
obj.tag(:return).types.
|
156
|
+
expect(obj).not_to be nil
|
157
|
+
expect(obj.docstring).to eq 'create a foo'
|
158
|
+
expect(obj.signature).to eq 'def foo(value)'
|
159
|
+
expect(obj.tag(:return).types).to eq ['String']
|
160
160
|
end
|
161
161
|
|
162
|
-
it "
|
162
|
+
it "handles macros on any object" do
|
163
163
|
macro = CodeObjects::MacroObject.find('xyz')
|
164
|
-
macro.
|
165
|
-
macro.macro_data.
|
164
|
+
expect(macro).not_to be nil
|
165
|
+
expect(macro.macro_data).to eq '@!method $1'
|
166
166
|
end
|
167
167
|
|
168
|
-
it "
|
169
|
-
Registry.at('E#a').
|
168
|
+
it "skips macros on instance methods" do
|
169
|
+
expect(Registry.at('E#a')).to be nil
|
170
170
|
end
|
171
171
|
|
172
|
-
it "
|
173
|
-
log.
|
172
|
+
it "warns if the macro name is invalid" do
|
173
|
+
expect(log).to receive(:warn).with(/Invalid directive.*@!macro/)
|
174
174
|
YARD.parse_string "class Foo\n# @!macro\ndef self.foo; end\nend"
|
175
175
|
end
|
176
176
|
|
177
|
-
it "
|
177
|
+
it "handles 'def end' methods" do
|
178
178
|
obj = Registry.at('F::A#foo')
|
179
|
-
obj.
|
179
|
+
expect(obj).not_to be nil
|
180
180
|
obj = Registry.at('F::A#bar')
|
181
|
-
obj.
|
182
|
-
obj.docstring.
|
181
|
+
expect(obj).not_to be nil
|
182
|
+
expect(obj.docstring).to eq 'PASS'
|
183
183
|
end
|
184
184
|
end
|
@@ -3,53 +3,53 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MixinHandler" do
|
4
4
|
before(:all) { parse_file :mixin_handler_001, __FILE__ }
|
5
5
|
|
6
|
-
it "
|
7
|
-
Registry.at(:X).instance_mixins.
|
8
|
-
Registry.at(:Y).instance_mixins.
|
6
|
+
it "handles includes from classes or modules" do
|
7
|
+
expect(Registry.at(:X).instance_mixins).to include(P(:A))
|
8
|
+
expect(Registry.at(:Y).instance_mixins).to include(P(:A))
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
12
|
-
Registry.at(:Y).class_mixins.
|
11
|
+
it "handles includes in class << self" do
|
12
|
+
expect(Registry.at(:Y).class_mixins).to include(P(:A))
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
16
|
-
Registry.at(:X).instance_mixins.
|
15
|
+
it "handles includes for modules that don't yet exist" do
|
16
|
+
expect(Registry.at(:X).instance_mixins).to include(P(nil, :NOTEXIST))
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
19
|
+
it "sets the type of non-existing modules to :module" do
|
20
20
|
o = Registry.at(:X).instance_mixins.find {|o| o.name == :NOTEXIST }
|
21
|
-
o.type.
|
21
|
+
expect(o.type).to eq :module
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
25
|
-
Registry.at(:X).
|
24
|
+
it "handles includes with multiple parameters" do
|
25
|
+
expect(Registry.at(:X)).not_to be nil
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
29
|
-
P(:Y).instance_mixins.
|
30
|
-
P(:Y).instance_mixins.
|
28
|
+
it "handles complex include statements" do
|
29
|
+
expect(P(:Y).instance_mixins).to include(P('B::C'))
|
30
|
+
expect(P(:Y).instance_mixins).to include(P(:B))
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
34
|
-
P(:Y).instance_mixins.
|
33
|
+
it "treats a mixed in Constant by taking its value as the real object name" do
|
34
|
+
expect(P(:Y).instance_mixins).to include(Registry.at('B::D'))
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
38
|
-
P(:Z).instance_mixins.
|
37
|
+
it "adds includes in the correct order when include is given multiple arguments" do
|
38
|
+
expect(P(:Z).instance_mixins).to eq [P(:A), P(:B)]
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
42
|
-
P("ABC::DEF::FOO").mixins.
|
43
|
-
P("ABC::DEF::BAR").mixins.
|
41
|
+
it "avoids including self for unresolved mixins of the same name" do
|
42
|
+
expect(P("ABC::DEF::FOO").mixins).to eq [P("ABC::FOO")]
|
43
|
+
expect(P("ABC::DEF::BAR").mixins).to eq [P("ABC::BAR")]
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
46
|
+
it "raises undocumentable error if argument is variable" do
|
47
47
|
undoc_error "module X; include invalid; end"
|
48
|
-
Registry.at('X').mixins.
|
48
|
+
expect(Registry.at('X').mixins).to eq []
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
51
|
+
it "parses all other arguments before erroring out on undocumentable error" do
|
52
52
|
undoc_error "module X; include invalid, Y; end"
|
53
|
-
Registry.at('X').mixins.
|
53
|
+
expect(Registry.at('X').mixins).to eq [P('Y')]
|
54
54
|
end
|
55
55
|
end
|
@@ -6,15 +6,15 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}VisibilityHand
|
|
6
6
|
def assert_module_function(namespace, name)
|
7
7
|
klass = Registry.at("#{namespace}.#{name}")
|
8
8
|
instance = Registry.at("#{namespace}##{name}")
|
9
|
-
klass.
|
10
|
-
instance.
|
11
|
-
klass.
|
12
|
-
instance.
|
13
|
-
klass.visibility.
|
14
|
-
instance.visibility.
|
9
|
+
expect(klass).not_to be nil
|
10
|
+
expect(instance).not_to be nil
|
11
|
+
expect(klass).to be_module_function
|
12
|
+
expect(instance).not_to be_module_function
|
13
|
+
expect(klass.visibility).to eq :public
|
14
|
+
expect(instance.visibility).to eq :private
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
17
|
+
it "is able to create a module function with parameters" do
|
18
18
|
YARD.parse_string <<-eof
|
19
19
|
module Foo
|
20
20
|
def bar; end
|
@@ -27,7 +27,7 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}VisibilityHand
|
|
27
27
|
assert_module_function('Foo', 'baz')
|
28
28
|
end
|
29
29
|
|
30
|
-
it "
|
30
|
+
it "is able to set scope for duration of block without params" do
|
31
31
|
YARD.parse_string <<-eof
|
32
32
|
module Foo
|
33
33
|
def qux; end
|
@@ -38,13 +38,13 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}VisibilityHand
|
|
38
38
|
def baz; end
|
39
39
|
end
|
40
40
|
eof
|
41
|
-
Registry.at('Foo.qux').
|
41
|
+
expect(Registry.at('Foo.qux')).to be nil
|
42
42
|
assert_module_function('Foo', 'bar')
|
43
43
|
assert_module_function('Foo', 'baz')
|
44
44
|
end
|
45
45
|
|
46
46
|
# @bug gh-563
|
47
|
-
it "
|
47
|
+
it "copies tags to module function properly" do
|
48
48
|
YARD.parse_string <<-eof
|
49
49
|
module Foo
|
50
50
|
# @param [String] foo bar
|
@@ -56,17 +56,17 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}VisibilityHand
|
|
56
56
|
eof
|
57
57
|
assert_module_function('Foo', 'bar')
|
58
58
|
o = Registry.at('Foo.bar')
|
59
|
-
o.tag(:param).types.
|
60
|
-
o.tag(:param).name.
|
61
|
-
o.tag(:param).text.
|
62
|
-
o.tag(:option).name.
|
63
|
-
o.tag(:option).pair.types.
|
64
|
-
o.tag(:option).pair.defaults.
|
65
|
-
o.tag(:option).pair.text.
|
66
|
-
o.tag(:return).types.
|
59
|
+
expect(o.tag(:param).types).to eq ['String']
|
60
|
+
expect(o.tag(:param).name).to eq 'foo'
|
61
|
+
expect(o.tag(:param).text).to eq 'bar'
|
62
|
+
expect(o.tag(:option).name).to eq 'foo'
|
63
|
+
expect(o.tag(:option).pair.types).to eq ['String']
|
64
|
+
expect(o.tag(:option).pair.defaults).to eq ['nil']
|
65
|
+
expect(o.tag(:option).pair.text).to eq 'baz'
|
66
|
+
expect(o.tag(:return).types).to eq ['void']
|
67
67
|
end
|
68
68
|
|
69
|
-
it "
|
69
|
+
it "handles all method names in parameters" do
|
70
70
|
YARD.parse_string <<-eof
|
71
71
|
module Foo
|
72
72
|
def -(t); end
|
@@ -80,7 +80,7 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}VisibilityHand
|
|
80
80
|
assert_module_function('Foo', 'a?')
|
81
81
|
end
|
82
82
|
|
83
|
-
it "
|
83
|
+
it "only accepts strings and symbols" do
|
84
84
|
YARD.parse_string <<-eof
|
85
85
|
module Foo
|
86
86
|
module_function name
|
@@ -88,12 +88,12 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}VisibilityHand
|
|
88
88
|
module_function *(method_call)
|
89
89
|
end
|
90
90
|
eof
|
91
|
-
Registry.at('Foo#name').
|
92
|
-
Registry.at('Foo#argument').
|
93
|
-
Registry.at('Foo#method_call').
|
91
|
+
expect(Registry.at('Foo#name')).to be nil
|
92
|
+
expect(Registry.at('Foo#argument')).to be nil
|
93
|
+
expect(Registry.at('Foo#method_call')).to be nil
|
94
94
|
end
|
95
95
|
|
96
|
-
it "
|
96
|
+
it "handles constants passed in as symbols" do
|
97
97
|
YARD.parse_string <<-eof
|
98
98
|
module Foo
|
99
99
|
def Foo; end
|