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
@@ -5,144 +5,144 @@ describe YARD::CodeObjects::MacroObject do
|
|
5
5
|
Registry.clear
|
6
6
|
end
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe ".create" do
|
9
9
|
def create(*args) MacroObject.create(*args) end
|
10
10
|
|
11
|
-
it "
|
11
|
+
it "creates an object" do
|
12
12
|
create('foo', '')
|
13
13
|
obj = Registry.at('.macro.foo')
|
14
|
-
obj.
|
14
|
+
expect(obj).not_to be nil
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
17
|
+
it "uses identity map" do
|
18
18
|
obj1 = create('foo', '')
|
19
19
|
obj2 = create('foo', '')
|
20
|
-
obj1.object_id.
|
20
|
+
expect(obj1.object_id).to eq obj2.object_id
|
21
21
|
end
|
22
22
|
|
23
|
-
it "
|
23
|
+
it "allows specifying of macro data" do
|
24
24
|
obj = create('foo', 'MACRODATA')
|
25
|
-
obj.macro_data.
|
25
|
+
expect(obj.macro_data).to eq 'MACRODATA'
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
context "if a method object is provided" do
|
29
|
+
it "attaches it" do
|
30
|
+
obj = create('foo', 'MACRODATA', P('Foo.property'))
|
31
|
+
expect(obj.method_object).to eq P('Foo.property')
|
32
|
+
expect(obj).to be_attached
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
|
-
describe
|
37
|
+
describe ".find" do
|
36
38
|
before { MacroObject.create('foo', 'DATA') }
|
37
39
|
|
38
|
-
it "
|
39
|
-
MacroObject.find('foo').macro_data.
|
40
|
+
it "searches for an object by name" do
|
41
|
+
expect(MacroObject.find('foo').macro_data).to eq 'DATA'
|
40
42
|
end
|
41
43
|
|
42
|
-
it "
|
43
|
-
MacroObject.find(:foo).macro_data.
|
44
|
+
it "accepts Symbol" do
|
45
|
+
expect(MacroObject.find(:foo).macro_data).to eq 'DATA'
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
|
-
describe
|
48
|
-
it "
|
49
|
+
describe ".find_or_create" do
|
50
|
+
it "looks up name if @!macro is present and find object" do
|
49
51
|
macro1 = MacroObject.create('foo', 'FOO')
|
50
52
|
macro2 = MacroObject.find_or_create('foo', "a b c")
|
51
|
-
macro1.
|
53
|
+
expect(macro1).to eq macro2
|
52
54
|
end
|
53
55
|
|
54
|
-
it "
|
56
|
+
it "creates new macro if macro by that name does not exist" do
|
55
57
|
MacroObject.find_or_create('foo', "@!method $1")
|
56
|
-
MacroObject.find('foo').macro_data.
|
58
|
+
expect(MacroObject.find('foo').macro_data).to eq "@!method $1"
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
60
|
-
describe
|
61
|
-
|
62
|
-
@args = %w(foo a b c)
|
63
|
-
end
|
62
|
+
describe ".apply" do
|
63
|
+
let(:args) { %w(foo a b c) }
|
64
64
|
|
65
65
|
def apply(comments)
|
66
|
-
MacroObject.apply(comments,
|
66
|
+
MacroObject.apply(comments, args)
|
67
67
|
end
|
68
68
|
|
69
|
-
it "
|
70
|
-
apply("$1$2$3").
|
69
|
+
it "only expands macros if @macro is present" do
|
70
|
+
expect(apply("$1$2$3")).to eq "$1$2$3"
|
71
71
|
end
|
72
72
|
|
73
|
-
it "
|
74
|
-
apply("@!macro\n foo$1$2$3\nfoobaz").
|
73
|
+
it "handles macro text inside block" do
|
74
|
+
expect(apply("@!macro\n foo$1$2$3\nfoobaz")).to eq "fooabc\nfoobaz"
|
75
75
|
end
|
76
76
|
|
77
|
-
it "
|
77
|
+
it "appends docstring to existing macro" do
|
78
78
|
macro = MacroObject.create('name', '$3$2$1')
|
79
|
-
result = MacroObject.apply("@!macro name\nfoobar",
|
80
|
-
result.
|
79
|
+
result = MacroObject.apply("@!macro name\nfoobar", args)
|
80
|
+
expect(result).to eq "cba\nfoobar"
|
81
81
|
end
|
82
82
|
|
83
|
-
it "
|
83
|
+
it "uses only non-macro data if docstring is an existing macro" do
|
84
84
|
data = "@!macro name\n $3$2$1\nEXTRA"
|
85
|
-
result = MacroObject.apply(data,
|
86
|
-
result.
|
87
|
-
MacroObject.apply("@!macro name\nFOO",
|
85
|
+
result = MacroObject.apply(data, args, 'SOURCE')
|
86
|
+
expect(result).to eq "cba\nEXTRA"
|
87
|
+
expect(MacroObject.apply("@!macro name\nFOO", args)).to eq "cba\nFOO"
|
88
88
|
end
|
89
89
|
|
90
|
-
it "
|
91
|
-
result = MacroObject.apply("@!macro name\n foo!$1",
|
92
|
-
result.
|
93
|
-
MacroObject.find('name').macro_data.
|
90
|
+
it "creates macros if they don't exist" do
|
91
|
+
result = MacroObject.apply("@!macro name\n foo!$1", args, 'SOURCE')
|
92
|
+
expect(result).to eq "foo!a"
|
93
|
+
expect(MacroObject.find('name').macro_data).to eq 'foo!$1'
|
94
94
|
end
|
95
95
|
|
96
|
-
it "
|
97
|
-
apply("@!macro\n foo$1$2$3\n@param name foo\nfoo").
|
98
|
-
"fooabc\nfoo\n@param name\n foo"
|
96
|
+
it "keeps other tags" do
|
97
|
+
expect(apply("@!macro\n foo$1$2$3\n@param name foo\nfoo")).to eq(
|
98
|
+
"fooabc\nfoo\n@param name\n foo")
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
describe
|
102
|
+
describe ".expand" do
|
103
103
|
def expand(comments)
|
104
104
|
args = %w(foo a b c)
|
105
105
|
full_line = 'foo :bar, :baz'
|
106
106
|
MacroObject.expand(comments, args, full_line)
|
107
107
|
end
|
108
108
|
|
109
|
-
it "
|
110
|
-
expand("$1\\$2$3").
|
109
|
+
it "allows escaping of macro syntax" do
|
110
|
+
expect(expand("$1\\$2$3")).to eq "a$2c"
|
111
111
|
end
|
112
112
|
|
113
|
-
it "
|
114
|
-
expand("$* ${*}").
|
113
|
+
it "replaces $* with the whole statement" do
|
114
|
+
expect(expand("$* ${*}")).to eq "foo :bar, :baz foo :bar, :baz"
|
115
115
|
end
|
116
116
|
|
117
|
-
it "
|
118
|
-
expand("$0 ${0}").
|
117
|
+
it "replaces $0 with method name" do
|
118
|
+
expect(expand("$0 ${0}")).to eq "foo foo"
|
119
119
|
end
|
120
120
|
|
121
|
-
it "
|
122
|
-
expand("$1$2$3${3}\nfoobar").
|
121
|
+
it "replaces all $N values with the Nth argument in the method call" do
|
122
|
+
expect(expand("$1$2$3${3}\nfoobar")).to eq "abcc\nfoobar"
|
123
123
|
end
|
124
124
|
|
125
|
-
it "
|
126
|
-
expand("${1-2}x").
|
125
|
+
it "replaces ${N-M} ranges with N-M arguments (incl. commas)" do
|
126
|
+
expect(expand("${1-2}x")).to eq "a, bx"
|
127
127
|
end
|
128
128
|
|
129
|
-
it "
|
130
|
-
expand("${2-}").
|
129
|
+
it "handles open ended ranges (${N-})" do
|
130
|
+
expect(expand("${2-}")).to eq "b, c"
|
131
131
|
end
|
132
132
|
|
133
|
-
it "
|
134
|
-
expand("$-1 ${-2-} ${-2--2}").
|
133
|
+
it "handles negative indexes ($-N)" do
|
134
|
+
expect(expand("$-1 ${-2-} ${-2--2}")).to eq "c b, c b"
|
135
135
|
end
|
136
136
|
|
137
|
-
it "
|
138
|
-
expand(Docstring.new("$1\n@param name foo")).
|
137
|
+
it "accepts Docstring objects" do
|
138
|
+
expect(expand(Docstring.new("$1\n@param name foo"))).to eq "a\n@param name foo"
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
|
-
describe
|
143
|
-
it "
|
142
|
+
describe "#expand" do
|
143
|
+
it "expands a macro given its data" do
|
144
144
|
macro = MacroObject.create_docstring('foo', '$1 $2 THREE!')
|
145
|
-
macro.expand(['NAME', 'ONE', 'TWO']).
|
145
|
+
expect(macro.expand(['NAME', 'ONE', 'TWO'])).to eq "ONE TWO THREE!"
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
@@ -6,170 +6,178 @@ describe YARD::CodeObjects::MethodObject do
|
|
6
6
|
@yard = ModuleObject.new(:root, :YARD)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
context "for an instance method in the root" do
|
10
|
+
it "has a path of testing" do
|
11
|
+
meth = MethodObject.new(:root, :testing)
|
12
|
+
expect(meth.path).to eq "#testing"
|
13
|
+
end
|
12
14
|
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
context "for an instance method in YARD" do
|
17
|
+
it "has a path of YARD#testing" do
|
18
|
+
meth = MethodObject.new(@yard, :testing)
|
19
|
+
expect(meth.path).to eq "YARD#testing"
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
context "for a class method in YARD" do
|
24
|
+
it "has a path of YARD.testing" do
|
25
|
+
meth = MethodObject.new(@yard, :testing, :class)
|
26
|
+
expect(meth.path).to eq "YARD.testing"
|
27
|
+
end
|
22
28
|
end
|
23
29
|
|
24
|
-
|
25
|
-
|
26
|
-
|
30
|
+
context "for a class method added to root namespace" do
|
31
|
+
it "has a path of ::testing (note the ::)" do
|
32
|
+
meth = MethodObject.new(:root, :testing, :class)
|
33
|
+
expect(meth.path).to eq "::testing"
|
34
|
+
end
|
27
35
|
end
|
28
36
|
|
29
|
-
it "
|
37
|
+
it "exists in the registry after successful creation" do
|
30
38
|
obj = MethodObject.new(@yard, :something, :class)
|
31
|
-
Registry.at("YARD.something").
|
32
|
-
Registry.at("YARD#something").
|
33
|
-
Registry.at("YARD::something").
|
39
|
+
expect(Registry.at("YARD.something")).not_to be nil
|
40
|
+
expect(Registry.at("YARD#something")).to be nil
|
41
|
+
expect(Registry.at("YARD::something")).to be nil
|
34
42
|
obj = MethodObject.new(@yard, :somethingelse)
|
35
|
-
Registry.at("YARD#somethingelse").
|
43
|
+
expect(Registry.at("YARD#somethingelse")).not_to be nil
|
36
44
|
end
|
37
45
|
|
38
|
-
it "
|
46
|
+
it "allows #scope to be changed after creation" do
|
39
47
|
obj = MethodObject.new(@yard, :something, :class)
|
40
|
-
Registry.at("YARD.something").
|
48
|
+
expect(Registry.at("YARD.something")).not_to be nil
|
41
49
|
obj.scope = :instance
|
42
|
-
Registry.at("YARD.something").
|
43
|
-
Registry.at("YARD#something").
|
50
|
+
expect(Registry.at("YARD.something")).to be nil
|
51
|
+
expect(Registry.at("YARD#something")).not_to be nil
|
44
52
|
end
|
45
53
|
|
46
|
-
it "
|
54
|
+
it "creates object in :class scope if scope is :module" do
|
47
55
|
obj = MethodObject.new(@yard, :module_func, :module)
|
48
|
-
obj.scope.
|
49
|
-
obj.visibility.
|
50
|
-
Registry.at('YARD.module_func').
|
56
|
+
expect(obj.scope).to eq :class
|
57
|
+
expect(obj.visibility).to eq :public
|
58
|
+
expect(Registry.at('YARD.module_func')).not_to be nil
|
51
59
|
end
|
52
60
|
|
53
|
-
it "
|
61
|
+
it "creates second private instance method if scope is :module" do
|
54
62
|
MethodObject.new(@yard, :module_func, :module)
|
55
63
|
obj = Registry.at('YARD#module_func')
|
56
|
-
obj.
|
57
|
-
obj.visibility.
|
58
|
-
obj.scope.
|
64
|
+
expect(obj).not_to be nil
|
65
|
+
expect(obj.visibility).to eq :private
|
66
|
+
expect(obj.scope).to eq :instance
|
59
67
|
end
|
60
68
|
|
61
|
-
it "
|
69
|
+
it "yields block to second method if scope is :module" do
|
62
70
|
MethodObject.new(@yard, :module_func, :module) do |o|
|
63
71
|
o.docstring = 'foo'
|
64
72
|
end
|
65
|
-
Registry.at('YARD.module_func').docstring.
|
66
|
-
Registry.at('YARD#module_func').docstring.
|
73
|
+
expect(Registry.at('YARD.module_func').docstring).to eq 'foo'
|
74
|
+
expect(Registry.at('YARD#module_func').docstring).to eq 'foo'
|
67
75
|
end
|
68
76
|
|
69
|
-
describe
|
70
|
-
it "
|
77
|
+
describe "#name" do
|
78
|
+
it "shows a prefix for an instance method when prefix=true" do
|
71
79
|
obj = MethodObject.new(nil, :something)
|
72
|
-
obj.name(true).
|
80
|
+
expect(obj.name(true)).to eq "#something"
|
73
81
|
end
|
74
82
|
|
75
|
-
it "
|
83
|
+
it "never shows a prefix for a class method" do
|
76
84
|
obj = MethodObject.new(nil, :something, :class)
|
77
|
-
obj.name.
|
78
|
-
obj.name(true).
|
85
|
+
expect(obj.name).to eq :"something"
|
86
|
+
expect(obj.name(true)).to eq "something"
|
79
87
|
end
|
80
88
|
end
|
81
89
|
|
82
|
-
describe
|
83
|
-
it "
|
90
|
+
describe "#is_attribute?" do
|
91
|
+
it "only returns true if attribute is set in namespace for read/write" do
|
84
92
|
obj = MethodObject.new(@yard, :foo)
|
85
93
|
@yard.attributes[:instance][:foo] = {:read => obj, :write => nil}
|
86
|
-
obj.is_attribute
|
87
|
-
MethodObject.new(@yard, :foo=).is_attribute
|
94
|
+
expect(obj.is_attribute?).to be true
|
95
|
+
expect(MethodObject.new(@yard, :foo=).is_attribute?).to be false
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
91
|
-
describe
|
92
|
-
it "
|
99
|
+
describe "#attr_info" do
|
100
|
+
it "returns attribute info if namespace is available" do
|
93
101
|
obj = MethodObject.new(@yard, :foo)
|
94
102
|
@yard.attributes[:instance][:foo] = {:read => obj, :write => nil}
|
95
|
-
obj.attr_info.
|
103
|
+
expect(obj.attr_info).to eq @yard.attributes[:instance][:foo]
|
96
104
|
end
|
97
105
|
|
98
|
-
it "
|
106
|
+
it "returns nil if namespace is proxy" do
|
99
107
|
obj = MethodObject.new(P(:ProxyClass), :foo)
|
100
|
-
MethodObject.new(@yard, :foo).attr_info.
|
108
|
+
expect(MethodObject.new(@yard, :foo).attr_info).to eq nil
|
101
109
|
end
|
102
110
|
|
103
|
-
it "
|
104
|
-
MethodObject.new(@yard, :notanattribute).attr_info.
|
111
|
+
it "returns nil if meth is not an attribute" do
|
112
|
+
expect(MethodObject.new(@yard, :notanattribute).attr_info).to eq nil
|
105
113
|
end
|
106
114
|
end
|
107
115
|
|
108
|
-
describe
|
109
|
-
it "
|
116
|
+
describe "#writer?" do
|
117
|
+
it "returns true if method is a writer attribute" do
|
110
118
|
obj = MethodObject.new(@yard, :foo=)
|
111
119
|
@yard.attributes[:instance][:foo] = {:read => nil, :write => obj}
|
112
|
-
obj.writer
|
113
|
-
MethodObject.new(@yard, :NOTfoo=).writer
|
120
|
+
expect(obj.writer?).to be true
|
121
|
+
expect(MethodObject.new(@yard, :NOTfoo=).writer?).to be false
|
114
122
|
end
|
115
123
|
end
|
116
124
|
|
117
|
-
describe
|
118
|
-
it "
|
125
|
+
describe "#reader?" do
|
126
|
+
it "returns true if method is a reader attribute" do
|
119
127
|
obj = MethodObject.new(@yard, :foo)
|
120
128
|
@yard.attributes[:instance][:foo] = {:read => obj, :write => nil}
|
121
|
-
obj.reader
|
122
|
-
MethodObject.new(@yard, :NOTfoo).reader
|
129
|
+
expect(obj.reader?).to be true
|
130
|
+
expect(MethodObject.new(@yard, :NOTfoo).reader?).to be false
|
123
131
|
end
|
124
132
|
end
|
125
133
|
|
126
|
-
describe
|
134
|
+
describe "#constructor?" do
|
127
135
|
before { @class = ClassObject.new(:root, :MyClass) }
|
128
136
|
|
129
|
-
it "
|
137
|
+
it "marks the #initialize method as constructor" do
|
130
138
|
MethodObject.new(@class, :initialize)
|
131
139
|
end
|
132
140
|
|
133
|
-
it "
|
134
|
-
MethodObject.new(@class, :initialize, :class).constructor
|
141
|
+
it "does not mark Klass.initialize as constructor" do
|
142
|
+
expect(MethodObject.new(@class, :initialize, :class).constructor?).to be false
|
135
143
|
end
|
136
144
|
|
137
|
-
it "
|
138
|
-
MethodObject.new(@yard, :initialize).constructor
|
145
|
+
it "does not mark module method #initialize as constructor" do
|
146
|
+
expect(MethodObject.new(@yard, :initialize).constructor?).to be false
|
139
147
|
end
|
140
148
|
end
|
141
149
|
|
142
|
-
describe
|
150
|
+
describe "#overridden_method" do
|
143
151
|
before { Registry.clear }
|
144
152
|
|
145
|
-
it "
|
153
|
+
it "returns overridden method from mixin first" do
|
146
154
|
YARD.parse_string(<<-eof)
|
147
155
|
module C; def foo; end end
|
148
156
|
class A; def foo; end end
|
149
157
|
class B < A; include C; def foo; end end
|
150
158
|
eof
|
151
|
-
Registry.at('B#foo').overridden_method.
|
159
|
+
expect(Registry.at('B#foo').overridden_method).to eq Registry.at('C#foo')
|
152
160
|
end
|
153
161
|
|
154
|
-
it "
|
162
|
+
it "returns overridden method from superclass" do
|
155
163
|
YARD.parse_string(<<-eof)
|
156
164
|
class A; def foo; end end
|
157
165
|
class B < A; def foo; end end
|
158
166
|
eof
|
159
|
-
Registry.at('B#foo').overridden_method.
|
167
|
+
expect(Registry.at('B#foo').overridden_method).to eq Registry.at('A#foo')
|
160
168
|
end
|
161
169
|
|
162
|
-
it "
|
170
|
+
it "returns nil if none is found" do
|
163
171
|
YARD.parse_string(<<-eof)
|
164
172
|
class A; end
|
165
173
|
class B < A; def foo; end end
|
166
174
|
eof
|
167
|
-
Registry.at('B#foo').overridden_method.
|
175
|
+
expect(Registry.at('B#foo').overridden_method).to be nil
|
168
176
|
end
|
169
177
|
|
170
|
-
it "
|
178
|
+
it "returns nil if namespace is a proxy" do
|
171
179
|
YARD.parse_string "def ARGV.foo; end"
|
172
|
-
Registry.at('ARGV.foo').overridden_method.
|
180
|
+
expect(Registry.at('ARGV.foo').overridden_method).to be nil
|
173
181
|
end
|
174
182
|
end
|
175
183
|
end
|