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
data/spec/docstring_spec.rb
CHANGED
@@ -3,85 +3,85 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe YARD::Docstring do
|
4
4
|
before { YARD::Registry.clear }
|
5
5
|
|
6
|
-
describe
|
7
|
-
it "
|
8
|
-
Docstring.new("\n\n").
|
6
|
+
describe "#initialize" do
|
7
|
+
it "handles docstrings with empty newlines" do
|
8
|
+
expect(Docstring.new("\n\n")).to eq ""
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
13
|
-
it "
|
12
|
+
describe "#+" do
|
13
|
+
it "adds another Docstring" do
|
14
14
|
d = Docstring.new("FOO") + Docstring.new("BAR")
|
15
|
-
d.
|
15
|
+
expect(d).to eq "FOO\nBAR"
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
18
|
+
it "copies over tags" do
|
19
19
|
d1 = Docstring.new("FOO\n@api private\n")
|
20
20
|
d2 = Docstring.new("BAR\n@param foo descr")
|
21
21
|
d = (d1 + d2)
|
22
|
-
d.
|
23
|
-
d.
|
22
|
+
expect(d).to have_tag(:api)
|
23
|
+
expect(d).to have_tag(:param)
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "adds a String" do
|
27
27
|
d = Docstring.new("FOO") + "BAR"
|
28
|
-
d.
|
28
|
+
expect(d).to eq "FOOBAR"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe
|
33
|
-
it "
|
34
|
-
Docstring.new('foo').line.
|
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
35
|
end
|
36
36
|
|
37
|
-
it "
|
37
|
+
it "returns line_range.first if #line_range is set" do
|
38
38
|
doc = Docstring.new('foo')
|
39
39
|
doc.line_range = (1..10)
|
40
|
-
doc.line.
|
40
|
+
expect(doc.line).to eq doc.line_range.first
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
describe
|
45
|
-
it "
|
44
|
+
describe "#summary" do
|
45
|
+
it "handles empty docstrings" do
|
46
46
|
o1 = Docstring.new
|
47
|
-
o1.summary.
|
47
|
+
expect(o1.summary).to eq ""
|
48
48
|
end
|
49
49
|
|
50
|
-
it "
|
50
|
+
it "handles multiple calls" do
|
51
51
|
o1 = Docstring.new("Hello. world")
|
52
|
-
5.times { o1.summary.
|
52
|
+
5.times { expect(o1.summary).to eq "Hello." }
|
53
53
|
end
|
54
54
|
|
55
|
-
it "
|
55
|
+
it "strips HTML before summarizing" do
|
56
56
|
doc = Docstring.new("<p>Hello <b>world</b></p>.")
|
57
|
-
doc.summary.
|
57
|
+
expect(doc.summary).to eq 'Hello world.'
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
60
|
+
it "strips newlines in first paragraph before summarizing" do
|
61
61
|
doc = Docstring.new("Foo\n<code>==</code> bar.")
|
62
|
-
doc.summary.
|
62
|
+
expect(doc.summary).to eq 'Foo == bar.'
|
63
63
|
end
|
64
64
|
|
65
|
-
it "
|
65
|
+
it "returns the first sentence" do
|
66
66
|
o = Docstring.new("DOCSTRING. Another sentence")
|
67
|
-
o.summary.
|
67
|
+
expect(o.summary).to eq "DOCSTRING."
|
68
68
|
end
|
69
69
|
|
70
|
-
it "
|
70
|
+
it "returns the first paragraph" do
|
71
71
|
o = Docstring.new("DOCSTRING, and other stuff\n\nAnother sentence.")
|
72
|
-
o.summary.
|
72
|
+
expect(o.summary).to eq "DOCSTRING, and other stuff."
|
73
73
|
end
|
74
74
|
|
75
|
-
it "
|
75
|
+
it "returns proper summary when docstring is changed" do
|
76
76
|
o = Docstring.new "DOCSTRING, and other stuff\n\nAnother sentence."
|
77
|
-
o.summary.
|
77
|
+
expect(o.summary).to eq "DOCSTRING, and other stuff."
|
78
78
|
o = Docstring.new "DOCSTRING."
|
79
|
-
o.summary.
|
79
|
+
expect(o.summary).to eq "DOCSTRING."
|
80
80
|
end
|
81
81
|
|
82
|
-
it "
|
82
|
+
it "does not double the ending period" do
|
83
83
|
o = Docstring.new("Returns a list of tags specified by +name+ or all tags if +name+ is not specified.\n\nTest")
|
84
|
-
o.summary.
|
84
|
+
expect(o.summary).to eq "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
|
85
85
|
|
86
86
|
doc = Docstring.new(<<-eof)
|
87
87
|
|
@@ -90,80 +90,87 @@ describe YARD::Docstring do
|
|
90
90
|
@param name the tag name to return data for, or nil for all tags
|
91
91
|
@return [Array<Tags::Tag>] the list of tags by the specified tag name
|
92
92
|
eof
|
93
|
-
doc.summary.
|
93
|
+
expect(doc.summary).to eq "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
|
94
94
|
end
|
95
95
|
|
96
|
-
it "
|
96
|
+
it "does not attach period if entire summary is include" do
|
97
97
|
YARD.parse_string "# docstring\ndef foo; end"
|
98
|
-
Docstring.new("{include:#foo}").summary.
|
98
|
+
expect(Docstring.new("{include:#foo}").summary).to eq '{include:#foo}'
|
99
99
|
Registry.clear
|
100
100
|
end
|
101
101
|
|
102
|
-
it "
|
103
|
-
Docstring.new("Aliasing {Test.test}. Done.").summary.
|
102
|
+
it "handles references embedded in summary" do
|
103
|
+
expect(Docstring.new("Aliasing {Test.test}. Done.").summary).to eq "Aliasing {Test.test}."
|
104
104
|
end
|
105
105
|
|
106
|
-
it "
|
107
|
-
Docstring.new("Hello (the best.) world. Foo bar.").summary.
|
108
|
-
Docstring.new("A[b.]c.").summary.
|
106
|
+
it "only ends first sentence when outside parentheses" do
|
107
|
+
expect(Docstring.new("Hello (the best.) world. Foo bar.").summary).to eq "Hello (the best.) world."
|
108
|
+
expect(Docstring.new("A[b.]c.").summary).to eq "A[b.]c."
|
109
109
|
end
|
110
110
|
|
111
|
-
it "
|
112
|
-
Docstring.new("hello 1.5 times.").summary.
|
113
|
-
Docstring.new("hello... me").summary.
|
114
|
-
Docstring.new("hello.").summary.
|
111
|
+
it "only sees '.' as period if whitespace (or eof) follows" do
|
112
|
+
expect(Docstring.new("hello 1.5 times.").summary).to eq "hello 1.5 times."
|
113
|
+
expect(Docstring.new("hello... me").summary).to eq "hello..."
|
114
|
+
expect(Docstring.new("hello.").summary).to eq "hello."
|
115
|
+
end
|
116
|
+
|
117
|
+
it "returns summary if there is a newline and parentheses count doesn't match" do
|
118
|
+
expect(Docstring.new("Happy method call :-)\n\nCall any time.").summary).to eq "Happy method call :-)."
|
119
|
+
expect(Docstring.new("Sad method call :-(\n\nCall any time.").summary).to eq "Sad method call :-(."
|
120
|
+
expect(Docstring.new("Hello (World. Forget to close.\n\nNew text").summary).to eq "Hello (World. Forget to close."
|
121
|
+
expect(Docstring.new("Hello (World. Forget to close\n\nNew text").summary).to eq "Hello (World. Forget to close."
|
115
122
|
end
|
116
123
|
end
|
117
124
|
|
118
|
-
describe
|
119
|
-
it "
|
125
|
+
describe "#ref_tags" do
|
126
|
+
it "parses reference tag into ref_tags" do
|
120
127
|
doc = Docstring.new("@return (see Foo#bar)")
|
121
|
-
doc.ref_tags.size.
|
122
|
-
doc.ref_tags.first.owner.
|
123
|
-
doc.ref_tags.first.tag_name.
|
124
|
-
doc.ref_tags.first.name.
|
128
|
+
expect(doc.ref_tags.size).to eq 1
|
129
|
+
expect(doc.ref_tags.first.owner).to eq P("Foo#bar")
|
130
|
+
expect(doc.ref_tags.first.tag_name).to eq "return"
|
131
|
+
expect(doc.ref_tags.first.name).to be nil
|
125
132
|
end
|
126
133
|
|
127
|
-
it "
|
134
|
+
it "parses named reference tag into ref_tags" do
|
128
135
|
doc = Docstring.new("@param blah \n (see Foo#bar )")
|
129
|
-
doc.ref_tags.size.
|
130
|
-
doc.ref_tags.first.owner.
|
131
|
-
doc.ref_tags.first.tag_name.
|
132
|
-
doc.ref_tags.first.name.
|
136
|
+
expect(doc.ref_tags.size).to eq 1
|
137
|
+
expect(doc.ref_tags.first.owner).to eq P("Foo#bar")
|
138
|
+
expect(doc.ref_tags.first.tag_name).to eq "param"
|
139
|
+
expect(doc.ref_tags.first.name).to eq "blah"
|
133
140
|
end
|
134
141
|
|
135
|
-
it "
|
142
|
+
it "fails to parse named reference tag into ref_tags" do
|
136
143
|
doc = Docstring.new("@param blah THIS_BREAKS_REFTAG (see Foo#bar)")
|
137
|
-
doc.ref_tags.size.
|
144
|
+
expect(doc.ref_tags.size).to eq 0
|
138
145
|
end
|
139
146
|
|
140
|
-
it "
|
147
|
+
it "returns all valid reference tags along with #tags" do
|
141
148
|
o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
|
142
149
|
o.docstring.add_tag Tags::Tag.new('return', 'testing')
|
143
150
|
doc = Docstring.new("@return (see Foo#bar)")
|
144
151
|
tags = doc.tags
|
145
|
-
tags.size.
|
146
|
-
tags.first.text.
|
147
|
-
tags.first.
|
148
|
-
tags.first.owner.
|
152
|
+
expect(tags.size).to eq 1
|
153
|
+
expect(tags.first.text).to eq 'testing'
|
154
|
+
expect(tags.first).to be_kind_of(Tags::RefTag)
|
155
|
+
expect(tags.first.owner).to eq o
|
149
156
|
end
|
150
157
|
|
151
|
-
it "
|
158
|
+
it "returns all valid named reference tags along with #tags(name)" do
|
152
159
|
o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
|
153
160
|
o.docstring.add_tag Tags::Tag.new('param', 'testing', nil, '*args')
|
154
161
|
o.docstring.add_tag Tags::Tag.new('param', 'NOTtesting', nil, 'notargs')
|
155
162
|
doc = Docstring.new("@param *args (see Foo#bar)")
|
156
163
|
tags = doc.tags('param')
|
157
|
-
tags.size.
|
158
|
-
tags.first.text.
|
159
|
-
tags.first.
|
160
|
-
tags.first.owner.
|
164
|
+
expect(tags.size).to eq 1
|
165
|
+
expect(tags.first.text).to eq 'testing'
|
166
|
+
expect(tags.first).to be_kind_of(Tags::RefTag)
|
167
|
+
expect(tags.first.owner).to eq o
|
161
168
|
end
|
162
169
|
|
163
|
-
it "
|
170
|
+
it "ignores invalid reference tags" do
|
164
171
|
doc = Docstring.new("@param *args (see INVALID::TAG#tag)")
|
165
172
|
tags = doc.tags('param')
|
166
|
-
tags.size.
|
173
|
+
expect(tags.size).to eq 0
|
167
174
|
end
|
168
175
|
|
169
176
|
it "resolves references to methods in the same class with #methname" do
|
@@ -174,147 +181,147 @@ describe YARD::Docstring do
|
|
174
181
|
ref.docstring = "@param (see #bar)"
|
175
182
|
|
176
183
|
tags = ref.docstring.tags("param")
|
177
|
-
tags.size.
|
178
|
-
tags.first.text.
|
179
|
-
tags.first.
|
180
|
-
tags.first.owner.
|
184
|
+
expect(tags.size).to eq 1
|
185
|
+
expect(tags.first.text).to eq "testing"
|
186
|
+
expect(tags.first).to be_kind_of(Tags::RefTag)
|
187
|
+
expect(tags.first.owner).to eq o
|
181
188
|
end
|
182
189
|
end
|
183
190
|
|
184
|
-
describe
|
191
|
+
describe "#empty?/#blank?" do
|
185
192
|
before(:all) do
|
186
193
|
Tags::Library.define_tag "Invisible", :invisible_tag
|
187
194
|
end
|
188
195
|
|
189
|
-
it "
|
190
|
-
Docstring.new.
|
191
|
-
Docstring.new.
|
196
|
+
it "is blank and empty if it has no content and no tags" do
|
197
|
+
expect(Docstring.new).to be_blank
|
198
|
+
expect(Docstring.new).to be_empty
|
192
199
|
end
|
193
200
|
|
194
|
-
it "
|
201
|
+
it "isn't empty or blank if it has content" do
|
195
202
|
d = Docstring.new("foo bar")
|
196
|
-
d.
|
197
|
-
d.
|
203
|
+
expect(d).not_to be_empty
|
204
|
+
expect(d).not_to be_blank
|
198
205
|
end
|
199
206
|
|
200
|
-
it "
|
207
|
+
it "is empty but not blank if it has tags" do
|
201
208
|
d = Docstring.new("@param foo")
|
202
|
-
d.
|
203
|
-
d.
|
209
|
+
expect(d).to be_empty
|
210
|
+
expect(d).not_to be_blank
|
204
211
|
end
|
205
212
|
|
206
|
-
it "
|
213
|
+
it "is empty but not blank if it has ref tags" do
|
207
214
|
o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
|
208
215
|
o.docstring.add_tag Tags::Tag.new('return', 'testing')
|
209
216
|
d = Docstring.new("@return (see Foo#bar)")
|
210
|
-
d.
|
211
|
-
d.
|
217
|
+
expect(d).to be_empty
|
218
|
+
expect(d).not_to be_blank
|
212
219
|
end
|
213
220
|
|
214
|
-
it "
|
221
|
+
it "is blank if it has no visible tags" do
|
215
222
|
d = Docstring.new("@invisible_tag value")
|
216
|
-
d.
|
223
|
+
expect(d).to be_blank
|
217
224
|
end
|
218
225
|
|
219
|
-
it "
|
226
|
+
it "is not blank if it has invisible tags and only_visible_tags = false" do
|
220
227
|
d = Docstring.new("@invisible_tag value")
|
221
228
|
d.add_tag Tags::Tag.new('invisible_tag', nil, nil)
|
222
|
-
d.blank?(false).
|
229
|
+
expect(d.blank?(false)).to be false
|
223
230
|
end
|
224
231
|
end
|
225
232
|
|
226
|
-
describe
|
227
|
-
it "
|
233
|
+
describe "#delete_tags" do
|
234
|
+
it "deletes tags by a given tag name" do
|
228
235
|
doc = Docstring.new("@param name x\n@param name2 y\n@return foo")
|
229
236
|
doc.delete_tags(:param)
|
230
|
-
doc.tags.size.
|
237
|
+
expect(doc.tags.size).to eq 1
|
231
238
|
end
|
232
239
|
end
|
233
240
|
|
234
|
-
describe
|
235
|
-
it "
|
241
|
+
describe "#delete_tag_if" do
|
242
|
+
it "deletes tags for a given block" do
|
236
243
|
doc = Docstring.new("@param name x\n@param name2 y\n@return foo")
|
237
244
|
doc.delete_tag_if {|t| t.name == 'name2' }
|
238
|
-
doc.tags.size.
|
245
|
+
expect(doc.tags.size).to eq 2
|
239
246
|
end
|
240
247
|
end
|
241
248
|
|
242
|
-
describe
|
243
|
-
it "
|
249
|
+
describe "#to_raw" do
|
250
|
+
it "returns a clean representation of tags" do
|
244
251
|
doc = Docstring.new("Hello world\n@return [String, X] foobar\n@param name<Array> the name\nBYE!")
|
245
|
-
doc.to_raw.
|
252
|
+
expect(doc.to_raw).to eq "Hello world\nBYE!\n@param [Array] name\n the name\n@return [String, X] foobar"
|
246
253
|
end
|
247
254
|
|
248
|
-
it "
|
255
|
+
it "handles tags with newlines and indentation" do
|
249
256
|
doc = Docstring.new("@example TITLE\n the \n example\n @foo\n@param [X] name\n the name")
|
250
|
-
doc.to_raw.
|
257
|
+
expect(doc.to_raw).to eq "@example TITLE\n the \n example\n @foo\n@param [X] name\n the name"
|
251
258
|
end
|
252
259
|
|
253
|
-
it "
|
260
|
+
it "handles deleted tags" do
|
254
261
|
doc = Docstring.new("@example TITLE\n the \n example\n @foo\n@param [X] name\n the name")
|
255
262
|
doc.delete_tags(:param)
|
256
|
-
doc.to_raw.
|
263
|
+
expect(doc.to_raw).to eq "@example TITLE\n the \n example\n @foo"
|
257
264
|
end
|
258
265
|
|
259
|
-
it "
|
266
|
+
it "handles added tags" do
|
260
267
|
doc = Docstring.new("@example TITLE\n the \n example\n @foo")
|
261
268
|
doc.add_tag(Tags::Tag.new('foo', 'foo'))
|
262
|
-
doc.to_raw.
|
269
|
+
expect(doc.to_raw).to eq "@example TITLE\n the \n example\n @foo\n@foo foo"
|
263
270
|
end
|
264
271
|
|
265
|
-
it "
|
272
|
+
it "is equal to .all if not modified" do
|
266
273
|
doc = Docstring.new("123\n@param")
|
267
|
-
doc.to_raw.
|
274
|
+
expect(doc.to_raw).to eq doc.all
|
268
275
|
end
|
269
276
|
|
270
277
|
# @bug gh-563
|
271
|
-
it "
|
278
|
+
it "handles full @option tags" do
|
272
279
|
doc = Docstring.new("@option foo [String] bar (nil) baz")
|
273
|
-
doc.to_raw.
|
280
|
+
expect(doc.to_raw).to eq "@option foo [String] bar (nil) baz"
|
274
281
|
end
|
275
282
|
|
276
283
|
# @bug gh-563
|
277
|
-
it "
|
284
|
+
it "handles simple @option tags" do
|
278
285
|
doc = Docstring.new("@option foo :key bar")
|
279
|
-
doc.to_raw.
|
286
|
+
expect(doc.to_raw).to eq "@option foo :key bar"
|
280
287
|
end
|
281
288
|
end
|
282
289
|
|
283
|
-
describe
|
284
|
-
it "
|
290
|
+
describe "#dup" do
|
291
|
+
it "duplicates docstring text" do
|
285
292
|
doc = Docstring.new("foo")
|
286
|
-
doc.dup.
|
287
|
-
doc.dup.all.
|
293
|
+
expect(doc.dup).to eq doc
|
294
|
+
expect(doc.dup.all).to eq doc
|
288
295
|
end
|
289
296
|
|
290
|
-
it "
|
297
|
+
it "duplicates tags to new list" do
|
291
298
|
doc = Docstring.new("@param x\n@return y")
|
292
299
|
doc2 = doc.dup
|
293
300
|
doc2.delete_tags(:param)
|
294
|
-
doc.tags.size.
|
295
|
-
doc2.tags.size.
|
301
|
+
expect(doc.tags.size).to eq 2
|
302
|
+
expect(doc2.tags.size).to eq 1
|
296
303
|
end
|
297
304
|
|
298
|
-
it "
|
305
|
+
it "preserves summary" do
|
299
306
|
doc = Docstring.new("foo. bar")
|
300
|
-
doc.dup.summary.
|
307
|
+
expect(doc.dup.summary).to eq doc.summary
|
301
308
|
end
|
302
309
|
|
303
|
-
it "
|
310
|
+
it "preserves hash_flag" do
|
304
311
|
doc = Docstring.new
|
305
312
|
doc.hash_flag = 'foo'
|
306
|
-
doc.dup.hash_flag.
|
313
|
+
expect(doc.dup.hash_flag).to eq doc.hash_flag
|
307
314
|
end
|
308
315
|
|
309
|
-
it "
|
316
|
+
it "preserves line_range" do
|
310
317
|
doc = Docstring.new
|
311
318
|
doc.line_range = (1..2)
|
312
|
-
doc.dup.line_range.
|
319
|
+
expect(doc.dup.line_range).to eq doc.line_range
|
313
320
|
end
|
314
321
|
end
|
315
322
|
|
316
|
-
describe
|
317
|
-
it
|
323
|
+
describe "reference docstrings" do
|
324
|
+
it "allows for construction of docstring with ref object" do
|
318
325
|
YARD.parse_string <<-eof
|
319
326
|
class A
|
320
327
|
# Docstring
|
@@ -326,8 +333,8 @@ describe YARD::Docstring do
|
|
326
333
|
eof
|
327
334
|
|
328
335
|
object = YARD::Registry.at('A#b')
|
329
|
-
object.docstring.
|
330
|
-
object.tags.map {|x| x.tag_name }.
|
336
|
+
expect(object.docstring).to eq 'Docstring'
|
337
|
+
expect(object.tags.map {|x| x.tag_name }).to eq ['return']
|
331
338
|
|
332
339
|
YARD::Registry.clear
|
333
340
|
end
|