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,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/spec_helper"
|
2
2
|
|
3
3
|
describe YARD::Handlers::C::MixinHandler do
|
4
|
-
it "
|
4
|
+
it "adds includes to modules or classes" do
|
5
5
|
parse_init <<-eof
|
6
6
|
mFoo = rb_define_module("Foo");
|
7
7
|
cBar = rb_define_class("Bar", rb_cObject);
|
@@ -12,16 +12,16 @@ describe YARD::Handlers::C::MixinHandler do
|
|
12
12
|
foo = Registry.at('Foo')
|
13
13
|
bar = Registry.at('Bar')
|
14
14
|
baz = Registry.at('Baz')
|
15
|
-
bar.mixins(:instance).
|
16
|
-
baz.mixins(:instance).
|
15
|
+
expect(bar.mixins(:instance)).to eq [foo]
|
16
|
+
expect(baz.mixins(:instance)).to eq [foo]
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
19
|
+
it "adds include as proxy if symbol lookup fails" do
|
20
20
|
parse_init <<-eof
|
21
21
|
mFoo = rb_define_module("Foo");
|
22
22
|
rb_include_module(mFoo, mXYZ);
|
23
23
|
eof
|
24
24
|
foo = Registry.at('Foo')
|
25
|
-
foo.mixins(:instance).
|
25
|
+
expect(foo.mixins(:instance)).to eq [P('XYZ')]
|
26
26
|
end
|
27
27
|
end
|
@@ -1,42 +1,54 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/spec_helper"
|
2
2
|
|
3
3
|
describe YARD::Handlers::C::ClassHandler do
|
4
|
-
it "
|
4
|
+
it "registers modules" do
|
5
5
|
parse_init 'mFoo = rb_define_module("Foo");'
|
6
|
-
Registry.at('Foo').type.
|
6
|
+
expect(Registry.at('Foo').type).to eq :module
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
10
|
-
parse_init
|
11
|
-
|
9
|
+
it "registers classes under namespaces" do
|
10
|
+
parse_init <<-EOF
|
11
|
+
mBar = rb_define_module("Bar");
|
12
|
+
mFoo = rb_define_module_under(mBar, "Foo");
|
13
|
+
EOF
|
14
|
+
expect(Registry.at('Bar::Foo').type).to eq :module
|
12
15
|
end
|
13
16
|
|
14
|
-
it "
|
17
|
+
it "remembers symbol defined with class" do
|
15
18
|
parse_init(<<-eof)
|
16
19
|
cXYZ = rb_define_module("Foo");
|
17
20
|
rb_define_method(cXYZ, "bar", bar, 0);
|
18
21
|
eof
|
19
|
-
Registry.at('Foo').type.
|
20
|
-
Registry.at('Foo#bar').
|
22
|
+
expect(Registry.at('Foo').type).to eq :module
|
23
|
+
expect(Registry.at('Foo#bar')).not_to be nil
|
21
24
|
end
|
22
25
|
|
23
|
-
it "
|
26
|
+
it "does not associate declaration comments as module docstring" do
|
24
27
|
parse_init(<<-eof)
|
25
28
|
/* Docstring! */
|
26
29
|
mFoo = rb_define_module("Foo");
|
27
30
|
eof
|
28
|
-
Registry.at('Foo').docstring.
|
31
|
+
expect(Registry.at('Foo').docstring).to be_blank
|
29
32
|
end
|
30
33
|
|
31
|
-
it "
|
34
|
+
it "associates a file with the declaration" do
|
32
35
|
parse_init(<<-eof)
|
33
36
|
mFoo = rb_define_module("Foo");
|
34
37
|
eof
|
35
|
-
Registry.at('Foo').file.
|
36
|
-
Registry.at('Foo').line.
|
38
|
+
expect(Registry.at('Foo').file).to eq '(stdin)'
|
39
|
+
expect(Registry.at('Foo').line).to eq 2
|
37
40
|
end
|
38
41
|
|
39
|
-
it "
|
42
|
+
it "resolves namespace variable names across multiple files" do
|
43
|
+
parse_multi_file_init(
|
44
|
+
'mBar = rb_define_module_under(mFoo, "Bar");',
|
45
|
+
'mFoo = rb_define_module("Foo");'
|
46
|
+
)
|
47
|
+
|
48
|
+
expect(Registry.at('Foo::Bar').type).to eq :module
|
49
|
+
end
|
50
|
+
|
51
|
+
it "raises undoc error if a class is defined under a namespace that cannot be resolved" do
|
40
52
|
with_parser(:c) do
|
41
53
|
undoc_error <<-eof
|
42
54
|
void Init_Foo() {
|
@@ -46,7 +58,7 @@ describe YARD::Handlers::C::ClassHandler do
|
|
46
58
|
end
|
47
59
|
end unless ENV['LEGACY']
|
48
60
|
|
49
|
-
it "
|
61
|
+
it "raises undoc error if a module is defined under a namespace that cannot be resolved" do
|
50
62
|
with_parser(:c) do
|
51
63
|
undoc_error <<-eof
|
52
64
|
void Init_Foo() {
|
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + "/spec_helper"
|
|
2
2
|
|
3
3
|
describe YARD::Handlers::C::OverrideCommentHandler do
|
4
4
|
[:class, :module].each do |type|
|
5
|
-
it "
|
5
|
+
it "handles Document-#{type}" do
|
6
6
|
parse(<<-eof)
|
7
7
|
void something;
|
8
8
|
/* Document-#{type}: A
|
@@ -10,14 +10,14 @@ describe YARD::Handlers::C::OverrideCommentHandler do
|
|
10
10
|
*/
|
11
11
|
void
|
12
12
|
eof
|
13
|
-
Registry.at('A').type.
|
14
|
-
Registry.at('A').docstring.
|
15
|
-
Registry.at('A').file.
|
16
|
-
Registry.at('A').line.
|
13
|
+
expect(Registry.at('A').type).to eq type
|
14
|
+
expect(Registry.at('A').docstring).to eq 'Foo bar baz'
|
15
|
+
expect(Registry.at('A').file).to eq '(stdin)'
|
16
|
+
expect(Registry.at('A').line).to eq 2
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
20
|
+
it "handles multiple class/module combinations" do
|
21
21
|
parse(<<-eof)
|
22
22
|
/* Document-class: A
|
23
23
|
* Document-class: B
|
@@ -25,13 +25,13 @@ describe YARD::Handlers::C::OverrideCommentHandler do
|
|
25
25
|
* Foo bar baz
|
26
26
|
*/
|
27
27
|
eof
|
28
|
-
Registry.at('A').docstring.
|
29
|
-
Registry.at('B').docstring.
|
30
|
-
Registry.at('C').docstring.
|
31
|
-
Registry.at('C').type
|
28
|
+
expect(Registry.at('A').docstring).to eq 'Foo bar baz'
|
29
|
+
expect(Registry.at('B').docstring).to eq 'Foo bar baz'
|
30
|
+
expect(Registry.at('C').docstring).to eq 'Foo bar baz'
|
31
|
+
expect(Registry.at('C').type).to eq :module
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "handles Document-class with inheritance" do
|
35
35
|
parse(<<-eof)
|
36
36
|
/* Document-class: A < B
|
37
37
|
* Foo bar baz
|
@@ -39,8 +39,8 @@ describe YARD::Handlers::C::OverrideCommentHandler do
|
|
39
39
|
void
|
40
40
|
eof
|
41
41
|
obj = Registry.at('A')
|
42
|
-
obj.type.
|
43
|
-
obj.docstring.
|
44
|
-
obj.superclass.
|
42
|
+
expect(obj.type).to eq :class
|
43
|
+
expect(obj.docstring).to eq 'Foo bar baz'
|
44
|
+
expect(obj.superclass).to eq P('B')
|
45
45
|
end
|
46
46
|
end
|
@@ -1,28 +1,28 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/spec_helper"
|
2
2
|
|
3
3
|
describe YARD::Handlers::C::PathHandler do
|
4
|
-
it
|
4
|
+
it "tracks variable names defined under namespaces" do
|
5
5
|
parse_init <<-eof
|
6
6
|
mFoo = rb_define_module("Foo");
|
7
7
|
cBar = rb_define_class_under(mFoo, "Bar", rb_cObject);
|
8
8
|
rb_define_method(cBar, "foo", foo, 1);
|
9
9
|
eof
|
10
|
-
Registry.at('Foo::Bar').
|
11
|
-
Registry.at('Foo::Bar#foo').
|
10
|
+
expect(Registry.at('Foo::Bar')).not_to be nil
|
11
|
+
expect(Registry.at('Foo::Bar#foo')).not_to be nil
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
14
|
+
it "tracks variable names defined under namespaces" do
|
15
15
|
parse_init <<-eof
|
16
16
|
mFoo = rb_define_module("Foo");
|
17
17
|
cBar = rb_define_class_under(mFoo, "Bar", rb_cObject);
|
18
18
|
mBaz = rb_define_module_under(cBar, "Baz");
|
19
19
|
rb_define_method(mBaz, "foo", foo, 1);
|
20
20
|
eof
|
21
|
-
Registry.at('Foo::Bar::Baz').
|
22
|
-
Registry.at('Foo::Bar::Baz#foo').
|
21
|
+
expect(Registry.at('Foo::Bar::Baz')).not_to be nil
|
22
|
+
expect(Registry.at('Foo::Bar::Baz#foo')).not_to be nil
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
25
|
+
it "handles rb_path2class() calls" do
|
26
26
|
parse_init <<-eof
|
27
27
|
somePath = rb_path2class("Foo::Bar::Baz")
|
28
28
|
mFoo = rb_define_module("Foo");
|
@@ -30,6 +30,6 @@ describe YARD::Handlers::C::PathHandler do
|
|
30
30
|
mBaz = rb_define_module_under(cBar, "Baz");
|
31
31
|
rb_define_method(somePath, "foo", foo, 1);
|
32
32
|
eof
|
33
|
-
Registry.at('Foo::Bar::Baz#foo').
|
33
|
+
expect(Registry.at('Foo::Bar::Baz#foo')).not_to be nil
|
34
34
|
end
|
35
35
|
end
|
@@ -11,3 +11,13 @@ def parse_init(src)
|
|
11
11
|
YARD::Registry.clear
|
12
12
|
YARD.parse_string("void Init_Foo() {\n#{src}\n}", :c)
|
13
13
|
end
|
14
|
+
|
15
|
+
def parse_multi_file_init(*srcs)
|
16
|
+
YARD::Registry.clear
|
17
|
+
srcs = srcs.map {|src| StringIO.new("void Init_Foo() {\n#{src}\n}") }
|
18
|
+
orig_type = YARD::Parser::SourceParser.parser_type
|
19
|
+
YARD::Parser::SourceParser.parser_type = :c
|
20
|
+
YARD::Parser::OrderedParser.new(OpenStruct.new, srcs).parse
|
21
|
+
ensure
|
22
|
+
YARD::Parser::SourceParser.parser_type = orig_type
|
23
|
+
end
|
@@ -3,13 +3,13 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe YARD::Handlers::C::StructHandler do
|
4
4
|
after { Registry.clear }
|
5
5
|
|
6
|
-
it "
|
6
|
+
it "handles Struct class definitions" do
|
7
7
|
parse_init <<-eof
|
8
8
|
rb_cRange = rb_struct_define_without_accessor(
|
9
9
|
"Range", rb_cFoo, range_alloc,
|
10
10
|
"begin", "end", "excl", NULL);
|
11
11
|
eof
|
12
|
-
Registry.at('Range').type.
|
13
|
-
Registry.at('Range').superclass.
|
12
|
+
expect(Registry.at('Range').type).to eq :class
|
13
|
+
expect(Registry.at('Range').superclass).to eq P(:Foo)
|
14
14
|
end
|
15
15
|
end
|
@@ -4,58 +4,58 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ClassCondition
|
|
4
4
|
before(:all) { parse_file :class_condition_handler_001, __FILE__ }
|
5
5
|
|
6
6
|
def verify_method(*names)
|
7
|
-
names.each {|name| Registry.at("A##{name}").
|
8
|
-
names.each {|name| Registry.at("A##{name}not").
|
7
|
+
names.each {|name| expect(Registry.at("A##{name}")).not_to be nil }
|
8
|
+
names.each {|name| expect(Registry.at("A##{name}not")).to be nil }
|
9
9
|
end
|
10
10
|
|
11
11
|
def no_undoc_error(code)
|
12
|
-
|
12
|
+
expect { StubbedSourceParser.parse_string(code) }.not_to raise_error
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "parses all unless blocks for complex conditions" do
|
16
16
|
verify_method :g
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
19
|
+
it "does not parse conditionals inside methods" do
|
20
20
|
verify_method :h
|
21
21
|
end
|
22
22
|
|
23
|
-
it "
|
23
|
+
it "only parses then block if condition is literal value `true`" do
|
24
24
|
verify_method :p
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "only parses then block if condition is literal integer != 0" do
|
28
28
|
verify_method :o
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "inverts block to parse for literal condition if it's an unless block" do
|
32
32
|
verify_method :e
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
35
|
+
it "handles conditions such as 'defined? VALUE'" do
|
36
36
|
verify_method :j, :k
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
39
|
+
it "parses all if/elsif blocks for complex conditions" do
|
40
40
|
verify_method :a, :b, :c, :d
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
43
|
+
it "parses else block if condition is literal value `false`" do
|
44
44
|
verify_method :q
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
47
|
+
it "only parses else block if condition is literal integer == 0" do
|
48
48
|
verify_method :n
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
52
|
-
Registry.at('A#m').visibility.
|
53
|
-
Registry.at('A#mnot').visibility.
|
51
|
+
it "maintains visibility and scope state inside condition" do
|
52
|
+
expect(Registry.at('A#m').visibility).to eq :private
|
53
|
+
expect(Registry.at('A#mnot').visibility).to eq :private
|
54
54
|
end
|
55
55
|
|
56
|
-
it "
|
57
|
-
log.
|
58
|
-
log.
|
56
|
+
it "does not fail on complex conditions" do
|
57
|
+
expect(log).not_to receive(:warn)
|
58
|
+
expect(log).not_to receive(:error)
|
59
59
|
no_undoc_error "if defined?(A) && defined?(B); puts 'hi' end"
|
60
60
|
no_undoc_error(<<-eof)
|
61
61
|
(<<-TEST) unless defined?(ABCD_MODEL_TEST)
|
@@ -3,176 +3,176 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ClassHandler" do
|
4
4
|
before(:all) { parse_file :class_handler_001, __FILE__ }
|
5
5
|
|
6
|
-
it "
|
7
|
-
P("A").docstring.
|
6
|
+
it "parses a class block with docstring" do
|
7
|
+
expect(P("A").docstring).to eq "Docstring"
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
11
|
-
P("A::B::C").
|
10
|
+
it "handles complex class names" do
|
11
|
+
expect(P("A::B::C")).not_to eq nil
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
15
|
-
P("A::B::C").superclass.
|
16
|
-
P("A::X").superclass.
|
14
|
+
it "handles the subclassing syntax" do
|
15
|
+
expect(P("A::B::C").superclass).to eq P(:String)
|
16
|
+
expect(P("A::X").superclass).to eq Registry.at("A::B::C")
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
20
|
-
P("A.classmethod1").
|
19
|
+
it "interprets class << self as a class level block" do
|
20
|
+
expect(P("A.classmethod1")).not_to eq nil
|
21
21
|
end
|
22
22
|
|
23
|
-
it "
|
24
|
-
P("A::B::C.Hello").
|
23
|
+
it "interprets class << ClassName as a class level block in ClassName's namespace" do
|
24
|
+
expect(P("A::B::C.Hello")).to be_instance_of(CodeObjects::MethodObject)
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
28
|
-
P("A::B::C#method1").visibility.
|
27
|
+
it "makes visibility public when parsing a block" do
|
28
|
+
expect(P("A::B::C#method1").visibility).to eq :public
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
32
|
-
P("A::B::C").superclass.type.
|
31
|
+
it "sets superclass type to :class if it is a Proxy" do
|
32
|
+
expect(P("A::B::C").superclass.type).to eq :class
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
36
|
-
P('B::A').superclass.
|
35
|
+
it "looks for a superclass before creating the class if it shares the same name" do
|
36
|
+
expect(P('B::A').superclass).to eq P('A')
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
40
|
-
Registry.at("MyRootClass").
|
39
|
+
it "handles class definitions in the form ::ClassName" do
|
40
|
+
expect(Registry.at("MyRootClass")).not_to be nil
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
44
|
-
P('Test1').superclass.
|
45
|
-
P('Test2').superclass.
|
46
|
-
P('Test6').superclass.
|
43
|
+
it "handles superclass as a constant-style method (camping style < R /path/)" do
|
44
|
+
expect(P('Test1').superclass).to eq P(:R)
|
45
|
+
expect(P('Test2').superclass).to eq P(:R)
|
46
|
+
expect(P('Test6').superclass).to eq P(:NotDelegateClass)
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
50
|
-
P('Test3').superclass.
|
51
|
-
P('Test4').superclass.
|
49
|
+
it "handles superclass with OStruct.new or Struct.new syntax (superclass should be OStruct/Struct)" do
|
50
|
+
expect(P('Test3').superclass).to eq P(:Struct)
|
51
|
+
expect(P('Test4').superclass).to eq P(:OStruct)
|
52
52
|
end
|
53
53
|
|
54
|
-
it "
|
55
|
-
P('Test5').superclass.
|
54
|
+
it "handles DelegateClass(CLASSNAME) superclass syntax" do
|
55
|
+
expect(P('Test5').superclass).to eq P(:Array)
|
56
56
|
end
|
57
57
|
|
58
|
-
it "
|
59
|
-
P('Q::Logger').superclass.
|
60
|
-
P('Q::Foo').superclass.
|
58
|
+
it "handles a superclass of the same name in the form ::ClassName" do
|
59
|
+
expect(P('Q::Logger').superclass).to eq P(:Logger)
|
60
|
+
expect(P('Q::Foo').superclass).not_to eq P('Q::Logger')
|
61
61
|
end
|
62
62
|
|
63
63
|
["CallMethod('test')", "VSD^#}}", 'not.aclass', 'self'].each do |klass|
|
64
|
-
it "
|
64
|
+
it "raises an UndocumentableError for invalid class '#{klass}'" do
|
65
65
|
with_parser(:ruby18) { undoc_error "class #{klass}; end" }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
['@@INVALID', 'hi', '$MYCLASS', 'AnotherClass.new'].each do |klass|
|
70
|
-
it "
|
71
|
-
YARD::CodeObjects::ClassObject.
|
70
|
+
it "raises an UndocumentableError for invalid superclass '#{klass}' but it should create the class." do
|
71
|
+
expect(YARD::CodeObjects::ClassObject).to receive(:new).with(Registry.root, 'A')
|
72
72
|
with_parser(:ruby18) { undoc_error "class A < #{klass}; end" }
|
73
|
-
Registry.at('A').superclass.
|
73
|
+
expect(Registry.at('A').superclass).to eq P(:Object)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
['not.aclass', 'self', 'AnotherClass.new'].each do |klass|
|
78
|
-
it "
|
78
|
+
it "raises an UndocumentableError if the constant class reference 'class << SomeConstant' does not point to a valid class name" do
|
79
79
|
with_parser(:ruby18) do
|
80
80
|
undoc_error <<-eof
|
81
81
|
CONST = #{klass}
|
82
82
|
class << CONST; end
|
83
83
|
eof
|
84
84
|
end
|
85
|
-
Registry.at(klass).
|
85
|
+
expect(Registry.at(klass)).to be nil
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
it "
|
90
|
-
Registry.at('String.classmethod').
|
89
|
+
it "documents 'class << SomeConstant' by using SomeConstant's value as a reference to the real class name" do
|
90
|
+
expect(Registry.at('String.classmethod')).not_to be nil
|
91
91
|
end
|
92
92
|
|
93
|
-
it "
|
94
|
-
Registry.at('Symbol.toString').
|
93
|
+
it "allows class << SomeRubyClass to create the class if it does not exist" do
|
94
|
+
expect(Registry.at('Symbol.toString')).not_to be nil
|
95
95
|
end
|
96
96
|
|
97
|
-
it "
|
97
|
+
it "documents 'class Exception' without running into superclass issues" do
|
98
98
|
Parser::SourceParser.parse_string <<-eof
|
99
99
|
class Exception
|
100
100
|
end
|
101
101
|
eof
|
102
|
-
Registry.at(:Exception).
|
102
|
+
expect(Registry.at(:Exception)).not_to be nil
|
103
103
|
end
|
104
104
|
|
105
|
-
it "
|
106
|
-
Registry.at(:RT).
|
107
|
-
Registry.at(:RT).superclass.
|
105
|
+
it "documents 'class RT < XX::RT' with proper superclass even if XX::RT is a proxy" do
|
106
|
+
expect(Registry.at(:RT)).not_to be nil
|
107
|
+
expect(Registry.at(:RT).superclass).to eq P('XX::RT')
|
108
108
|
end
|
109
109
|
|
110
|
-
it "
|
111
|
-
Registry.at(:Zebra).docstring.
|
110
|
+
it "does not overwrite docstring with an empty one" do
|
111
|
+
expect(Registry.at(:Zebra).docstring).to eq "Docstring 2"
|
112
112
|
end
|
113
113
|
|
114
|
-
it "
|
114
|
+
it "turns 'class Const < Struct.new(:sym)' into class Const with attr :sym" do
|
115
115
|
obj = Registry.at("Point")
|
116
|
-
obj.
|
116
|
+
expect(obj).to be_kind_of(CodeObjects::ClassObject)
|
117
117
|
attrs = obj.attributes[:instance]
|
118
118
|
[:x, :y, :z].each do |key|
|
119
|
-
attrs.
|
120
|
-
attrs[key][:read].
|
121
|
-
attrs[key][:write].
|
119
|
+
expect(attrs).to have_key(key)
|
120
|
+
expect(attrs[key][:read]).not_to be nil
|
121
|
+
expect(attrs[key][:write]).not_to be nil
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
it "
|
125
|
+
it "turns 'class Const < Struct.new('Name', :sym)' into class Const with attr :sym" do
|
126
126
|
obj = Registry.at("AnotherPoint")
|
127
|
-
obj.
|
127
|
+
expect(obj).to be_kind_of(CodeObjects::ClassObject)
|
128
128
|
attrs = obj.attributes[:instance]
|
129
129
|
[:a, :b, :c].each do |key|
|
130
|
-
attrs.
|
131
|
-
attrs[key][:read].
|
132
|
-
attrs[key][:write].
|
130
|
+
expect(attrs).to have_key(key)
|
131
|
+
expect(attrs[key][:read]).not_to be nil
|
132
|
+
expect(attrs[key][:write]).not_to be nil
|
133
133
|
end
|
134
134
|
|
135
|
-
Registry.at("XPoint").
|
135
|
+
expect(Registry.at("XPoint")).to be nil
|
136
136
|
end
|
137
137
|
|
138
|
-
it "
|
138
|
+
it "creates a Struct::Name class when class Const < Struct.new('Name', :sym) is found" do
|
139
139
|
obj = Registry.at("Struct::XPoint")
|
140
|
-
obj.
|
140
|
+
expect(obj).not_to be nil
|
141
141
|
end
|
142
142
|
|
143
|
-
it "
|
143
|
+
it "attaches attribtues to the generated Struct::Name class when Struct.new('Name') is used" do
|
144
144
|
obj = Registry.at("Struct::XPoint")
|
145
145
|
attrs = obj.attributes[:instance]
|
146
146
|
[:a, :b, :c].each do |key|
|
147
|
-
attrs.
|
148
|
-
attrs[key][:read].
|
149
|
-
attrs[key][:write].
|
147
|
+
expect(attrs).to have_key(key)
|
148
|
+
expect(attrs[key][:read]).not_to be nil
|
149
|
+
expect(attrs[key][:write]).not_to be nil
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
it "
|
153
|
+
it "uses @attr to set attribute descriptions on Struct subclasses" do
|
154
154
|
obj = Registry.at("DoccedStruct#input")
|
155
|
-
obj.docstring.
|
155
|
+
expect(obj.docstring).to eq "the input stream"
|
156
156
|
end
|
157
157
|
|
158
|
-
it "
|
158
|
+
it "uses @attr to set attribute types on Struct subclasses" do
|
159
159
|
obj = Registry.at("DoccedStruct#someproc")
|
160
|
-
obj.
|
161
|
-
obj.tag(:return).
|
162
|
-
obj.tag(:return).types.
|
160
|
+
expect(obj).not_to be nil
|
161
|
+
expect(obj.tag(:return)).not_to be nil
|
162
|
+
expect(obj.tag(:return).types).to eq ["Proc", "#call"]
|
163
163
|
end
|
164
164
|
|
165
|
-
it "
|
165
|
+
it "defaults types unspecified by @attr to Object on Struct subclasses" do
|
166
166
|
obj = Registry.at("DoccedStruct#mode")
|
167
|
-
obj.
|
168
|
-
obj.tag(:return).
|
169
|
-
obj.tag(:return).types.
|
167
|
+
expect(obj).not_to be nil
|
168
|
+
expect(obj.tag(:return)).not_to be nil
|
169
|
+
expect(obj.tag(:return).types).to eq ["Object"]
|
170
170
|
end
|
171
171
|
|
172
|
-
it "
|
172
|
+
it "creates parameters for writers of Struct subclass's attributes" do
|
173
173
|
obj = Registry.at("DoccedStruct#input=")
|
174
|
-
obj.tags(:param).size.
|
175
|
-
obj.tag(:param).types.
|
174
|
+
expect(obj.tags(:param).size).to eq 1
|
175
|
+
expect(obj.tag(:param).types).to eq ["IO"]
|
176
176
|
end
|
177
177
|
|
178
178
|
["SemiDoccedStruct", "NotAStruct"].each do |struct|
|
@@ -180,67 +180,67 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ClassHandler"
|
|
180
180
|
it "defines both readers and writers when @attr is used on Structs" do
|
181
181
|
obj = Registry.at(struct)
|
182
182
|
attrs = obj.attributes[:instance]
|
183
|
-
attrs[:first][:read].
|
184
|
-
attrs[:first][:write].
|
183
|
+
expect(attrs[:first][:read]).not_to be nil
|
184
|
+
expect(attrs[:first][:write]).not_to be nil
|
185
185
|
end
|
186
186
|
|
187
187
|
it "defines only a reader when only @attr_reader is used on Structs" do
|
188
188
|
obj = Registry.at(struct)
|
189
189
|
attrs = obj.attributes[:instance]
|
190
|
-
attrs[:second][:read].
|
191
|
-
attrs[:second][:write].
|
190
|
+
expect(attrs[:second][:read]).not_to be nil
|
191
|
+
expect(attrs[:second][:write]).to be nil
|
192
192
|
end
|
193
193
|
|
194
194
|
it "defines only a writer when only @attr_writer is used on Structs" do
|
195
195
|
obj = Registry.at(struct)
|
196
196
|
attrs = obj.attributes[:instance]
|
197
|
-
attrs[:third][:read].
|
198
|
-
attrs[:third][:write].
|
197
|
+
expect(attrs[:third][:read]).to be nil
|
198
|
+
expect(attrs[:third][:write]).not_to be nil
|
199
199
|
end
|
200
200
|
|
201
201
|
it "defines a reader with correct return types when @attr_reader is used on Structs" do
|
202
202
|
obj = Registry.at("#{struct}#second")
|
203
|
-
obj.tag(:return).types.
|
203
|
+
expect(obj.tag(:return).types).to eq ["Fixnum"]
|
204
204
|
end
|
205
205
|
|
206
206
|
it "defines a writer with correct parameter types when @attr_writer is used on Structs" do
|
207
207
|
obj = Registry.at("#{struct}#third=")
|
208
|
-
obj.tag(:param).types.
|
208
|
+
expect(obj.tag(:param).types).to eq ["Array"]
|
209
209
|
end
|
210
210
|
|
211
211
|
it "defines a reader and a writer when both @attr_reader and @attr_writer are used" do
|
212
212
|
obj = Registry.at(struct)
|
213
213
|
attrs = obj.attributes[:instance]
|
214
|
-
attrs[:fourth][:read].
|
215
|
-
attrs[:fourth][:write].
|
214
|
+
expect(attrs[:fourth][:read]).not_to be nil
|
215
|
+
expect(attrs[:fourth][:write]).not_to be nil
|
216
216
|
end
|
217
217
|
|
218
218
|
it "uses @attr_reader for the getter when both @attr_reader and @attr_writer are given" do
|
219
219
|
obj = Registry.at("#{struct}#fourth")
|
220
|
-
obj.tag(:return).types.
|
220
|
+
expect(obj.tag(:return).types).to eq ["#read"]
|
221
221
|
end
|
222
222
|
|
223
223
|
it "uses @attr_writer for the setter when both @attr_reader and @attr_writer are given" do
|
224
224
|
obj = Registry.at("#{struct}#fourth=")
|
225
|
-
obj.tag(:param).types.
|
225
|
+
expect(obj.tag(:param).types).to eq ["IO"]
|
226
226
|
end
|
227
227
|
|
228
228
|
it "extracts text from @attr_reader" do
|
229
|
-
Registry.at("#{struct}#fourth").docstring.
|
229
|
+
expect(Registry.at("#{struct}#fourth").docstring).to eq "returns a proc that reads"
|
230
230
|
end
|
231
231
|
|
232
232
|
it "extracts text from @attr_writer" do
|
233
|
-
Registry.at("#{struct}#fourth=").docstring.
|
233
|
+
expect(Registry.at("#{struct}#fourth=").docstring).to eq "sets the proc that writes stuff"
|
234
234
|
end
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
238
|
-
it "
|
239
|
-
Registry.at('RegularStruct').superclass.
|
240
|
-
Registry.at('RegularStruct2').superclass.
|
238
|
+
it "inherits from a regular struct" do
|
239
|
+
expect(Registry.at('RegularStruct').superclass).to eq P(:Struct)
|
240
|
+
expect(Registry.at('RegularStruct2').superclass).to eq P(:Struct)
|
241
241
|
end
|
242
242
|
|
243
|
-
it "
|
244
|
-
Registry.at('Outer1::Inner1').superclass.
|
243
|
+
it "handles inheritance from 'self'" do
|
244
|
+
expect(Registry.at('Outer1::Inner1').superclass).to eq Registry.at('Outer1')
|
245
245
|
end
|
246
246
|
end
|