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/core_ext/array_spec.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe Array do
|
4
|
-
describe "#place" do
|
5
|
-
it "creates an Insertion object" do
|
6
|
-
expect([].place('x')).to be_kind_of(Insertion)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "allows multiple objects to be placed" do
|
10
|
-
expect([1, 2].place('x', 'y', 'z').before(2)).to eq [1, 'x', 'y', 'z', 2]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/spec/core_ext/file_spec.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe File do
|
4
|
-
describe ".relative_path" do
|
5
|
-
it "returns the relative path between two files" do
|
6
|
-
expect(File.relative_path('a/b/c/d.html', 'a/b/d/q.html')).to eq '../d/q.html'
|
7
|
-
end
|
8
|
-
|
9
|
-
it "returns the relative path between two directories" do
|
10
|
-
expect(File.relative_path('a/b/c/d/', 'a/b/d/')).to eq '../d'
|
11
|
-
end
|
12
|
-
|
13
|
-
it "returns only the to file if from file is in the same directory as the to file" do
|
14
|
-
expect(File.relative_path('a/b/c/d', 'a/b/c/e')).to eq 'e'
|
15
|
-
end
|
16
|
-
|
17
|
-
it "handles non-normalized paths" do
|
18
|
-
expect(File.relative_path('Hello/./I/Am/Fred', 'Hello/Fred')).to eq '../../Fred'
|
19
|
-
expect(File.relative_path('A//B/C', 'Q/X')).to eq '../../Q/X'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe ".cleanpath" do
|
24
|
-
it "cleans double brackets" do
|
25
|
-
expect(File.cleanpath('A//B/C')).to eq "A/B/C"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "cleans a path with ." do
|
29
|
-
expect(File.cleanpath('Hello/./I/.Am/Fred')).to eq "Hello/I/.Am/Fred"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "cleans a path with .." do
|
33
|
-
expect(File.cleanpath('Hello/../World')).to eq "World"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "cleans a path with multiple .." do
|
37
|
-
expect(File.cleanpath('A/B/C/../../D')).to eq "A/D"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "cleans a path ending in .." do
|
41
|
-
expect(File.cleanpath('A/B/C/D/..')).to eq "A/B/C"
|
42
|
-
end
|
43
|
-
|
44
|
-
it "allows '../' at the beginning if rel_root=true" do
|
45
|
-
expect(File.cleanpath('A/../../B', true)).to eq '../B'
|
46
|
-
end
|
47
|
-
|
48
|
-
it "does not allow relative path above root" do
|
49
|
-
expect(File.cleanpath('A/../../../../../D')).to eq "D"
|
50
|
-
end
|
51
|
-
|
52
|
-
it "does not remove multiple '../' at the beginning" do
|
53
|
-
expect(File.cleanpath('../../A/B')).to eq 'A/B'
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe ".open!" do
|
58
|
-
it "creates the path before opening" do
|
59
|
-
expect(File).to receive(:directory?).with('/path/to').and_return(false)
|
60
|
-
expect(FileUtils).to receive(:mkdir_p).with('/path/to')
|
61
|
-
expect(File).to receive(:open).with('/path/to/file', 'w')
|
62
|
-
File.open!('/path/to/file', 'w')
|
63
|
-
end
|
64
|
-
|
65
|
-
it "just opens the file if the path exists" do
|
66
|
-
expect(File).to receive(:directory?).with('/path/to').and_return(true)
|
67
|
-
expect(FileUtils).not_to receive(:mkdir_p)
|
68
|
-
expect(File).to receive(:open).with('/path/to/file', 'w')
|
69
|
-
File.open!('/path/to/file', 'w')
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
data/spec/core_ext/hash_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe Hash do
|
4
|
-
describe ".[]" do
|
5
|
-
it "accepts an Array argument (Ruby 1.8.6 and older)" do
|
6
|
-
list = [['foo', 'bar'], ['foo2', 'bar2']]
|
7
|
-
expect(Hash[list]).to eq('foo' => 'bar', 'foo2' => 'bar2')
|
8
|
-
end
|
9
|
-
|
10
|
-
it "accepts an array as a key" do
|
11
|
-
expect(Hash[['a', 'b'], 1]).to eq(['a', 'b'] => 1)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe Insertion do
|
4
|
-
describe "#before" do
|
5
|
-
it "places an object before another" do
|
6
|
-
expect([1, 2].place(3).before(2)).to eq [1, 3, 2]
|
7
|
-
expect([1, 2].place(3).before(1)).to eq [3, 1, 2]
|
8
|
-
expect([1, [4], 2].place(3).before(2)).to eq [1, [4], 3, 2]
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#after" do
|
13
|
-
it "places an object after another" do
|
14
|
-
expect([1, 2].place(3).after(2)).to eq [1, 2, 3]
|
15
|
-
end
|
16
|
-
|
17
|
-
it "no longer places an object after another and its subsections (0.6)" do
|
18
|
-
expect([1, [2]].place(3).after(1)).to eq [1, 3, [2]]
|
19
|
-
end
|
20
|
-
|
21
|
-
it "places an array after an object" do
|
22
|
-
expect([1, 2, 3].place([4]).after(1)).to eq [1, [4], 2, 3]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#before_any" do
|
27
|
-
it "places an object before another anywhere inside list (including sublists)" do
|
28
|
-
expect([1, 2, [3]].place(4).before_any(3)).to eq [1, 2, [4, 3]]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#after_any" do
|
33
|
-
it "places an object after another anywhere inside list (including sublists)" do
|
34
|
-
expect([1, 2, [3]].place(4).after_any(3)).to eq [1, 2, [3, 4]]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# described_in_docs String, '#camelcase'
|
4
|
-
# described_in_docs String, '#underscore'
|
5
|
-
|
6
|
-
RSpec.describe String do
|
7
|
-
describe "#shell_split" do
|
8
|
-
it "splits simple non-quoted text" do
|
9
|
-
expect("a b c".shell_split).to eq %w(a b c)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "splits double quoted text into single token" do
|
13
|
-
expect('a "b c d" e'.shell_split).to eq ["a", "b c d", "e"]
|
14
|
-
end
|
15
|
-
|
16
|
-
it "splits single quoted text into single token" do
|
17
|
-
expect("a 'b c d' e".shell_split).to eq ["a", "b c d", "e"]
|
18
|
-
end
|
19
|
-
|
20
|
-
it "handles escaped quotations in quotes" do
|
21
|
-
expect("'a \\' b'".shell_split).to eq ["a ' b"]
|
22
|
-
end
|
23
|
-
|
24
|
-
it "handles escaped quotations outside quotes" do
|
25
|
-
expect("\\'a 'b'".shell_split).to eq %w('a b)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "handles escaped backslash" do
|
29
|
-
expect("\\\\'a b c'".shell_split).to eq ['\a b c']
|
30
|
-
end
|
31
|
-
|
32
|
-
it "handles any whitespace as space" do
|
33
|
-
text = "foo\tbar\nbaz\r\nfoo2 bar2"
|
34
|
-
expect(text.shell_split).to eq %w(foo bar baz foo2 bar2)
|
35
|
-
end
|
36
|
-
|
37
|
-
it "handles complex input" do
|
38
|
-
text = "hello \\\"world \"1 2\\\" 3\" a 'b \"\\\\\\'' c"
|
39
|
-
expect(text.shell_split).to eq ["hello", "\"world", "1 2\" 3", "a", "b \"\\'", "c"]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe SymbolHash do
|
4
|
-
it "allows access to keys as String or Symbol" do
|
5
|
-
h = SymbolHash.new(false)
|
6
|
-
h['test'] = true
|
7
|
-
expect(h[:test]).to be true
|
8
|
-
expect(h['test']).to be true
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "#delete" do
|
12
|
-
it "accepts either Strings or Symbols as deletion key" do
|
13
|
-
h = SymbolHash.new
|
14
|
-
expect(h.keys.length).to eq 0
|
15
|
-
|
16
|
-
h['test'] = true
|
17
|
-
expect(h.keys.length).to eq 1
|
18
|
-
|
19
|
-
h.delete(:test)
|
20
|
-
expect(h.keys.length).to eq 0
|
21
|
-
|
22
|
-
h[:test] = true
|
23
|
-
expect(h.keys.length).to eq 1
|
24
|
-
|
25
|
-
h.delete('test')
|
26
|
-
expect(h.keys.length).to eq 0
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#key?" do
|
31
|
-
it "returns same result for String or Symbol" do
|
32
|
-
h = SymbolHash.new
|
33
|
-
h[:test] = 1
|
34
|
-
expect(h.key?(:test)).to be true
|
35
|
-
expect(h.has_key?('test')).to be true # rubocop:disable Style/PreferredHashMethods
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it "symbolizes value if it is a String (and only a string)" do
|
40
|
-
class Substring < String; end
|
41
|
-
|
42
|
-
h = SymbolHash.new
|
43
|
-
h['test1'] = "hello"
|
44
|
-
h['test2'] = Substring.new("hello")
|
45
|
-
expect(h['test1']).to eq :hello
|
46
|
-
expect(h['test2']).to eq "hello"
|
47
|
-
end
|
48
|
-
|
49
|
-
it "does not symbolize value if SymbolHash.new(false) is created" do
|
50
|
-
h = SymbolHash.new(false)
|
51
|
-
h['test'] = "hello"
|
52
|
-
expect(h[:test]).to eq "hello"
|
53
|
-
end
|
54
|
-
|
55
|
-
it "does not symbolize value if it is not a String" do
|
56
|
-
h = SymbolHash.new
|
57
|
-
h['test'] = [1, 2, 3]
|
58
|
-
expect(h['test']).to eq [1, 2, 3]
|
59
|
-
end
|
60
|
-
|
61
|
-
it "supports symbolization using #update or #merge!" do
|
62
|
-
h = SymbolHash.new
|
63
|
-
h.update('test' => 'value')
|
64
|
-
expect(h[:test]).to eq :value
|
65
|
-
h.merge!('test' => 'value2') # rubocop:disable Performance/RedundantMerge
|
66
|
-
expect(h[:test]).to eq :value2
|
67
|
-
end
|
68
|
-
|
69
|
-
it "supports symbolization non-destructively using #merge" do
|
70
|
-
h = SymbolHash.new
|
71
|
-
expect(h.merge('test' => 'value')[:test]).to eq :value
|
72
|
-
expect(h).to eq SymbolHash.new
|
73
|
-
end
|
74
|
-
|
75
|
-
it "supports #initializing of a hash" do
|
76
|
-
h = SymbolHash[:test => 1]
|
77
|
-
expect(h[:test]).to eq 1
|
78
|
-
expect(h[:somethingelse]).to be nil
|
79
|
-
end
|
80
|
-
|
81
|
-
it "supports reverse merge syntax" do
|
82
|
-
opts = {}
|
83
|
-
opts = SymbolHash[
|
84
|
-
'default' => 1
|
85
|
-
].update(opts)
|
86
|
-
expect(opts.keys).to eq [:default]
|
87
|
-
expect(opts[:default]).to eq 1
|
88
|
-
end
|
89
|
-
end
|
@@ -1,280 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe YARD::DocstringParser do
|
4
|
-
after(:all) do
|
5
|
-
YARD::Registry.clear
|
6
|
-
end
|
7
|
-
|
8
|
-
def parse(content, object = nil, handler = nil)
|
9
|
-
@library ||= Tags::Library.instance
|
10
|
-
@parser = DocstringParser.new(@library)
|
11
|
-
@parser.parse(content, object, handler)
|
12
|
-
@parser
|
13
|
-
end
|
14
|
-
|
15
|
-
def docstring(content, object = nil, handler = nil)
|
16
|
-
parse(content, object, handler).to_docstring
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#parse" do
|
20
|
-
it "parses comments into tags" do
|
21
|
-
doc = docstring(<<-eof)
|
22
|
-
@param name Hello world
|
23
|
-
how are you?
|
24
|
-
@param name2
|
25
|
-
this is a new line
|
26
|
-
@param name3 and this
|
27
|
-
is a new paragraph:
|
28
|
-
|
29
|
-
right here.
|
30
|
-
eof
|
31
|
-
tags = doc.tags(:param)
|
32
|
-
expect(tags[0].name).to eq "name"
|
33
|
-
expect(tags[0].text).to eq "Hello world\nhow are you?"
|
34
|
-
expect(tags[1].name).to eq "name2"
|
35
|
-
expect(tags[1].text).to eq "this is a new line"
|
36
|
-
expect(tags[2].name).to eq "name3"
|
37
|
-
expect(tags[2].text).to eq "and this\nis a new paragraph:\n\nright here."
|
38
|
-
end
|
39
|
-
|
40
|
-
it "ends parsing a tag on de-dent" do
|
41
|
-
doc = docstring(<<-eof)
|
42
|
-
@note test
|
43
|
-
one two three
|
44
|
-
rest of docstring
|
45
|
-
eof
|
46
|
-
expect(doc.tag(:note).text).to eq "test\none two three"
|
47
|
-
expect(doc).to eq "rest of docstring"
|
48
|
-
end
|
49
|
-
|
50
|
-
it "parses examples embedded in doc" do
|
51
|
-
doc = docstring(<<-eof)
|
52
|
-
test string here
|
53
|
-
@example code
|
54
|
-
|
55
|
-
def foo(x, y, z)
|
56
|
-
end
|
57
|
-
|
58
|
-
class A; end
|
59
|
-
|
60
|
-
more stuff
|
61
|
-
eof
|
62
|
-
expect(doc).to eq "test string here\nmore stuff"
|
63
|
-
expect(doc.tag(:example).text).to eq "\ndef foo(x, y, z)\nend\n\nclass A; end"
|
64
|
-
end
|
65
|
-
|
66
|
-
it "removes only original indentation from beginning of line in tags" do
|
67
|
-
doc = docstring(<<-eof)
|
68
|
-
@param name
|
69
|
-
some value
|
70
|
-
foo bar
|
71
|
-
baz
|
72
|
-
eof
|
73
|
-
expect(doc.tag(:param).text).to eq "some value\nfoo bar\n baz"
|
74
|
-
end
|
75
|
-
|
76
|
-
it "allows numbers in tags" do
|
77
|
-
Tags::Library.define_tag(nil, :foo1)
|
78
|
-
Tags::Library.define_tag(nil, :foo2)
|
79
|
-
Tags::Library.define_tag(nil, :foo3)
|
80
|
-
doc = docstring(<<-eof)
|
81
|
-
@foo1 bar1
|
82
|
-
@foo2 bar2
|
83
|
-
@foo3 bar3
|
84
|
-
eof
|
85
|
-
expect(doc.tag(:foo1).text).to eq "bar1"
|
86
|
-
expect(doc.tag(:foo2).text).to eq "bar2"
|
87
|
-
end
|
88
|
-
|
89
|
-
it "ends tag on newline if next line is not indented" do
|
90
|
-
doc = docstring(<<-eof)
|
91
|
-
@author bar1
|
92
|
-
@api bar2
|
93
|
-
Hello world
|
94
|
-
eof
|
95
|
-
expect(doc.tag(:author).text).to eq "bar1"
|
96
|
-
expect(doc.tag(:api).text).to eq "bar2"
|
97
|
-
end
|
98
|
-
|
99
|
-
it "warns about unknown tag" do
|
100
|
-
expect(log).to receive(:warn).with(/Unknown tag @hello$/)
|
101
|
-
docstring("@hello world")
|
102
|
-
end
|
103
|
-
|
104
|
-
it "does not add trailing whitespace to freeform tags" do
|
105
|
-
doc = docstring("@api private \t ")
|
106
|
-
expect(doc.tag(:api).text).to eq "private"
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "#parse with custom tag library" do
|
111
|
-
class TestLibrary < Tags::Library; end
|
112
|
-
|
113
|
-
before { @library = TestLibrary.new }
|
114
|
-
|
115
|
-
it "accepts valid tags" do
|
116
|
-
valid = %w(testing valid is_a is_A __)
|
117
|
-
valid.each do |tag|
|
118
|
-
TestLibrary.define_tag("Tag", tag)
|
119
|
-
doc = docstring('@' + tag + ' foo bar')
|
120
|
-
expect(doc.tag(tag).text).to eq 'foo bar'
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
it "does not parse invalid tag names" do
|
125
|
-
invalid = %w(@ @return@ @p,aram @x-y @.x.y.z)
|
126
|
-
invalid.each do |tag|
|
127
|
-
expect(docstring(tag + ' foo bar')).to eq tag + ' foo bar'
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
it "allows namespaced tags in the form @x.y.z" do
|
132
|
-
TestLibrary.define_tag("Tag", 'x.y.z')
|
133
|
-
doc = docstring("@x.y.z foo bar")
|
134
|
-
expect(doc.tag('x.y.z').text).to eq 'foo bar'
|
135
|
-
end
|
136
|
-
|
137
|
-
it "ignores new directives without @! prefix syntax" do
|
138
|
-
TestLibrary.define_directive('dir1', Tags::ScopeDirective)
|
139
|
-
expect(log).to receive(:warn).with(/@dir1/)
|
140
|
-
docstring("@dir1")
|
141
|
-
end
|
142
|
-
|
143
|
-
%w(attribute endgroup group macro method scope visibility).each do |tag|
|
144
|
-
it "handles non prefixed @#{tag} syntax as directive, not tag" do
|
145
|
-
TestLibrary.define_directive(tag, Tags::ScopeDirective)
|
146
|
-
parse("@#{tag}")
|
147
|
-
expect(@parser.directives.first).to be_a(Tags::ScopeDirective)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
it "handles directives with @! prefix syntax" do
|
152
|
-
TestLibrary.define_directive('dir2', Tags::ScopeDirective)
|
153
|
-
docstring("@!dir2 class")
|
154
|
-
expect(@parser.state.scope).to eq :class
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
describe "#text" do
|
159
|
-
it "only returns text data" do
|
160
|
-
parse("Foo\n@param foo x y z\nBar")
|
161
|
-
expect(@parser.text).to eq "Foo\nBar"
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
describe "#raw_text" do
|
166
|
-
it "returns the entire original data" do
|
167
|
-
data = "Foo\n@param foo x y z\nBar"
|
168
|
-
parse(data)
|
169
|
-
expect(@parser.raw_text).to eq data
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
describe "#tags" do
|
174
|
-
it "returns the parsed tags" do
|
175
|
-
data = "Foo\n@param foo x y z\nBar"
|
176
|
-
parse(data)
|
177
|
-
expect(@parser.tags.size).to eq 1
|
178
|
-
expect(@parser.tags.first.tag_name).to eq 'param'
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
describe "#directives" do
|
183
|
-
it "groups all processed directives" do
|
184
|
-
data = "Foo\n@!scope class\n@!visibility private\nBar"
|
185
|
-
parse(data)
|
186
|
-
dirs = @parser.directives
|
187
|
-
expect(dirs[0]).to be_a(Tags::ScopeDirective)
|
188
|
-
expect(dirs[0].tag.text).to eq 'class'
|
189
|
-
expect(dirs[1]).to be_a(Tags::VisibilityDirective)
|
190
|
-
expect(dirs[1].tag.text).to eq 'private'
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
describe "#state" do
|
195
|
-
it "handles modified state" do
|
196
|
-
parse("@!scope class")
|
197
|
-
expect(@parser.state.scope).to eq :class
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
describe "after_parse (param)" do
|
202
|
-
it "allows specifying of callbacks" do
|
203
|
-
parser = DocstringParser.new
|
204
|
-
the_yielded_obj = nil
|
205
|
-
DocstringParser.after_parse {|obj| the_yielded_obj = obj }
|
206
|
-
parser.parse("Some text")
|
207
|
-
expect(the_yielded_obj).to eq parser
|
208
|
-
end
|
209
|
-
|
210
|
-
it "warns about invalid named parameters" do
|
211
|
-
expect(log).to receive(:warn).with(/@param tag has unknown parameter name: notaparam/)
|
212
|
-
YARD.parse_string <<-eof
|
213
|
-
# @param notaparam foo
|
214
|
-
def foo(a) end
|
215
|
-
eof
|
216
|
-
end
|
217
|
-
|
218
|
-
it "warns about invalid named parameters on @!method directives" do
|
219
|
-
expect(log).to receive(:warn).with(/@param tag has unknown parameter name: notaparam/)
|
220
|
-
YARD.parse_string <<-eof
|
221
|
-
# @!method foo(a)
|
222
|
-
# @param notaparam foo
|
223
|
-
test
|
224
|
-
eof
|
225
|
-
end
|
226
|
-
|
227
|
-
it "warns about duplicate named parameters" do
|
228
|
-
expect(log).to receive(:warn).with(/@param tag has duplicate parameter name: a/)
|
229
|
-
YARD.parse_string <<-eof
|
230
|
-
# @param a foo
|
231
|
-
# @param a foo
|
232
|
-
def foo(a) end
|
233
|
-
eof
|
234
|
-
end
|
235
|
-
|
236
|
-
it "does not warn on aliases" do
|
237
|
-
expect(log).to_not receive(:warn)
|
238
|
-
YARD.parse_string <<-eof
|
239
|
-
# @param a foo
|
240
|
-
def foo(a) end
|
241
|
-
alias bar foo
|
242
|
-
eof
|
243
|
-
end
|
244
|
-
|
245
|
-
it "does not warn on matching param with inline method modifier" do
|
246
|
-
expect(log).to_not receive(:warn)
|
247
|
-
YARD.parse_string <<-eof
|
248
|
-
# @param [Numeric] a
|
249
|
-
# @return [Numeric]
|
250
|
-
private_class_method def self.foo(a); a + 1; end
|
251
|
-
eof
|
252
|
-
end
|
253
|
-
|
254
|
-
it "warns on mismatching param with inline method modifier" do
|
255
|
-
expect(log).to receive(:warn).with(/@param tag has unknown parameter name: notaparam/)
|
256
|
-
YARD.parse_string <<-eof
|
257
|
-
# @param [Numeric] notaparam
|
258
|
-
# @return [Numeric]
|
259
|
-
private_class_method def self.foo(a); a + 1; end
|
260
|
-
eof
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
describe "after_parse (see)" do
|
265
|
-
it "does not warn on valid see tag" do
|
266
|
-
expect(log).to_not receive(:warn)
|
267
|
-
YARD.parse_string "# @see valid\nclass Foo;end"
|
268
|
-
end
|
269
|
-
|
270
|
-
it "warns if {} wraps single name" do
|
271
|
-
expect(log).to receive(:warn).with(/@see tag \(#1\) should not be wrapped in \{\}/)
|
272
|
-
YARD.parse_string "# @see {invalid}\nclass Foo;end"
|
273
|
-
end
|
274
|
-
|
275
|
-
it "warns if {} wraps across name and text" do
|
276
|
-
expect(log).to receive(:warn).with(/@see tag \(#1\) should not be wrapped in \{\}/)
|
277
|
-
YARD.parse_string "# @see {invalid tag}\nclass Foo;end"
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|