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
@@ -4,189 +4,188 @@ require 'ostruct'
|
|
4
4
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}DSLHandler" do
|
5
5
|
before(:all) { parse_file :dsl_handler_001, __FILE__ }
|
6
6
|
|
7
|
-
it "
|
7
|
+
it "creates a readable attribute when @!attribute r is found" do
|
8
8
|
obj = Registry.at('Foo#attr1')
|
9
|
-
obj.
|
10
|
-
obj.
|
11
|
-
obj.tag(:return).types.
|
12
|
-
Registry.at('Foo#attr1=').
|
9
|
+
expect(obj).not_to be nil
|
10
|
+
expect(obj).to be_reader
|
11
|
+
expect(obj.tag(:return).types).to eq ['Numeric']
|
12
|
+
expect(Registry.at('Foo#attr1=')).to be nil
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "creates a writable attribute when @!attribute w is found" do
|
16
16
|
obj = Registry.at('Foo#attr2=')
|
17
|
-
obj.
|
18
|
-
obj.
|
19
|
-
Registry.at('Foo#attr2').
|
17
|
+
expect(obj).not_to be nil
|
18
|
+
expect(obj).to be_writer
|
19
|
+
expect(Registry.at('Foo#attr2')).to be nil
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
22
|
+
it "defaults to readwrite @!attribute" do
|
23
23
|
obj = Registry.at('Foo#attr3')
|
24
|
-
obj.
|
25
|
-
obj.
|
24
|
+
expect(obj).not_to be nil
|
25
|
+
expect(obj).to be_reader
|
26
26
|
obj = Registry.at('Foo#attr3=')
|
27
|
-
obj.
|
28
|
-
obj.
|
27
|
+
expect(obj).not_to be nil
|
28
|
+
expect(obj).to be_writer
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
32
|
-
Registry.at('Foo#attr4').
|
33
|
-
Registry.at('Foo#custom').
|
31
|
+
it "allows @!attribute to define alternate method name" do
|
32
|
+
expect(Registry.at('Foo#attr4')).to be nil
|
33
|
+
expect(Registry.at('Foo#custom')).not_to be nil
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
36
|
+
it "defaults to creating an instance method for any DSL method with special tags" do
|
37
37
|
obj = Registry.at('Foo#implicit0')
|
38
|
-
obj.
|
39
|
-
obj.docstring.
|
40
|
-
obj.tag(:return).types.
|
38
|
+
expect(obj).not_to be nil
|
39
|
+
expect(obj.docstring).to eq "IMPLICIT METHOD!"
|
40
|
+
expect(obj.tag(:return).types).to eq ['String']
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
43
|
+
it "recognizes implicit docstring when it has scope tag" do
|
44
44
|
obj = Registry.at("Foo.implicit1")
|
45
|
-
obj.
|
46
|
-
obj.scope.
|
45
|
+
expect(obj).not_to be nil
|
46
|
+
expect(obj.scope).to eq :class
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
49
|
+
it "recognizes implicit docstring when it has visibility tag" do
|
50
50
|
obj = Registry.at("Foo#implicit2")
|
51
|
-
obj.
|
52
|
-
obj.visibility.
|
51
|
+
expect(obj).not_to be nil
|
52
|
+
expect(obj.visibility).to eq :protected
|
53
53
|
end
|
54
54
|
|
55
|
-
it "
|
55
|
+
it "does not recognize implicit docstring with any other normal tag" do
|
56
56
|
obj = Registry.at('Foo#implicit_invalid3')
|
57
|
-
obj.
|
57
|
+
expect(obj).to be nil
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
60
|
+
it "sets the method name when using @!method" do
|
61
61
|
obj = Registry.at('Foo.xyz')
|
62
|
-
obj.
|
63
|
-
obj.signature.
|
64
|
-
obj.parameters.
|
65
|
-
obj.source.
|
66
|
-
obj.docstring.
|
62
|
+
expect(obj).not_to be nil
|
63
|
+
expect(obj.signature).to eq 'def xyz(a, b, c)'
|
64
|
+
expect(obj.parameters).to eq [['a', nil], ['b', nil], ['c', nil]]
|
65
|
+
expect(obj.source).to eq 'foo_bar'
|
66
|
+
expect(obj.docstring).to eq 'The foo method'
|
67
67
|
end
|
68
68
|
|
69
|
-
it "
|
70
|
-
Registry.at('Foo.xyz').scope.
|
69
|
+
it "allows setting of @!scope" do
|
70
|
+
expect(Registry.at('Foo.xyz').scope).to eq :class
|
71
71
|
end
|
72
72
|
|
73
|
-
it "
|
73
|
+
it "creates module function if @!scope is module" do
|
74
74
|
mod_c = Registry.at('Foo.modfunc1')
|
75
75
|
mod_i = Registry.at('Foo#modfunc1')
|
76
|
-
mod_c.scope.
|
77
|
-
mod_i.visibility.
|
76
|
+
expect(mod_c.scope).to eq :class
|
77
|
+
expect(mod_i.visibility).to eq :private
|
78
78
|
end
|
79
79
|
|
80
|
-
it "
|
81
|
-
Registry.at('Foo.xyz').visibility.
|
80
|
+
it "allows setting of @!visibility" do
|
81
|
+
expect(Registry.at('Foo.xyz').visibility).to eq :protected
|
82
82
|
end
|
83
83
|
|
84
|
-
it "
|
85
|
-
Registry.at('Foo#implicit_invalid').
|
84
|
+
it "ignores DSL methods without tags" do
|
85
|
+
expect(Registry.at('Foo#implicit_invalid')).to be nil
|
86
86
|
end
|
87
87
|
|
88
|
-
it "
|
89
|
-
Registry.at('Foo#implicit_valid').
|
90
|
-
Registry.at('Foo#implicit_invalid2').
|
88
|
+
it "accepts a DSL method without tags if it has hash_flag (##)" do
|
89
|
+
expect(Registry.at('Foo#implicit_valid')).not_to be nil
|
90
|
+
expect(Registry.at('Foo#implicit_invalid2')).to be nil
|
91
91
|
end
|
92
92
|
|
93
|
-
it "
|
93
|
+
it "allows creation of macros" do
|
94
94
|
macro = CodeObjects::MacroObject.find('property')
|
95
|
-
macro.
|
96
|
-
macro.
|
97
|
-
macro.method_object.
|
95
|
+
expect(macro).not_to be nil
|
96
|
+
expect(macro).not_to be_attached
|
97
|
+
expect(macro.method_object).to be nil
|
98
98
|
end
|
99
99
|
|
100
|
-
it "
|
101
|
-
Registry.at('Foo#none').
|
102
|
-
Registry.at('Baz#none').signature.
|
100
|
+
it "handles macros with no parameters to expand" do
|
101
|
+
expect(Registry.at('Foo#none')).not_to be nil
|
102
|
+
expect(Registry.at('Baz#none').signature).to eq 'def none(foo, bar)'
|
103
103
|
end
|
104
104
|
|
105
|
-
it "
|
106
|
-
Registry.at('Foo#regular_meth').docstring.
|
105
|
+
it "expands $N on method definitions" do
|
106
|
+
expect(Registry.at('Foo#regular_meth').docstring).to eq 'a b c'
|
107
107
|
end
|
108
108
|
|
109
|
-
it "
|
109
|
+
it "applies new macro docstrings on new objects" do
|
110
110
|
obj = Registry.at('Foo#name')
|
111
|
-
obj.
|
112
|
-
obj.source.
|
113
|
-
obj.signature.
|
114
|
-
obj.docstring.
|
115
|
-
obj.tag(:param).name.
|
116
|
-
obj.tag(:param).text.
|
117
|
-
obj.tag(:return).types.
|
118
|
-
obj.tag(:return).text.
|
111
|
+
expect(obj).not_to be nil
|
112
|
+
expect(obj.source).to eq 'property :name, String, :a, :b, :c'
|
113
|
+
expect(obj.signature).to eq 'def name(a, b, c)'
|
114
|
+
expect(obj.docstring).to eq 'A property that is awesome.'
|
115
|
+
expect(obj.tag(:param).name).to eq 'a'
|
116
|
+
expect(obj.tag(:param).text).to eq 'first parameter'
|
117
|
+
expect(obj.tag(:return).types).to eq ['String']
|
118
|
+
expect(obj.tag(:return).text).to eq 'the property name'
|
119
119
|
end
|
120
120
|
|
121
|
-
it "
|
121
|
+
it "allows reuse of named macros" do
|
122
122
|
obj = Registry.at('Foo#age')
|
123
|
-
obj.
|
124
|
-
obj.source.
|
125
|
-
obj.signature.
|
126
|
-
obj.docstring.
|
127
|
-
obj.tag(:param).name.
|
128
|
-
obj.tag(:param).text.
|
129
|
-
obj.tag(:return).types.
|
130
|
-
obj.tag(:return).text.
|
123
|
+
expect(obj).not_to be nil
|
124
|
+
expect(obj.source).to eq 'property :age, Fixnum, :value'
|
125
|
+
expect(obj.signature).to eq 'def age(value)'
|
126
|
+
expect(obj.docstring).to eq 'A property that is awesome.'
|
127
|
+
expect(obj.tag(:param).name).to eq 'value'
|
128
|
+
expect(obj.tag(:param).text).to eq 'first parameter'
|
129
|
+
expect(obj.tag(:return).types).to eq ['Fixnum']
|
130
|
+
expect(obj.tag(:return).text).to eq 'the property age'
|
131
131
|
end
|
132
132
|
|
133
|
-
it "
|
134
|
-
Registry.at('Foo#right_name').
|
135
|
-
Registry.at('Foo#right_name').source.
|
136
|
-
|
137
|
-
Registry.at('Foo#wrong_name').should be_nil
|
133
|
+
it "knows about method information on DSL with macro expansion" do
|
134
|
+
expect(Registry.at('Foo#right_name')).not_to be nil
|
135
|
+
expect(Registry.at('Foo#right_name').source).to eq 'implicit_with_different_method_name :wrong, :right'
|
136
|
+
expect(Registry.at('Foo#wrong_name')).to be nil
|
138
137
|
end
|
139
138
|
|
140
|
-
it "
|
139
|
+
it "uses attached macros" do
|
141
140
|
macro = CodeObjects::MacroObject.find('parser')
|
142
|
-
macro.macro_data.
|
143
|
-
macro.
|
144
|
-
macro.
|
145
|
-
macro.method_object.
|
141
|
+
expect(macro.macro_data).to eq "@!method $1(opts = {})\n@return NOTHING!"
|
142
|
+
expect(macro).not_to be nil
|
143
|
+
expect(macro).to be_attached
|
144
|
+
expect(macro.method_object).to eq P('Foo.parser')
|
146
145
|
obj = Registry.at('Foo#c_parser')
|
147
|
-
obj.
|
148
|
-
obj.docstring.
|
149
|
-
obj.signature.
|
150
|
-
obj.docstring.tag(:return).text.
|
146
|
+
expect(obj).not_to be nil
|
147
|
+
expect(obj.docstring).to eq ""
|
148
|
+
expect(obj.signature).to eq "def c_parser(opts = {})"
|
149
|
+
expect(obj.docstring.tag(:return).text).to eq "NOTHING!"
|
151
150
|
end
|
152
151
|
|
153
|
-
it "
|
152
|
+
it "appends docstring on DSL method to attached macro" do
|
154
153
|
obj = Registry.at('Foo#d_parser')
|
155
|
-
obj.
|
156
|
-
obj.docstring.
|
157
|
-
obj.signature.
|
158
|
-
obj.docstring.tag(:return).text.
|
154
|
+
expect(obj).not_to be nil
|
155
|
+
expect(obj.docstring).to eq "Another docstring"
|
156
|
+
expect(obj.signature).to eq "def d_parser(opts = {})"
|
157
|
+
expect(obj.docstring.tag(:return).text).to eq "NOTHING!"
|
159
158
|
end
|
160
159
|
|
161
|
-
it "
|
162
|
-
Registry.at('Bar#x_parser').
|
163
|
-
Registry.at('Baz#y_parser').
|
160
|
+
it "only uses attached macros on methods defined in inherited hierarchy" do
|
161
|
+
expect(Registry.at('Bar#x_parser')).to be nil
|
162
|
+
expect(Registry.at('Baz#y_parser')).not_to be nil
|
164
163
|
end
|
165
164
|
|
166
|
-
it "
|
165
|
+
it "looks through mixins for attached macros" do
|
167
166
|
meth = Registry.at('Baz#mixin_method')
|
168
|
-
meth.
|
169
|
-
meth.docstring.
|
167
|
+
expect(meth).not_to be nil
|
168
|
+
expect(meth.docstring).to eq 'DSL method mixin_method'
|
170
169
|
end
|
171
170
|
|
172
|
-
it "
|
171
|
+
it "handles top-level DSL methods" do
|
173
172
|
obj = Registry.at('#my_other_method')
|
174
|
-
obj.
|
175
|
-
obj.docstring.
|
173
|
+
expect(obj).not_to be nil
|
174
|
+
expect(obj.docstring).to eq "Docstring for method"
|
176
175
|
end
|
177
176
|
|
178
|
-
it "
|
177
|
+
it "handles Constant.foo syntax" do
|
179
178
|
obj = Registry.at('#beep')
|
180
|
-
obj.
|
181
|
-
obj.signature.
|
179
|
+
expect(obj).not_to be nil
|
180
|
+
expect(obj.signature).to eq 'def beep(a, b, c)'
|
182
181
|
end
|
183
182
|
|
184
|
-
it "
|
185
|
-
Registry.at('DSLMethods#foo').docstring.
|
186
|
-
Registry.at('DSLMethods#bar').docstring.
|
183
|
+
it "expands attached macros in first DSL method" do
|
184
|
+
expect(Registry.at('DSLMethods#foo').docstring).to eq "Returns String for foo"
|
185
|
+
expect(Registry.at('DSLMethods#bar').docstring).to eq "Returns Integer for bar"
|
187
186
|
end
|
188
187
|
|
189
|
-
it "
|
188
|
+
it "does not detect implicit macros with invalid method names" do
|
190
189
|
undoc_error <<-eof
|
191
190
|
##
|
192
191
|
# IMPLICIT METHOD THAT SHOULD
|
@@ -22,4 +22,7 @@ MyEmptyStruct = Struct.new
|
|
22
22
|
#
|
23
23
|
# @attr [String] bar An attr
|
24
24
|
# @attr [Number] baz Another attr
|
25
|
-
|
25
|
+
# @!attribute new_syntax
|
26
|
+
# Attribute defined with the new syntax
|
27
|
+
# @return [Symbol] something usefull
|
28
|
+
DocstringStruct = Struct.new(:bar, :baz, :new_syntax)
|
@@ -3,46 +3,46 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ExceptionHandler" do
|
4
4
|
before(:all) { parse_file :exception_handler_001, __FILE__ }
|
5
5
|
|
6
|
-
it "
|
7
|
-
P('Testing').has_tag?(:raise).
|
6
|
+
it "does not document an exception outside of a method" do
|
7
|
+
expect(P('Testing').has_tag?(:raise)).to be false
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
11
|
-
P('Testing#mymethod').tag(:raise).types.
|
10
|
+
it "documents a valid raise" do
|
11
|
+
expect(P('Testing#mymethod').tag(:raise).types).to eq ['ArgumentError']
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
15
|
-
P('Testing#mymethod2').tag(:raise).
|
16
|
-
P('Testing#mymethod6').tag(:raise).
|
17
|
-
P('Testing#mymethod7').tag(:raise).
|
14
|
+
it "only documents non-dynamic raises" do
|
15
|
+
expect(P('Testing#mymethod2').tag(:raise)).to be nil
|
16
|
+
expect(P('Testing#mymethod6').tag(:raise)).to be nil
|
17
|
+
expect(P('Testing#mymethod7').tag(:raise)).to be nil
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
21
|
-
P('Testing#mymethod8').tag(:raise).types.
|
20
|
+
it "treats ConstantName.new as a valid exception class" do
|
21
|
+
expect(P('Testing#mymethod8').tag(:raise).types).to eq ['ExceptionClass']
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
25
|
-
P('Testing#mymethod3').tag(:raise).types.
|
24
|
+
it "does not document a method with an existing @raise tag" do
|
25
|
+
expect(P('Testing#mymethod3').tag(:raise).types).to eq ['A']
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
29
|
-
P('Testing#mymethod4').tag(:raise).types.
|
28
|
+
it "only documents the first raise message of a method (limitation of exception handler)" do
|
29
|
+
expect(P('Testing#mymethod4').tag(:raise).types).to eq ['A']
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
33
|
-
P('Testing#mymethod5').tag(:raise).types.
|
32
|
+
it "handles complex class names" do
|
33
|
+
expect(P('Testing#mymethod5').tag(:raise).types).to eq ['YARD::Parser::UndocumentableError']
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
37
|
-
P('Testing#mymethod9').tag(:raise).
|
36
|
+
it "ignores any raise calls on a receiver" do
|
37
|
+
expect(P('Testing#mymethod9').tag(:raise)).to be nil
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
41
|
-
P('Testing#mymethod10').tag(:raise).
|
42
|
-
P('Testing#mymethod11').tag(:raise).
|
40
|
+
it "handles raise expressions that are method calls" do
|
41
|
+
expect(P('Testing#mymethod10').tag(:raise)).to be nil
|
42
|
+
expect(P('Testing#mymethod11').tag(:raise)).to be nil
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
46
|
-
P('Testing#mymethod12').tag(:raise).
|
45
|
+
it "ignores empty raise call" do
|
46
|
+
expect(P('Testing#mymethod12').tag(:raise)).to be nil
|
47
47
|
end
|
48
48
|
end
|
@@ -3,21 +3,21 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ExtendHandler" do
|
4
4
|
before(:all) { parse_file :extend_handler_001, __FILE__ }
|
5
5
|
|
6
|
-
it "
|
7
|
-
Registry.at(:B).class_mixins.
|
8
|
-
Registry.at(:B).instance_mixins.
|
6
|
+
it "includes modules at class scope" do
|
7
|
+
expect(Registry.at(:B).class_mixins).to eq [P(:A)]
|
8
|
+
expect(Registry.at(:B).instance_mixins).to be_empty
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
12
|
-
Registry.at(:C).class_mixins.
|
13
|
-
Registry.at(:C).instance_mixins.
|
11
|
+
it "handles a module extending itself" do
|
12
|
+
expect(Registry.at(:C).class_mixins).to eq [P(:C)]
|
13
|
+
expect(Registry.at(:C).instance_mixins).to be_empty
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
Registry.at('Q::R::S').class_mixins.first.path.
|
16
|
+
it "extends module with correct namespace" do
|
17
|
+
expect(Registry.at('Q::R::S').class_mixins.first.path).to eq 'A'
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
20
|
+
it "does not allow extending self if object is a class" do
|
21
21
|
undoc_error "class Foo; extend self; end"
|
22
22
|
end
|
23
23
|
end
|
@@ -10,58 +10,58 @@ describe YARD::Handlers::Ruby::Legacy::Base, "#tokval" do
|
|
10
10
|
@handler.send(:tokval, TokenList.new(code).first, *types)
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
14
|
-
tokval('"hello"').
|
13
|
+
it "returns the String's value without quotes" do
|
14
|
+
expect(tokval('"hello"')).to eq "hello"
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
18
|
-
tokval('"#{c}"', RubyToken::TkSTRING).
|
17
|
+
it "does not allow interpolated strings with TkSTRING" do
|
18
|
+
expect(tokval('"#{c}"', RubyToken::TkSTRING)).to be nil
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
22
|
-
tokval(':sym').
|
21
|
+
it "returns a Symbol's value as a String (as if it was done via :name.to_sym)" do
|
22
|
+
expect(tokval(':sym')).to eq :sym
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
tokval('identifier').
|
27
|
-
tokval(':sym', RubyToken::TkId).
|
25
|
+
it "returns nil for any non accepted type" do
|
26
|
+
expect(tokval('identifier')).to be nil
|
27
|
+
expect(tokval(':sym', RubyToken::TkId)).to be nil
|
28
28
|
end
|
29
29
|
|
30
|
-
it "
|
31
|
-
tokval('2.5').
|
32
|
-
tokval(':sym').
|
30
|
+
it "accepts TkVal tokens by default" do
|
31
|
+
expect(tokval('2.5')).to eq 2.5
|
32
|
+
expect(tokval(':sym')).to eq :sym
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
36
|
-
tokval('variable', RubyToken::TkId).
|
37
|
-
tokval('CONSTANT', RubyToken::TkId).
|
35
|
+
it "accepts any ID type if TkId is set" do
|
36
|
+
expect(tokval('variable', RubyToken::TkId)).to eq "variable"
|
37
|
+
expect(tokval('CONSTANT', RubyToken::TkId)).to eq "CONSTANT"
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
41
|
-
tokval('2.5', RubyToken::TkFLOAT).
|
42
|
-
tokval('2', RubyToken::TkFLOAT).
|
43
|
-
tokval(':symbol', RubyToken::TkFLOAT).
|
40
|
+
it "allows extra token types to be accepted" do
|
41
|
+
expect(tokval('2.5', RubyToken::TkFLOAT)).to eq 2.5
|
42
|
+
expect(tokval('2', RubyToken::TkFLOAT)).to be nil
|
43
|
+
expect(tokval(':symbol', RubyToken::TkFLOAT)).to be nil
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
47
|
-
tokval('"hello"', :string).
|
48
|
-
tokval('"#{c}"', :string).
|
46
|
+
it "allows :string for any string type" do
|
47
|
+
expect(tokval('"hello"', :string)).to eq "hello"
|
48
|
+
expect(tokval('"#{c}"', :string)).to eq '#{c}'
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
52
|
-
tokval('"#{c}"', :attr).
|
51
|
+
it "does not include interpolated strings when using :attr" do
|
52
|
+
expect(tokval('"#{c}"', :attr)).to be nil
|
53
53
|
end
|
54
54
|
|
55
|
-
it "
|
56
|
-
tokval('2.5', :number).
|
57
|
-
tokval('2', :number).
|
55
|
+
it "allows any number type with :number" do
|
56
|
+
expect(tokval('2.5', :number)).to eq 2.5
|
57
|
+
expect(tokval('2', :number)).to eq 2
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
61
|
-
tokval('methodname?', :identifier).
|
60
|
+
it "allows method names with :identifier" do
|
61
|
+
expect(tokval('methodname?', :identifier)).to eq "methodname?"
|
62
62
|
end
|
63
63
|
|
64
|
-
#it "
|
64
|
+
#it "obeys documentation expectations" do docspec end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe YARD::Handlers::Base, "#tokval_list" do
|
@@ -71,58 +71,58 @@ describe YARD::Handlers::Base, "#tokval_list" do
|
|
71
71
|
@handler.send(:tokval_list, TokenList.new(code), *types)
|
72
72
|
end
|
73
73
|
|
74
|
-
it "
|
75
|
-
tokval_list(":a, :b, \"\#{c}\", 'd'", :attr).
|
76
|
-
tokval_list(":a, :b, File.read(\"\#{c}\", ['w']), :d",
|
77
|
-
RubyToken::Token).
|
74
|
+
it "returns the list of tokvalues" do
|
75
|
+
expect(tokval_list(":a, :b, \"\#{c}\", 'd'", :attr)).to eq [:a, :b, 'd']
|
76
|
+
expect(tokval_list(":a, :b, File.read(\"\#{c}\", ['w']), :d",
|
77
|
+
RubyToken::Token)).to eq [:a, :b, 'File.read("#{c}", [\'w\'])', :d]
|
78
78
|
end
|
79
79
|
|
80
|
-
it "
|
81
|
-
tokval_list(":a, :b, \"\#{c}\", :d", :attr).
|
82
|
-
tokval_list(":a, :b, File.read(\"\#{c}\", 'w', File.open { }), :d", :attr).
|
83
|
-
tokval_list("CONST1, identifier, File.read(\"\#{c}\", 'w', File.open { }), CONST2",
|
84
|
-
RubyToken::TkId).
|
80
|
+
it "tries to skip any invalid tokens" do
|
81
|
+
expect(tokval_list(":a, :b, \"\#{c}\", :d", :attr)).to eq [:a, :b, :d]
|
82
|
+
expect(tokval_list(":a, :b, File.read(\"\#{c}\", 'w', File.open { }), :d", :attr)).to eq [:a, :b, :d]
|
83
|
+
expect(tokval_list("CONST1, identifier, File.read(\"\#{c}\", 'w', File.open { }), CONST2",
|
84
|
+
RubyToken::TkId)).to eq ['CONST1', 'identifier', 'CONST2']
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
88
|
-
tokval_list(":a, :b XYZ, :c", RubyToken::TkSYMBOL).
|
87
|
+
it "ignores a token if another invalid token is read before a comma" do
|
88
|
+
expect(tokval_list(":a, :b XYZ, :c", RubyToken::TkSYMBOL)).to eq [:a, :c]
|
89
89
|
end
|
90
90
|
|
91
|
-
it "
|
92
|
-
tokval_list(':a rescue :x == 5', RubyToken::Token).
|
91
|
+
it "stops on most keywords" do
|
92
|
+
expect(tokval_list(':a rescue :x == 5', RubyToken::Token)).to eq [:a]
|
93
93
|
end
|
94
94
|
|
95
|
-
it "
|
96
|
-
tokval_list('(:a, :b, :c)', :attr).
|
95
|
+
it "handles ignore parentheses that begin the token list" do
|
96
|
+
expect(tokval_list('(:a, :b, :c)', :attr)).to eq [:a, :b, :c]
|
97
97
|
end
|
98
98
|
|
99
|
-
it "
|
100
|
-
tokval_list(':a, :b, :c), :d', :attr).
|
99
|
+
it "ends when a closing parenthesis was found" do
|
100
|
+
expect(tokval_list(':a, :b, :c), :d', :attr)).to eq [:a, :b, :c]
|
101
101
|
end
|
102
102
|
|
103
|
-
it "
|
104
|
-
tokval_list(':a, (:b), :c, (:d TEST), :e, [:f], :g', :attr).
|
105
|
-
tokval_list(':a, (((:f)))', :attr).
|
106
|
-
tokval_list(':a, ([:f]), :c)', RubyToken::Token).
|
103
|
+
it "ignores parentheses around items in a list" do
|
104
|
+
expect(tokval_list(':a, (:b), :c, (:d TEST), :e, [:f], :g', :attr)).to eq [:a, :b, :c, :e, :g]
|
105
|
+
expect(tokval_list(':a, (((:f)))', :attr)).to eq [:a, :f]
|
106
|
+
expect(tokval_list(':a, ([:f]), :c)', RubyToken::Token)).to eq [:a, '[:f]', :c]
|
107
107
|
end
|
108
108
|
|
109
|
-
it "
|
110
|
-
tokval_list(':a, true, :b, self, false, :c, nil, File, super, if, XYZ',
|
111
|
-
RubyToken::Token).
|
109
|
+
it "does not stop on a true/false/self keyword (cannot handle nil)" do
|
110
|
+
expect(tokval_list(':a, true, :b, self, false, :c, nil, File, super, if, XYZ',
|
111
|
+
RubyToken::Token)).to eq [:a, true, :b, 'self', false, :c, 'File', 'super']
|
112
112
|
end
|
113
113
|
|
114
|
-
it "
|
115
|
-
tokval_list(":a, :b, , :d").
|
114
|
+
it "ignores invalid commas" do
|
115
|
+
expect(tokval_list(":a, :b, , :d")).to eq [:a, :b, :d]
|
116
116
|
end
|
117
117
|
|
118
|
-
it "
|
119
|
-
tokval_list('attr_accessor :x').
|
118
|
+
it "returns an empty list if no matches were found" do
|
119
|
+
expect(tokval_list('attr_accessor :x')).to eq []
|
120
120
|
end
|
121
121
|
|
122
|
-
it "
|
122
|
+
it "treats {} as a valid value" do
|
123
123
|
# FIXME: tokval_list destroys extra spaces surrounding the '=' in
|
124
124
|
# this situation. This is technically a design flaw of the
|
125
125
|
# tokval parser, but this is now the expected behaviour.
|
126
|
-
tokval_list("opts = {}", :all).
|
126
|
+
expect(tokval_list("opts = {}", :all)).to eq ["opts={}"]
|
127
127
|
end
|
128
128
|
end
|