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
@@ -37,65 +37,65 @@ describe YARD::CodeObjects::ModuleObject do
|
|
37
37
|
@yard.class_mixins << @another
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
40
|
+
it "lists all methods (including mixin methods) via #meths" do
|
41
41
|
meths = @yard.meths
|
42
|
-
meths.
|
43
|
-
meths.
|
44
|
-
meths.
|
45
|
-
meths.
|
46
|
-
meths.
|
42
|
+
expect(meths).to include(P("YARD#foo"))
|
43
|
+
expect(meths).to include(P("YARD#foo2"))
|
44
|
+
expect(meths).to include(P("YARD.bar"))
|
45
|
+
expect(meths).to include(P("SomeMod#mixmethod"))
|
46
|
+
expect(meths).to include(P("AnotherMod#fizz"))
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
49
|
+
it "allows :visibility to be set" do
|
50
50
|
meths = @yard.meths(:visibility => :public)
|
51
|
-
meths.
|
51
|
+
expect(meths).not_to include(P("YARD.bar"))
|
52
52
|
meths = @yard.meths(:visibility => [:public, :private])
|
53
|
-
meths.
|
54
|
-
meths.
|
55
|
-
meths.
|
53
|
+
expect(meths).to include(P("YARD#foo"))
|
54
|
+
expect(meths).to include(P("YARD.bar"))
|
55
|
+
expect(meths).not_to include(P("YARD#foo2"))
|
56
56
|
end
|
57
57
|
|
58
|
-
it "
|
58
|
+
it "only displays class methods for :scope => :class" do
|
59
59
|
meths = @yard.meths(:scope => :class)
|
60
|
-
meths.
|
61
|
-
meths.
|
62
|
-
meths.
|
63
|
-
meths.
|
64
|
-
meths.
|
65
|
-
meths.
|
66
|
-
meths.
|
60
|
+
expect(meths).not_to include(P("YARD#foo"))
|
61
|
+
expect(meths).not_to include(P("YARD#foo2"))
|
62
|
+
expect(meths).not_to include(P("SomeMod#mixmethod"))
|
63
|
+
expect(meths).not_to include(P("SomeMod.baz"))
|
64
|
+
expect(meths).not_to include(P("AnotherMod#fazz"))
|
65
|
+
expect(meths).to include(P("YARD.bar"))
|
66
|
+
expect(meths).to include(P("AnotherMod#fizz"))
|
67
67
|
end
|
68
68
|
|
69
|
-
it "
|
69
|
+
it "only displays instance methods for :scope => :class" do
|
70
70
|
meths = @yard.meths(:scope => :instance)
|
71
|
-
meths.
|
72
|
-
meths.
|
73
|
-
meths.
|
74
|
-
meths.
|
75
|
-
meths.
|
71
|
+
expect(meths).to include(P("YARD#foo"))
|
72
|
+
expect(meths).to include(P("YARD#foo2"))
|
73
|
+
expect(meths).to include(P("SomeMod#mixmethod"))
|
74
|
+
expect(meths).not_to include(P("YARD.bar"))
|
75
|
+
expect(meths).not_to include(P("AnotherMod#fizz"))
|
76
76
|
end
|
77
77
|
|
78
|
-
it "
|
78
|
+
it "allows :included to be set" do
|
79
79
|
meths = @yard.meths(:included => false)
|
80
|
-
meths.
|
81
|
-
meths.
|
82
|
-
meths.
|
83
|
-
meths.
|
84
|
-
meths.
|
80
|
+
expect(meths).not_to include(P("SomeMod#mixmethod"))
|
81
|
+
expect(meths).not_to include(P("AnotherMod#fizz"))
|
82
|
+
expect(meths).to include(P("YARD#foo"))
|
83
|
+
expect(meths).to include(P("YARD#foo2"))
|
84
|
+
expect(meths).to include(P("YARD.bar"))
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
87
|
+
it "chooses the method defined in the class over an included module" do
|
88
88
|
meths = @yard.meths
|
89
|
-
meths.
|
90
|
-
meths.
|
91
|
-
meths.
|
92
|
-
meths.
|
89
|
+
expect(meths).not_to include(P("SomeMod#xyz"))
|
90
|
+
expect(meths).to include(P("YARD#xyz"))
|
91
|
+
expect(meths).not_to include(P("AnotherMod#bar"))
|
92
|
+
expect(meths).to include(P("YARD.bar"))
|
93
93
|
|
94
94
|
meths = @other.meths
|
95
|
-
meths.
|
95
|
+
expect(meths).to include(P("SomeMod#xyz"))
|
96
96
|
|
97
97
|
meths = @another.meths
|
98
|
-
meths.
|
98
|
+
expect(meths).to include(P("AnotherMod#bar"))
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -118,24 +118,24 @@ describe YARD::CodeObjects::ModuleObject do
|
|
118
118
|
@mod5.instance_mixins << @proxy
|
119
119
|
end
|
120
120
|
|
121
|
-
it "
|
122
|
-
@mod1.inheritance_tree.
|
121
|
+
it "shows only itself for an inheritance tree without included modules" do
|
122
|
+
expect(@mod1.inheritance_tree).to eq [@mod1]
|
123
123
|
end
|
124
124
|
|
125
|
-
it "
|
126
|
-
@mod1.inheritance_tree(true).
|
125
|
+
it "shows proper inheritance tree when modules are included" do
|
126
|
+
expect(@mod1.inheritance_tree(true)).to eq [@mod1, @mod2, @mod3, @mod4]
|
127
127
|
end
|
128
128
|
|
129
|
-
it "
|
130
|
-
@proxy.
|
131
|
-
@mod5.instance_mixins.
|
129
|
+
it "does not list inheritance tree of proxy objects in inheritance tree" do
|
130
|
+
expect(@proxy).not_to receive(:inheritance_tree)
|
131
|
+
expect(@mod5.instance_mixins).to eq [@proxy]
|
132
132
|
end
|
133
133
|
|
134
|
-
it "
|
134
|
+
it "lists class mixins in inheritance tree" do
|
135
135
|
mod = ModuleObject.new(:root, :ClassMethods)
|
136
136
|
recvmod = ModuleObject.new(:root, :ReceivingModule)
|
137
137
|
recvmod.class_mixins << mod
|
138
|
-
recvmod.inheritance_tree(true).
|
138
|
+
expect(recvmod.inheritance_tree(true)).to eq [recvmod, mod]
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
@@ -3,30 +3,30 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe YARD::CodeObjects::NamespaceObject do
|
4
4
|
before { Registry.clear }
|
5
5
|
|
6
|
-
describe
|
7
|
-
it "
|
6
|
+
describe "#child" do
|
7
|
+
it "returns the object matching the name passed in if argument is a Symbol" do
|
8
8
|
obj = NamespaceObject.new(nil, :YARD)
|
9
9
|
other = NamespaceObject.new(obj, :Other)
|
10
|
-
obj.child(:Other).
|
11
|
-
obj.child('Other').
|
10
|
+
expect(obj.child(:Other)).to eq other
|
11
|
+
expect(obj.child('Other')).to eq other
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
14
|
+
it "looks for attributes matching the object if the argument is a Hash" do
|
15
15
|
obj = NamespaceObject.new(nil, :YARD)
|
16
16
|
NamespaceObject.new(obj, :NotOther)
|
17
17
|
other = NamespaceObject.new(obj, :Other)
|
18
18
|
other.somevalue = 2
|
19
|
-
obj.child(:somevalue => 2).
|
19
|
+
expect(obj.child(:somevalue => 2)).to eq other
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it "
|
23
|
+
describe "#meths" do
|
24
|
+
it "returns #meths even if parent is a Proxy" do
|
25
25
|
obj = NamespaceObject.new(P(:String), :YARD)
|
26
|
-
obj.meths.
|
26
|
+
expect(obj.meths).to be_empty
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "does not list included methods that are already defined in the namespace using #meths" do
|
30
30
|
a = ModuleObject.new(nil, :Mod1)
|
31
31
|
ameth = MethodObject.new(a, :testing)
|
32
32
|
b = ModuleObject.new(nil, :Mod2)
|
@@ -38,33 +38,33 @@ describe YARD::CodeObjects::NamespaceObject do
|
|
38
38
|
c.class_mixins << b
|
39
39
|
|
40
40
|
meths = c.meths
|
41
|
-
meths.
|
42
|
-
meths.
|
43
|
-
meths.
|
44
|
-
meths.
|
41
|
+
expect(meths).to include(bmeth)
|
42
|
+
expect(meths).to include(cmeth)
|
43
|
+
expect(meths).to include(cmeth2)
|
44
|
+
expect(meths).not_to include(ameth)
|
45
45
|
|
46
46
|
meths = c.included_meths
|
47
|
-
meths.
|
48
|
-
meths.
|
49
|
-
meths.
|
50
|
-
meths.
|
47
|
+
expect(meths).to include(bmeth)
|
48
|
+
expect(meths).not_to include(ameth)
|
49
|
+
expect(meths).not_to include(cmeth)
|
50
|
+
expect(meths).not_to include(cmeth2)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe
|
55
|
-
it "
|
54
|
+
describe "#included_meths" do
|
55
|
+
it "lists methods mixed into the class scope as class methods" do
|
56
56
|
b = ModuleObject.new(nil, :Mod2)
|
57
57
|
bmeth = MethodObject.new(b, :foo)
|
58
58
|
bmeth2 = MethodObject.new(b, :foo2)
|
59
59
|
c = NamespaceObject.new(nil, :YARD)
|
60
60
|
c.class_mixins << b
|
61
61
|
|
62
|
-
[bmeth, bmeth2].each {|o| o.scope.
|
62
|
+
[bmeth, bmeth2].each { |o| expect(o.scope).to eq :instance }
|
63
63
|
meths = c.included_meths(:scope => :class)
|
64
|
-
meths.each {|o| o.scope.
|
64
|
+
meths.each { |o| expect(o.scope).to eq :class }
|
65
65
|
end
|
66
66
|
|
67
|
-
it "
|
67
|
+
it "does not list methods overridden by another included module" do
|
68
68
|
a = ModuleObject.new(nil, :Mod)
|
69
69
|
ameth = MethodObject.new(a, :testing)
|
70
70
|
b = ModuleObject.new(nil, :Mod2)
|
@@ -76,38 +76,38 @@ describe YARD::CodeObjects::NamespaceObject do
|
|
76
76
|
c.class_mixins.unshift a
|
77
77
|
|
78
78
|
meths = c.included_meths(:scope => :instance)
|
79
|
-
meths.
|
80
|
-
meths.
|
79
|
+
expect(meths).not_to include(ameth)
|
80
|
+
expect(meths).to include(bmeth)
|
81
81
|
|
82
82
|
meths = c.included_meths(:scope => :class)
|
83
|
-
meths.
|
84
|
-
meths.
|
83
|
+
expect(meths).to include(ameth)
|
84
|
+
expect(meths).not_to include(bmeth)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
describe
|
89
|
-
it "
|
88
|
+
describe "#class_attributes" do
|
89
|
+
it "lists class attributes" do
|
90
90
|
a = NamespaceObject.new(nil, :Mod)
|
91
91
|
a.attributes[:instance][:a] = { :read => MethodObject.new(a, :a), :write => nil }
|
92
92
|
a.attributes[:instance][:b] = { :read => MethodObject.new(a, :b), :write => nil }
|
93
93
|
a.attributes[:class][:a] = { :read => MethodObject.new(a, :a, :class), :write => nil }
|
94
|
-
a.class_attributes.keys.
|
95
|
-
a.class_attributes.keys.
|
94
|
+
expect(a.class_attributes.keys).to include(:a)
|
95
|
+
expect(a.class_attributes.keys).not_to include(:b)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
describe
|
100
|
-
it "
|
99
|
+
describe "#instance_attributes" do
|
100
|
+
it "lists instance attributes" do
|
101
101
|
a = NamespaceObject.new(nil, :Mod)
|
102
102
|
a.attributes[:instance][:a] = { :read => MethodObject.new(a, :a), :write => nil }
|
103
103
|
a.attributes[:instance][:b] = { :read => MethodObject.new(a, :b), :write => nil }
|
104
104
|
a.attributes[:class][:a] = { :read => MethodObject.new(a, :a, :class), :write => nil }
|
105
|
-
a.instance_attributes.keys.
|
106
|
-
a.instance_attributes.keys.
|
105
|
+
expect(a.instance_attributes.keys).to include(:a)
|
106
|
+
expect(a.instance_attributes.keys).to include(:b)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
describe
|
110
|
+
describe "#constants/#included_constants" do
|
111
111
|
before do
|
112
112
|
Registry.clear
|
113
113
|
|
@@ -132,39 +132,39 @@ describe YARD::CodeObjects::NamespaceObject do
|
|
132
132
|
eof
|
133
133
|
end
|
134
134
|
|
135
|
-
it "
|
135
|
+
it "lists all included constants by default" do
|
136
136
|
consts = P(:C).constants
|
137
|
-
consts.
|
138
|
-
consts.
|
137
|
+
expect(consts).to include(P('A::CONST1'))
|
138
|
+
expect(consts).to include(P('C::CONST4'))
|
139
139
|
end
|
140
140
|
|
141
|
-
it "
|
141
|
+
it "allows :included to be set to false to ignore included constants" do
|
142
142
|
consts = P(:C).constants(:included => false)
|
143
|
-
consts.
|
144
|
-
consts.
|
143
|
+
expect(consts).not_to include(P('A::CONST1'))
|
144
|
+
expect(consts).to include(P('C::CONST4'))
|
145
145
|
end
|
146
146
|
|
147
|
-
it "
|
147
|
+
it "does not list an included constant if it is defined in the object" do
|
148
148
|
consts = P(:C).constants
|
149
|
-
consts.
|
150
|
-
consts.
|
149
|
+
expect(consts).to include(P('C::CONST3'))
|
150
|
+
expect(consts).not_to include(P('B::CONST3'))
|
151
151
|
end
|
152
152
|
|
153
|
-
it "
|
153
|
+
it "does not list an included constant if it is shadowed by another included constant" do
|
154
154
|
consts = P(:C).included_constants
|
155
|
-
consts.
|
156
|
-
consts.
|
155
|
+
expect(consts).to include(P('B::CONST2'))
|
156
|
+
expect(consts).not_to include(P('A::CONST2'))
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
-
describe
|
161
|
-
it "
|
160
|
+
describe "#included_meths" do
|
161
|
+
it "returns all included methods with :all = true" do
|
162
162
|
YARD.parse_string <<-eof
|
163
163
|
module B; def foo; end end
|
164
164
|
module C; def bar; end end
|
165
165
|
class A; include B; include C; def foo; end; def bar; end end
|
166
166
|
eof
|
167
|
-
Registry.at('A').included_meths(:all => true).
|
167
|
+
expect(Registry.at('A').included_meths(:all => true)).to eq [P('C#bar'), P('B#foo')]
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
@@ -3,87 +3,87 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe YARD::CodeObjects::Proxy do
|
4
4
|
before { Registry.clear }
|
5
5
|
|
6
|
-
it "
|
6
|
+
it "returns the object if it's in the Registry" do
|
7
7
|
pathobj = ModuleObject.new(:root, :YARD)
|
8
8
|
proxyobj = P(:root, :YARD)
|
9
|
-
proxyobj.type.
|
10
|
-
Proxy
|
9
|
+
expect(proxyobj.type).to eq :module
|
10
|
+
expect(Proxy === proxyobj).to be false
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "handles complex string namespaces" do
|
14
14
|
ModuleObject.new(:root, :A)
|
15
15
|
pathobj = ModuleObject.new(P(nil, :A), :B)
|
16
|
-
P(:root, "A::B").
|
16
|
+
expect(P(:root, "A::B")).to be_instance_of(ModuleObject)
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
20
|
-
Proxy
|
21
|
-
Proxy
|
19
|
+
it "does not return true to Proxy === obj if obj is a Proxy class holding a resolved object" do
|
20
|
+
expect(Proxy === P(:root, 'a')).to be true
|
21
|
+
expect(Proxy === P(:root)).to be false
|
22
22
|
MethodObject.new(:root, 'a')
|
23
|
-
Proxy
|
23
|
+
expect(Proxy === P(:root, 'a')).to be false
|
24
24
|
x = Proxy.new(:root, 'a')
|
25
|
-
Proxy
|
25
|
+
expect(Proxy === x).to be false
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "returns the object if it's an included Module" do
|
29
29
|
yardobj = ModuleObject.new(:root, :YARD)
|
30
30
|
pathobj = ClassObject.new(:root, :TestClass)
|
31
31
|
pathobj.instance_mixins << yardobj
|
32
|
-
P(P(nil, :TestClass), :YARD).
|
32
|
+
expect(P(P(nil, :TestClass), :YARD)).to be_instance_of(ModuleObject)
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
35
|
+
it "responds to respond_to?" do
|
36
36
|
obj = ClassObject.new(:root, :Object)
|
37
37
|
yardobj = ModuleObject.new(:root, :YARD)
|
38
|
-
P(:YARD).respond_to?(:children).
|
39
|
-
P(:NOTYARD).respond_to?(:children).
|
38
|
+
expect(P(:YARD).respond_to?(:children)).to be true
|
39
|
+
expect(P(:NOTYARD).respond_to?(:children)).to be false
|
40
40
|
|
41
|
-
P(:YARD).respond_to?(:initialize).
|
42
|
-
P(:YARD).respond_to?(:initialize, true).
|
43
|
-
P(:NOTYARD).respond_to?(:initialize).
|
44
|
-
P(:NOTYARD).respond_to?(:initialize, true).
|
41
|
+
expect(P(:YARD).respond_to?(:initialize)).to be false
|
42
|
+
expect(P(:YARD).respond_to?(:initialize, true)).to be true
|
43
|
+
expect(P(:NOTYARD).respond_to?(:initialize)).to be false
|
44
|
+
expect(P(:NOTYARD).respond_to?(:initialize, true)).to be true
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
47
|
+
it "makes itself obvious that it's a proxy" do
|
48
48
|
pathobj = P(:root, :YARD)
|
49
|
-
pathobj.class.
|
50
|
-
(Proxy === pathobj).
|
49
|
+
expect(pathobj.class).to eq Proxy
|
50
|
+
expect(Proxy === pathobj).to be true
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "pretends it's the object's type if it can resolve" do
|
54
54
|
pathobj = ModuleObject.new(:root, :YARD)
|
55
55
|
proxyobj = P(:root, :YARD)
|
56
|
-
proxyobj.
|
56
|
+
expect(proxyobj).to be_instance_of(ModuleObject)
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
59
|
+
it "handles instance method names" do
|
60
60
|
obj = P(nil, '#test')
|
61
|
-
obj.name.
|
62
|
-
obj.path.
|
63
|
-
obj.namespace.
|
61
|
+
expect(obj.name).to eq :test
|
62
|
+
expect(obj.path).to eq "#test"
|
63
|
+
expect(obj.namespace).to eq Registry.root
|
64
64
|
end
|
65
65
|
|
66
|
-
it "
|
66
|
+
it "handles instance method names under a namespace" do
|
67
67
|
pathobj = ModuleObject.new(:root, :YARD)
|
68
68
|
obj = P(pathobj, "A::B#test")
|
69
|
-
obj.name.
|
70
|
-
obj.path.
|
69
|
+
expect(obj.name).to eq :test
|
70
|
+
expect(obj.path).to eq "A::B#test"
|
71
71
|
end
|
72
72
|
|
73
|
-
it "
|
73
|
+
it "allows type to be changed" do
|
74
74
|
obj = P("InvalidClass")
|
75
|
-
obj.type.
|
76
|
-
Proxy
|
75
|
+
expect(obj.type).to eq :proxy
|
76
|
+
expect(Proxy === obj).to be true
|
77
77
|
obj.type = :class
|
78
|
-
obj.type.
|
78
|
+
expect(obj.type).to eq :class
|
79
79
|
end
|
80
80
|
|
81
|
-
it "
|
81
|
+
it "does NOT retain a type change between Proxy objects" do
|
82
82
|
P("InvalidClass").type = :class
|
83
|
-
P("InvalidClass").type.
|
83
|
+
expect(P("InvalidClass").type).to eq :proxy
|
84
84
|
end
|
85
85
|
|
86
|
-
it "
|
86
|
+
it "uses type to ensure resolved object is of intended type" do
|
87
87
|
YARD.parse_string <<-eof
|
88
88
|
module Foo
|
89
89
|
class Bar; end
|
@@ -92,49 +92,49 @@ describe YARD::CodeObjects::Proxy do
|
|
92
92
|
eof
|
93
93
|
proxy = Proxy.new(P('Foo'), 'Bar')
|
94
94
|
proxy.type = :method
|
95
|
-
proxy.path.
|
95
|
+
expect(proxy.path).to eq 'Foo.Bar'
|
96
96
|
end
|
97
97
|
|
98
|
-
it "
|
99
|
-
Proxy.new(Registry.root, 'Foo', :method).type.
|
100
|
-
P(Registry.root, 'Foo', :method).type.
|
98
|
+
it "allows type in initializer" do
|
99
|
+
expect(Proxy.new(Registry.root, 'Foo', :method).type).to eq :method
|
100
|
+
expect(P(Registry.root, 'Foo', :method).type).to eq :method
|
101
101
|
end
|
102
102
|
|
103
|
-
it "
|
104
|
-
P("MYPROXY").
|
105
|
-
P("X::A").
|
103
|
+
it "never equals Registry.root" do
|
104
|
+
expect(P("MYPROXY")).not_to eq Registry.root
|
105
|
+
expect(P("X::A")).not_to eq Registry.root
|
106
106
|
end
|
107
107
|
|
108
|
-
it "
|
108
|
+
it "resets namespace and name when object is resolved" do
|
109
109
|
obj1 = ModuleObject.new(:root, :YARD)
|
110
110
|
obj2 = ModuleObject.new(:root, :NOTYARD)
|
111
111
|
resolved = Proxy.new(obj2, :YARD)
|
112
|
-
resolved.
|
113
|
-
resolved.namespace.
|
114
|
-
resolved.name.
|
112
|
+
expect(resolved).to eq obj1
|
113
|
+
expect(resolved.namespace).to eq Registry.root
|
114
|
+
expect(resolved.name).to eq :YARD
|
115
115
|
end
|
116
116
|
|
117
|
-
it "
|
117
|
+
it "ensures that the correct object was resolved" do
|
118
118
|
foo = ModuleObject.new(:root, :Foo)
|
119
119
|
foobar = ModuleObject.new(foo, :Bar)
|
120
120
|
foobaz = ClassObject.new(foo, :Baz)
|
121
121
|
|
122
122
|
# Remember, we're looking for Qux::Bar, not just 'Bar'
|
123
123
|
proxy = Proxy.new(foobar, 'Foo::Qux::Bar')
|
124
|
-
proxy.type.
|
124
|
+
expect(proxy.type).to eq :proxy
|
125
125
|
|
126
126
|
qux = ModuleObject.new(foo, :Qux)
|
127
127
|
quxbar = ModuleObject.new(qux, :Bar)
|
128
128
|
|
129
129
|
# Now it should resolve
|
130
|
-
proxy.type.
|
130
|
+
expect(proxy.type).to eq :module
|
131
131
|
end
|
132
132
|
|
133
|
-
it "
|
133
|
+
it "handles constant names in namespaces" do
|
134
134
|
YARD.parse_string <<-eof
|
135
135
|
module A; end; B = A
|
136
136
|
module B::C; def foo; end end
|
137
137
|
eof
|
138
|
-
Proxy.new(:root, 'B::C').
|
138
|
+
expect(Proxy.new(:root, 'B::C')).to eq Registry.at('A::C')
|
139
139
|
end
|
140
140
|
end
|