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/tags/library_spec.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe YARD::Tags::Library do
|
4
|
-
def tag(docstring)
|
5
|
-
Docstring.new(docstring).tags.first
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#see_tag" do
|
9
|
-
it "takes a URL" do
|
10
|
-
expect(tag("@see http://example.com").name).to eq "http://example.com"
|
11
|
-
end
|
12
|
-
|
13
|
-
it "takes an object path" do
|
14
|
-
expect(tag("@see String#reverse").name).to eq "String#reverse"
|
15
|
-
end
|
16
|
-
|
17
|
-
it "takes a description after the url/object" do
|
18
|
-
tag = tag("@see http://example.com An Example Site")
|
19
|
-
expect(tag.name).to eq "http://example.com"
|
20
|
-
expect(tag.text).to eq "An Example Site"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe ".define_tag" do
|
25
|
-
it "allows defining tags with '.' in the name (x.y.z defines method x_y_z)" do
|
26
|
-
Tags::Library.define_tag("foo", 'x.y.z')
|
27
|
-
Tags::Library.define_tag("foo2", 'x.y.zz', Tags::OverloadTag)
|
28
|
-
expect(Tags::Library.instance.method(:x_y_z_tag)).not_to be nil
|
29
|
-
expect(Tags::Library.instance.method(:x_y_zz_tag)).not_to be nil
|
30
|
-
expect(tag('@x.y.z foo bar').text).to eq 'foo bar'
|
31
|
-
expect(tag('@x.y.zz foo(bar)').signature).to eq 'foo(bar)'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#tag.explain_types" do
|
36
|
-
it "can explain tag types" do
|
37
|
-
expect(tag("@return [A, B<String>]").explain_types).to eq "an A; a B of (Strings)"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "returns nil if no types present" do
|
41
|
-
expect(tag("@return").explain_types).to eq nil
|
42
|
-
end
|
43
|
-
|
44
|
-
it "returns nil if types are not parseable" do
|
45
|
-
expect(tag("@return [$]").explain_types).to eq nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe YARD::Tags::OverloadTag do
|
4
|
-
before do
|
5
|
-
@tag = Tags::OverloadTag.new(:overload, <<-'eof')
|
6
|
-
def bar(a, b = 1, &block)
|
7
|
-
Hello world
|
8
|
-
@param a [String]
|
9
|
-
@return [String]
|
10
|
-
eof
|
11
|
-
end
|
12
|
-
|
13
|
-
it "parses the first line as a method signature" do
|
14
|
-
expect(@tag.signature).to eq "def bar(a, b = 1, &block)"
|
15
|
-
expect(@tag.parameters).to eq [['a', nil], ['b', "1"], ['&block', nil]]
|
16
|
-
end
|
17
|
-
|
18
|
-
it "parses the rest of the text as a new Docstring" do
|
19
|
-
expect(@tag.docstring).to be_instance_of(Docstring)
|
20
|
-
expect(@tag.docstring).to eq "Hello world"
|
21
|
-
end
|
22
|
-
|
23
|
-
it "sets Docstring's object after #object= is called" do
|
24
|
-
m = double(:object)
|
25
|
-
@tag.object = m
|
26
|
-
expect(@tag.docstring.object).to eq m
|
27
|
-
end
|
28
|
-
|
29
|
-
it "responds to #tag, #tags and #has_tag?" do
|
30
|
-
@tag.object = double(:object)
|
31
|
-
expect(@tag.tags.size).to eq 2
|
32
|
-
expect(@tag.tag(:param).name).to eq "a"
|
33
|
-
expect(@tag.has_tag?(:return)).to be true
|
34
|
-
end
|
35
|
-
|
36
|
-
it "is not a CodeObjects::Base when not hooked up to an object" do
|
37
|
-
@tag.object = nil
|
38
|
-
expect(@tag.is_a?(CodeObjects::Base)).to be false
|
39
|
-
end
|
40
|
-
|
41
|
-
it "is a CodeObjects::Base when hooked up to an object" do
|
42
|
-
@tag.object = double(:object)
|
43
|
-
expect(@tag.object).to receive(:is_a?).at_least(3).times.with(CodeObjects::Base).and_return(true)
|
44
|
-
expect(@tag.is_a?(CodeObjects::Base)).to be true
|
45
|
-
expect(@tag.is_a?(CodeObjects::Base)).to be true
|
46
|
-
expect(CodeObjects::Base === @tag).to be true
|
47
|
-
end
|
48
|
-
|
49
|
-
it "does not parse 'def' out of method name" do
|
50
|
-
tag = Tags::OverloadTag.new(:overload, "default")
|
51
|
-
expect(tag.signature).to eq "default"
|
52
|
-
end
|
53
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe YARD::Tags::RefTagList do
|
4
|
-
before { YARD::Registry.clear }
|
5
|
-
|
6
|
-
it "accepts symbol or string as owner's path and convert it into a proxy" do
|
7
|
-
t = Tags::RefTagList.new('author', :String)
|
8
|
-
expect(t.owner).to eq P(:String)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "accepts proxy object as owner" do
|
12
|
-
t = Tags::RefTagList.new('author', P(:String))
|
13
|
-
expect(t.owner).to eq P(:String)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "returns tags from a proxy object" do
|
17
|
-
o = CodeObjects::ClassObject.new(:root, :String)
|
18
|
-
t = Tags::Tag.new(:author, 'foo')
|
19
|
-
o.docstring.add_tag(t)
|
20
|
-
|
21
|
-
ref = Tags::RefTagList.new('author', :String)
|
22
|
-
expect(ref.tags).to eq [t]
|
23
|
-
expect(ref.tags.first.text).to eq 'foo'
|
24
|
-
end
|
25
|
-
|
26
|
-
it "returns named tags from a proxy object" do
|
27
|
-
o = CodeObjects::ClassObject.new(:root, :String)
|
28
|
-
p1 = Tags::Tag.new(:param, 'bar1', nil, 'foo')
|
29
|
-
p2 = Tags::Tag.new(:param, 'bar2', nil, 'foo')
|
30
|
-
p3 = Tags::Tag.new(:param, 'bar3', nil, 'bar')
|
31
|
-
t1 = Tags::Tag.new(:return, 'blah')
|
32
|
-
o.docstring.add_tag(p1, t1, p2, p3)
|
33
|
-
|
34
|
-
ref = Tags::RefTagList.new('param', :String, 'foo')
|
35
|
-
expect(ref.tags).to eq [p1, p2]
|
36
|
-
expect(ref.tags.first.text).to eq 'bar1'
|
37
|
-
end
|
38
|
-
|
39
|
-
it "all tags should respond to #owner and be a RefTag" do
|
40
|
-
o = CodeObjects::ClassObject.new(:root, :String)
|
41
|
-
p1 = Tags::Tag.new(:param, 'bar1', nil, 'foo')
|
42
|
-
p2 = Tags::Tag.new(:param, 'bar2', nil, 'foo')
|
43
|
-
p3 = Tags::Tag.new(:param, 'bar3', nil, 'bar')
|
44
|
-
t1 = Tags::Tag.new(:return, 'blah')
|
45
|
-
o.docstring.add_tag(p1, t1, p2, p3)
|
46
|
-
|
47
|
-
ref = Tags::RefTagList.new('param', :String)
|
48
|
-
ref.tags.each do |t|
|
49
|
-
expect(t).to be_kind_of(Tags::RefTag)
|
50
|
-
expect(t.owner).to eq o
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,203 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe YARD::Tags::TypesExplainer do
|
4
|
-
Type = YARD::Tags::TypesExplainer::Type
|
5
|
-
CollectionType = YARD::Tags::TypesExplainer::CollectionType
|
6
|
-
FixedCollectionType = YARD::Tags::TypesExplainer::FixedCollectionType
|
7
|
-
HashCollectionType = YARD::Tags::TypesExplainer::HashCollectionType
|
8
|
-
Parser = YARD::Tags::TypesExplainer::Parser
|
9
|
-
|
10
|
-
def parse(types)
|
11
|
-
Parser.new(types).parse
|
12
|
-
end
|
13
|
-
|
14
|
-
def parse_fail(types)
|
15
|
-
expect(lambda { parse(types) }).to raise_error(SyntaxError)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe Type, '#to_s' do
|
19
|
-
before { @t = Type.new(nil) }
|
20
|
-
|
21
|
-
it "works for a class/module reference" do
|
22
|
-
@t.name = "ClassModuleName"
|
23
|
-
expect(@t.to_s).to eq "a ClassModuleName"
|
24
|
-
expect(@t.to_s(false)).to eq "ClassModuleNames"
|
25
|
-
|
26
|
-
@t.name = "XYZ"
|
27
|
-
expect(@t.to_s).to eq "a XYZ"
|
28
|
-
expect(@t.to_s(false)).to eq "XYZ's"
|
29
|
-
|
30
|
-
@t.name = "Array"
|
31
|
-
expect(@t.to_s).to eq "an Array"
|
32
|
-
expect(@t.to_s(false)).to eq "Arrays"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "works for a method (ducktype)" do
|
36
|
-
@t.name = "#mymethod"
|
37
|
-
expect(@t.to_s).to eq "an object that responds to #mymethod"
|
38
|
-
expect(@t.to_s(false)).to eq "objects that respond to #mymethod"
|
39
|
-
end
|
40
|
-
|
41
|
-
it "works for a constant value" do
|
42
|
-
['false', 'true', 'nil', '4'].each do |name|
|
43
|
-
@t.name = name
|
44
|
-
expect(@t.to_s).to eq name
|
45
|
-
expect(@t.to_s(false)).to eq name
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe CollectionType, '#to_s' do
|
51
|
-
before { @t = CollectionType.new("Array", nil) }
|
52
|
-
|
53
|
-
it "can contain one item" do
|
54
|
-
@t.types = [Type.new("Object")]
|
55
|
-
expect(@t.to_s).to eq "an Array of (Objects)"
|
56
|
-
end
|
57
|
-
|
58
|
-
it "can contain more than one item" do
|
59
|
-
@t.types = [Type.new("Object"), Type.new("String"), Type.new("Symbol")]
|
60
|
-
expect(@t.to_s).to eq "an Array of (Objects, Strings or Symbols)"
|
61
|
-
end
|
62
|
-
|
63
|
-
it "can contain nested collections" do
|
64
|
-
@t.types = [CollectionType.new("List", [Type.new("Object")])]
|
65
|
-
expect(@t.to_s).to eq "an Array of (a List of (Objects))"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe FixedCollectionType, '#to_s' do
|
70
|
-
before { @t = FixedCollectionType.new("Array", nil) }
|
71
|
-
|
72
|
-
it "can contain one item" do
|
73
|
-
@t.types = [Type.new("Object")]
|
74
|
-
expect(@t.to_s).to eq "an Array containing (an Object)"
|
75
|
-
end
|
76
|
-
|
77
|
-
it "can contain more than one item" do
|
78
|
-
@t.types = [Type.new("Object"), Type.new("String"), Type.new("Symbol")]
|
79
|
-
expect(@t.to_s).to eq "an Array containing (an Object followed by a String followed by a Symbol)"
|
80
|
-
end
|
81
|
-
|
82
|
-
it "can contain nested collections" do
|
83
|
-
@t.types = [FixedCollectionType.new("List", [Type.new("Object")])]
|
84
|
-
expect(@t.to_s).to eq "an Array containing (a List containing (an Object))"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe FixedCollectionType, '#to_s' do
|
89
|
-
before { @t = HashCollectionType.new("Hash", nil, nil) }
|
90
|
-
|
91
|
-
it "can contain a single key type and value type" do
|
92
|
-
@t.key_types = [Type.new("Object")]
|
93
|
-
@t.value_types = [Type.new("Object")]
|
94
|
-
expect(@t.to_s).to eq "a Hash with keys made of (Objects) and values of (Objects)"
|
95
|
-
end
|
96
|
-
|
97
|
-
it "can contain multiple key types" do
|
98
|
-
@t.key_types = [Type.new("Key"), Type.new("String")]
|
99
|
-
@t.value_types = [Type.new("Object")]
|
100
|
-
expect(@t.to_s).to eq "a Hash with keys made of (Keys or Strings) and values of (Objects)"
|
101
|
-
end
|
102
|
-
|
103
|
-
it "can contain multiple value types" do
|
104
|
-
@t.key_types = [Type.new("String")]
|
105
|
-
@t.value_types = [Type.new("true"), Type.new("false")]
|
106
|
-
expect(@t.to_s).to eq "a Hash with keys made of (Strings) and values of (true or false)"
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe Parser, '#parse' do
|
111
|
-
it "parses a regular class name" do
|
112
|
-
type = parse("MyClass")
|
113
|
-
expect(type.size).to eq 1
|
114
|
-
expect(type.first).to be_a(Type)
|
115
|
-
expect(type.first.name).to eq "MyClass"
|
116
|
-
end
|
117
|
-
|
118
|
-
it "parses a path reference name" do
|
119
|
-
type = parse("A::B")
|
120
|
-
expect(type.size).to eq 1
|
121
|
-
expect(type.first).to be_a(Type)
|
122
|
-
expect(type.first.name).to eq "A::B"
|
123
|
-
end
|
124
|
-
|
125
|
-
it "parses a list of simple names" do
|
126
|
-
type = parse("A, B::C, D, E")
|
127
|
-
expect(type.size).to eq 4
|
128
|
-
expect(type[0].name).to eq "A"
|
129
|
-
expect(type[1].name).to eq "B::C"
|
130
|
-
expect(type[2].name).to eq "D"
|
131
|
-
expect(type[3].name).to eq "E"
|
132
|
-
end
|
133
|
-
|
134
|
-
it "parses a collection type" do
|
135
|
-
type = parse("MyList<String>")
|
136
|
-
expect(type.first).to be_a(CollectionType)
|
137
|
-
expect(type.first.types.size).to eq 1
|
138
|
-
expect(type.first.name).to eq "MyList"
|
139
|
-
expect(type.first.types.first.name).to eq "String"
|
140
|
-
end
|
141
|
-
|
142
|
-
it "allows a collection type without a name" do
|
143
|
-
type = parse("<String>")
|
144
|
-
expect(type.first.name).to eq "Array"
|
145
|
-
end
|
146
|
-
|
147
|
-
it "allows a fixed collection type without a name" do
|
148
|
-
type = parse("(String)")
|
149
|
-
expect(type.first.name).to eq "Array"
|
150
|
-
end
|
151
|
-
|
152
|
-
it "allows a hash collection type without a name" do
|
153
|
-
type = parse("{K=>V}")
|
154
|
-
expect(type.first.name).to eq "Hash"
|
155
|
-
end
|
156
|
-
|
157
|
-
it "does not accept two commas in a row" do
|
158
|
-
parse_fail "A,,B"
|
159
|
-
end
|
160
|
-
|
161
|
-
it "does not accept two types not separated by a comma" do
|
162
|
-
parse_fail "A B"
|
163
|
-
end
|
164
|
-
|
165
|
-
it "does not allow a comma without a following type" do
|
166
|
-
parse_fail "A, "
|
167
|
-
end
|
168
|
-
|
169
|
-
it "fails on any unrecognized character" do
|
170
|
-
parse_fail "$"
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
describe ".explain" do
|
175
|
-
it "parses an arbitrarily nested collection type" do
|
176
|
-
explain = YARD::Tags::TypesExplainer.explain("Array<String, Array<Symbol, List(String, {K=>V})>>")
|
177
|
-
result = "an Array of (Strings or an Array of (Symbols or a List containing
|
178
|
-
(a String followed by a Hash with keys made of (K's) and values of (V's))))"
|
179
|
-
expect(explain).to eq result.delete("\n").squeeze(' ')
|
180
|
-
end
|
181
|
-
|
182
|
-
it "parses various examples" do
|
183
|
-
expect = {
|
184
|
-
"Fixnum, Foo, Object, true" => "a Fixnum; a Foo; an Object; true",
|
185
|
-
"#read" => "an object that responds to #read",
|
186
|
-
"Array<String, Symbol, #read>" => "an Array of (Strings, Symbols or objects that respond to #read)",
|
187
|
-
"Set<Number>" => "a Set of (Numbers)",
|
188
|
-
"Array(String, Symbol)" => "an Array containing (a String followed by a Symbol)",
|
189
|
-
"Hash{String => Symbol, Number}" => "a Hash with keys made of (Strings) and values of (Symbols or Numbers)",
|
190
|
-
"Array<Foo, Bar>, List(String, Symbol, #to_s), {Foo, Bar => Symbol, Number}" => "an Array of (Foos or Bars);
|
191
|
-
a List containing (a String followed by a Symbol followed by an object that responds to #to_s);
|
192
|
-
a Hash with keys made of (Foos or Bars) and values of (Symbols or Numbers)",
|
193
|
-
"#weird_method?, #<=>, #!=" => "an object that responds to #weird_method?;
|
194
|
-
an object that responds to #<=>;
|
195
|
-
an object that responds to #!="
|
196
|
-
}
|
197
|
-
expect.each do |input, expected|
|
198
|
-
explain = YARD::Tags::TypesExplainer.explain(input)
|
199
|
-
expect(explain).to eq expected.delete("\n").squeeze(' ')
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe YARD::Templates::Engine.template(:default, :docstring) do
|
5
|
-
before do
|
6
|
-
Registry.clear
|
7
|
-
YARD.parse_string <<-'eof'
|
8
|
-
private
|
9
|
-
# Comments
|
10
|
-
# @abstract override this class
|
11
|
-
# @author Test
|
12
|
-
# @version 1.0
|
13
|
-
# @see A
|
14
|
-
# @see http://example.com Example
|
15
|
-
class A < B
|
16
|
-
# HI
|
17
|
-
def method_missing(*args) end
|
18
|
-
# @deprecated
|
19
|
-
def a; end
|
20
|
-
|
21
|
-
# constructor method!
|
22
|
-
def initialize(test) end
|
23
|
-
end
|
24
|
-
|
25
|
-
class C < A; end
|
26
|
-
|
27
|
-
class D
|
28
|
-
# @private
|
29
|
-
def initialize; end
|
30
|
-
end
|
31
|
-
eof
|
32
|
-
end
|
33
|
-
|
34
|
-
it "renders html format correctly" do
|
35
|
-
html_equals(Registry.at('A').format(html_options), :class001)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "renders text format correctly" do
|
39
|
-
text_equals(Registry.at('A').format, :class001)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "hides private constructors" do
|
43
|
-
html_equals(Registry.at('D').format(html_options(:verifier => Verifier.new("!@private"))), :class002)
|
44
|
-
end
|
45
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
3
|
-
|
4
|
-
RSpec.describe YARD::Templates::Engine.template(:default, :constant) do
|
5
|
-
describe "fully dressed constant" do
|
6
|
-
it "renders text format correctly" do
|
7
|
-
YARD.parse_string <<-'eof'
|
8
|
-
class YARD::CLI::YRI
|
9
|
-
# Default search paths that should be loaded dynamically into YRI. These paths
|
10
|
-
# take precedence over all other paths ({SEARCH_PATHS_FILE} and RubyGems
|
11
|
-
# paths). To add a path, call:
|
12
|
-
#
|
13
|
-
# DEFAULT_SEARCH_PATHS.push("/path/to/.yardoc")
|
14
|
-
#
|
15
|
-
# @return [Array<String>] a list of extra search paths
|
16
|
-
# @since 0.6.0
|
17
|
-
DEFAULT_SEARCH_PATHS = []
|
18
|
-
end
|
19
|
-
eof
|
20
|
-
text_equals(Registry.at('YARD::CLI::YRI::DEFAULT_SEARCH_PATHS').format(text_options), :constant001)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "simple constant with no documentation" do
|
25
|
-
it "renders text format correctly" do
|
26
|
-
# Short constant should show on single line
|
27
|
-
YARD.parse_string <<-'eof'
|
28
|
-
MYCONST = 'foo'
|
29
|
-
eof
|
30
|
-
text_equals(Registry.at('MYCONST').format(text_options), :constant002)
|
31
|
-
|
32
|
-
# Long constant should show on multiple lines, indented
|
33
|
-
YARD.parse_string <<-'eof'
|
34
|
-
MYCONST = [A, B, C, D, E, F, G, H, I, J, K, L,
|
35
|
-
M, N, O, P, Q, R, S, T, U, V, W,
|
36
|
-
X, Y, Z]
|
37
|
-
eof
|
38
|
-
text_equals(Registry.at('MYCONST').format(text_options), :constant003)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|