yard 0.9.24 → 0.9.25
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/.rubocop.yml +37 -24
- data/CHANGELOG.md +18 -3
- data/README.md +96 -101
- data/Rakefile +2 -0
- data/lib/yard/cli/diff.rb +4 -1
- data/lib/yard/cli/server.rb +22 -13
- data/lib/yard/code_objects/proxy.rb +2 -1
- data/lib/yard/globals.rb +1 -1
- data/lib/yard/handlers/c/base.rb +164 -129
- data/lib/yard/parser/ruby/ruby_parser.rb +6 -4
- data/lib/yard/registry_store.rb +1 -1
- data/lib/yard/templates/helpers/html_helper.rb +10 -3
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +5 -4
- data/lib/yard/version.rb +1 -1
- data/tasks/update_error_map.rake +53 -0
- data/yard.gemspec +1 -1
- metadata +3 -207
- data/spec/cli/command_parser_spec.rb +0 -43
- data/spec/cli/command_spec.rb +0 -36
- data/spec/cli/config_spec.rb +0 -148
- data/spec/cli/diff_spec.rb +0 -254
- data/spec/cli/display_spec.rb +0 -30
- data/spec/cli/gems_spec.rb +0 -81
- data/spec/cli/graph_spec.rb +0 -18
- data/spec/cli/help_spec.rb +0 -22
- data/spec/cli/i18n_spec.rb +0 -107
- data/spec/cli/list_spec.rb +0 -8
- data/spec/cli/markup_types_spec.rb +0 -22
- data/spec/cli/server_spec.rb +0 -324
- data/spec/cli/stats_spec.rb +0 -96
- data/spec/cli/yard_on_yard_spec.rb +0 -38
- data/spec/cli/yardoc_spec.rb +0 -896
- data/spec/cli/yri_spec.rb +0 -101
- data/spec/code_objects/base_spec.rb +0 -485
- data/spec/code_objects/class_object_spec.rb +0 -226
- data/spec/code_objects/code_object_list_spec.rb +0 -36
- data/spec/code_objects/constants_spec.rb +0 -116
- data/spec/code_objects/extra_file_object_spec.rb +0 -161
- data/spec/code_objects/macro_object_spec.rb +0 -150
- data/spec/code_objects/method_object_spec.rb +0 -184
- data/spec/code_objects/module_object_spec.rb +0 -142
- data/spec/code_objects/namespace_mapper_spec.rb +0 -32
- data/spec/code_objects/namespace_object_spec.rb +0 -171
- data/spec/code_objects/proxy_spec.rb +0 -147
- data/spec/code_objects/spec_helper.rb +0 -3
- data/spec/config_spec.rb +0 -171
- data/spec/core_ext/array_spec.rb +0 -13
- data/spec/core_ext/file_spec.rb +0 -72
- data/spec/core_ext/hash_spec.rb +0 -14
- data/spec/core_ext/insertion_spec.rb +0 -37
- data/spec/core_ext/module_spec.rb +0 -9
- data/spec/core_ext/string_spec.rb +0 -42
- data/spec/core_ext/symbol_hash_spec.rb +0 -89
- data/spec/docstring_parser_spec.rb +0 -280
- data/spec/docstring_spec.rb +0 -373
- data/spec/handlers/alias_handler_spec.rb +0 -82
- data/spec/handlers/attribute_handler_spec.rb +0 -96
- data/spec/handlers/base_spec.rb +0 -216
- data/spec/handlers/c/alias_handler_spec.rb +0 -34
- data/spec/handlers/c/attribute_handler_spec.rb +0 -41
- data/spec/handlers/c/class_handler_spec.rb +0 -78
- data/spec/handlers/c/constant_handler_spec.rb +0 -71
- data/spec/handlers/c/init_handler_spec.rb +0 -48
- data/spec/handlers/c/method_handler_spec.rb +0 -327
- data/spec/handlers/c/mixin_handler_spec.rb +0 -44
- data/spec/handlers/c/module_handler_spec.rb +0 -71
- data/spec/handlers/c/override_comment_handler_spec.rb +0 -47
- data/spec/handlers/c/path_handler_spec.rb +0 -36
- data/spec/handlers/c/spec_helper.rb +0 -23
- data/spec/handlers/c/struct_handler_spec.rb +0 -16
- data/spec/handlers/class_condition_handler_spec.rb +0 -87
- data/spec/handlers/class_handler_spec.rb +0 -247
- data/spec/handlers/class_method_handler_shared_examples.rb +0 -133
- data/spec/handlers/class_variable_handler_spec.rb +0 -12
- data/spec/handlers/constant_handler_spec.rb +0 -112
- data/spec/handlers/decorator_handler_methods_spec.rb +0 -393
- data/spec/handlers/dsl_handler_spec.rb +0 -226
- data/spec/handlers/examples/alias_handler_001.rb.txt +0 -46
- data/spec/handlers/examples/attribute_handler_001.rb.txt +0 -32
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +0 -69
- data/spec/handlers/examples/class_handler_001.rb.txt +0 -120
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +0 -10
- data/spec/handlers/examples/constant_handler_001.rb.txt +0 -35
- data/spec/handlers/examples/dsl_handler_001.rb.txt +0 -156
- data/spec/handlers/examples/exception_handler_001.rb.txt +0 -59
- data/spec/handlers/examples/extend_handler_001.rb.txt +0 -19
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +0 -10
- data/spec/handlers/examples/method_handler_001.rb.txt +0 -128
- data/spec/handlers/examples/mixin_handler_001.rb.txt +0 -40
- data/spec/handlers/examples/module_handler_001.rb.txt +0 -29
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +0 -8
- data/spec/handlers/examples/process_handler_001.rb.txt +0 -11
- data/spec/handlers/examples/visibility_handler_001.rb.txt +0 -36
- data/spec/handlers/examples/yield_handler_001.rb.txt +0 -54
- data/spec/handlers/exception_handler_spec.rb +0 -49
- data/spec/handlers/extend_handler_spec.rb +0 -28
- data/spec/handlers/legacy_base_spec.rb +0 -128
- data/spec/handlers/method_condition_handler_spec.rb +0 -15
- data/spec/handlers/method_handler_spec.rb +0 -214
- data/spec/handlers/mixin_handler_spec.rb +0 -60
- data/spec/handlers/module_function_handler_spec.rb +0 -106
- data/spec/handlers/module_handler_spec.rb +0 -35
- data/spec/handlers/private_class_method_handler_spec.rb +0 -11
- data/spec/handlers/private_constant_handler_spec.rb +0 -25
- data/spec/handlers/processor_spec.rb +0 -35
- data/spec/handlers/public_class_method_handler_spec.rb +0 -11
- data/spec/handlers/ruby/base_spec.rb +0 -95
- data/spec/handlers/ruby/legacy/base_spec.rb +0 -84
- data/spec/handlers/spec_helper.rb +0 -33
- data/spec/handlers/visibility_handler_spec.rb +0 -44
- data/spec/handlers/yield_handler_spec.rb +0 -52
- data/spec/i18n/locale_spec.rb +0 -81
- data/spec/i18n/message_spec.rb +0 -52
- data/spec/i18n/messages_spec.rb +0 -67
- data/spec/i18n/pot_generator_spec.rb +0 -295
- data/spec/i18n/text_spec.rb +0 -184
- data/spec/logging_spec.rb +0 -44
- data/spec/options_spec.rb +0 -171
- data/spec/parser/base_spec.rb +0 -24
- data/spec/parser/c_parser_spec.rb +0 -236
- data/spec/parser/examples/array.c.txt +0 -6267
- data/spec/parser/examples/example1.rb.txt +0 -8
- data/spec/parser/examples/extrafile.c.txt +0 -8
- data/spec/parser/examples/file.c.txt +0 -28
- data/spec/parser/examples/multifile.c.txt +0 -22
- data/spec/parser/examples/namespace.cpp.txt +0 -68
- data/spec/parser/examples/override.c.txt +0 -424
- data/spec/parser/examples/parse_in_order_001.rb.txt +0 -2
- data/spec/parser/examples/parse_in_order_002.rb.txt +0 -2
- data/spec/parser/examples/tag_handler_001.rb.txt +0 -8
- data/spec/parser/ruby/ast_node_spec.rb +0 -33
- data/spec/parser/ruby/legacy/statement_list_spec.rb +0 -299
- data/spec/parser/ruby/legacy/token_list_spec.rb +0 -79
- data/spec/parser/ruby/ruby_parser_spec.rb +0 -520
- data/spec/parser/ruby/token_resolver_spec.rb +0 -165
- data/spec/parser/source_parser_spec.rb +0 -727
- data/spec/parser/tag_parsing_spec.rb +0 -17
- data/spec/rake/yardoc_task_spec.rb +0 -118
- data/spec/registry_resolver_spec.rb +0 -15
- data/spec/registry_spec.rb +0 -463
- data/spec/registry_store_spec.rb +0 -327
- data/spec/rubygems/doc_manager_spec.rb +0 -112
- data/spec/serializers/data/serialized_yardoc/checksums +0 -1
- data/spec/serializers/data/serialized_yardoc/objects/Foo.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/root.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/proxy_types +0 -2
- data/spec/serializers/file_system_serializer_spec.rb +0 -145
- data/spec/serializers/spec_helper.rb +0 -2
- data/spec/serializers/yardoc_serializer_spec.rb +0 -90
- data/spec/server/adapter_spec.rb +0 -39
- data/spec/server/commands/base_spec.rb +0 -91
- data/spec/server/commands/library_command_spec.rb +0 -39
- data/spec/server/doc_server_helper_spec.rb +0 -72
- data/spec/server/doc_server_serializer_spec.rb +0 -60
- data/spec/server/rack_adapter_spec.rb +0 -21
- data/spec/server/router_spec.rb +0 -123
- data/spec/server/spec_helper.rb +0 -22
- data/spec/server/static_caching_spec.rb +0 -47
- data/spec/server/webrick_servlet_spec.rb +0 -20
- data/spec/server_spec.rb +0 -19
- data/spec/spec_helper.rb +0 -212
- data/spec/tags/default_factory_spec.rb +0 -168
- data/spec/tags/default_tag_spec.rb +0 -11
- data/spec/tags/directives_spec.rb +0 -463
- data/spec/tags/library_spec.rb +0 -48
- data/spec/tags/overload_tag_spec.rb +0 -53
- data/spec/tags/ref_tag_list_spec.rb +0 -53
- data/spec/tags/types_explainer_spec.rb +0 -203
- data/spec/templates/class_spec.rb +0 -45
- data/spec/templates/constant_spec.rb +0 -41
- data/spec/templates/engine_spec.rb +0 -131
- data/spec/templates/examples/class001.html +0 -308
- data/spec/templates/examples/class001.txt +0 -36
- data/spec/templates/examples/class002.html +0 -39
- data/spec/templates/examples/constant001.txt +0 -25
- data/spec/templates/examples/constant002.txt +0 -7
- data/spec/templates/examples/constant003.txt +0 -11
- data/spec/templates/examples/method001.html +0 -137
- data/spec/templates/examples/method001.txt +0 -35
- data/spec/templates/examples/method002.html +0 -91
- data/spec/templates/examples/method002.txt +0 -20
- data/spec/templates/examples/method003.html +0 -165
- data/spec/templates/examples/method003.txt +0 -45
- data/spec/templates/examples/method004.html +0 -48
- data/spec/templates/examples/method004.txt +0 -10
- data/spec/templates/examples/method005.html +0 -105
- data/spec/templates/examples/method005.txt +0 -33
- data/spec/templates/examples/method006.html +0 -108
- data/spec/templates/examples/method006.txt +0 -20
- data/spec/templates/examples/module001.dot +0 -33
- data/spec/templates/examples/module001.html +0 -833
- data/spec/templates/examples/module001.txt +0 -33
- data/spec/templates/examples/module002.html +0 -341
- data/spec/templates/examples/module003.html +0 -202
- data/spec/templates/examples/module004.html +0 -394
- data/spec/templates/examples/module005.html +0 -82
- data/spec/templates/examples/tag001.txt +0 -82
- data/spec/templates/helpers/base_helper_spec.rb +0 -171
- data/spec/templates/helpers/html_helper_spec.rb +0 -666
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +0 -65
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +0 -84
- data/spec/templates/helpers/markup_helper_spec.rb +0 -136
- data/spec/templates/helpers/method_helper_spec.rb +0 -107
- data/spec/templates/helpers/module_helper_spec.rb +0 -35
- data/spec/templates/helpers/shared_signature_examples.rb +0 -126
- data/spec/templates/helpers/text_helper_spec.rb +0 -65
- data/spec/templates/markup_processor_integrations/asciidoctor_spec.rb +0 -60
- data/spec/templates/markup_processor_integrations/integration_spec_helper.rb +0 -50
- data/spec/templates/markup_processor_integrations/rdoc_markdown_spec.rb +0 -48
- data/spec/templates/markup_processor_integrations/rdoc_spec.rb +0 -39
- data/spec/templates/markup_processor_integrations/redcarpet_spec.rb +0 -64
- data/spec/templates/markup_processor_integrations/redcloth_spec.rb +0 -64
- data/spec/templates/method_spec.rb +0 -118
- data/spec/templates/module_spec.rb +0 -203
- data/spec/templates/onefile_spec.rb +0 -66
- data/spec/templates/section_spec.rb +0 -144
- data/spec/templates/spec_helper.rb +0 -76
- data/spec/templates/tag_spec.rb +0 -52
- data/spec/templates/template_spec.rb +0 -410
- data/spec/verifier_spec.rb +0 -106
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
3
|
-
|
4
|
-
RSpec.describe YARD::Handlers::C::ConstantHandler do
|
5
|
-
it "registers constants" do
|
6
|
-
parse_init <<-eof
|
7
|
-
mFoo = rb_define_module("Foo");
|
8
|
-
rb_define_const(mFoo, "FOO", ID2SYM(100));
|
9
|
-
rb_define_global_const("BAR", ID2SYM(100));
|
10
|
-
eof
|
11
|
-
expect(Registry.at('Foo::FOO').type).to eq :constant
|
12
|
-
expect(Registry.at('BAR').type).to eq :constant
|
13
|
-
end
|
14
|
-
|
15
|
-
it "looks for override comments" do
|
16
|
-
parse <<-eof
|
17
|
-
/* Document-const: FOO
|
18
|
-
* Document-const: Foo::BAR
|
19
|
-
* Foo bar!
|
20
|
-
*/
|
21
|
-
|
22
|
-
void Init_Foo() {
|
23
|
-
mFoo = rb_define_module("Foo");
|
24
|
-
rb_define_const(mFoo, "FOO", ID2SYM(100));
|
25
|
-
rb_define_const(mFoo, "BAR", ID2SYM(101));
|
26
|
-
}
|
27
|
-
eof
|
28
|
-
foo = Registry.at('Foo::FOO')
|
29
|
-
expect(foo.type).to eq :constant
|
30
|
-
expect(foo.docstring).to eq 'Foo bar!'
|
31
|
-
expect(foo.value).to eq 'ID2SYM(100)'
|
32
|
-
expect(foo.file).to eq '(stdin)'
|
33
|
-
expect(foo.line).to eq 8
|
34
|
-
bar = Registry.at('Foo::BAR')
|
35
|
-
expect(bar.type).to eq :constant
|
36
|
-
expect(bar.docstring).to eq 'Foo bar!'
|
37
|
-
expect(bar.file).to eq '(stdin)'
|
38
|
-
expect(bar.line).to eq 9
|
39
|
-
expect(bar.value).to eq 'ID2SYM(101)'
|
40
|
-
end
|
41
|
-
|
42
|
-
it "uses comment attached to declaration as fallback" do
|
43
|
-
parse_init <<-eof
|
44
|
-
mFoo = rb_define_module("Foo");
|
45
|
-
rb_define_const(mFoo, "FOO", ID2SYM(100)); // foobar!
|
46
|
-
eof
|
47
|
-
foo = Registry.at('Foo::FOO')
|
48
|
-
expect(foo.value).to eq 'ID2SYM(100)'
|
49
|
-
expect(foo.docstring).to eq 'foobar!'
|
50
|
-
end
|
51
|
-
|
52
|
-
it "allows the form VALUE: DOCSTRING to document value" do
|
53
|
-
parse_init <<-eof
|
54
|
-
mFoo = rb_define_module("Foo");
|
55
|
-
rb_define_const(mFoo, "FOO", ID2SYM(100)); // 100: foobar!
|
56
|
-
eof
|
57
|
-
foo = Registry.at('Foo::FOO')
|
58
|
-
expect(foo.value).to eq '100'
|
59
|
-
expect(foo.docstring).to eq 'foobar!'
|
60
|
-
end
|
61
|
-
|
62
|
-
it "allows escaping of backslashes in VALUE: DOCSTRING syntax" do
|
63
|
-
parse_init <<-eof
|
64
|
-
mFoo = rb_define_module("Foo");
|
65
|
-
rb_define_const(mFoo, "FOO", ID2SYM(100)); // 100\\:x\\:y: foobar:x!
|
66
|
-
eof
|
67
|
-
foo = Registry.at('Foo::FOO')
|
68
|
-
expect(foo.value).to eq '100:x:y'
|
69
|
-
expect(foo.docstring).to eq 'foobar:x!'
|
70
|
-
end
|
71
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
3
|
-
|
4
|
-
RSpec.describe YARD::Handlers::C::InitHandler do
|
5
|
-
it "adds documentation in Init_ClassName() to ClassName" do
|
6
|
-
parse(<<-eof)
|
7
|
-
// Bar!
|
8
|
-
void Init_A() {
|
9
|
-
rb_cA = rb_define_class("A", rb_cObject);
|
10
|
-
}
|
11
|
-
eof
|
12
|
-
expect(Registry.at('A').docstring).to eq 'Bar!'
|
13
|
-
end
|
14
|
-
|
15
|
-
it "does not add documentation if ClassName is not created in Init" do
|
16
|
-
parse(<<-eof)
|
17
|
-
// Bar!
|
18
|
-
void Init_A() {
|
19
|
-
}
|
20
|
-
eof
|
21
|
-
expect(Registry.at('A')).to be nil
|
22
|
-
end
|
23
|
-
|
24
|
-
it "does not overwrite override comment" do
|
25
|
-
parse(<<-eof)
|
26
|
-
/* Document-class: A
|
27
|
-
* Foo!
|
28
|
-
*/
|
29
|
-
|
30
|
-
// Bar!
|
31
|
-
static SWIGEXPORT void Init_A() {
|
32
|
-
rb_cA = rb_define_class("A", rb_cObject);
|
33
|
-
}
|
34
|
-
eof
|
35
|
-
expect(Registry.at('A').docstring).to eq 'Foo!'
|
36
|
-
end
|
37
|
-
|
38
|
-
it "checks non-Init methods for declarations too" do
|
39
|
-
parse(<<-eof)
|
40
|
-
void foo(int x, int y, char *name) {
|
41
|
-
rb_cB = rb_define_class("B", rb_cObject);
|
42
|
-
rb_define_method(rb_cB, "foo", foo_impl, 0);
|
43
|
-
}
|
44
|
-
eof
|
45
|
-
expect(Registry.at('B')).to be_a(CodeObjects::ClassObject)
|
46
|
-
expect(Registry.at('B#foo')).to be_a(CodeObjects::MethodObject)
|
47
|
-
end
|
48
|
-
end
|
@@ -1,327 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
3
|
-
|
4
|
-
RSpec.describe YARD::Handlers::C::MethodHandler do
|
5
|
-
it "registers methods" do
|
6
|
-
parse_init <<-eof
|
7
|
-
mFoo = rb_define_module("Foo");
|
8
|
-
rb_define_method(mFoo, "bar", bar, 0);
|
9
|
-
eof
|
10
|
-
expect(Registry.at('Foo#bar')).not_to be nil
|
11
|
-
expect(Registry.at('Foo#bar').visibility).to eq :public
|
12
|
-
end
|
13
|
-
|
14
|
-
it "registers private methods" do
|
15
|
-
parse_init <<-eof
|
16
|
-
mFoo = rb_define_module("Foo");
|
17
|
-
rb_define_private_method(mFoo, "bar", bar, 0);
|
18
|
-
eof
|
19
|
-
expect(Registry.at('Foo#bar')).not_to be nil
|
20
|
-
expect(Registry.at('Foo#bar').visibility).to eq :private
|
21
|
-
end
|
22
|
-
|
23
|
-
it "registers singleton methods" do
|
24
|
-
parse_init <<-eof
|
25
|
-
mFoo = rb_define_module("Foo");
|
26
|
-
rb_define_singleton_method(mFoo, "bar", bar, 0);
|
27
|
-
eof
|
28
|
-
expect(Registry.at('Foo.bar')).not_to be nil
|
29
|
-
expect(Registry.at('Foo.bar').visibility).to eq :public
|
30
|
-
end
|
31
|
-
|
32
|
-
it "registers module functions" do
|
33
|
-
parse <<-eof
|
34
|
-
/* DOCSTRING
|
35
|
-
* @return [String] foo!
|
36
|
-
*/
|
37
|
-
static VALUE bar(VALUE self) { x(); y(); z(); }
|
38
|
-
|
39
|
-
void Init_Foo() {
|
40
|
-
mFoo = rb_define_module("Foo");
|
41
|
-
rb_define_module_function(mFoo, "bar", bar, 0);
|
42
|
-
}
|
43
|
-
eof
|
44
|
-
bar_c = Registry.at('Foo.bar')
|
45
|
-
bar_i = Registry.at('Foo#bar')
|
46
|
-
expect(bar_c).to be_module_function
|
47
|
-
expect(bar_c.visibility).to eq :public
|
48
|
-
expect(bar_c.docstring).to eq "DOCSTRING"
|
49
|
-
expect(bar_c.tag(:return).object).to eq bar_c
|
50
|
-
expect(bar_c.source).to eq "static VALUE bar(VALUE self) { x(); y(); z(); }"
|
51
|
-
expect(bar_i).not_to be_module_function
|
52
|
-
expect(bar_i.visibility).to eq :private
|
53
|
-
expect(bar_i.docstring).to eq "DOCSTRING"
|
54
|
-
expect(bar_i.tag(:return).object).to eq bar_i
|
55
|
-
expect(bar_i.source).to eq bar_c.source
|
56
|
-
end
|
57
|
-
|
58
|
-
it "registers global functions into Kernel" do
|
59
|
-
parse_init 'rb_define_global_function("bar", bar, 0);'
|
60
|
-
expect(Registry.at('Kernel#bar')).not_to be nil
|
61
|
-
end
|
62
|
-
|
63
|
-
it "looks for symbol containing method source" do
|
64
|
-
parse <<-eof
|
65
|
-
static VALUE foo(VALUE self) { x(); y(); z(); }
|
66
|
-
VALUE bar() { a(); b(); c(); }
|
67
|
-
void Init_Foo() {
|
68
|
-
mFoo = rb_define_module("Foo");
|
69
|
-
rb_define_method(mFoo, "foo", foo, 0);
|
70
|
-
rb_define_method(mFoo, "bar", bar, 0);
|
71
|
-
}
|
72
|
-
eof
|
73
|
-
foo = Registry.at('Foo#foo')
|
74
|
-
bar = Registry.at('Foo#bar')
|
75
|
-
expect(foo.source).to eq "static VALUE foo(VALUE self) { x(); y(); z(); }"
|
76
|
-
expect(foo.file).to eq '(stdin)'
|
77
|
-
expect(foo.line).to eq 1
|
78
|
-
expect(bar.source).to eq "VALUE bar() { a(); b(); c(); }"
|
79
|
-
expect(bar.file).to eq '(stdin)'
|
80
|
-
expect(bar.line).to eq 2
|
81
|
-
end
|
82
|
-
|
83
|
-
it "finds docstrings attached to method symbols" do
|
84
|
-
parse <<-eof
|
85
|
-
/* DOCSTRING */
|
86
|
-
static VALUE foo(VALUE self) { x(); y(); z(); }
|
87
|
-
void Init_Foo() {
|
88
|
-
mFoo = rb_define_module("Foo");
|
89
|
-
rb_define_method(mFoo, "foo", foo, 0);
|
90
|
-
}
|
91
|
-
eof
|
92
|
-
foo = Registry.at('Foo#foo')
|
93
|
-
expect(foo.docstring).to eq 'DOCSTRING'
|
94
|
-
end
|
95
|
-
|
96
|
-
it "uses declaration comments as docstring if there are no others" do
|
97
|
-
parse <<-eof
|
98
|
-
static VALUE foo(VALUE self) { x(); y(); z(); }
|
99
|
-
void Init_Foo() {
|
100
|
-
mFoo = rb_define_module("Foo");
|
101
|
-
/* DOCSTRING */
|
102
|
-
rb_define_method(mFoo, "foo", foo, 0);
|
103
|
-
// DOCSTRING!
|
104
|
-
rb_define_method(mFoo, "bar", bar, 0);
|
105
|
-
}
|
106
|
-
eof
|
107
|
-
foo = Registry.at('Foo#foo')
|
108
|
-
expect(foo.docstring).to eq 'DOCSTRING'
|
109
|
-
bar = Registry.at('Foo#bar')
|
110
|
-
expect(bar.docstring).to eq 'DOCSTRING!'
|
111
|
-
end
|
112
|
-
|
113
|
-
it "looks for symbols in other file" do
|
114
|
-
other = <<-eof
|
115
|
-
/* DOCSTRING! */
|
116
|
-
static VALUE foo() { x(); }
|
117
|
-
eof
|
118
|
-
expect(File).to receive(:read).with('other.c').and_return(other)
|
119
|
-
parse <<-eof
|
120
|
-
void Init_Foo() {
|
121
|
-
mFoo = rb_define_module("Foo");
|
122
|
-
rb_define_method(mFoo, "foo", foo, 0); // in other.c
|
123
|
-
}
|
124
|
-
eof
|
125
|
-
foo = Registry.at('Foo#foo')
|
126
|
-
expect(foo.docstring).to eq 'DOCSTRING!'
|
127
|
-
expect(foo.file).to eq 'other.c'
|
128
|
-
expect(foo.line).to eq 2
|
129
|
-
expect(foo.source).to eq 'static VALUE foo() { x(); }'
|
130
|
-
end
|
131
|
-
|
132
|
-
it "allows extra file to include /'s and other filename characters" do
|
133
|
-
expect(File).to receive(:read).at_least(1).times.with('ext/a-file.c').and_return(<<-eof)
|
134
|
-
/* FOO */
|
135
|
-
VALUE foo(VALUE x) { int value = x; }
|
136
|
-
|
137
|
-
/* BAR */
|
138
|
-
VALUE bar(VALUE x) { int value = x; }
|
139
|
-
eof
|
140
|
-
parse_init <<-eof
|
141
|
-
rb_define_method(rb_cFoo, "foo", foo, 1); /* in ext/a-file.c */
|
142
|
-
rb_define_global_function("bar", bar, 1); /* in ext/a-file.c */
|
143
|
-
eof
|
144
|
-
expect(Registry.at('Foo#foo').docstring).to eq 'FOO'
|
145
|
-
expect(Registry.at('Kernel#bar').docstring).to eq 'BAR'
|
146
|
-
end
|
147
|
-
|
148
|
-
it "warns if other file can't be found" do
|
149
|
-
expect(log).to receive(:warn).with(/Missing source file `other.c' when parsing Foo#foo/)
|
150
|
-
parse <<-eof
|
151
|
-
void Init_Foo() {
|
152
|
-
mFoo = rb_define_module("Foo");
|
153
|
-
rb_define_method(mFoo, "foo", foo, 0); // in other.c
|
154
|
-
}
|
155
|
-
eof
|
156
|
-
end
|
157
|
-
|
158
|
-
it "looks at override comments for docstring" do
|
159
|
-
parse <<-eof
|
160
|
-
/* Document-method: Foo::foo
|
161
|
-
* Document-method: new
|
162
|
-
* Document-method: Foo::Bar#baz
|
163
|
-
* Foo bar!
|
164
|
-
*/
|
165
|
-
|
166
|
-
// init comments
|
167
|
-
void Init_Foo() {
|
168
|
-
mFoo = rb_define_module("Foo");
|
169
|
-
rb_define_method(mFoo, "foo", foo, 0);
|
170
|
-
rb_define_method(mFoo, "initialize", foo, 0);
|
171
|
-
mBar = rb_define_module_under(mFoo, "Bar");
|
172
|
-
rb_define_method(mBar, "baz", foo, 0);
|
173
|
-
}
|
174
|
-
eof
|
175
|
-
expect(Registry.at('Foo#foo').docstring).to eq 'Foo bar!'
|
176
|
-
expect(Registry.at('Foo#initialize').docstring).to eq 'Foo bar!'
|
177
|
-
expect(Registry.at('Foo::Bar#baz').docstring).to eq 'Foo bar!'
|
178
|
-
end
|
179
|
-
|
180
|
-
it "looks at overrides in other files" do
|
181
|
-
other = <<-eof
|
182
|
-
/* Document-method: Foo::foo
|
183
|
-
* Document-method: new
|
184
|
-
* Document-method: Foo::Bar#baz
|
185
|
-
* Foo bar!
|
186
|
-
*/
|
187
|
-
eof
|
188
|
-
expect(File).to receive(:read).with('foo/bar/other.c').and_return(other)
|
189
|
-
src = <<-eof
|
190
|
-
void Init_Foo() {
|
191
|
-
mFoo = rb_define_module("Foo");
|
192
|
-
rb_define_method(mFoo, "foo", foo, 0); // in foo/bar/other.c
|
193
|
-
rb_define_method(mFoo, "initialize", foo, 0); // in foo/bar/other.c
|
194
|
-
mBar = rb_define_module_under(mFoo, "Bar"); // in foo/bar/other.c
|
195
|
-
rb_define_method(mBar, "baz", foo, 0); // in foo/bar/other.c
|
196
|
-
}
|
197
|
-
eof
|
198
|
-
parse(src, 'foo/bar/baz/init.c')
|
199
|
-
expect(Registry.at('Foo#foo').docstring).to eq 'Foo bar!'
|
200
|
-
expect(Registry.at('Foo#initialize').docstring).to eq 'Foo bar!'
|
201
|
-
expect(Registry.at('Foo::Bar#baz').docstring).to eq 'Foo bar!'
|
202
|
-
end
|
203
|
-
|
204
|
-
it "adds return tag on methods ending in '?'" do
|
205
|
-
parse <<-eof
|
206
|
-
/* DOCSTRING */
|
207
|
-
static VALUE foo(VALUE self) { x(); y(); z(); }
|
208
|
-
void Init_Foo() {
|
209
|
-
mFoo = rb_define_module("Foo");
|
210
|
-
rb_define_method(mFoo, "foo?", foo, 0);
|
211
|
-
}
|
212
|
-
eof
|
213
|
-
foo = Registry.at('Foo#foo?')
|
214
|
-
expect(foo.docstring).to eq 'DOCSTRING'
|
215
|
-
expect(foo.tag(:return).types).to eq ['Boolean']
|
216
|
-
expect(foo.tags(:return).size).to eq 1
|
217
|
-
end
|
218
|
-
|
219
|
-
it "does not add return tag if return tags exist" do
|
220
|
-
parse <<-eof
|
221
|
-
// @return [String] foo
|
222
|
-
static VALUE foo(VALUE self) { x(); y(); z(); }
|
223
|
-
void Init_Foo() {
|
224
|
-
mFoo = rb_define_module("Foo");
|
225
|
-
rb_define_method(mFoo, "foo?", foo, 0);
|
226
|
-
}
|
227
|
-
eof
|
228
|
-
foo = Registry.at('Foo#foo?')
|
229
|
-
expect(foo.tag(:return).types).to eq ['String']
|
230
|
-
expect(foo.tags(:return).size).to eq 1
|
231
|
-
end
|
232
|
-
|
233
|
-
it "handles casted method names" do
|
234
|
-
parse_init <<-eof
|
235
|
-
mFoo = rb_define_module("Foo");
|
236
|
-
rb_define_method(mFoo, "bar", (METHOD)bar, 0);
|
237
|
-
rb_define_global_function("baz", (METHOD)baz, 0);
|
238
|
-
eof
|
239
|
-
expect(Registry.at('Foo#bar')).not_to be nil
|
240
|
-
expect(Registry.at('Kernel#baz')).not_to be nil
|
241
|
-
end
|
242
|
-
|
243
|
-
it "extracts at regular method parameters from C function signatures" do
|
244
|
-
parse <<-eof
|
245
|
-
static VALUE noargs_func(VALUE self) { return Qnil; }
|
246
|
-
static VALUE twoargs_func(VALUE self, VALUE a, VALUE b) { return a; }
|
247
|
-
void Init_Foo() {
|
248
|
-
mFoo = rb_define_module("Foo");
|
249
|
-
rb_define_method(mFoo, "noargs", noargs_func, 0);
|
250
|
-
rb_define_method(mFoo, "twoargs", twoargs_func, 2);
|
251
|
-
}
|
252
|
-
eof
|
253
|
-
expect(Registry.at('Foo#noargs').parameters).to be_empty
|
254
|
-
expect(Registry.at('Foo#twoargs').parameters).to eq [['a', nil], ['b', nil]]
|
255
|
-
end
|
256
|
-
|
257
|
-
it "extracts at varargs method parameters from C function signatures" do
|
258
|
-
parse <<-eof
|
259
|
-
static VALUE varargs_func(int argc, VALUE *argv, VALUE self) { return self; }
|
260
|
-
/* let's see if parser is robust in the face of strange spacing */
|
261
|
-
static VALUE varargs_func2( int argc , VALUE
|
262
|
-
* argv ,VALUE self )
|
263
|
-
|
264
|
-
{return self;}
|
265
|
-
void Init_Foo() {
|
266
|
-
mFoo = rb_define_module("Foo");
|
267
|
-
rb_define_method(mFoo, "varargs", varargs_func, -1);
|
268
|
-
rb_define_method( mFoo ,"varargs2",varargs_func2 ,-1);
|
269
|
-
}
|
270
|
-
eof
|
271
|
-
expect(Registry.at('Foo#varargs').parameters).to eq [['*args', nil]]
|
272
|
-
expect(Registry.at('Foo#varargs2').parameters).to eq [['*args', nil]]
|
273
|
-
end
|
274
|
-
|
275
|
-
it "is not too strict or too loose about matching override comments to methods" do
|
276
|
-
parse <<-eof
|
277
|
-
/* Document-method: Foo::foo
|
278
|
-
* Document-method: new
|
279
|
-
* Document-method: Foo::Bar#baz
|
280
|
-
* Foo bar!
|
281
|
-
*/
|
282
|
-
|
283
|
-
void Init_Foo() {
|
284
|
-
mFoo = rb_define_module("Foo");
|
285
|
-
mBar = rb_define_module_under(mFoo, "Bar");
|
286
|
-
|
287
|
-
rb_define_method(mFoo, "foo", foo, 0);
|
288
|
-
rb_define_singleton_method(mFoo, "foo", foo, 0);
|
289
|
-
rb_define_method(mBar, "foo", foo, 0);
|
290
|
-
rb_define_singleton_method(mBar, "foo", foo, 0);
|
291
|
-
|
292
|
-
rb_define_method(mFoo, "initialize", foo, 0);
|
293
|
-
rb_define_method(mBar, "initialize", foo, 0);
|
294
|
-
|
295
|
-
rb_define_method(mFoo, "baz", foo, 0);
|
296
|
-
rb_define_singleton_method(mFoo, "baz", foo, 0);
|
297
|
-
rb_define_method(mBar, "baz", foo, 0);
|
298
|
-
rb_define_singleton_method(mBar, "baz", foo, 0);
|
299
|
-
}
|
300
|
-
eof
|
301
|
-
expect(Registry.at('Foo#foo').docstring).to eq 'Foo bar!'
|
302
|
-
expect(Registry.at('Foo.foo').docstring).to eq 'Foo bar!'
|
303
|
-
expect(Registry.at('Foo::Bar#foo').docstring).to be_empty
|
304
|
-
expect(Registry.at('Foo::Bar.foo').docstring).to be_empty
|
305
|
-
expect(Registry.at('Foo#initialize').docstring).to eq 'Foo bar!'
|
306
|
-
expect(Registry.at('Foo::Bar#initialize').docstring).to eq 'Foo bar!'
|
307
|
-
expect(Registry.at('Foo#baz').docstring).to be_empty
|
308
|
-
expect(Registry.at('Foo.baz').docstring).to be_empty
|
309
|
-
expect(Registry.at('Foo::Bar#baz').docstring).to eq 'Foo bar!'
|
310
|
-
expect(Registry.at('Foo::Bar.baz').docstring).to be_empty
|
311
|
-
end
|
312
|
-
|
313
|
-
it "recognizes core Ruby classes and modules provided by ruby.h" do
|
314
|
-
parse_init <<-eof
|
315
|
-
rb_define_method(rb_cFixnum, "popcount", fix_popcount, 0);
|
316
|
-
rb_define_private_method(rb_mKernel, "pp", obj_pp, 0);
|
317
|
-
rb_define_method(rb_mEnumerable, "to_hash", enum_to_hash, 0);
|
318
|
-
eof
|
319
|
-
expect(Registry.at('Fixnum').type).to eq :class
|
320
|
-
expect(Registry.at('Fixnum#popcount').type).to eq :method
|
321
|
-
expect(Registry.at('Object').type).to eq :class
|
322
|
-
# Methods defined on Kernel are treated as if they were defined on Object
|
323
|
-
expect(Registry.at('Object#pp').type).to eq :method
|
324
|
-
expect(Registry.at('Enumerable').type).to eq :module
|
325
|
-
expect(Registry.at('Enumerable#to_hash').type).to eq :method
|
326
|
-
end
|
327
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
3
|
-
|
4
|
-
RSpec.describe YARD::Handlers::C::MixinHandler do
|
5
|
-
it "adds includes to modules or classes" do
|
6
|
-
parse_init <<-eof
|
7
|
-
mFoo = rb_define_module("Foo");
|
8
|
-
cBar = rb_define_class("Bar", rb_cObject);
|
9
|
-
mBaz = rb_define_module("Baz");
|
10
|
-
rb_include_module(cBar, mFoo);
|
11
|
-
rb_include_module(mBaz, mFoo);
|
12
|
-
eof
|
13
|
-
foo = Registry.at('Foo')
|
14
|
-
bar = Registry.at('Bar')
|
15
|
-
baz = Registry.at('Baz')
|
16
|
-
expect(bar.mixins(:instance)).to eq [foo]
|
17
|
-
expect(baz.mixins(:instance)).to eq [foo]
|
18
|
-
end
|
19
|
-
|
20
|
-
it "adds include as proxy if symbol lookup fails" do
|
21
|
-
parse_init <<-eof
|
22
|
-
mFoo = rb_define_module("Foo");
|
23
|
-
rb_include_module(mFoo, mXYZ);
|
24
|
-
eof
|
25
|
-
foo = Registry.at('Foo')
|
26
|
-
expect(foo.mixins(:instance)).to eq [P('XYZ')]
|
27
|
-
end
|
28
|
-
|
29
|
-
it "fails if mixin variable cannot be detected" do
|
30
|
-
with_parser(:c) do
|
31
|
-
undoc_error <<-eof
|
32
|
-
void Init_Foo() {
|
33
|
-
VALUE noprefix;
|
34
|
-
|
35
|
-
mFoo = rb_define_module("Foo");
|
36
|
-
// YARD doesn't understand this
|
37
|
-
noprefix = rb_const_get(rb_cObject, rb_intern("Observable"));
|
38
|
-
|
39
|
-
rb_include_module(mFoo, noprefix);
|
40
|
-
}
|
41
|
-
eof
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|