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
@@ -1,20 +1,19 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
3
|
describe YARD::Server::WebrickServlet do
|
4
|
-
describe
|
5
|
-
it "
|
4
|
+
describe "#do_GET" do
|
5
|
+
it "performs a GET" do
|
6
6
|
resp = OpenStruct.new
|
7
7
|
class << resp
|
8
8
|
def []=(name, value) (self.headers ||= {})[name] = value end
|
9
9
|
end
|
10
|
-
server =
|
11
|
-
server.stub!(:[])
|
10
|
+
server = double(:server, :[] => nil)
|
12
11
|
adapter = mock_adapter
|
13
12
|
adapter.router = proc { [200, {'Header' => 'foo'}, ['body']]}
|
14
13
|
WebrickServlet.new(server, adapter).do_GET(mock_request('/foo'), resp)
|
15
|
-
resp.status.
|
16
|
-
resp.headers.
|
17
|
-
resp.body.
|
14
|
+
expect(resp.status).to eq 200
|
15
|
+
expect(resp.headers).to eq({'Header' => 'foo'})
|
16
|
+
expect(resp.body).to eq 'body'
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
data/spec/server_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/spec_helper"
|
2
2
|
|
3
3
|
describe YARD::Server do
|
4
|
-
describe
|
5
|
-
it "
|
4
|
+
describe ".register_static_path" do
|
5
|
+
it "registers a static path" do
|
6
6
|
YARD::Server.register_static_path 'foo'
|
7
|
-
YARD::Server::Commands::StaticFileCommand::STATIC_PATHS.last.
|
7
|
+
expect(YARD::Server::Commands::StaticFileCommand::STATIC_PATHS.last).to eq "foo"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -32,7 +32,7 @@ unless defined?(HAVE_RIPPER)
|
|
32
32
|
LEGACY_PARSER = !HAVE_RIPPER
|
33
33
|
|
34
34
|
class YARD::Parser::SourceParser
|
35
|
-
def self.parser_type; :ruby18 end
|
35
|
+
def self.parser_type; @parser_type == :ruby ? :ruby18 : @parser_type end
|
36
36
|
end if ENV['LEGACY']
|
37
37
|
end
|
38
38
|
|
@@ -101,7 +101,7 @@ def docspec(objname = self.class.description, klass = self.class.described_type)
|
|
101
101
|
exs.text.split(/\n/).each do |ex|
|
102
102
|
begin
|
103
103
|
hash = eval("{ #{ex} }")
|
104
|
-
hash.keys.first.
|
104
|
+
expect(hash.keys.first).to eq hash.values.first
|
105
105
|
rescue => e
|
106
106
|
raise e, "#{e.message}\nInvalid spec example in #{objname}:\n\n\t#{ex}\n"
|
107
107
|
end
|
@@ -125,6 +125,15 @@ end if ENV['TM_APP_PATH']
|
|
125
125
|
|
126
126
|
RSpec.configure do |config|
|
127
127
|
config.before(:each) { log.io = StringIO.new }
|
128
|
+
|
129
|
+
# isolate environment of each test
|
130
|
+
# any other global settings which might be modified by a test should also
|
131
|
+
# be saved and restored here
|
132
|
+
config.around(:each) do |example|
|
133
|
+
saved_level = log.level
|
134
|
+
example.run
|
135
|
+
log.level = saved_level
|
136
|
+
end
|
128
137
|
end
|
129
138
|
|
130
139
|
include YARD
|
@@ -3,155 +3,155 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
3
3
|
describe YARD::Tags::DefaultFactory do
|
4
4
|
before { @f = YARD::Tags::DefaultFactory.new }
|
5
5
|
|
6
|
-
describe
|
7
|
-
it "
|
8
|
-
@f.parse_tag('api', 'private ').text.
|
6
|
+
describe "#parse_tag" do
|
7
|
+
it "does not have trailing whitespace on a regular freeform tag" do
|
8
|
+
expect(@f.parse_tag('api', 'private ').text).to eq "private"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe "#extract_types_and_name_from_text" do
|
13
13
|
def parse_types(types)
|
14
14
|
@f.send(:extract_types_and_name_from_text, types)
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
18
|
-
parse_types('[A]').
|
17
|
+
it "handles one type" do
|
18
|
+
expect(parse_types('[A]')).to eq [nil, ['A'], ""]
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
22
|
-
parse_types('[A, B, C]').
|
21
|
+
it "handles a list of types" do
|
22
|
+
expect(parse_types('[A, B, C]')).to eq [nil, ['A', 'B', 'C'], ""]
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
parse_types('[#foo]').
|
25
|
+
it "handles ducktypes" do
|
26
|
+
expect(parse_types('[#foo]')).to eq [nil, ['#foo'], '']
|
27
27
|
end
|
28
28
|
|
29
29
|
%w(#foo= #<< #<=> #>> #== #=== Array<#<=>> Array<#==>).each do |meth|
|
30
|
-
it "
|
31
|
-
parse_types("[#{meth}]").
|
30
|
+
it "handles ducktypes with special method name #{meth}" do
|
31
|
+
expect(parse_types("[#{meth}]")).to eq [nil, [meth], '']
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
36
|
-
parse_types("#ducktype").
|
35
|
+
it "only parses #ducktypes inside brackets" do
|
36
|
+
expect(parse_types("#ducktype")).to eq [nil, nil, '#ducktype']
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
40
|
-
parse_types(' b <String> description').
|
41
|
-
parse_types('b c <String> description (test)').
|
39
|
+
it "returns the text before and after the type list" do
|
40
|
+
expect(parse_types(' b <String> description')).to eq ['b', ['String'], 'description']
|
41
|
+
expect(parse_types('b c <String> description (test)')).to eq [nil, nil, 'b c <String> description (test)']
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "handles a complex list of types" do
|
45
45
|
v = parse_types(' [Test, Array<String, Hash, C>, String]')
|
46
|
-
v.
|
46
|
+
expect(v).to include(["Test", "Array<String, Hash, C>", "String"])
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
49
|
+
it "handles any of the following start/end delimiting chars: (), <>, {}, []" do
|
50
50
|
a = parse_types('[a,b,c]')
|
51
51
|
b = parse_types('<a,b,c>')
|
52
52
|
c = parse_types('(a,b,c)')
|
53
53
|
d = parse_types('{a,b,c}')
|
54
|
-
a.
|
55
|
-
b.
|
56
|
-
c.
|
57
|
-
a.
|
54
|
+
expect(a).to eq b
|
55
|
+
expect(b).to eq c
|
56
|
+
expect(c).to eq d
|
57
|
+
expect(a).to include(['a','b','c'])
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
61
|
-
parse_types('b[x, y, z]').
|
62
|
-
parse_types(' ! <x>').
|
60
|
+
it "returns the text before the type list as the last element" do
|
61
|
+
expect(parse_types('b[x, y, z]')).to eq ['b', ['x', 'y', 'z'], '']
|
62
|
+
expect(parse_types(' ! <x>')).to eq ["!", ['x'], '']
|
63
63
|
end
|
64
64
|
|
65
|
-
it "
|
66
|
-
parse_types('').
|
67
|
-
parse_types('[]').
|
65
|
+
it "returns text unparsed if there is no type list" do
|
66
|
+
expect(parse_types('')).to eq [nil, nil, '']
|
67
|
+
expect(parse_types('[]')).to eq [nil, nil, '[]']
|
68
68
|
end
|
69
69
|
|
70
|
-
it "
|
70
|
+
it "allows A => B syntax" do
|
71
71
|
v = parse_types(' [Test, Array<String, Hash{A => {B => C}}, C>, String]')
|
72
|
-
v.
|
72
|
+
expect(v).to include(["Test", "Array<String, Hash{A => {B => C}}, C>", "String"])
|
73
73
|
end
|
74
74
|
|
75
|
-
it "
|
75
|
+
it "handles quoted values" do
|
76
76
|
v = parse_types(' ["foo, bar", \'baz, qux\', in"them,iddle"]')
|
77
|
-
v.
|
77
|
+
expect(v).to include(["\"foo, bar\"", "'baz, qux'", 'in"them,iddle"'])
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
describe
|
81
|
+
describe "#parse_tag_with_types" do
|
82
82
|
def parse_types(text)
|
83
83
|
@f.send(:parse_tag_with_types, 'test', text)
|
84
84
|
end
|
85
85
|
|
86
|
-
it "
|
87
|
-
YARD::Tags::Tag.
|
86
|
+
it "parses given types and description" do
|
87
|
+
expect(YARD::Tags::Tag).to receive(:new).with("test", "description", ["x", "y", "z"])
|
88
88
|
parse_types(' [x, y, z] description')
|
89
89
|
end
|
90
90
|
|
91
|
-
it "
|
92
|
-
YARD::Tags::Tag.
|
91
|
+
it "parses given types only" do
|
92
|
+
expect(YARD::Tags::Tag).to receive(:new).with("test", "", ["x", "y", "z"])
|
93
93
|
parse_types(' [x, y, z] ')
|
94
94
|
end
|
95
95
|
|
96
|
-
it "
|
97
|
-
YARD::Tags::Tag.
|
96
|
+
it "allows type list to be omitted" do
|
97
|
+
expect(YARD::Tags::Tag).to receive(:new).with('test', 'description', nil)
|
98
98
|
parse_types(' description ')
|
99
99
|
end
|
100
100
|
|
101
|
-
it "
|
102
|
-
|
101
|
+
it "raises an error if a name is specified before type list" do
|
102
|
+
expect { parse_types('b<String> desc') }.to raise_error(YARD::Tags::TagFormatError, 'cannot specify a name before type list for \'@test\'')
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
describe
|
106
|
+
describe "#parse_tag_with_types_name_and_default" do
|
107
107
|
def parse_types(text)
|
108
108
|
@f.send(:parse_tag_with_types_name_and_default, 'test', text)
|
109
109
|
end
|
110
110
|
|
111
|
-
it "
|
112
|
-
YARD::Tags::DefaultTag.
|
111
|
+
it "parses a standard type list with name before types (no default)" do
|
112
|
+
expect(YARD::Tags::DefaultTag).to receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', nil)
|
113
113
|
parse_types('NAME [x, y, z] description')
|
114
114
|
end
|
115
115
|
|
116
|
-
it "
|
117
|
-
YARD::Tags::DefaultTag.
|
116
|
+
it "parses a standard type list with name after types (no default)" do
|
117
|
+
expect(YARD::Tags::DefaultTag).to receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', nil)
|
118
118
|
parse_types(' [x, y, z] NAME description')
|
119
119
|
end
|
120
120
|
|
121
|
-
it "
|
122
|
-
YARD::Tags::DefaultTag.
|
121
|
+
it "parses a tag definition with name, typelist and default" do
|
122
|
+
expect(YARD::Tags::DefaultTag).to receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', ['default', 'values'])
|
123
123
|
parse_types(' [x, y, z] NAME (default, values) description')
|
124
124
|
end
|
125
125
|
|
126
|
-
it "
|
127
|
-
YARD::Tags::DefaultTag.
|
126
|
+
it "parses a tag definition with name, typelist and default when name is before type list" do
|
127
|
+
expect(YARD::Tags::DefaultTag).to receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', ['default', 'values'])
|
128
128
|
parse_types(' NAME [x, y, z] (default, values) description')
|
129
129
|
end
|
130
130
|
|
131
|
-
it "
|
132
|
-
YARD::Tags::DefaultTag.
|
131
|
+
it "allows typelist to be omitted" do
|
132
|
+
expect(YARD::Tags::DefaultTag).to receive(:new).with("test", "description", nil, 'NAME', ['default', 'values'])
|
133
133
|
parse_types(' NAME (default, values) description')
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
describe
|
137
|
+
describe "#parse_tag_with_options" do
|
138
138
|
def parse_options(text)
|
139
139
|
@f.parse_tag_with_options('option', text)
|
140
140
|
end
|
141
141
|
|
142
|
-
it "
|
142
|
+
it "has a name before tag info" do
|
143
143
|
t = parse_options("xyz key [Types] (default) description")
|
144
|
-
t.tag_name.
|
145
|
-
t.name.
|
144
|
+
expect(t.tag_name).to eq 'option'
|
145
|
+
expect(t.name).to eq 'xyz'
|
146
146
|
end
|
147
147
|
|
148
|
-
it "
|
148
|
+
it "parses the rest of the tag like DefaultTag" do
|
149
149
|
t = parse_options("xyz key [Types] (default) description")
|
150
|
-
t.pair.
|
151
|
-
t.pair.types.
|
152
|
-
t.pair.name.
|
153
|
-
t.pair.defaults.
|
154
|
-
t.pair.text.
|
150
|
+
expect(t.pair).to be_instance_of(Tags::DefaultTag)
|
151
|
+
expect(t.pair.types).to eq ["Types"]
|
152
|
+
expect(t.pair.name).to eq "key"
|
153
|
+
expect(t.pair.defaults).to eq ["default"]
|
154
|
+
expect(t.pair.text).to eq "description"
|
155
155
|
end
|
156
156
|
end
|
157
157
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe YARD::Tags::DefaultTag do
|
4
|
-
it "
|
4
|
+
it "creates a tag with defaults" do
|
5
5
|
o = YARD::Tags::DefaultTag.new('tagname', 'desc', ['types'], 'name', ['defaults'])
|
6
|
-
o.defaults.
|
7
|
-
o.tag_name.
|
8
|
-
o.name.
|
9
|
-
o.types.
|
6
|
+
expect(o.defaults).to eq ['defaults']
|
7
|
+
expect(o.tag_name).to eq 'tagname'
|
8
|
+
expect(o.name).to eq 'name'
|
9
|
+
expect(o.types).to eq ['types']
|
10
10
|
end
|
11
11
|
end
|
@@ -7,28 +7,28 @@ def tag_parse(content, object = nil, handler = nil)
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe YARD::Tags::ParseDirective do
|
10
|
-
describe
|
10
|
+
describe "#call" do
|
11
11
|
after { Registry.clear }
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "parses if handler=nil but use file=(stdin)" do
|
14
14
|
tag_parse %{@!parse
|
15
15
|
# Docstring here
|
16
16
|
def foo; end
|
17
17
|
}
|
18
|
-
Registry.at('#foo').docstring.
|
19
|
-
Registry.at('#foo').file.
|
18
|
+
expect(Registry.at('#foo').docstring).to eq "Docstring here"
|
19
|
+
expect(Registry.at('#foo').file).to eq '(stdin)'
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
22
|
+
it "allows parser type to be specified in type" do
|
23
23
|
tag_parse %{@!parse [c]
|
24
24
|
void Init_Foo() {
|
25
25
|
rb_define_method(rb_cMyClass, "foo", foo, 1);
|
26
26
|
}
|
27
27
|
}
|
28
|
-
Registry.at('MyClass#foo').
|
28
|
+
expect(Registry.at('MyClass#foo')).not_to be nil
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "parses code in context of current handler" do
|
32
32
|
src = <<-eof
|
33
33
|
class A
|
34
34
|
# @!parse
|
@@ -39,35 +39,35 @@ describe YARD::Tags::ParseDirective do
|
|
39
39
|
parser = Parser::SourceParser.new
|
40
40
|
parser.file = "myfile.rb"
|
41
41
|
parser.parse(StringIO.new(src))
|
42
|
-
Registry.at('A#foo').file.
|
42
|
+
expect(Registry.at('A#foo').file).to eq 'myfile.rb'
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe YARD::Tags::GroupDirective do
|
48
|
-
describe
|
49
|
-
it "
|
48
|
+
describe "#call" do
|
49
|
+
it "does nothing if handler=nil" do
|
50
50
|
tag_parse("@!group foo")
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "sets group value in parser state (with handler)" do
|
54
54
|
handler = OpenStruct.new(:extra_state => OpenStruct.new)
|
55
55
|
tag_parse("@!group foo", nil, handler)
|
56
|
-
handler.extra_state.group.
|
56
|
+
expect(handler.extra_state.group).to eq 'foo'
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
describe YARD::Tags::EndGroupDirective do
|
62
|
-
describe
|
63
|
-
it "
|
62
|
+
describe "#call" do
|
63
|
+
it "does nothing if handler=nil" do
|
64
64
|
tag_parse("@!endgroup foo")
|
65
65
|
end
|
66
66
|
|
67
|
-
it "
|
67
|
+
it "sets group value in parser state (with handler)" do
|
68
68
|
handler = OpenStruct.new(:extra_state => OpenStruct.new(:group => "foo"))
|
69
69
|
tag_parse("@!endgroup", nil, handler)
|
70
|
-
handler.extra_state.group.
|
70
|
+
expect(handler.extra_state.group).to be nil
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -83,79 +83,79 @@ describe YARD::Tags::MacroDirective do
|
|
83
83
|
|
84
84
|
after(:all) { Registry.clear }
|
85
85
|
|
86
|
-
describe
|
87
|
-
it "
|
86
|
+
describe "#call" do
|
87
|
+
it "defines new macro when [new] is provided" do
|
88
88
|
tag_parse("@!macro [new] foo\n foo")
|
89
|
-
CodeObjects::MacroObject.find('foo').macro_data.
|
89
|
+
expect(CodeObjects::MacroObject.find('foo').macro_data).to eq 'foo'
|
90
90
|
end
|
91
91
|
|
92
|
-
it "
|
92
|
+
it "defines new macro if text block is provided" do
|
93
93
|
tag_parse("@!macro bar\n bar")
|
94
|
-
CodeObjects::MacroObject.find('bar').macro_data.
|
94
|
+
expect(CodeObjects::MacroObject.find('bar').macro_data).to eq 'bar'
|
95
95
|
end
|
96
96
|
|
97
|
-
it "
|
97
|
+
it "expands macros and return #expanded_text to tag parser" do
|
98
98
|
tag_parse("@!macro [new] foo\n foo")
|
99
|
-
tag_parse("@!macro foo").text.
|
99
|
+
expect(tag_parse("@!macro foo").text).to eq 'foo'
|
100
100
|
end
|
101
101
|
|
102
|
-
it "
|
103
|
-
tag_parse("@!macro [new] foo\n foo").text.
|
102
|
+
it "does not expand new macro if docstring is unattached" do
|
103
|
+
expect(tag_parse("@!macro [new] foo\n foo").text).not_to eq 'foo'
|
104
104
|
end
|
105
105
|
|
106
|
-
it "
|
107
|
-
tag_parse("@!macro\n foo").text.
|
106
|
+
it "expands new anonymous macro even if docstring is unattached" do
|
107
|
+
expect(tag_parse("@!macro\n foo").text).to eq 'foo'
|
108
108
|
end
|
109
109
|
|
110
|
-
it "
|
110
|
+
it "allows multiple macros to be expanded" do
|
111
111
|
tag_parse("@!macro [new] foo\n foo")
|
112
112
|
tag_parse("@!macro bar\n bar")
|
113
|
-
tag_parse("@!macro foo\n@!macro bar").text.
|
113
|
+
expect(tag_parse("@!macro foo\n@!macro bar").text).to eq "foo\nbar"
|
114
114
|
end
|
115
115
|
|
116
|
-
it "
|
116
|
+
it "allows anonymous macros" do
|
117
117
|
tag_parse("@!macro\n a b c", nil, handler)
|
118
|
-
@parser.text.
|
118
|
+
expect(@parser.text).to eq 'a b c'
|
119
119
|
end
|
120
120
|
|
121
|
-
it "
|
121
|
+
it "expands call_params and caller_method using $N when handler is provided" do
|
122
122
|
tag_parse("@!macro\n $1 $2 $3", nil, handler)
|
123
|
-
@parser.text.
|
123
|
+
expect(@parser.text).to eq 'a b c'
|
124
124
|
end
|
125
125
|
|
126
|
-
it "
|
126
|
+
it "attaches macro to method if one exists" do
|
127
127
|
tag_parse("@!macro [attach] attached\n $1 $2 $3", nil, handler)
|
128
128
|
macro = CodeObjects::MacroObject.find('attached')
|
129
|
-
macro.method_object.
|
129
|
+
expect(macro.method_object).to eq P('Foo::Bar.foo')
|
130
130
|
end
|
131
131
|
|
132
|
-
it "
|
132
|
+
it "does not expand new attached macro if defined on class method" do
|
133
133
|
baz = CodeObjects::MethodObject.new(P('Foo::Bar'), :baz, :class)
|
134
|
-
baz.visibility.
|
134
|
+
expect(baz.visibility).to eq :public
|
135
135
|
tag_parse("@!macro [attach] attached2\n @!visibility private", baz, handler)
|
136
136
|
macro = CodeObjects::MacroObject.find('attached2')
|
137
|
-
macro.method_object.
|
138
|
-
baz.visibility.
|
137
|
+
expect(macro.method_object).to eq P('Foo::Bar.baz')
|
138
|
+
expect(baz.visibility).to eq :public
|
139
139
|
end
|
140
140
|
|
141
|
-
it "
|
141
|
+
it "expands macro if defined on class method and there is no data block" do
|
142
142
|
tag_parse("@!macro [new] attached3\n expanded_data")
|
143
143
|
baz = CodeObjects::MethodObject.new(P('Foo::Bar'), :baz, :class)
|
144
144
|
doc = DocstringParser.new.parse('@!macro attached3', baz, handler).to_docstring
|
145
|
-
doc.
|
145
|
+
expect(doc).to eq 'expanded_data'
|
146
146
|
end
|
147
147
|
|
148
|
-
it "
|
148
|
+
it "does not attempt to expand macro values if handler = nil" do
|
149
149
|
tag_parse("@!macro [attach] xyz\n $1 $2 $3")
|
150
150
|
end
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
154
|
describe YARD::Tags::MethodDirective do
|
155
|
-
describe
|
155
|
+
describe "#call" do
|
156
156
|
after { Registry.clear }
|
157
157
|
|
158
|
-
it "
|
158
|
+
it "uses entire docstring if no indented data is found" do
|
159
159
|
YARD.parse_string <<-eof
|
160
160
|
class Foo
|
161
161
|
# @!method foo
|
@@ -163,11 +163,11 @@ describe YARD::Tags::MethodDirective do
|
|
163
163
|
# @!scope class
|
164
164
|
end
|
165
165
|
eof
|
166
|
-
Registry.at('Foo.foo').
|
167
|
-
Registry.at('Foo.bar').
|
166
|
+
expect(Registry.at('Foo.foo')).to be_a(CodeObjects::MethodObject)
|
167
|
+
expect(Registry.at('Foo.bar')).to be_a(CodeObjects::MethodObject)
|
168
168
|
end
|
169
169
|
|
170
|
-
it "
|
170
|
+
it "handles indented block text in @!method" do
|
171
171
|
YARD.parse_string <<-eof
|
172
172
|
# @!method foo(a)
|
173
173
|
# Docstring here
|
@@ -176,12 +176,12 @@ describe YARD::Tags::MethodDirective do
|
|
176
176
|
# @param [String] a
|
177
177
|
eof
|
178
178
|
foo = Registry.at('#foo')
|
179
|
-
foo.docstring.
|
180
|
-
foo.docstring.tag(:return).
|
181
|
-
foo.tag(:param).
|
179
|
+
expect(foo.docstring).to eq "Docstring here"
|
180
|
+
expect(foo.docstring.tag(:return)).not_to be nil
|
181
|
+
expect(foo.tag(:param)).to be nil
|
182
182
|
end
|
183
183
|
|
184
|
-
it "
|
184
|
+
it "executes directives on object in indented block" do
|
185
185
|
YARD.parse_string <<-eof
|
186
186
|
class Foo
|
187
187
|
# @!method foo(a)
|
@@ -193,12 +193,12 @@ describe YARD::Tags::MethodDirective do
|
|
193
193
|
end
|
194
194
|
eof
|
195
195
|
foo = Registry.at('Foo.foo')
|
196
|
-
foo.visibility.
|
196
|
+
expect(foo.visibility).to eq :private
|
197
197
|
bar = Registry.at('Foo#bar')
|
198
|
-
bar.visibility.
|
198
|
+
expect(bar.visibility).to eq :public
|
199
199
|
end
|
200
200
|
|
201
|
-
it "
|
201
|
+
it "is able to define multiple @methods in docstring" do
|
202
202
|
YARD.parse_string <<-eof
|
203
203
|
class Foo
|
204
204
|
# @!method foo1
|
@@ -213,12 +213,12 @@ describe YARD::Tags::MethodDirective do
|
|
213
213
|
foo1 = Registry.at('Foo#foo1')
|
214
214
|
foo2 = Registry.at('Foo#foo2')
|
215
215
|
foo3 = Registry.at('Foo.foo3')
|
216
|
-
foo1.docstring.
|
217
|
-
foo2.docstring.
|
218
|
-
foo3.docstring.
|
216
|
+
expect(foo1.docstring).to eq 'Docstring1'
|
217
|
+
expect(foo2.docstring).to eq 'Docstring2'
|
218
|
+
expect(foo3.docstring).to eq 'Docstring3'
|
219
219
|
end
|
220
220
|
|
221
|
-
it "
|
221
|
+
it "defines the method inside namespace if attached to namespace object" do
|
222
222
|
YARD.parse_string <<-eof
|
223
223
|
module Foo
|
224
224
|
# @!method foo
|
@@ -229,11 +229,11 @@ describe YARD::Tags::MethodDirective do
|
|
229
229
|
end
|
230
230
|
end
|
231
231
|
eof
|
232
|
-
Registry.at('Foo::Bar#foo').docstring.
|
233
|
-
Registry.at('Foo::Bar#bar').docstring.
|
232
|
+
expect(Registry.at('Foo::Bar#foo').docstring).to eq 'Docstring1'
|
233
|
+
expect(Registry.at('Foo::Bar#bar').docstring).to eq 'Docstring2'
|
234
234
|
end
|
235
235
|
|
236
|
-
it "
|
236
|
+
it "sets scope to class if signature has 'self.' prefix" do
|
237
237
|
YARD.parse_string <<-eof
|
238
238
|
# @!method self.foo
|
239
239
|
# @!method self. bar
|
@@ -242,18 +242,18 @@ describe YARD::Tags::MethodDirective do
|
|
242
242
|
end
|
243
243
|
eof
|
244
244
|
%w(foo bar baz).each do |name|
|
245
|
-
Registry.at("Foo.#{name}").
|
245
|
+
expect(Registry.at("Foo.#{name}")).to be_a(CodeObjects::MethodObject)
|
246
246
|
end
|
247
247
|
end
|
248
248
|
|
249
|
-
it "
|
249
|
+
it "defines parameters from signature" do
|
250
250
|
YARD.parse_string <<-eof
|
251
251
|
# @!method foo(a, b, c = nil)
|
252
252
|
eof
|
253
|
-
Registry.at('#foo').parameters.
|
253
|
+
expect(Registry.at('#foo').parameters).to eq [['a', nil], ['b', nil], ['c', 'nil']]
|
254
254
|
end
|
255
255
|
|
256
|
-
it "
|
256
|
+
it "is able to define method with module scope (module function)" do
|
257
257
|
YARD.parse_string <<-eof
|
258
258
|
# @!method foo
|
259
259
|
# @!scope module
|
@@ -264,20 +264,20 @@ describe YARD::Tags::MethodDirective do
|
|
264
264
|
eof
|
265
265
|
foo_c = Registry.at('Foo.foo')
|
266
266
|
foo_i = Registry.at('Foo#foo')
|
267
|
-
foo_c.
|
268
|
-
foo_i.
|
269
|
-
foo_c.
|
270
|
-
foo_c.docstring.
|
271
|
-
foo_c.tag(:return).text.
|
267
|
+
expect(foo_c).not_to be nil
|
268
|
+
expect(foo_i).not_to be nil
|
269
|
+
expect(foo_c).to be_module_function
|
270
|
+
expect(foo_c.docstring).to eq foo_i.docstring
|
271
|
+
expect(foo_c.tag(:return).text).to eq foo_i.tag(:return).text
|
272
272
|
end
|
273
273
|
end
|
274
274
|
end
|
275
275
|
|
276
276
|
describe YARD::Tags::AttributeDirective do
|
277
|
-
describe
|
277
|
+
describe "#call" do
|
278
278
|
after { Registry.clear }
|
279
279
|
|
280
|
-
it "
|
280
|
+
it "uses entire docstring if no indented data is found" do
|
281
281
|
YARD.parse_string <<-eof
|
282
282
|
class Foo
|
283
283
|
# @!attribute foo
|
@@ -285,11 +285,11 @@ describe YARD::Tags::AttributeDirective do
|
|
285
285
|
# @!scope class
|
286
286
|
end
|
287
287
|
eof
|
288
|
-
Registry.at('Foo.foo').
|
289
|
-
Registry.at('Foo.bar').
|
288
|
+
expect(Registry.at('Foo.foo')).to be_reader
|
289
|
+
expect(Registry.at('Foo.bar')).to be_reader
|
290
290
|
end
|
291
291
|
|
292
|
-
it "
|
292
|
+
it "handles indented block in @!attribute" do
|
293
293
|
YARD.parse_string <<-eof
|
294
294
|
# @!attribute foo
|
295
295
|
# Docstring here
|
@@ -298,13 +298,13 @@ describe YARD::Tags::AttributeDirective do
|
|
298
298
|
# @param [String] a
|
299
299
|
eof
|
300
300
|
foo = Registry.at('#foo')
|
301
|
-
foo.is_attribute
|
302
|
-
foo.docstring.
|
303
|
-
foo.docstring.tag(:return).
|
304
|
-
foo.tag(:param).
|
301
|
+
expect(foo.is_attribute?).to be true
|
302
|
+
expect(foo.docstring).to eq "Docstring here"
|
303
|
+
expect(foo.docstring.tag(:return)).not_to be nil
|
304
|
+
expect(foo.tag(:param)).to be nil
|
305
305
|
end
|
306
306
|
|
307
|
-
it "
|
307
|
+
it "is able to define multiple @attributes in docstring" do
|
308
308
|
YARD.parse_string <<-eof
|
309
309
|
class Foo
|
310
310
|
# @!attribute [r] foo1
|
@@ -320,18 +320,18 @@ describe YARD::Tags::AttributeDirective do
|
|
320
320
|
foo2 = Registry.at('Foo#foo2=')
|
321
321
|
foo3 = Registry.at('Foo.foo3')
|
322
322
|
foo4 = Registry.at('Foo.foo3=')
|
323
|
-
foo1.
|
324
|
-
foo2.
|
325
|
-
foo3.
|
326
|
-
foo1.docstring.
|
327
|
-
foo2.docstring.
|
328
|
-
foo3.docstring.
|
329
|
-
foo4.
|
330
|
-
foo1.attr_info[:write].
|
331
|
-
foo2.attr_info[:read].
|
332
|
-
end
|
333
|
-
|
334
|
-
it "
|
323
|
+
expect(foo1).to be_reader
|
324
|
+
expect(foo2).to be_writer
|
325
|
+
expect(foo3).to be_reader
|
326
|
+
expect(foo1.docstring).to eq 'Docstring1'
|
327
|
+
expect(foo2.docstring).to eq 'Docstring2'
|
328
|
+
expect(foo3.docstring).to eq 'Docstring3'
|
329
|
+
expect(foo4).to be_writer
|
330
|
+
expect(foo1.attr_info[:write]).to be nil
|
331
|
+
expect(foo2.attr_info[:read]).to be nil
|
332
|
+
end
|
333
|
+
|
334
|
+
it "defines the attr inside namespace if attached to namespace object" do
|
335
335
|
YARD.parse_string <<-eof
|
336
336
|
module Foo
|
337
337
|
# @!attribute [r] foo
|
@@ -340,12 +340,12 @@ describe YARD::Tags::AttributeDirective do
|
|
340
340
|
end
|
341
341
|
end
|
342
342
|
eof
|
343
|
-
Registry.at('Foo::Bar#foo').
|
344
|
-
Registry.at('Foo::Bar#bar').
|
343
|
+
expect(Registry.at('Foo::Bar#foo')).to be_reader
|
344
|
+
expect(Registry.at('Foo::Bar#bar')).to be_reader
|
345
345
|
end
|
346
346
|
end
|
347
347
|
|
348
|
-
it "
|
348
|
+
it "sets scope to class if signature has 'self.' prefix" do
|
349
349
|
YARD.parse_string <<-eof
|
350
350
|
# @!attribute self.foo
|
351
351
|
# @!attribute self. bar
|
@@ -354,82 +354,82 @@ describe YARD::Tags::AttributeDirective do
|
|
354
354
|
end
|
355
355
|
eof
|
356
356
|
%w(foo bar baz).each do |name|
|
357
|
-
Registry.at("Foo.#{name}").
|
357
|
+
expect(Registry.at("Foo.#{name}")).to be_reader
|
358
358
|
end
|
359
359
|
end
|
360
360
|
end
|
361
361
|
|
362
362
|
describe YARD::Tags::ScopeDirective do
|
363
|
-
describe
|
363
|
+
describe "#call" do
|
364
364
|
after { Registry.clear }
|
365
365
|
|
366
|
-
it "
|
366
|
+
it "sets state on tag parser if object = nil" do
|
367
367
|
tag_parse("@!scope class")
|
368
|
-
@parser.state.scope.
|
368
|
+
expect(@parser.state.scope).to eq :class
|
369
369
|
end
|
370
370
|
|
371
|
-
it "
|
371
|
+
it "sets state on tag parser if object is namespace" do
|
372
372
|
object = CodeObjects::ClassObject.new(:root, 'Foo')
|
373
373
|
tag_parse("@!scope class", object)
|
374
|
-
object[:scope].
|
375
|
-
@parser.state.scope.
|
374
|
+
expect(object[:scope]).to be nil
|
375
|
+
expect(@parser.state.scope).to eq :class
|
376
376
|
end
|
377
377
|
|
378
|
-
it "
|
378
|
+
it "sets scope on object if object is a method object" do
|
379
379
|
object = CodeObjects::MethodObject.new(:root, 'foo')
|
380
380
|
tag_parse("@!scope class", object)
|
381
|
-
object.scope.
|
381
|
+
expect(object.scope).to eq :class
|
382
382
|
end
|
383
383
|
|
384
384
|
%w(class instance module).each do |type|
|
385
|
-
it "
|
385
|
+
it "allows #{type} as value" do
|
386
386
|
tag_parse("@!scope #{type}")
|
387
|
-
@parser.state.scope.
|
387
|
+
expect(@parser.state.scope).to eq type.to_sym
|
388
388
|
end
|
389
389
|
end
|
390
390
|
|
391
391
|
%w(invalid foo FOO CLASS INSTANCE).each do |type|
|
392
|
-
it "
|
392
|
+
it "does not allow #{type} as value" do
|
393
393
|
tag_parse("@!scope #{type}")
|
394
|
-
@parser.state.scope.
|
394
|
+
expect(@parser.state.scope).to be nil
|
395
395
|
end
|
396
396
|
end
|
397
397
|
end
|
398
398
|
end
|
399
399
|
|
400
400
|
describe YARD::Tags::VisibilityDirective do
|
401
|
-
describe
|
401
|
+
describe "#call" do
|
402
402
|
after { Registry.clear }
|
403
403
|
|
404
|
-
it "
|
404
|
+
it "sets visibility on tag parser if object = nil" do
|
405
405
|
tag_parse("@!visibility private")
|
406
|
-
@parser.state.visibility.
|
406
|
+
expect(@parser.state.visibility).to eq :private
|
407
407
|
end
|
408
408
|
|
409
|
-
it "
|
409
|
+
it "sets state on tag parser if object is namespace" do
|
410
410
|
object = CodeObjects::ClassObject.new(:root, 'Foo')
|
411
411
|
tag_parse("@!visibility protected", object)
|
412
|
-
object.visibility.
|
413
|
-
@parser.state.visibility.
|
412
|
+
expect(object.visibility).to eq :protected
|
413
|
+
expect(@parser.state.visibility).to be nil
|
414
414
|
end
|
415
415
|
|
416
|
-
it "
|
416
|
+
it "sets visibility on object if object is a method object" do
|
417
417
|
object = CodeObjects::MethodObject.new(:root, 'foo')
|
418
418
|
tag_parse("@!visibility private", object)
|
419
|
-
object.visibility.
|
419
|
+
expect(object.visibility).to eq :private
|
420
420
|
end
|
421
421
|
|
422
422
|
%w(public private protected).each do |type|
|
423
|
-
it "
|
423
|
+
it "allows #{type} as value" do
|
424
424
|
tag_parse("@!visibility #{type}")
|
425
|
-
@parser.state.visibility.
|
425
|
+
expect(@parser.state.visibility).to eq type.to_sym
|
426
426
|
end
|
427
427
|
end
|
428
428
|
|
429
429
|
%w(invalid foo FOO PRIVATE INSTANCE).each do |type|
|
430
|
-
it "
|
430
|
+
it "does not allow #{type} as value" do
|
431
431
|
tag_parse("@!visibility #{type}")
|
432
|
-
@parser.state.visibility.
|
432
|
+
expect(@parser.state.visibility).to be nil
|
433
433
|
end
|
434
434
|
end
|
435
435
|
|
@@ -446,7 +446,7 @@ describe YARD::Tags::VisibilityDirective do
|
|
446
446
|
end
|
447
447
|
eof
|
448
448
|
%w(foo bar baz).each do |name|
|
449
|
-
Registry.at("Foo##{name}").visibility.
|
449
|
+
expect(Registry.at("Foo##{name}").visibility).to eq :private
|
450
450
|
end
|
451
451
|
end if YARD::Parser::SourceParser.parser_type == :ruby
|
452
452
|
end
|