yard 0.8.7.6 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/LICENSE +2 -2
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/bin/yard +0 -0
- data/bin/yardoc +0 -0
- data/bin/yri +0 -0
- data/docs/GettingStarted.md +88 -6
- data/docs/images/handlers-class-diagram.png +0 -0
- data/docs/images/overview-class-diagram.png +0 -0
- data/docs/images/parser-class-diagram.png +0 -0
- data/docs/templates/default/fulldoc/html/full_list_tag.erb +6 -4
- data/lib/yard/autoload.rb +3 -0
- data/lib/yard/cli/yardoc.rb +1 -1
- data/lib/yard/code_objects/base.rb +4 -1
- data/lib/yard/code_objects/extra_file_object.rb +3 -1
- data/lib/yard/code_objects/proxy.rb +2 -2
- data/lib/yard/docstring.rb +11 -6
- data/lib/yard/handlers/base.rb +1 -2
- data/lib/yard/handlers/c/base.rb +19 -0
- data/lib/yard/handlers/c/handler_methods.rb +42 -8
- data/lib/yard/handlers/c/init_handler.rb +1 -1
- data/lib/yard/handlers/c/method_handler.rb +3 -3
- data/lib/yard/handlers/ruby/decorator_handler_methods.rb +132 -0
- data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +1 -1
- data/lib/yard/handlers/ruby/private_class_method_handler.rb +6 -39
- data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -30
- data/lib/yard/handlers/ruby/public_class_method_handler.rb +13 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +1 -0
- data/lib/yard/handlers/ruby/visibility_handler.rb +5 -8
- data/lib/yard/logging.rb +1 -0
- data/lib/yard/parser/ruby/ruby_parser.rb +2 -2
- data/lib/yard/parser/source_parser.rb +6 -6
- data/lib/yard/rake/yardoc_task.rb +2 -2
- data/lib/yard/serializers/file_system_serializer.rb +33 -1
- data/lib/yard/server/commands/display_file_command.rb +8 -3
- data/lib/yard/server/commands/display_object_command.rb +7 -3
- data/lib/yard/server/doc_server_helper.rb +2 -8
- data/lib/yard/server/doc_server_serializer.rb +2 -4
- data/lib/yard/server/router.rb +1 -1
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +57 -8
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -10
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +1 -2
- data/lib/yard/server/templates/default/method_details/html/permalink.erb +3 -3
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
- data/lib/yard/tags/directives.rb +1 -0
- data/lib/yard/tags/library.rb +9 -7
- data/lib/yard/tags/overload_tag.rb +4 -1
- data/lib/yard/templates/helpers/html_helper.rb +4 -3
- data/lib/yard/templates/template_options.rb +3 -0
- data/lib/yard/version.rb +1 -1
- data/spec/cli/command_parser_spec.rb +14 -14
- data/spec/cli/command_spec.rb +11 -11
- data/spec/cli/config_spec.rb +32 -32
- data/spec/cli/diff_spec.rb +86 -90
- data/spec/cli/display_spec.rb +6 -6
- data/spec/cli/gems_spec.rb +28 -28
- data/spec/cli/graph_spec.rb +8 -8
- data/spec/cli/help_spec.rb +8 -8
- data/spec/cli/i18n_spec.rb +33 -37
- data/spec/cli/list_spec.rb +2 -2
- data/spec/cli/markup_types_spec.rb +3 -3
- data/spec/cli/server_spec.rb +74 -88
- data/spec/cli/stats_spec.rb +14 -14
- data/spec/cli/yardoc_spec.rb +316 -321
- data/spec/cli/yri_spec.rb +45 -45
- data/spec/code_objects/base_spec.rb +174 -173
- data/spec/code_objects/class_object_spec.rb +65 -65
- data/spec/code_objects/code_object_list_spec.rb +13 -11
- data/spec/code_objects/constants_spec.rb +68 -58
- data/spec/code_objects/extra_file_object_spec.rb +71 -59
- data/spec/code_objects/macro_object_spec.rb +64 -64
- data/spec/code_objects/method_object_spec.rb +80 -72
- data/spec/code_objects/module_object_spec.rb +47 -47
- data/spec/code_objects/namespace_object_spec.rb +51 -51
- data/spec/code_objects/proxy_spec.rb +54 -54
- data/spec/config_spec.rb +104 -104
- data/spec/core_ext/array_spec.rb +5 -5
- data/spec/core_ext/file_spec.rb +33 -33
- data/spec/core_ext/hash_spec.rb +5 -5
- data/spec/core_ext/insertion_spec.rb +18 -18
- data/spec/core_ext/module_spec.rb +6 -6
- data/spec/core_ext/string_spec.rb +17 -17
- data/spec/core_ext/symbol_hash_spec.rb +42 -39
- data/spec/docstring_parser_spec.rb +65 -65
- data/spec/docstring_spec.rb +137 -130
- data/spec/handlers/alias_handler_spec.rb +39 -39
- data/spec/handlers/attribute_handler_spec.rb +35 -35
- data/spec/handlers/base_spec.rb +60 -51
- data/spec/handlers/c/alias_handler_spec.rb +6 -6
- data/spec/handlers/c/attribute_handler_spec.rb +12 -12
- data/spec/handlers/c/class_handler_spec.rb +35 -22
- data/spec/handlers/c/constant_handler_spec.rb +24 -22
- data/spec/handlers/c/init_handler_spec.rb +10 -10
- data/spec/handlers/c/method_handler_spec.rb +150 -65
- data/spec/handlers/c/mixin_handler_spec.rb +5 -5
- data/spec/handlers/c/module_handler_spec.rb +27 -15
- data/spec/handlers/c/override_comment_handler_spec.rb +14 -14
- data/spec/handlers/c/path_handler_spec.rb +8 -8
- data/spec/handlers/c/spec_helper.rb +10 -0
- data/spec/handlers/c/struct_handler_spec.rb +3 -3
- data/spec/handlers/class_condition_handler_spec.rb +18 -18
- data/spec/handlers/class_handler_spec.rb +97 -97
- data/spec/handlers/class_method_handler_shared_examples.rb +132 -0
- data/spec/handlers/class_variable_handler_spec.rb +3 -3
- data/spec/handlers/constant_handler_spec.rb +32 -29
- data/spec/handlers/decorator_handler_methods_spec.rb +405 -0
- data/spec/handlers/dsl_handler_spec.rb +108 -109
- data/spec/handlers/examples/constant_handler_001.rb.txt +4 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
- data/spec/handlers/exception_handler_spec.rb +23 -23
- data/spec/handlers/extend_handler_spec.rb +9 -9
- data/spec/handlers/legacy_base_spec.rb +60 -60
- data/spec/handlers/method_condition_handler_spec.rb +5 -5
- data/spec/handlers/method_handler_spec.rb +92 -92
- data/spec/handlers/mixin_handler_spec.rb +25 -25
- data/spec/handlers/module_function_handler_spec.rb +24 -24
- data/spec/handlers/module_handler_spec.rb +15 -15
- data/spec/handlers/private_class_method_handler_spec.rb +4 -48
- data/spec/handlers/private_constant_handler_spec.rb +8 -8
- data/spec/handlers/processor_spec.rb +12 -12
- data/spec/handlers/public_class_method_handler_spec.rb +10 -0
- data/spec/handlers/ruby/base_spec.rb +16 -16
- data/spec/handlers/ruby/legacy/base_spec.rb +20 -18
- data/spec/handlers/spec_helper.rb +1 -1
- data/spec/handlers/visibility_handler_spec.rb +25 -21
- data/spec/handlers/yield_handler_spec.rb +28 -28
- data/spec/i18n/locale_spec.rb +16 -16
- data/spec/i18n/message_spec.rb +8 -8
- data/spec/i18n/messages_spec.rb +14 -14
- data/spec/i18n/pot_generator_spec.rb +32 -32
- data/spec/i18n/text_spec.rb +22 -22
- data/spec/logging_spec.rb +12 -12
- data/spec/options_spec.rb +56 -56
- data/spec/parser/base_spec.rb +9 -9
- data/spec/parser/c_parser_spec.rb +50 -50
- data/spec/parser/ruby/ast_node_spec.rb +7 -7
- data/spec/parser/ruby/legacy/statement_list_spec.rb +106 -106
- data/spec/parser/ruby/legacy/token_list_spec.rb +27 -27
- data/spec/parser/ruby/ruby_parser_spec.rb +123 -113
- data/spec/parser/source_parser_spec.rb +224 -224
- data/spec/parser/tag_parsing_spec.rb +6 -7
- data/spec/rake/yardoc_task_spec.rb +38 -48
- data/spec/registry_spec.rb +143 -143
- data/spec/registry_store_spec.rb +165 -165
- data/spec/rubygems/doc_manager_spec.rb +38 -38
- data/spec/serializers/file_system_serializer_spec.rb +53 -33
- data/spec/serializers/yardoc_serializer_spec.rb +15 -15
- data/spec/server/adapter_spec.rb +15 -15
- data/spec/server/commands/base_spec.rb +29 -29
- data/spec/server/commands/library_command_spec.rb +12 -12
- data/spec/server/commands/static_file_command_spec.rb +28 -28
- data/spec/server/doc_server_helper_spec.rb +8 -8
- data/spec/server/doc_server_serializer_spec.rb +23 -18
- data/spec/server/rack_adapter_spec.rb +6 -6
- data/spec/server/router_spec.rb +39 -39
- data/spec/server/static_caching_spec.rb +16 -16
- data/spec/server/webrick_servlet_spec.rb +6 -7
- data/spec/server_spec.rb +3 -3
- data/spec/spec_helper.rb +11 -2
- data/spec/tags/default_factory_spec.rb +64 -64
- data/spec/tags/default_tag_spec.rb +5 -5
- data/spec/tags/directives_spec.rb +121 -121
- data/spec/tags/library_spec.rb +14 -14
- data/spec/tags/overload_tag_spec.rb +24 -24
- data/spec/tags/ref_tag_list_spec.rb +12 -12
- data/spec/templates/class_spec.rb +3 -3
- data/spec/templates/constant_spec.rb +4 -4
- data/spec/templates/engine_spec.rb +47 -48
- data/spec/templates/examples/class001.html +129 -101
- data/spec/templates/examples/class002.html +31 -27
- data/spec/templates/examples/method001.html +54 -47
- data/spec/templates/examples/method002.html +33 -28
- data/spec/templates/examples/method003.html +70 -64
- data/spec/templates/examples/method004.html +13 -9
- data/spec/templates/examples/method005.html +38 -32
- data/spec/templates/examples/module001.html +343 -339
- data/spec/templates/examples/module002.html +147 -124
- data/spec/templates/examples/module003.html +94 -81
- data/spec/templates/examples/module004.html +40 -33
- data/spec/templates/helpers/base_helper_spec.rb +91 -95
- data/spec/templates/helpers/html_helper_spec.rb +276 -279
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +16 -15
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +27 -34
- data/spec/templates/helpers/markup_helper_spec.rb +57 -57
- data/spec/templates/helpers/method_helper_spec.rb +20 -20
- data/spec/templates/helpers/shared_signature_examples.rb +33 -31
- data/spec/templates/helpers/text_helper_spec.rb +6 -6
- data/spec/templates/method_spec.rb +7 -7
- data/spec/templates/module_spec.rb +7 -7
- data/spec/templates/onefile_spec.rb +7 -7
- data/spec/templates/section_spec.rb +66 -69
- data/spec/templates/spec_helper.rb +1 -1
- data/spec/templates/tag_spec.rb +5 -5
- data/spec/templates/template_spec.rb +158 -158
- data/spec/verifier_spec.rb +52 -52
- data/templates/default/fulldoc/html/css/full_list.css +32 -31
- data/templates/default/fulldoc/html/css/style.css +212 -77
- data/templates/default/fulldoc/html/frames.erb +6 -15
- data/templates/default/fulldoc/html/full_list.erb +14 -21
- data/templates/default/fulldoc/html/full_list_class.erb +1 -1
- data/templates/default/fulldoc/html/full_list_file.erb +6 -4
- data/templates/default/fulldoc/html/full_list_method.erb +8 -6
- data/templates/default/fulldoc/html/js/app.js +100 -76
- data/templates/default/fulldoc/html/js/full_list.js +170 -135
- data/templates/default/fulldoc/html/setup.rb +50 -7
- data/templates/default/layout/html/breadcrumb.erb +0 -2
- data/templates/default/layout/html/headers.erb +2 -1
- data/templates/default/layout/html/layout.erb +16 -10
- data/templates/default/layout/html/script_setup.erb +1 -2
- data/templates/default/layout/html/search.erb +7 -2
- data/templates/default/layout/html/setup.rb +16 -0
- data/templates/default/method/html/header.erb +7 -6
- data/templates/default/module/html/attribute_summary.erb +1 -1
- data/templates/default/module/html/box_info.erb +24 -18
- data/templates/default/module/html/constant_summary.erb +9 -11
- data/templates/default/module/html/item_summary.erb +1 -1
- data/templates/default/module/html/method_summary.erb +1 -1
- data/templates/guide/fulldoc/html/setup.rb +1 -1
- data/yard.gemspec +1 -2
- metadata +10 -7
- data/spec/handlers/examples/private_class_method_handler_001.rb.txt +0 -9
- data/spec/handlers/examples/private_class_method_handler_002.rb.txt +0 -18
- data/spec/handlers/examples/private_class_method_handler_003.rb.txt +0 -11
data/spec/logging_spec.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
2
|
|
3
3
|
describe YARD::Logger do
|
4
|
-
describe
|
5
|
-
it "
|
4
|
+
describe "#show_backtraces" do
|
5
|
+
it "is true if debug level is on" do
|
6
6
|
log.show_backtraces = true
|
7
7
|
log.enter_level(Logger::DEBUG) do
|
8
8
|
log.show_backtraces = false
|
9
|
-
log.show_backtraces.
|
9
|
+
expect(log.show_backtraces).to be true
|
10
10
|
end
|
11
|
-
log.show_backtraces.
|
11
|
+
expect(log.show_backtraces).to be false
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
15
|
+
describe "#backtrace" do
|
16
16
|
before { log.show_backtraces = true }
|
17
|
-
after
|
17
|
+
after { log.show_backtraces = false }
|
18
18
|
|
19
|
-
it "
|
20
|
-
log.
|
21
|
-
log.
|
19
|
+
it "logs backtrace in error by default" do
|
20
|
+
expect(log).to receive(:error).with("RuntimeError: foo")
|
21
|
+
expect(log).to receive(:error).with("Stack trace:\n\tline1\n\tline2\n")
|
22
22
|
exc = RuntimeError.new("foo")
|
23
23
|
exc.set_backtrace(['line1', 'line2'])
|
24
24
|
log.enter_level(Logger::INFO) { log.backtrace(exc) }
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
28
|
-
log.
|
29
|
-
log.
|
27
|
+
it "allows backtrace to be entered in other modes" do
|
28
|
+
expect(log).to receive(:warn).with("RuntimeError: foo")
|
29
|
+
expect(log).to receive(:warn).with("Stack trace:\n\tline1\n\tline2\n")
|
30
30
|
exc = RuntimeError.new("foo")
|
31
31
|
exc.set_backtrace(['line1', 'line2'])
|
32
32
|
log.enter_level(Logger::INFO) { log.backtrace(exc, :warn) }
|
data/spec/options_spec.rb
CHANGED
@@ -6,38 +6,38 @@ describe YARD::Options do
|
|
6
6
|
def initialize; self.foo = "abc" end
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
10
|
-
it "
|
9
|
+
describe ".default_attr" do
|
10
|
+
it "allows default attributes to be defined with symbols" do
|
11
11
|
class DefaultOptions1 < YARD::Options
|
12
12
|
default_attr :foo, 'HELLO'
|
13
13
|
end
|
14
14
|
o = DefaultOptions1.new
|
15
15
|
o.reset_defaults
|
16
|
-
o.foo.
|
16
|
+
expect(o.foo).to eq 'HELLO'
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
19
|
+
it "calls lambda if value is a Proc" do
|
20
20
|
class DefaultOptions2 < YARD::Options
|
21
21
|
default_attr :foo, lambda { 100 }
|
22
22
|
end
|
23
23
|
o = DefaultOptions2.new
|
24
24
|
o.reset_defaults
|
25
|
-
o.foo.
|
25
|
+
expect(o.foo).to eq 100
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
30
|
-
it "
|
29
|
+
describe "#reset_defaults" do
|
30
|
+
it "does not define defaults until reset is called" do
|
31
31
|
class ResetDefaultOptions1 < YARD::Options
|
32
32
|
default_attr :foo, 'FOO'
|
33
33
|
end
|
34
|
-
ResetDefaultOptions1.new.foo.
|
34
|
+
expect(ResetDefaultOptions1.new.foo).to be nil
|
35
35
|
o = ResetDefaultOptions1.new
|
36
36
|
o.reset_defaults
|
37
|
-
o.foo.
|
37
|
+
expect(o.foo).to eq 'FOO'
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
40
|
+
it "uses defaults from superclass as well" do
|
41
41
|
class ResetDefaultOptions2 < YARD::Options
|
42
42
|
default_attr :foo, 'FOO'
|
43
43
|
end
|
@@ -45,127 +45,127 @@ describe YARD::Options do
|
|
45
45
|
end
|
46
46
|
o = ResetDefaultOptions3.new
|
47
47
|
o.reset_defaults
|
48
|
-
o.foo.
|
48
|
+
expect(o.foo).to eq 'FOO'
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe
|
53
|
-
it "
|
52
|
+
describe "#delete" do
|
53
|
+
it "deletes an option" do
|
54
54
|
o = FooOptions.new
|
55
55
|
o.delete(:foo)
|
56
|
-
o.to_hash.
|
56
|
+
expect(o.to_hash).to eq({})
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
59
|
+
it "does not error if an option is deleted that does not exist" do
|
60
60
|
o = FooOptions.new
|
61
61
|
o.delete(:foo)
|
62
62
|
o.delete(:foo)
|
63
|
-
o.to_hash.
|
63
|
+
expect(o.to_hash).to eq({})
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
describe
|
68
|
-
it "
|
69
|
-
FooOptions.new[:foo].
|
67
|
+
describe "#[]" do
|
68
|
+
it "handles getting option values using hash syntax" do
|
69
|
+
expect(FooOptions.new[:foo]).to eq "abc"
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
describe
|
74
|
-
it "
|
73
|
+
describe "#[]=" do
|
74
|
+
it "handles setting options using hash syntax" do
|
75
75
|
o = FooOptions.new
|
76
76
|
o[:foo] = "xyz"
|
77
|
-
o[:foo].
|
77
|
+
expect(o[:foo]).to eq "xyz"
|
78
78
|
end
|
79
79
|
|
80
|
-
it "
|
80
|
+
it "allows setting of unregistered keys" do
|
81
81
|
o = FooOptions.new
|
82
82
|
o[:bar] = "foo"
|
83
|
-
o[:bar].
|
83
|
+
expect(o[:bar]).to eq "foo"
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
describe
|
88
|
-
it "
|
87
|
+
describe "#method_missing" do
|
88
|
+
it "allows setting of unregistered keys" do
|
89
89
|
o = FooOptions.new
|
90
90
|
o.bar = 'foo'
|
91
|
-
o.bar.
|
91
|
+
expect(o.bar).to eq 'foo'
|
92
92
|
end
|
93
93
|
|
94
|
-
it "
|
95
|
-
FooOptions.new.bar.
|
94
|
+
it "allows getting values of unregistered keys (return nil)" do
|
95
|
+
expect(FooOptions.new.bar).to be nil
|
96
96
|
end
|
97
97
|
|
98
|
-
it "
|
99
|
-
log.
|
98
|
+
it "prints debugging messages about unregistered keys" do
|
99
|
+
expect(log).to receive(:debug).with("Attempting to access unregistered key bar on FooOptions")
|
100
100
|
FooOptions.new.bar
|
101
|
-
log.
|
101
|
+
expect(log).to receive(:debug).with("Attempting to set unregistered key bar on FooOptions")
|
102
102
|
FooOptions.new.bar = 1
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
describe
|
107
|
-
it "
|
108
|
-
FooOptions.new.update(:foo => "xyz").foo.
|
106
|
+
describe "#update" do
|
107
|
+
it "allows updating of options" do
|
108
|
+
expect(FooOptions.new.update(:foo => "xyz").foo).to eq "xyz"
|
109
109
|
end
|
110
110
|
|
111
|
-
it "
|
111
|
+
it "does not ignore keys with no setter (OpenStruct behaviour)" do
|
112
112
|
o = FooOptions.new
|
113
113
|
o.update(:bar => "xyz")
|
114
|
-
o.to_hash.
|
114
|
+
expect(o.to_hash).to eq({:foo => "abc", :bar => "xyz"})
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
describe
|
119
|
-
it "
|
118
|
+
describe "#merge" do
|
119
|
+
it "updates a new object" do
|
120
120
|
o = FooOptions.new
|
121
|
-
o.merge(:foo => "xyz").object_id.
|
122
|
-
o.merge(:foo => "xyz").to_hash.
|
121
|
+
expect(o.merge(:foo => "xyz").object_id).not_to eq o.object_id
|
122
|
+
expect(o.merge(:foo => "xyz").to_hash).to eq({:foo => "xyz"})
|
123
123
|
end
|
124
124
|
|
125
|
-
it "
|
125
|
+
it "adds in values from original object" do
|
126
126
|
o = FooOptions.new
|
127
127
|
o.update(:bar => "foo")
|
128
|
-
o.merge(:baz => 1).to_hash.
|
128
|
+
expect(o.merge(:baz => 1).to_hash).to eq({:foo => "abc", :bar => "foo", :baz => 1})
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
describe
|
133
|
-
it "
|
132
|
+
describe "#to_hash" do
|
133
|
+
it "converts all instance variables and symbolized keys" do
|
134
134
|
class ToHashOptions1 < YARD::Options
|
135
135
|
attr_accessor :foo, :bar, :baz
|
136
136
|
def initialize; @foo = 1; @bar = 2; @baz = "hello" end
|
137
137
|
end
|
138
138
|
o = ToHashOptions1.new
|
139
139
|
hash = o.to_hash
|
140
|
-
hash.keys.
|
141
|
-
hash[:foo].
|
142
|
-
hash[:bar].
|
143
|
-
hash[:baz].
|
140
|
+
expect(hash.keys).to include(:foo, :bar, :baz)
|
141
|
+
expect(hash[:foo]).to eq 1
|
142
|
+
expect(hash[:bar]).to eq 2
|
143
|
+
expect(hash[:baz]).to eq "hello"
|
144
144
|
end
|
145
145
|
|
146
|
-
it "
|
146
|
+
it "uses accessor when converting values to hash" do
|
147
147
|
class ToHashOptions2 < YARD::Options
|
148
148
|
def initialize; @foo = 1 end
|
149
149
|
def foo; "HELLO#{@foo}" end
|
150
150
|
end
|
151
151
|
o = ToHashOptions2.new
|
152
|
-
o.to_hash.
|
152
|
+
expect(o.to_hash).to eq({:foo => "HELLO1"})
|
153
153
|
end
|
154
154
|
|
155
|
-
it "
|
155
|
+
it "ignores ivars with no accessor" do
|
156
156
|
class ToHashOptions3 < YARD::Options
|
157
157
|
attr_accessor :foo
|
158
158
|
def initialize; @foo = 1; @bar = "NOIGNORE" end
|
159
159
|
end
|
160
160
|
o = ToHashOptions3.new
|
161
|
-
o.to_hash.
|
161
|
+
expect(o.to_hash).to eq({:foo => 1, :bar => "NOIGNORE"})
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
-
describe
|
166
|
-
it "
|
165
|
+
describe "#tap" do
|
166
|
+
it "supports #tap(&block) (even in 1.8.6)" do
|
167
167
|
o = FooOptions.new.tap {|o| o.foo = :BAR }
|
168
|
-
o.to_hash.
|
168
|
+
expect(o.to_hash).to eq({:foo => :BAR})
|
169
169
|
end
|
170
170
|
end
|
171
171
|
end
|
data/spec/parser/base_spec.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
2
|
|
3
3
|
describe YARD::Parser::Base do
|
4
|
-
describe
|
4
|
+
describe "#initialize" do
|
5
5
|
class MyParser < Parser::Base; def initialize(a, b) end end
|
6
6
|
|
7
|
-
it "
|
8
|
-
|
7
|
+
it "takes 2 arguments" do
|
8
|
+
expect { YARD::Parser::Base.new }.to raise_error(ArgumentError,
|
9
9
|
/wrong (number|#) of arguments|given 0, expected 2/)
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
13
|
-
|
12
|
+
it "raises NotImplementedError on #initialize" do
|
13
|
+
expect { YARD::Parser::Base.new('a', 'b') }.to raise_error(NotImplementedError)
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
|
16
|
+
it "raises NotImplementedError on #parse" do
|
17
|
+
expect { MyParser.new('a', 'b').parse }.to raise_error(NotImplementedError)
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
21
|
-
|
20
|
+
it "raises NotImplementedError on #tokenize" do
|
21
|
+
expect { MyParser.new('a', 'b').tokenize }.to raise_error(NotImplementedError)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -1,60 +1,60 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
2
|
|
3
3
|
describe YARD::Parser::C::CParser do
|
4
|
-
describe
|
4
|
+
describe "#parse" do
|
5
5
|
def parse(contents)
|
6
6
|
Registry.clear
|
7
7
|
YARD.parse_string(contents, :c)
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe "Array class" do
|
11
11
|
before(:all) do
|
12
12
|
file = File.join(File.dirname(__FILE__), 'examples', 'array.c.txt')
|
13
13
|
parse(File.read(file))
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "parses Array class" do
|
17
17
|
obj = YARD::Registry.at('Array')
|
18
|
-
obj.
|
19
|
-
obj.docstring.
|
18
|
+
expect(obj).not_to be nil
|
19
|
+
expect(obj.docstring).not_to be_blank
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
22
|
+
it "parses method" do
|
23
23
|
obj = YARD::Registry.at('Array#initialize')
|
24
|
-
obj.docstring.
|
25
|
-
obj.tags(:overload).size.
|
24
|
+
expect(obj.docstring).not_to be_blank
|
25
|
+
expect(obj.tags(:overload).size).to be > 1
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
29
|
+
describe "Source located in extra files" do
|
30
30
|
before(:all) do
|
31
31
|
@multifile = File.join(File.dirname(__FILE__), 'examples', 'multifile.c.txt')
|
32
32
|
@extrafile = File.join(File.dirname(__FILE__), 'examples', 'extrafile.c.txt')
|
33
33
|
@contents = File.read(@multifile)
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
36
|
+
it "looks for methods in extra files (if 'in' comment is found)" do
|
37
37
|
extra_contents = File.read(@extrafile)
|
38
|
-
File.
|
38
|
+
expect(File).to receive(:read).with('extra.c').and_return(extra_contents)
|
39
39
|
parse(@contents)
|
40
|
-
Registry.at('Multifile#extra').docstring.
|
40
|
+
expect(Registry.at('Multifile#extra').docstring).to eq 'foo'
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
44
|
-
File.
|
45
|
-
log.
|
43
|
+
it "stops searching for extra source file gracefully if file is not found" do
|
44
|
+
expect(File).to receive(:read).with('extra.c').and_raise(Errno::ENOENT)
|
45
|
+
expect(log).to receive(:warn).with("Missing source file `extra.c' when parsing Multifile#extra")
|
46
46
|
parse(@contents)
|
47
|
-
Registry.at('Multifile#extra').docstring.
|
47
|
+
expect(Registry.at('Multifile#extra').docstring).to eq ''
|
48
48
|
end
|
49
49
|
|
50
|
-
it "
|
50
|
+
it "differentiates between a struct and a pointer to a struct retval" do
|
51
51
|
parse(@contents)
|
52
|
-
Registry.at('Multifile#hello_mars').docstring.
|
52
|
+
expect(Registry.at('Multifile#hello_mars').docstring).to eq 'Hello Mars'
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe
|
57
|
-
it
|
56
|
+
describe "Foo class" do
|
57
|
+
it "does not include comments in docstring source" do
|
58
58
|
parse <<-eof
|
59
59
|
/*
|
60
60
|
* Hello world
|
@@ -67,13 +67,13 @@ describe YARD::Parser::C::CParser do
|
|
67
67
|
rb_define_method(rb_cFoo, "foo", foo, 1);
|
68
68
|
}
|
69
69
|
eof
|
70
|
-
Registry.at('Foo#foo').source.gsub(/\s\s+/, ' ').
|
71
|
-
"VALUE foo(VALUE x) { int value = x;\n}"
|
70
|
+
expect(Registry.at('Foo#foo').source.gsub(/\s\s+/, ' ')).to eq(
|
71
|
+
"VALUE foo(VALUE x) { int value = x;\n}")
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe
|
76
|
-
it
|
75
|
+
describe "Constant" do
|
76
|
+
it "does not truncate docstring" do
|
77
77
|
parse <<-eof
|
78
78
|
#define MSK_DEADBEEF 0xdeadbeef
|
79
79
|
void
|
@@ -86,13 +86,13 @@ describe YARD::Parser::C::CParser do
|
|
86
86
|
}
|
87
87
|
eof
|
88
88
|
constant = Registry.at('Mask::DEADBEEF')
|
89
|
-
constant.value.
|
90
|
-
constant.docstring.
|
89
|
+
expect(constant.value).to eq '0xdeadbeef'
|
90
|
+
expect(constant.docstring).to eq "This constant is frequently used to indicate a\nsoftware crash or deadlock in embedded systems."
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
describe
|
95
|
-
it "
|
94
|
+
describe "Macros" do
|
95
|
+
it "handles param## inside of macros" do
|
96
96
|
thr = Thread.new do
|
97
97
|
parse <<-eof
|
98
98
|
void
|
@@ -127,8 +127,8 @@ describe YARD::Parser::C::CParser do
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
describe
|
131
|
-
it "
|
130
|
+
describe "C macros in declaration" do
|
131
|
+
it "handles C macros in method declaration" do
|
132
132
|
Registry.clear
|
133
133
|
parse <<-eof
|
134
134
|
// docstring
|
@@ -141,49 +141,49 @@ describe YARD::Parser::C::CParser do
|
|
141
141
|
}
|
142
142
|
eof
|
143
143
|
|
144
|
-
Registry.at('Foo#func').docstring.
|
144
|
+
expect(Registry.at('Foo#func').docstring).to eq "docstring"
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
-
describe
|
149
|
+
describe "Override comments" do
|
150
150
|
before(:all) do
|
151
151
|
Registry.clear
|
152
152
|
override_file = File.join(File.dirname(__FILE__), 'examples', 'override.c.txt')
|
153
153
|
@override_parser = YARD.parse_string(File.read(override_file), :c)
|
154
154
|
end
|
155
155
|
|
156
|
-
it "
|
156
|
+
it "parses GMP::Z class" do
|
157
157
|
z = YARD::Registry.at('GMP::Z')
|
158
|
-
z.
|
159
|
-
z.docstring.
|
158
|
+
expect(z).not_to be nil
|
159
|
+
expect(z.docstring).not_to be_blank
|
160
160
|
end
|
161
161
|
|
162
|
-
it "
|
162
|
+
it "parses GMP::Z methods w/ bodies" do
|
163
163
|
add = YARD::Registry.at('GMP::Z#+')
|
164
|
-
add.docstring.
|
165
|
-
add.source.
|
166
|
-
add.source.
|
164
|
+
expect(add.docstring).not_to be_blank
|
165
|
+
expect(add.source).not_to be nil
|
166
|
+
expect(add.source).not_to be_empty
|
167
167
|
|
168
168
|
add_self = YARD::Registry.at('GMP::Z#+')
|
169
|
-
add_self.docstring.
|
170
|
-
add_self.source.
|
171
|
-
add_self.source.
|
169
|
+
expect(add_self.docstring).not_to be_blank
|
170
|
+
expect(add_self.source).not_to be nil
|
171
|
+
expect(add_self.source).not_to be_empty
|
172
172
|
|
173
173
|
sqrtrem = YARD::Registry.at('GMP::Z#+')
|
174
|
-
sqrtrem.docstring.
|
175
|
-
sqrtrem.source.
|
176
|
-
sqrtrem.source.
|
174
|
+
expect(sqrtrem.docstring).not_to be_blank
|
175
|
+
expect(sqrtrem.source).not_to be nil
|
176
|
+
expect(sqrtrem.source).not_to be_empty
|
177
177
|
end
|
178
178
|
|
179
|
-
it "
|
179
|
+
it "parses GMP::Z methods w/o bodies" do
|
180
180
|
neg = YARD::Registry.at('GMP::Z#neg')
|
181
|
-
neg.docstring.
|
182
|
-
neg.source.
|
181
|
+
expect(neg.docstring).not_to be_blank
|
182
|
+
expect(neg.source).to be nil
|
183
183
|
|
184
184
|
neg_self = YARD::Registry.at('GMP::Z#neg')
|
185
|
-
neg_self.docstring.
|
186
|
-
neg_self.source.
|
185
|
+
expect(neg_self.docstring).not_to be_blank
|
186
|
+
expect(neg_self.source).to be nil
|
187
187
|
end
|
188
188
|
end
|
189
189
|
end
|