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
@@ -3,77 +3,77 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}AliasHandler" do
|
4
4
|
before(:all) { parse_file :alias_handler_001, __FILE__ }
|
5
5
|
|
6
|
-
it "
|
7
|
-
P(:A).aliases[P("A#b")].
|
6
|
+
it "throws alias into namespace object list" do
|
7
|
+
expect(P(:A).aliases[P("A#b")]).to eq :a
|
8
8
|
end
|
9
9
|
|
10
10
|
['c', 'd?', '[]', '[]=', '-@', '%', '*', 'cstrkey', 'cstrmeth'].each do |a|
|
11
|
-
it "
|
12
|
-
P('A#' + a).
|
13
|
-
P('A#' + a).is_alias
|
11
|
+
it "handles the Ruby 'alias' keyword syntax for method ##{a}" do
|
12
|
+
expect(P('A#' + a)).to be_instance_of(CodeObjects::MethodObject)
|
13
|
+
expect(P('A#' + a).is_alias?).to be true
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
18
|
-
P('A#for').
|
17
|
+
it "handles keywords as the alias name" do
|
18
|
+
expect(P('A#for')).to be_instance_of(CodeObjects::MethodObject)
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
22
|
-
P('A#ConstantName').
|
21
|
+
it "allows ConstantNames to be specified as aliases" do
|
22
|
+
expect(P('A#ConstantName')).to be_instance_of(CodeObjects::MethodObject)
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
P("A#b").
|
25
|
+
it "creates a new method object for the alias" do
|
26
|
+
expect(P("A#b")).to be_instance_of(CodeObjects::MethodObject)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
30
|
-
P(:B).aliases[P("B#q")].
|
31
|
-
P(:B).aliases[P("B#r?")].
|
29
|
+
it "pulls the method into the current class if it's from another one" do
|
30
|
+
expect(P(:B).aliases[P("B#q")]).to eq :x
|
31
|
+
expect(P(:B).aliases[P("B#r?")]).to eq :x
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
35
|
-
P(:B).aliases[P("B#s")].
|
34
|
+
it "gracefully fails to pull a method in if the original method cannot be found" do
|
35
|
+
expect(P(:B).aliases[P("B#s")]).to eq :to_s
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
39
|
-
P(:B).aliases[P("B#t")].
|
38
|
+
it "allows complex Ruby expressions after the alias parameters" do
|
39
|
+
expect(P(:B).aliases[P("B#t")]).to eq :inspect
|
40
40
|
end
|
41
41
|
|
42
|
-
it "
|
43
|
-
P("B#t").is_alias
|
44
|
-
P('B#r?').is_alias
|
42
|
+
it "shows up in #is_alias? for method" do
|
43
|
+
expect(P("B#t").is_alias?).to be true
|
44
|
+
expect(P('B#r?').is_alias?).to be true
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
48
|
-
P('B#<<').
|
49
|
-
P('B#for').
|
47
|
+
it "allows operators and keywords to be specified as symbols" do
|
48
|
+
expect(P('B#<<')).to be_instance_of(CodeObjects::MethodObject)
|
49
|
+
expect(P('B#for')).to be_instance_of(CodeObjects::MethodObject)
|
50
50
|
end
|
51
51
|
|
52
|
-
it "
|
53
|
-
P('B#do').is_alias
|
54
|
-
P('B#x2').is_alias
|
55
|
-
P(:B).aliases[P('B#do')].
|
56
|
-
P(:B).aliases[P('B#x2')].
|
52
|
+
it "handles keywords in alias names" do
|
53
|
+
expect(P('B#do').is_alias?).to be true
|
54
|
+
expect(P('B#x2').is_alias?).to be true
|
55
|
+
expect(P(:B).aliases[P('B#do')]).to eq :x
|
56
|
+
expect(P(:B).aliases[P('B#x2')]).to eq :do
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
59
|
+
it "handles quoted symbols" do
|
60
60
|
foo = Registry.at('A#foo')
|
61
|
-
foo.
|
62
|
-
foo.
|
63
|
-
Registry.at('A').aliases[foo].
|
61
|
+
expect(foo).not_to be nil
|
62
|
+
expect(foo.is_alias?).to be true
|
63
|
+
expect(Registry.at('A').aliases[foo]).to eq :a
|
64
64
|
end
|
65
65
|
|
66
|
-
it "
|
67
|
-
Registry.at('D#a').tag(:return).types.
|
68
|
-
Registry.at('D#b').tag(:return).types.
|
69
|
-
Registry.at('D#b').docstring.
|
66
|
+
it "prepends aliases object's docstring to comments" do
|
67
|
+
expect(Registry.at('D#a').tag(:return).types).to eq ['Numeric']
|
68
|
+
expect(Registry.at('D#b').tag(:return).types).to eq ['String']
|
69
|
+
expect(Registry.at('D#b').docstring).to eq "Foo bar"
|
70
70
|
end
|
71
71
|
|
72
|
-
it "
|
72
|
+
it "raises an UndocumentableError if only one parameter is passed" do
|
73
73
|
undoc_error "alias_method :q"
|
74
74
|
end
|
75
75
|
|
76
|
-
it "
|
76
|
+
it "raises an UndocumentableError if the parameter is not a Symbol or String" do
|
77
77
|
undoc_error "alias_method CONST, Something"
|
78
78
|
undoc_error "alias_method variable, ClassName"
|
79
79
|
undoc_error "alias_method variable, other_variable"
|
@@ -6,89 +6,89 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}AttributeHandl
|
|
6
6
|
def read_write(namespace, name, read, write, scope = :instance)
|
7
7
|
rname, wname = namespace.to_s+"#"+name.to_s, namespace.to_s+"#"+name.to_s+"="
|
8
8
|
if read
|
9
|
-
Registry.at(rname).
|
9
|
+
expect(Registry.at(rname)).to be_instance_of(CodeObjects::MethodObject)
|
10
10
|
else
|
11
|
-
Registry.at(rname).
|
11
|
+
expect(Registry.at(rname)).to eq nil
|
12
12
|
end
|
13
13
|
|
14
14
|
if write
|
15
|
-
Registry.at(wname).
|
15
|
+
expect(Registry.at(wname)).to be_kind_of(CodeObjects::MethodObject)
|
16
16
|
else
|
17
|
-
Registry.at(wname).
|
17
|
+
expect(Registry.at(wname)).to eq nil
|
18
18
|
end
|
19
19
|
|
20
20
|
attrs = Registry.at(namespace).attributes[scope][name]
|
21
|
-
attrs[:read].
|
22
|
-
attrs[:write].
|
21
|
+
expect(attrs[:read]).to eq (read ? Registry.at(rname) : nil)
|
22
|
+
expect(attrs[:write]).to eq (write ? Registry.at(wname) : nil)
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
Registry.at("A#x=").
|
25
|
+
it "parses attributes inside modules too" do
|
26
|
+
expect(Registry.at("A#x=")).not_to eq nil
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "parses 'attr'" do
|
30
30
|
read_write(:B, :a, true, true)
|
31
31
|
read_write(:B, :a2, true, false)
|
32
32
|
read_write(:B, "a3", true, false)
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
35
|
+
it "parses 'attr_reader'" do
|
36
36
|
read_write(:B, :b, true, false)
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
39
|
+
it "parses 'attr_writer'" do
|
40
40
|
read_write(:B, :e, false, true)
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
43
|
+
it "parses 'attr_accessor'" do
|
44
44
|
read_write(:B, :f, true, true)
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
47
|
+
it "parses a list of attributes" do
|
48
48
|
read_write(:B, :b, true, false)
|
49
49
|
read_write(:B, :c, true, false)
|
50
50
|
read_write(:B, :d, true, false)
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
54
|
-
Registry.at("B#f=").docstring.
|
53
|
+
it "has a default docstring if one is not supplied" do
|
54
|
+
expect(Registry.at("B#f=").docstring).not_to be_empty
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
58
|
-
Registry.at("B#b").docstring.
|
59
|
-
Registry.at("B#c").docstring.
|
60
|
-
Registry.at("B#d").docstring.
|
57
|
+
it "sets the correct docstring if one is supplied" do
|
58
|
+
expect(Registry.at("B#b").docstring).to eq "Docstring"
|
59
|
+
expect(Registry.at("B#c").docstring).to eq "Docstring"
|
60
|
+
expect(Registry.at("B#d").docstring).to eq "Docstring"
|
61
61
|
end
|
62
62
|
|
63
|
-
it "
|
64
|
-
P('B').class_attributes[:z][:read].scope.
|
65
|
-
P('B').instance_attributes[:z][:read].scope.
|
63
|
+
it "is able to differentiate between class and instance attributes" do
|
64
|
+
expect(P('B').class_attributes[:z][:read].scope).to eq :class
|
65
|
+
expect(P('B').instance_attributes[:z][:read].scope).to eq :instance
|
66
66
|
end
|
67
67
|
|
68
|
-
it "
|
69
|
-
P('B#a').is_attribute
|
70
|
-
P('B#a=').is_attribute
|
68
|
+
it "responds true in method's #is_attribute?" do
|
69
|
+
expect(P('B#a').is_attribute?).to be true
|
70
|
+
expect(P('B#a=').is_attribute?).to be true
|
71
71
|
end
|
72
72
|
|
73
|
-
it "
|
73
|
+
it "does not return true for #is_explicit? in created methods" do
|
74
74
|
Registry.at(:B).meths.each do |meth|
|
75
|
-
meth.is_explicit
|
75
|
+
expect(meth.is_explicit?).to be false
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
it "
|
80
|
-
|
79
|
+
it "handles attr call with no arguments" do
|
80
|
+
expect { StubbedSourceParser.parse_string "attr" }.not_to raise_error
|
81
81
|
end
|
82
82
|
|
83
|
-
it "
|
84
|
-
Registry.at('C#foo=').attr_info[:read].
|
83
|
+
it "adds existing reader method as part of attr_writer combo" do
|
84
|
+
expect(Registry.at('C#foo=').attr_info[:read]).to eq Registry.at('C#foo')
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
88
|
-
Registry.at('C#foo').attr_info[:write].
|
87
|
+
it "adds existing writer method as part of attr_reader combo" do
|
88
|
+
expect(Registry.at('C#foo').attr_info[:write]).to eq Registry.at('C#foo=')
|
89
89
|
end
|
90
90
|
|
91
|
-
it "
|
92
|
-
Registry.at('D#parser').visibility.
|
91
|
+
it "maintains visibility for attr_reader" do
|
92
|
+
expect(Registry.at('D#parser').visibility).to eq :protected
|
93
93
|
end
|
94
94
|
end
|
data/spec/handlers/base_spec.rb
CHANGED
@@ -6,51 +6,51 @@ include Parser
|
|
6
6
|
describe YARD::Handlers::Base do
|
7
7
|
describe "#handles and inheritance" do
|
8
8
|
before do
|
9
|
-
Handlers::Base.
|
9
|
+
allow(Handlers::Base).to receive(:inherited)
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
13
|
-
Handlers::Base.
|
12
|
+
it "keeps track of subclasses" do
|
13
|
+
expect(Handlers::Base).to receive(:inherited).once
|
14
14
|
class TestHandler < Handlers::Base; end
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
17
|
+
it "raises NotImplementedError if process is called on a class with no #process" do
|
18
18
|
class TestNotImplementedHandler < Handlers::Base
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
expect { TestNotImplementedHandler.new(0, 0).process }.to raise_error(NotImplementedError)
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
25
|
-
Handlers::Base.
|
24
|
+
it "allows multiple handles arguments" do
|
25
|
+
expect(Handlers::Base).to receive(:inherited).once
|
26
26
|
class TestHandler1 < Handlers::Base
|
27
27
|
handles :a, :b, :c
|
28
28
|
end
|
29
|
-
TestHandler1.handlers.
|
29
|
+
expect(TestHandler1.handlers).to eq [:a, :b, :c]
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
33
|
-
Handlers::Base.
|
32
|
+
it "allows multiple handles calls" do
|
33
|
+
expect(Handlers::Base).to receive(:inherited).once
|
34
34
|
class TestHandler2 < Handlers::Base
|
35
35
|
handles :a
|
36
36
|
handles :b
|
37
37
|
handles :c
|
38
38
|
end
|
39
|
-
TestHandler2.handlers.
|
39
|
+
expect(TestHandler2.handlers).to eq [:a, :b, :c]
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
describe
|
44
|
-
it
|
43
|
+
describe "#abort! (and HandlerAborted)" do
|
44
|
+
it "allows HandlerAborted to be raised" do
|
45
45
|
class AbortHandler1 < Handlers::Ruby::Base
|
46
46
|
process { abort! }
|
47
47
|
end
|
48
|
-
|
48
|
+
expect { AbortHandler1.new(nil, nil).process }.to raise_error(HandlerAborted)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe
|
53
|
-
it "
|
52
|
+
describe "transitive tags" do
|
53
|
+
it "adds transitive tags to children" do
|
54
54
|
Registry.clear
|
55
55
|
YARD.parse_string <<-eof
|
56
56
|
# @since 1.0
|
@@ -61,15 +61,15 @@ describe YARD::Handlers::Base do
|
|
61
61
|
def bar; end
|
62
62
|
end
|
63
63
|
eof
|
64
|
-
Registry.at('A').tag(:since).text.
|
65
|
-
Registry.at('A#foo').tag(:since).text.
|
66
|
-
Registry.at('A#bar').tag(:since).text.
|
67
|
-
Registry.at('A#bar').tag(:author).
|
64
|
+
expect(Registry.at('A').tag(:since).text).to eq "1.0"
|
65
|
+
expect(Registry.at('A#foo').tag(:since).text).to eq "1.0"
|
66
|
+
expect(Registry.at('A#bar').tag(:since).text).to eq "1.1"
|
67
|
+
expect(Registry.at('A#bar').tag(:author)).to be nil
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
describe
|
72
|
-
it "
|
71
|
+
describe "sharing global state" do
|
72
|
+
it "allows globals to share global state among handlers" do
|
73
73
|
class GlobalStateHandler1 < Handlers::Ruby::Base
|
74
74
|
class << self; attr_accessor :state end
|
75
75
|
handles :class
|
@@ -84,64 +84,73 @@ describe YARD::Handlers::Base do
|
|
84
84
|
|
85
85
|
2.times do
|
86
86
|
YARD.parse_string 'class Foo; end; def foo; end'
|
87
|
-
GlobalStateHandler1.state.
|
88
|
-
GlobalStateHandler2.state.
|
87
|
+
expect(GlobalStateHandler1.state).to eq nil
|
88
|
+
expect(GlobalStateHandler2.state).to eq :bar
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end if HAVE_RIPPER
|
92
92
|
|
93
|
-
describe
|
93
|
+
describe "#push_state" do
|
94
94
|
def process(klass)
|
95
95
|
state = OpenStruct.new(:namespace => "ROOT", :scope => :instance, :owner => "ROOT")
|
96
96
|
klass.new(state, nil).process
|
97
97
|
end
|
98
98
|
|
99
|
-
it "
|
99
|
+
it "pushes and return all old state info after block" do
|
100
100
|
class PushStateHandler1 < Handlers::Base
|
101
|
+
include RSpec::Matchers
|
102
|
+
RSpec::Expectations::Syntax.enable_expect(self)
|
103
|
+
|
101
104
|
def process
|
102
105
|
push_state(:namespace => "FOO", :scope => :class, :owner => "BAR") do
|
103
|
-
namespace.
|
104
|
-
scope.
|
105
|
-
owner.
|
106
|
+
expect(namespace).to eq "FOO"
|
107
|
+
expect(scope).to eq :class
|
108
|
+
expect(owner).to eq "BAR"
|
106
109
|
end
|
107
|
-
namespace.
|
108
|
-
owner.
|
109
|
-
scope.
|
110
|
+
expect(namespace).to eq "ROOT"
|
111
|
+
expect(owner).to eq "ROOT"
|
112
|
+
expect(scope).to eq :instance
|
110
113
|
end
|
111
114
|
end
|
112
115
|
process PushStateHandler1
|
113
116
|
end
|
114
117
|
|
115
|
-
it "
|
118
|
+
it "allows owner to be pushed individually" do
|
116
119
|
class PushStateHandler2 < Handlers::Base
|
120
|
+
include RSpec::Matchers
|
121
|
+
RSpec::Expectations::Syntax.enable_expect(self)
|
122
|
+
|
117
123
|
def process
|
118
124
|
push_state(:owner => "BAR") do
|
119
|
-
namespace.
|
120
|
-
scope.
|
121
|
-
owner.
|
125
|
+
expect(namespace).to eq "ROOT"
|
126
|
+
expect(scope).to eq :instance
|
127
|
+
expect(owner).to eq "BAR"
|
122
128
|
end
|
123
|
-
owner.
|
129
|
+
expect(owner).to eq "ROOT"
|
124
130
|
end
|
125
131
|
end
|
126
132
|
process PushStateHandler2
|
127
133
|
end
|
128
134
|
|
129
|
-
it "
|
135
|
+
it "allows scope to be pushed individually" do
|
130
136
|
class PushStateHandler3 < Handlers::Base
|
137
|
+
include RSpec::Matchers
|
138
|
+
RSpec::Expectations::Syntax.enable_expect(self)
|
139
|
+
|
131
140
|
def process
|
132
141
|
push_state(:scope => :foo) do
|
133
|
-
namespace.
|
134
|
-
scope.
|
135
|
-
owner.
|
142
|
+
expect(namespace).to eq "ROOT"
|
143
|
+
expect(scope).to eq :foo
|
144
|
+
expect(owner).to eq "ROOT"
|
136
145
|
end
|
137
|
-
scope.
|
146
|
+
expect(scope).to eq :instance
|
138
147
|
end
|
139
148
|
end
|
140
149
|
process PushStateHandler3
|
141
150
|
end
|
142
151
|
end
|
143
152
|
|
144
|
-
describe
|
153
|
+
describe ".in_file" do
|
145
154
|
def parse(filename, parser_type, src = "class A; end")
|
146
155
|
parser = Parser::SourceParser.new(parser_type)
|
147
156
|
parser.instance_variable_set("@file", filename)
|
@@ -162,39 +171,39 @@ describe YARD::Handlers::Base do
|
|
162
171
|
|
163
172
|
def test_handler(file, stmts, creates = true, parser_type = :ruby)
|
164
173
|
Registry.clear
|
165
|
-
Registry.at('#FOO').
|
174
|
+
expect(Registry.at('#FOO')).to be nil
|
166
175
|
create_handler(stmts, parser_type)
|
167
176
|
parse(file, parser_type)
|
168
|
-
Registry.at('#FOO').send(creates ? :
|
177
|
+
expect(Registry.at('#FOO')).send(creates ? :not_to : :to, be_nil)
|
169
178
|
Handlers::Base.subclasses.delete_if {|k,v| k.to_s =~ /^InFileHandler/ }
|
170
179
|
end
|
171
180
|
|
172
181
|
[:ruby, :ruby18].each do |parser_type|
|
173
182
|
next if parser_type == :ruby && LEGACY_PARSER
|
174
183
|
describe "Parser type = #{parser_type.inspect}" do
|
175
|
-
it "
|
184
|
+
it "allows handler to be specific to a file" do
|
176
185
|
test_handler 'file_a.rb', 'in_file "file_a.rb"', true, parser_type
|
177
186
|
end
|
178
187
|
|
179
|
-
it "
|
188
|
+
it "ignores handler if filename does not match" do
|
180
189
|
test_handler 'file_b.rb', 'in_file "file_a.rb"', false, parser_type
|
181
190
|
end
|
182
191
|
|
183
|
-
it "
|
192
|
+
it "only tests filename part when given a String" do
|
184
193
|
test_handler '/path/to/file_a.rb', 'in_file "/to/file_a.rb"', false, parser_type
|
185
194
|
end
|
186
195
|
|
187
|
-
it "
|
196
|
+
it "tests exact match for entire String" do
|
188
197
|
test_handler 'file_a.rb', 'in_file "file"', false, parser_type
|
189
198
|
end
|
190
199
|
|
191
|
-
it "
|
200
|
+
it "allows a Regexp as argument and test against full path" do
|
192
201
|
test_handler 'file_a.rbx', 'in_file /\.rbx$/', true, parser_type
|
193
202
|
test_handler '/path/to/file_a.rbx', 'in_file /\/to\/file_/', true, parser_type
|
194
203
|
test_handler '/path/to/file_a.rbx', 'in_file /^\/path/', true, parser_type
|
195
204
|
end
|
196
205
|
|
197
|
-
it "
|
206
|
+
it "allows multiple in_file declarations" do
|
198
207
|
stmts = 'in_file "x"; in_file /y/; in_file "foo.rb"'
|
199
208
|
test_handler 'foo.rb', stmts, true, parser_type
|
200
209
|
test_handler 'xyzzy.rb', stmts, true, parser_type
|