yard 0.9.24 → 0.9.25
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/.rubocop.yml +37 -24
- data/CHANGELOG.md +18 -3
- data/README.md +96 -101
- data/Rakefile +2 -0
- data/lib/yard/cli/diff.rb +4 -1
- data/lib/yard/cli/server.rb +22 -13
- data/lib/yard/code_objects/proxy.rb +2 -1
- data/lib/yard/globals.rb +1 -1
- data/lib/yard/handlers/c/base.rb +164 -129
- data/lib/yard/parser/ruby/ruby_parser.rb +6 -4
- data/lib/yard/registry_store.rb +1 -1
- data/lib/yard/templates/helpers/html_helper.rb +10 -3
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +5 -4
- data/lib/yard/version.rb +1 -1
- data/tasks/update_error_map.rake +53 -0
- data/yard.gemspec +1 -1
- metadata +3 -207
- data/spec/cli/command_parser_spec.rb +0 -43
- data/spec/cli/command_spec.rb +0 -36
- data/spec/cli/config_spec.rb +0 -148
- data/spec/cli/diff_spec.rb +0 -254
- data/spec/cli/display_spec.rb +0 -30
- data/spec/cli/gems_spec.rb +0 -81
- data/spec/cli/graph_spec.rb +0 -18
- data/spec/cli/help_spec.rb +0 -22
- data/spec/cli/i18n_spec.rb +0 -107
- data/spec/cli/list_spec.rb +0 -8
- data/spec/cli/markup_types_spec.rb +0 -22
- data/spec/cli/server_spec.rb +0 -324
- data/spec/cli/stats_spec.rb +0 -96
- data/spec/cli/yard_on_yard_spec.rb +0 -38
- data/spec/cli/yardoc_spec.rb +0 -896
- data/spec/cli/yri_spec.rb +0 -101
- data/spec/code_objects/base_spec.rb +0 -485
- data/spec/code_objects/class_object_spec.rb +0 -226
- data/spec/code_objects/code_object_list_spec.rb +0 -36
- data/spec/code_objects/constants_spec.rb +0 -116
- data/spec/code_objects/extra_file_object_spec.rb +0 -161
- data/spec/code_objects/macro_object_spec.rb +0 -150
- data/spec/code_objects/method_object_spec.rb +0 -184
- data/spec/code_objects/module_object_spec.rb +0 -142
- data/spec/code_objects/namespace_mapper_spec.rb +0 -32
- data/spec/code_objects/namespace_object_spec.rb +0 -171
- data/spec/code_objects/proxy_spec.rb +0 -147
- data/spec/code_objects/spec_helper.rb +0 -3
- data/spec/config_spec.rb +0 -171
- data/spec/core_ext/array_spec.rb +0 -13
- data/spec/core_ext/file_spec.rb +0 -72
- data/spec/core_ext/hash_spec.rb +0 -14
- data/spec/core_ext/insertion_spec.rb +0 -37
- data/spec/core_ext/module_spec.rb +0 -9
- data/spec/core_ext/string_spec.rb +0 -42
- data/spec/core_ext/symbol_hash_spec.rb +0 -89
- data/spec/docstring_parser_spec.rb +0 -280
- data/spec/docstring_spec.rb +0 -373
- data/spec/handlers/alias_handler_spec.rb +0 -82
- data/spec/handlers/attribute_handler_spec.rb +0 -96
- data/spec/handlers/base_spec.rb +0 -216
- data/spec/handlers/c/alias_handler_spec.rb +0 -34
- data/spec/handlers/c/attribute_handler_spec.rb +0 -41
- data/spec/handlers/c/class_handler_spec.rb +0 -78
- data/spec/handlers/c/constant_handler_spec.rb +0 -71
- data/spec/handlers/c/init_handler_spec.rb +0 -48
- data/spec/handlers/c/method_handler_spec.rb +0 -327
- data/spec/handlers/c/mixin_handler_spec.rb +0 -44
- data/spec/handlers/c/module_handler_spec.rb +0 -71
- data/spec/handlers/c/override_comment_handler_spec.rb +0 -47
- data/spec/handlers/c/path_handler_spec.rb +0 -36
- data/spec/handlers/c/spec_helper.rb +0 -23
- data/spec/handlers/c/struct_handler_spec.rb +0 -16
- data/spec/handlers/class_condition_handler_spec.rb +0 -87
- data/spec/handlers/class_handler_spec.rb +0 -247
- data/spec/handlers/class_method_handler_shared_examples.rb +0 -133
- data/spec/handlers/class_variable_handler_spec.rb +0 -12
- data/spec/handlers/constant_handler_spec.rb +0 -112
- data/spec/handlers/decorator_handler_methods_spec.rb +0 -393
- data/spec/handlers/dsl_handler_spec.rb +0 -226
- data/spec/handlers/examples/alias_handler_001.rb.txt +0 -46
- data/spec/handlers/examples/attribute_handler_001.rb.txt +0 -32
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +0 -69
- data/spec/handlers/examples/class_handler_001.rb.txt +0 -120
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +0 -10
- data/spec/handlers/examples/constant_handler_001.rb.txt +0 -35
- data/spec/handlers/examples/dsl_handler_001.rb.txt +0 -156
- data/spec/handlers/examples/exception_handler_001.rb.txt +0 -59
- data/spec/handlers/examples/extend_handler_001.rb.txt +0 -19
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +0 -10
- data/spec/handlers/examples/method_handler_001.rb.txt +0 -128
- data/spec/handlers/examples/mixin_handler_001.rb.txt +0 -40
- data/spec/handlers/examples/module_handler_001.rb.txt +0 -29
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +0 -8
- data/spec/handlers/examples/process_handler_001.rb.txt +0 -11
- data/spec/handlers/examples/visibility_handler_001.rb.txt +0 -36
- data/spec/handlers/examples/yield_handler_001.rb.txt +0 -54
- data/spec/handlers/exception_handler_spec.rb +0 -49
- data/spec/handlers/extend_handler_spec.rb +0 -28
- data/spec/handlers/legacy_base_spec.rb +0 -128
- data/spec/handlers/method_condition_handler_spec.rb +0 -15
- data/spec/handlers/method_handler_spec.rb +0 -214
- data/spec/handlers/mixin_handler_spec.rb +0 -60
- data/spec/handlers/module_function_handler_spec.rb +0 -106
- data/spec/handlers/module_handler_spec.rb +0 -35
- data/spec/handlers/private_class_method_handler_spec.rb +0 -11
- data/spec/handlers/private_constant_handler_spec.rb +0 -25
- data/spec/handlers/processor_spec.rb +0 -35
- data/spec/handlers/public_class_method_handler_spec.rb +0 -11
- data/spec/handlers/ruby/base_spec.rb +0 -95
- data/spec/handlers/ruby/legacy/base_spec.rb +0 -84
- data/spec/handlers/spec_helper.rb +0 -33
- data/spec/handlers/visibility_handler_spec.rb +0 -44
- data/spec/handlers/yield_handler_spec.rb +0 -52
- data/spec/i18n/locale_spec.rb +0 -81
- data/spec/i18n/message_spec.rb +0 -52
- data/spec/i18n/messages_spec.rb +0 -67
- data/spec/i18n/pot_generator_spec.rb +0 -295
- data/spec/i18n/text_spec.rb +0 -184
- data/spec/logging_spec.rb +0 -44
- data/spec/options_spec.rb +0 -171
- data/spec/parser/base_spec.rb +0 -24
- data/spec/parser/c_parser_spec.rb +0 -236
- data/spec/parser/examples/array.c.txt +0 -6267
- data/spec/parser/examples/example1.rb.txt +0 -8
- data/spec/parser/examples/extrafile.c.txt +0 -8
- data/spec/parser/examples/file.c.txt +0 -28
- data/spec/parser/examples/multifile.c.txt +0 -22
- data/spec/parser/examples/namespace.cpp.txt +0 -68
- data/spec/parser/examples/override.c.txt +0 -424
- data/spec/parser/examples/parse_in_order_001.rb.txt +0 -2
- data/spec/parser/examples/parse_in_order_002.rb.txt +0 -2
- data/spec/parser/examples/tag_handler_001.rb.txt +0 -8
- data/spec/parser/ruby/ast_node_spec.rb +0 -33
- data/spec/parser/ruby/legacy/statement_list_spec.rb +0 -299
- data/spec/parser/ruby/legacy/token_list_spec.rb +0 -79
- data/spec/parser/ruby/ruby_parser_spec.rb +0 -520
- data/spec/parser/ruby/token_resolver_spec.rb +0 -165
- data/spec/parser/source_parser_spec.rb +0 -727
- data/spec/parser/tag_parsing_spec.rb +0 -17
- data/spec/rake/yardoc_task_spec.rb +0 -118
- data/spec/registry_resolver_spec.rb +0 -15
- data/spec/registry_spec.rb +0 -463
- data/spec/registry_store_spec.rb +0 -327
- data/spec/rubygems/doc_manager_spec.rb +0 -112
- data/spec/serializers/data/serialized_yardoc/checksums +0 -1
- data/spec/serializers/data/serialized_yardoc/objects/Foo.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/root.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/proxy_types +0 -2
- data/spec/serializers/file_system_serializer_spec.rb +0 -145
- data/spec/serializers/spec_helper.rb +0 -2
- data/spec/serializers/yardoc_serializer_spec.rb +0 -90
- data/spec/server/adapter_spec.rb +0 -39
- data/spec/server/commands/base_spec.rb +0 -91
- data/spec/server/commands/library_command_spec.rb +0 -39
- data/spec/server/doc_server_helper_spec.rb +0 -72
- data/spec/server/doc_server_serializer_spec.rb +0 -60
- data/spec/server/rack_adapter_spec.rb +0 -21
- data/spec/server/router_spec.rb +0 -123
- data/spec/server/spec_helper.rb +0 -22
- data/spec/server/static_caching_spec.rb +0 -47
- data/spec/server/webrick_servlet_spec.rb +0 -20
- data/spec/server_spec.rb +0 -19
- data/spec/spec_helper.rb +0 -212
- data/spec/tags/default_factory_spec.rb +0 -168
- data/spec/tags/default_tag_spec.rb +0 -11
- data/spec/tags/directives_spec.rb +0 -463
- data/spec/tags/library_spec.rb +0 -48
- data/spec/tags/overload_tag_spec.rb +0 -53
- data/spec/tags/ref_tag_list_spec.rb +0 -53
- data/spec/tags/types_explainer_spec.rb +0 -203
- data/spec/templates/class_spec.rb +0 -45
- data/spec/templates/constant_spec.rb +0 -41
- data/spec/templates/engine_spec.rb +0 -131
- data/spec/templates/examples/class001.html +0 -308
- data/spec/templates/examples/class001.txt +0 -36
- data/spec/templates/examples/class002.html +0 -39
- data/spec/templates/examples/constant001.txt +0 -25
- data/spec/templates/examples/constant002.txt +0 -7
- data/spec/templates/examples/constant003.txt +0 -11
- data/spec/templates/examples/method001.html +0 -137
- data/spec/templates/examples/method001.txt +0 -35
- data/spec/templates/examples/method002.html +0 -91
- data/spec/templates/examples/method002.txt +0 -20
- data/spec/templates/examples/method003.html +0 -165
- data/spec/templates/examples/method003.txt +0 -45
- data/spec/templates/examples/method004.html +0 -48
- data/spec/templates/examples/method004.txt +0 -10
- data/spec/templates/examples/method005.html +0 -105
- data/spec/templates/examples/method005.txt +0 -33
- data/spec/templates/examples/method006.html +0 -108
- data/spec/templates/examples/method006.txt +0 -20
- data/spec/templates/examples/module001.dot +0 -33
- data/spec/templates/examples/module001.html +0 -833
- data/spec/templates/examples/module001.txt +0 -33
- data/spec/templates/examples/module002.html +0 -341
- data/spec/templates/examples/module003.html +0 -202
- data/spec/templates/examples/module004.html +0 -394
- data/spec/templates/examples/module005.html +0 -82
- data/spec/templates/examples/tag001.txt +0 -82
- data/spec/templates/helpers/base_helper_spec.rb +0 -171
- data/spec/templates/helpers/html_helper_spec.rb +0 -666
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +0 -65
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +0 -84
- data/spec/templates/helpers/markup_helper_spec.rb +0 -136
- data/spec/templates/helpers/method_helper_spec.rb +0 -107
- data/spec/templates/helpers/module_helper_spec.rb +0 -35
- data/spec/templates/helpers/shared_signature_examples.rb +0 -126
- data/spec/templates/helpers/text_helper_spec.rb +0 -65
- data/spec/templates/markup_processor_integrations/asciidoctor_spec.rb +0 -60
- data/spec/templates/markup_processor_integrations/integration_spec_helper.rb +0 -50
- data/spec/templates/markup_processor_integrations/rdoc_markdown_spec.rb +0 -48
- data/spec/templates/markup_processor_integrations/rdoc_spec.rb +0 -39
- data/spec/templates/markup_processor_integrations/redcarpet_spec.rb +0 -64
- data/spec/templates/markup_processor_integrations/redcloth_spec.rb +0 -64
- data/spec/templates/method_spec.rb +0 -118
- data/spec/templates/module_spec.rb +0 -203
- data/spec/templates/onefile_spec.rb +0 -66
- data/spec/templates/section_spec.rb +0 -144
- data/spec/templates/spec_helper.rb +0 -76
- data/spec/templates/tag_spec.rb +0 -52
- data/spec/templates/template_spec.rb +0 -410
- data/spec/verifier_spec.rb +0 -106
data/spec/docstring_spec.rb
DELETED
@@ -1,373 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe YARD::Docstring do
|
4
|
-
before { YARD::Registry.clear }
|
5
|
-
|
6
|
-
describe "#initialize" do
|
7
|
-
it "handles docstrings with empty newlines" do
|
8
|
-
expect(Docstring.new("\n\n")).to eq ""
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#+" do
|
13
|
-
it "adds another Docstring" do
|
14
|
-
d = Docstring.new("FOO") + Docstring.new("BAR")
|
15
|
-
expect(d).to eq "FOO\nBAR"
|
16
|
-
end
|
17
|
-
|
18
|
-
it "copies over tags" do
|
19
|
-
d1 = Docstring.new("FOO\n@api private\n")
|
20
|
-
d2 = Docstring.new("BAR\n@param foo descr")
|
21
|
-
d = (d1 + d2)
|
22
|
-
expect(d).to have_tag(:api)
|
23
|
-
expect(d).to have_tag(:param)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "adds a String" do
|
27
|
-
d = Docstring.new("FOO") + "BAR"
|
28
|
-
expect(d).to eq "FOOBAR"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#line" do
|
33
|
-
it "returns nil if #line_range is not set" do
|
34
|
-
expect(Docstring.new('foo').line).to be nil
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns line_range.first if #line_range is set" do
|
38
|
-
doc = Docstring.new('foo')
|
39
|
-
doc.line_range = (1..10)
|
40
|
-
expect(doc.line).to eq doc.line_range.first
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#summary" do
|
45
|
-
it "handles empty docstrings" do
|
46
|
-
o1 = Docstring.new
|
47
|
-
expect(o1.summary).to eq ""
|
48
|
-
end
|
49
|
-
|
50
|
-
it "handles multiple calls" do
|
51
|
-
o1 = Docstring.new("Hello. world")
|
52
|
-
5.times { expect(o1.summary).to eq "Hello." }
|
53
|
-
end
|
54
|
-
|
55
|
-
it "strips newlines in first paragraph before summarizing" do
|
56
|
-
doc = Docstring.new("Foo\n<code>==</code> bar.")
|
57
|
-
expect(doc.summary).to eq 'Foo <code>==</code> bar.'
|
58
|
-
end
|
59
|
-
|
60
|
-
it "returns the first sentence" do
|
61
|
-
o = Docstring.new("DOCSTRING. Another sentence")
|
62
|
-
expect(o.summary).to eq "DOCSTRING."
|
63
|
-
end
|
64
|
-
|
65
|
-
it "returns the first paragraph" do
|
66
|
-
o = Docstring.new("DOCSTRING, and other stuff\n\nAnother sentence.")
|
67
|
-
expect(o.summary).to eq "DOCSTRING, and other stuff."
|
68
|
-
end
|
69
|
-
|
70
|
-
it "returns proper summary when docstring is changed" do
|
71
|
-
o = Docstring.new "DOCSTRING, and other stuff\n\nAnother sentence."
|
72
|
-
expect(o.summary).to eq "DOCSTRING, and other stuff."
|
73
|
-
o = Docstring.new "DOCSTRING."
|
74
|
-
expect(o.summary).to eq "DOCSTRING."
|
75
|
-
end
|
76
|
-
|
77
|
-
it "does not double the ending period" do
|
78
|
-
o = Docstring.new("Returns a list of tags specified by +name+ or all tags if +name+ is not specified.\n\nTest")
|
79
|
-
expect(o.summary).to eq "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
|
80
|
-
|
81
|
-
doc = Docstring.new(<<-eof)
|
82
|
-
|
83
|
-
Returns a list of tags specified by +name+ or all tags if +name+ is not specified.
|
84
|
-
|
85
|
-
@param name the tag name to return data for, or nil for all tags
|
86
|
-
@return [Array<Tags::Tag>] the list of tags by the specified tag name
|
87
|
-
eof
|
88
|
-
expect(doc.summary).to eq "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
|
89
|
-
end
|
90
|
-
|
91
|
-
it "does not attach period if entire summary is include" do
|
92
|
-
YARD.parse_string "# docstring\ndef foo; end"
|
93
|
-
expect(Docstring.new("{include:#foo}").summary).to eq '{include:#foo}'
|
94
|
-
Registry.clear
|
95
|
-
end
|
96
|
-
|
97
|
-
it "handles references embedded in summary" do
|
98
|
-
expect(Docstring.new("Aliasing {Test.test}. Done.").summary).to eq "Aliasing {Test.test}."
|
99
|
-
end
|
100
|
-
|
101
|
-
it "only ends first sentence when outside parentheses" do
|
102
|
-
expect(Docstring.new("Hello (the best.) world. Foo bar.").summary).to eq "Hello (the best.) world."
|
103
|
-
expect(Docstring.new("A[b.]c.").summary).to eq "A[b.]c."
|
104
|
-
end
|
105
|
-
|
106
|
-
it "only sees '.' as period if whitespace (or eof) follows" do
|
107
|
-
expect(Docstring.new("hello 1.5 times.").summary).to eq "hello 1.5 times."
|
108
|
-
expect(Docstring.new("hello... me").summary).to eq "hello..."
|
109
|
-
expect(Docstring.new("hello.").summary).to eq "hello."
|
110
|
-
end
|
111
|
-
|
112
|
-
it "returns summary if there is a newline and parentheses count doesn't match" do
|
113
|
-
expect(Docstring.new("Happy method call :-)\n\nCall any time.").summary).to eq "Happy method call :-)."
|
114
|
-
expect(Docstring.new("Sad method call :-(\n\nCall any time.").summary).to eq "Sad method call :-(."
|
115
|
-
expect(Docstring.new("Hello (World. Forget to close.\n\nNew text").summary).to eq "Hello (World. Forget to close."
|
116
|
-
expect(Docstring.new("Hello (World. Forget to close\n\nNew text").summary).to eq "Hello (World. Forget to close."
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe "#ref_tags" do
|
121
|
-
it "parses reference tag into ref_tags" do
|
122
|
-
doc = Docstring.new("@return (see Foo#bar)")
|
123
|
-
expect(doc.ref_tags.size).to eq 1
|
124
|
-
expect(doc.ref_tags.first.owner).to eq P("Foo#bar")
|
125
|
-
expect(doc.ref_tags.first.tag_name).to eq "return"
|
126
|
-
expect(doc.ref_tags.first.name).to be nil
|
127
|
-
end
|
128
|
-
|
129
|
-
it "parses named reference tag into ref_tags" do
|
130
|
-
doc = Docstring.new("@param blah \n (see Foo#bar )")
|
131
|
-
expect(doc.ref_tags.size).to eq 1
|
132
|
-
expect(doc.ref_tags.first.owner).to eq P("Foo#bar")
|
133
|
-
expect(doc.ref_tags.first.tag_name).to eq "param"
|
134
|
-
expect(doc.ref_tags.first.name).to eq "blah"
|
135
|
-
end
|
136
|
-
|
137
|
-
it "fails to parse named reference tag into ref_tags" do
|
138
|
-
doc = Docstring.new("@param blah THIS_BREAKS_REFTAG (see Foo#bar)")
|
139
|
-
expect(doc.ref_tags.size).to eq 0
|
140
|
-
end
|
141
|
-
|
142
|
-
it "returns all valid reference tags along with #tags" do
|
143
|
-
o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
|
144
|
-
o.docstring.add_tag Tags::Tag.new('return', 'testing')
|
145
|
-
doc = Docstring.new("@return (see Foo#bar)")
|
146
|
-
tags = doc.tags
|
147
|
-
expect(tags.size).to eq 1
|
148
|
-
expect(tags.first.text).to eq 'testing'
|
149
|
-
expect(tags.first).to be_kind_of(Tags::RefTag)
|
150
|
-
expect(tags.first.owner).to eq o
|
151
|
-
end
|
152
|
-
|
153
|
-
it "returns all valid named reference tags along with #tags(name)" do
|
154
|
-
o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
|
155
|
-
o.docstring.add_tag Tags::Tag.new('param', 'testing', nil, '*args')
|
156
|
-
o.docstring.add_tag Tags::Tag.new('param', 'NOTtesting', nil, 'notargs')
|
157
|
-
doc = Docstring.new("@param *args (see Foo#bar)")
|
158
|
-
tags = doc.tags('param')
|
159
|
-
expect(tags.size).to eq 1
|
160
|
-
expect(tags.first.text).to eq 'testing'
|
161
|
-
expect(tags.first).to be_kind_of(Tags::RefTag)
|
162
|
-
expect(tags.first.owner).to eq o
|
163
|
-
end
|
164
|
-
|
165
|
-
it "ignores invalid reference tags" do
|
166
|
-
doc = Docstring.new("@param *args (see INVALID::TAG#tag)")
|
167
|
-
tags = doc.tags('param')
|
168
|
-
expect(tags.size).to eq 0
|
169
|
-
end
|
170
|
-
|
171
|
-
it "resolves references to methods in the same class with #methname" do
|
172
|
-
klass = CodeObjects::ClassObject.new(:root, "Foo")
|
173
|
-
o = CodeObjects::MethodObject.new(klass, "bar")
|
174
|
-
ref = CodeObjects::MethodObject.new(klass, "baz")
|
175
|
-
o.docstring.add_tag Tags::Tag.new('param', 'testing', nil, 'arg1')
|
176
|
-
ref.docstring = "@param (see #bar)"
|
177
|
-
|
178
|
-
tags = ref.docstring.tags("param")
|
179
|
-
expect(tags.size).to eq 1
|
180
|
-
expect(tags.first.text).to eq "testing"
|
181
|
-
expect(tags.first).to be_kind_of(Tags::RefTag)
|
182
|
-
expect(tags.first.owner).to eq o
|
183
|
-
end
|
184
|
-
|
185
|
-
it "returns an empty list (and warning) if circular reftags are found" do
|
186
|
-
YARD.parse_string <<-eof
|
187
|
-
class Foo
|
188
|
-
# @param (see #b)
|
189
|
-
def a; end
|
190
|
-
# @param (see #a)
|
191
|
-
def b; end
|
192
|
-
end
|
193
|
-
eof
|
194
|
-
|
195
|
-
expect(log.io.string).to match(/error.*circular reference tag in `Foo#b'/)
|
196
|
-
expect(Registry.at('Foo#a').tags).to be_empty
|
197
|
-
expect(Registry.at('Foo#b').tags).to be_empty
|
198
|
-
end
|
199
|
-
|
200
|
-
it "returns an empty list (and warning) if self-circular reftags are found" do
|
201
|
-
YARD.parse_string <<-eof
|
202
|
-
class Foo
|
203
|
-
# @param (see #bar)
|
204
|
-
def bar; end
|
205
|
-
end
|
206
|
-
eof
|
207
|
-
|
208
|
-
expect(log.io.string).to match(/error.*circular reference tag in `Foo#bar'/)
|
209
|
-
expect(Registry.at('Foo#bar').tags).to be_empty
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
describe "#empty?/#blank?" do
|
214
|
-
before(:all) do
|
215
|
-
Tags::Library.define_tag "Invisible", :invisible_tag
|
216
|
-
end
|
217
|
-
|
218
|
-
it "is blank and empty if it has no content and no tags" do
|
219
|
-
expect(Docstring.new).to be_blank
|
220
|
-
expect(Docstring.new).to be_empty
|
221
|
-
end
|
222
|
-
|
223
|
-
it "isn't empty or blank if it has content" do
|
224
|
-
d = Docstring.new("foo bar")
|
225
|
-
expect(d).not_to be_empty
|
226
|
-
expect(d).not_to be_blank
|
227
|
-
end
|
228
|
-
|
229
|
-
it "is empty but not blank if it has tags" do
|
230
|
-
d = Docstring.new("@param foo")
|
231
|
-
expect(d).to be_empty
|
232
|
-
expect(d).not_to be_blank
|
233
|
-
end
|
234
|
-
|
235
|
-
it "is empty but not blank if it has ref tags" do
|
236
|
-
o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
|
237
|
-
o.docstring.add_tag Tags::Tag.new('return', 'testing')
|
238
|
-
d = Docstring.new("@return (see Foo#bar)")
|
239
|
-
expect(d).to be_empty
|
240
|
-
expect(d).not_to be_blank
|
241
|
-
end
|
242
|
-
|
243
|
-
it "is blank if it has no visible tags" do
|
244
|
-
d = Docstring.new("@invisible_tag value")
|
245
|
-
expect(d).to be_blank
|
246
|
-
end
|
247
|
-
|
248
|
-
it "is not blank if it has invisible tags and only_visible_tags = false" do
|
249
|
-
d = Docstring.new("@invisible_tag value")
|
250
|
-
d.add_tag Tags::Tag.new('invisible_tag', nil, nil)
|
251
|
-
expect(d.blank?(false)).to be false
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
describe "#delete_tags" do
|
256
|
-
it "deletes tags by a given tag name" do
|
257
|
-
doc = Docstring.new("@param name x\n@param name2 y\n@return foo")
|
258
|
-
doc.delete_tags(:param)
|
259
|
-
expect(doc.tags.size).to eq 1
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
describe "#delete_tag_if" do
|
264
|
-
it "deletes tags for a given block" do
|
265
|
-
doc = Docstring.new("@param name x\n@param name2 y\n@return foo")
|
266
|
-
doc.delete_tag_if {|t| t.name == 'name2' }
|
267
|
-
expect(doc.tags.size).to eq 2
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
describe "#to_raw" do
|
272
|
-
it "returns a clean representation of tags" do
|
273
|
-
doc = Docstring.new("Hello world\n@return [String, X] foobar\n@param name<Array> the name\nBYE!")
|
274
|
-
expect(doc.to_raw).to eq "Hello world\nBYE!\n@param [Array] name\n the name\n@return [String, X] foobar"
|
275
|
-
end
|
276
|
-
|
277
|
-
it "handles tags with newlines and indentation" do
|
278
|
-
doc = Docstring.new("@example TITLE\n the \n example\n @foo\n@param [X] name\n the name")
|
279
|
-
expect(doc.to_raw).to eq "@example TITLE\n the \n example\n @foo\n@param [X] name\n the name"
|
280
|
-
end
|
281
|
-
|
282
|
-
it "handles deleted tags" do
|
283
|
-
doc = Docstring.new("@example TITLE\n the \n example\n @foo\n@param [X] name\n the name")
|
284
|
-
doc.delete_tags(:param)
|
285
|
-
expect(doc.to_raw).to eq "@example TITLE\n the \n example\n @foo"
|
286
|
-
end
|
287
|
-
|
288
|
-
it "handles added tags" do
|
289
|
-
doc = Docstring.new("@example TITLE\n the \n example\n @foo")
|
290
|
-
doc.add_tag(Tags::Tag.new('foo', 'foo'))
|
291
|
-
expect(doc.to_raw).to eq "@example TITLE\n the \n example\n @foo\n@foo foo"
|
292
|
-
end
|
293
|
-
|
294
|
-
it "is equal to .all if not modified" do
|
295
|
-
doc = Docstring.new("123\n@param")
|
296
|
-
expect(doc.to_raw).to eq doc.all
|
297
|
-
end
|
298
|
-
|
299
|
-
it "is stable sorting tags" do
|
300
|
-
expected = Docstring.new("123\n@param x\n@param y\n@version A")
|
301
|
-
doc = Docstring.new("123")
|
302
|
-
doc.add_tag(Tags::Tag.new('version', 'A'))
|
303
|
-
doc.add_tag(Tags::Tag.new('param', 'x'))
|
304
|
-
doc.add_tag(Tags::Tag.new('param', 'y'))
|
305
|
-
expect(doc.to_raw).to eq expected.all
|
306
|
-
end
|
307
|
-
|
308
|
-
# @bug gh-563
|
309
|
-
it "handles full @option tags" do
|
310
|
-
doc = Docstring.new("@option foo [String] bar (nil) baz")
|
311
|
-
expect(doc.to_raw).to eq "@option foo [String] bar (nil) baz"
|
312
|
-
end
|
313
|
-
|
314
|
-
# @bug gh-563
|
315
|
-
it "handles simple @option tags" do
|
316
|
-
doc = Docstring.new("@option foo :key bar")
|
317
|
-
expect(doc.to_raw).to eq "@option foo :key bar"
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
describe "#dup" do
|
322
|
-
it "duplicates docstring text" do
|
323
|
-
doc = Docstring.new("foo")
|
324
|
-
expect(doc.dup).to eq doc
|
325
|
-
expect(doc.dup.all).to eq doc
|
326
|
-
end
|
327
|
-
|
328
|
-
it "duplicates tags to new list" do
|
329
|
-
doc = Docstring.new("@param x\n@return y")
|
330
|
-
doc2 = doc.dup
|
331
|
-
doc2.delete_tags(:param)
|
332
|
-
expect(doc.tags.size).to eq 2
|
333
|
-
expect(doc2.tags.size).to eq 1
|
334
|
-
end
|
335
|
-
|
336
|
-
it "preserves summary" do
|
337
|
-
doc = Docstring.new("foo. bar")
|
338
|
-
expect(doc.dup.summary).to eq doc.summary
|
339
|
-
end
|
340
|
-
|
341
|
-
it "preserves hash_flag" do
|
342
|
-
doc = Docstring.new
|
343
|
-
doc.hash_flag = 'foo'
|
344
|
-
expect(doc.dup.hash_flag).to eq doc.hash_flag
|
345
|
-
end
|
346
|
-
|
347
|
-
it "preserves line_range" do
|
348
|
-
doc = Docstring.new
|
349
|
-
doc.line_range = (1..2)
|
350
|
-
expect(doc.dup.line_range).to eq doc.line_range
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
describe "reference docstrings" do
|
355
|
-
it "allows for construction of docstring with ref object" do
|
356
|
-
YARD.parse_string <<-eof
|
357
|
-
class A
|
358
|
-
# Docstring
|
359
|
-
# @return [Boolean]
|
360
|
-
def a; end
|
361
|
-
# (see #a)
|
362
|
-
def b; end
|
363
|
-
end
|
364
|
-
eof
|
365
|
-
|
366
|
-
object = YARD::Registry.at('A#b')
|
367
|
-
expect(object.docstring).to eq 'Docstring'
|
368
|
-
expect(object.tags.map(&:tag_name)).to eq ['return']
|
369
|
-
|
370
|
-
YARD::Registry.clear
|
371
|
-
end
|
372
|
-
end
|
373
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}AliasHandler" do
|
5
|
-
before(:all) { parse_file :alias_handler_001, __FILE__ }
|
6
|
-
|
7
|
-
it "throws alias into namespace object list" do
|
8
|
-
expect(P(:A).aliases[P("A#b")]).to eq :a
|
9
|
-
end
|
10
|
-
|
11
|
-
['c', 'd?', '[]', '[]=', '-@', '%', '*', 'cstrkey', 'cstrmeth'].each do |a|
|
12
|
-
it "handles the Ruby 'alias' keyword syntax for method ##{a}" do
|
13
|
-
expect(P('A#' + a)).to be_instance_of(CodeObjects::MethodObject)
|
14
|
-
expect(P('A#' + a).is_alias?).to be true
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
it "handles keywords as the alias name" do
|
19
|
-
expect(P('A#for')).to be_instance_of(CodeObjects::MethodObject)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "allows ConstantNames to be specified as aliases" do
|
23
|
-
expect(P('A#ConstantName')).to be_instance_of(CodeObjects::MethodObject)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "creates a new method object for the alias" do
|
27
|
-
expect(P("A#b")).to be_instance_of(CodeObjects::MethodObject)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "pulls the method into the current class if it's from another one" do
|
31
|
-
expect(P(:B).aliases[P("B#q")]).to eq :x
|
32
|
-
expect(P(:B).aliases[P("B#r?")]).to eq :x
|
33
|
-
end
|
34
|
-
|
35
|
-
it "gracefully fails to pull a method in if the original method cannot be found" do
|
36
|
-
expect(P(:B).aliases[P("B#s")]).to eq :to_s
|
37
|
-
end
|
38
|
-
|
39
|
-
it "allows complex Ruby expressions after the alias parameters" do
|
40
|
-
expect(P(:B).aliases[P("B#t")]).to eq :inspect
|
41
|
-
end
|
42
|
-
|
43
|
-
it "shows up in #is_alias? for method" do
|
44
|
-
expect(P("B#t").is_alias?).to be true
|
45
|
-
expect(P('B#r?').is_alias?).to be true
|
46
|
-
end
|
47
|
-
|
48
|
-
it "allows operators and keywords to be specified as symbols" do
|
49
|
-
expect(P('B#<<')).to be_instance_of(CodeObjects::MethodObject)
|
50
|
-
expect(P('B#for')).to be_instance_of(CodeObjects::MethodObject)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "handles keywords in alias names" do
|
54
|
-
expect(P('B#do').is_alias?).to be true
|
55
|
-
expect(P('B#x2').is_alias?).to be true
|
56
|
-
expect(P(:B).aliases[P('B#do')]).to eq :x
|
57
|
-
expect(P(:B).aliases[P('B#x2')]).to eq :do
|
58
|
-
end
|
59
|
-
|
60
|
-
it "handles quoted symbols" do
|
61
|
-
foo = Registry.at('A#foo')
|
62
|
-
expect(foo).not_to be nil
|
63
|
-
expect(foo.is_alias?).to be true
|
64
|
-
expect(Registry.at('A').aliases[foo]).to eq :a
|
65
|
-
end
|
66
|
-
|
67
|
-
it "prepends aliases object's docstring to comments" do
|
68
|
-
expect(Registry.at('D#a').tag(:return).types).to eq ['Numeric']
|
69
|
-
expect(Registry.at('D#b').tag(:return).types).to eq ['String']
|
70
|
-
expect(Registry.at('D#b').docstring).to eq "Foo bar"
|
71
|
-
end
|
72
|
-
|
73
|
-
it "raises an UndocumentableError if only one parameter is passed" do
|
74
|
-
undoc_error "alias_method :q"
|
75
|
-
end
|
76
|
-
|
77
|
-
it "raises an UndocumentableError if the parameter is not a Symbol or String" do
|
78
|
-
undoc_error "alias_method CONST, Something"
|
79
|
-
undoc_error "alias_method variable, ClassName"
|
80
|
-
undoc_error "alias_method variable, other_variable"
|
81
|
-
end
|
82
|
-
end
|