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.

Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/LICENSE +2 -2
  4. data/README.md +2 -2
  5. data/Rakefile +1 -1
  6. data/bin/yard +0 -0
  7. data/bin/yardoc +0 -0
  8. data/bin/yri +0 -0
  9. data/docs/GettingStarted.md +88 -6
  10. data/docs/images/handlers-class-diagram.png +0 -0
  11. data/docs/images/overview-class-diagram.png +0 -0
  12. data/docs/images/parser-class-diagram.png +0 -0
  13. data/docs/templates/default/fulldoc/html/full_list_tag.erb +6 -4
  14. data/lib/yard/autoload.rb +3 -0
  15. data/lib/yard/cli/yardoc.rb +1 -1
  16. data/lib/yard/code_objects/base.rb +4 -1
  17. data/lib/yard/code_objects/extra_file_object.rb +3 -1
  18. data/lib/yard/code_objects/proxy.rb +2 -2
  19. data/lib/yard/docstring.rb +11 -6
  20. data/lib/yard/handlers/base.rb +1 -2
  21. data/lib/yard/handlers/c/base.rb +19 -0
  22. data/lib/yard/handlers/c/handler_methods.rb +42 -8
  23. data/lib/yard/handlers/c/init_handler.rb +1 -1
  24. data/lib/yard/handlers/c/method_handler.rb +3 -3
  25. data/lib/yard/handlers/ruby/decorator_handler_methods.rb +132 -0
  26. data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +1 -1
  27. data/lib/yard/handlers/ruby/private_class_method_handler.rb +6 -39
  28. data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -30
  29. data/lib/yard/handlers/ruby/public_class_method_handler.rb +13 -0
  30. data/lib/yard/handlers/ruby/struct_handler_methods.rb +1 -0
  31. data/lib/yard/handlers/ruby/visibility_handler.rb +5 -8
  32. data/lib/yard/logging.rb +1 -0
  33. data/lib/yard/parser/ruby/ruby_parser.rb +2 -2
  34. data/lib/yard/parser/source_parser.rb +6 -6
  35. data/lib/yard/rake/yardoc_task.rb +2 -2
  36. data/lib/yard/serializers/file_system_serializer.rb +33 -1
  37. data/lib/yard/server/commands/display_file_command.rb +8 -3
  38. data/lib/yard/server/commands/display_object_command.rb +7 -3
  39. data/lib/yard/server/doc_server_helper.rb +2 -8
  40. data/lib/yard/server/doc_server_serializer.rb +2 -4
  41. data/lib/yard/server/router.rb +1 -1
  42. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +57 -8
  43. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -10
  44. data/lib/yard/server/templates/default/layout/html/script_setup.erb +1 -2
  45. data/lib/yard/server/templates/default/method_details/html/permalink.erb +3 -3
  46. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
  47. data/lib/yard/tags/directives.rb +1 -0
  48. data/lib/yard/tags/library.rb +9 -7
  49. data/lib/yard/tags/overload_tag.rb +4 -1
  50. data/lib/yard/templates/helpers/html_helper.rb +4 -3
  51. data/lib/yard/templates/template_options.rb +3 -0
  52. data/lib/yard/version.rb +1 -1
  53. data/spec/cli/command_parser_spec.rb +14 -14
  54. data/spec/cli/command_spec.rb +11 -11
  55. data/spec/cli/config_spec.rb +32 -32
  56. data/spec/cli/diff_spec.rb +86 -90
  57. data/spec/cli/display_spec.rb +6 -6
  58. data/spec/cli/gems_spec.rb +28 -28
  59. data/spec/cli/graph_spec.rb +8 -8
  60. data/spec/cli/help_spec.rb +8 -8
  61. data/spec/cli/i18n_spec.rb +33 -37
  62. data/spec/cli/list_spec.rb +2 -2
  63. data/spec/cli/markup_types_spec.rb +3 -3
  64. data/spec/cli/server_spec.rb +74 -88
  65. data/spec/cli/stats_spec.rb +14 -14
  66. data/spec/cli/yardoc_spec.rb +316 -321
  67. data/spec/cli/yri_spec.rb +45 -45
  68. data/spec/code_objects/base_spec.rb +174 -173
  69. data/spec/code_objects/class_object_spec.rb +65 -65
  70. data/spec/code_objects/code_object_list_spec.rb +13 -11
  71. data/spec/code_objects/constants_spec.rb +68 -58
  72. data/spec/code_objects/extra_file_object_spec.rb +71 -59
  73. data/spec/code_objects/macro_object_spec.rb +64 -64
  74. data/spec/code_objects/method_object_spec.rb +80 -72
  75. data/spec/code_objects/module_object_spec.rb +47 -47
  76. data/spec/code_objects/namespace_object_spec.rb +51 -51
  77. data/spec/code_objects/proxy_spec.rb +54 -54
  78. data/spec/config_spec.rb +104 -104
  79. data/spec/core_ext/array_spec.rb +5 -5
  80. data/spec/core_ext/file_spec.rb +33 -33
  81. data/spec/core_ext/hash_spec.rb +5 -5
  82. data/spec/core_ext/insertion_spec.rb +18 -18
  83. data/spec/core_ext/module_spec.rb +6 -6
  84. data/spec/core_ext/string_spec.rb +17 -17
  85. data/spec/core_ext/symbol_hash_spec.rb +42 -39
  86. data/spec/docstring_parser_spec.rb +65 -65
  87. data/spec/docstring_spec.rb +137 -130
  88. data/spec/handlers/alias_handler_spec.rb +39 -39
  89. data/spec/handlers/attribute_handler_spec.rb +35 -35
  90. data/spec/handlers/base_spec.rb +60 -51
  91. data/spec/handlers/c/alias_handler_spec.rb +6 -6
  92. data/spec/handlers/c/attribute_handler_spec.rb +12 -12
  93. data/spec/handlers/c/class_handler_spec.rb +35 -22
  94. data/spec/handlers/c/constant_handler_spec.rb +24 -22
  95. data/spec/handlers/c/init_handler_spec.rb +10 -10
  96. data/spec/handlers/c/method_handler_spec.rb +150 -65
  97. data/spec/handlers/c/mixin_handler_spec.rb +5 -5
  98. data/spec/handlers/c/module_handler_spec.rb +27 -15
  99. data/spec/handlers/c/override_comment_handler_spec.rb +14 -14
  100. data/spec/handlers/c/path_handler_spec.rb +8 -8
  101. data/spec/handlers/c/spec_helper.rb +10 -0
  102. data/spec/handlers/c/struct_handler_spec.rb +3 -3
  103. data/spec/handlers/class_condition_handler_spec.rb +18 -18
  104. data/spec/handlers/class_handler_spec.rb +97 -97
  105. data/spec/handlers/class_method_handler_shared_examples.rb +132 -0
  106. data/spec/handlers/class_variable_handler_spec.rb +3 -3
  107. data/spec/handlers/constant_handler_spec.rb +32 -29
  108. data/spec/handlers/decorator_handler_methods_spec.rb +405 -0
  109. data/spec/handlers/dsl_handler_spec.rb +108 -109
  110. data/spec/handlers/examples/constant_handler_001.rb.txt +4 -1
  111. data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
  112. data/spec/handlers/exception_handler_spec.rb +23 -23
  113. data/spec/handlers/extend_handler_spec.rb +9 -9
  114. data/spec/handlers/legacy_base_spec.rb +60 -60
  115. data/spec/handlers/method_condition_handler_spec.rb +5 -5
  116. data/spec/handlers/method_handler_spec.rb +92 -92
  117. data/spec/handlers/mixin_handler_spec.rb +25 -25
  118. data/spec/handlers/module_function_handler_spec.rb +24 -24
  119. data/spec/handlers/module_handler_spec.rb +15 -15
  120. data/spec/handlers/private_class_method_handler_spec.rb +4 -48
  121. data/spec/handlers/private_constant_handler_spec.rb +8 -8
  122. data/spec/handlers/processor_spec.rb +12 -12
  123. data/spec/handlers/public_class_method_handler_spec.rb +10 -0
  124. data/spec/handlers/ruby/base_spec.rb +16 -16
  125. data/spec/handlers/ruby/legacy/base_spec.rb +20 -18
  126. data/spec/handlers/spec_helper.rb +1 -1
  127. data/spec/handlers/visibility_handler_spec.rb +25 -21
  128. data/spec/handlers/yield_handler_spec.rb +28 -28
  129. data/spec/i18n/locale_spec.rb +16 -16
  130. data/spec/i18n/message_spec.rb +8 -8
  131. data/spec/i18n/messages_spec.rb +14 -14
  132. data/spec/i18n/pot_generator_spec.rb +32 -32
  133. data/spec/i18n/text_spec.rb +22 -22
  134. data/spec/logging_spec.rb +12 -12
  135. data/spec/options_spec.rb +56 -56
  136. data/spec/parser/base_spec.rb +9 -9
  137. data/spec/parser/c_parser_spec.rb +50 -50
  138. data/spec/parser/ruby/ast_node_spec.rb +7 -7
  139. data/spec/parser/ruby/legacy/statement_list_spec.rb +106 -106
  140. data/spec/parser/ruby/legacy/token_list_spec.rb +27 -27
  141. data/spec/parser/ruby/ruby_parser_spec.rb +123 -113
  142. data/spec/parser/source_parser_spec.rb +224 -224
  143. data/spec/parser/tag_parsing_spec.rb +6 -7
  144. data/spec/rake/yardoc_task_spec.rb +38 -48
  145. data/spec/registry_spec.rb +143 -143
  146. data/spec/registry_store_spec.rb +165 -165
  147. data/spec/rubygems/doc_manager_spec.rb +38 -38
  148. data/spec/serializers/file_system_serializer_spec.rb +53 -33
  149. data/spec/serializers/yardoc_serializer_spec.rb +15 -15
  150. data/spec/server/adapter_spec.rb +15 -15
  151. data/spec/server/commands/base_spec.rb +29 -29
  152. data/spec/server/commands/library_command_spec.rb +12 -12
  153. data/spec/server/commands/static_file_command_spec.rb +28 -28
  154. data/spec/server/doc_server_helper_spec.rb +8 -8
  155. data/spec/server/doc_server_serializer_spec.rb +23 -18
  156. data/spec/server/rack_adapter_spec.rb +6 -6
  157. data/spec/server/router_spec.rb +39 -39
  158. data/spec/server/static_caching_spec.rb +16 -16
  159. data/spec/server/webrick_servlet_spec.rb +6 -7
  160. data/spec/server_spec.rb +3 -3
  161. data/spec/spec_helper.rb +11 -2
  162. data/spec/tags/default_factory_spec.rb +64 -64
  163. data/spec/tags/default_tag_spec.rb +5 -5
  164. data/spec/tags/directives_spec.rb +121 -121
  165. data/spec/tags/library_spec.rb +14 -14
  166. data/spec/tags/overload_tag_spec.rb +24 -24
  167. data/spec/tags/ref_tag_list_spec.rb +12 -12
  168. data/spec/templates/class_spec.rb +3 -3
  169. data/spec/templates/constant_spec.rb +4 -4
  170. data/spec/templates/engine_spec.rb +47 -48
  171. data/spec/templates/examples/class001.html +129 -101
  172. data/spec/templates/examples/class002.html +31 -27
  173. data/spec/templates/examples/method001.html +54 -47
  174. data/spec/templates/examples/method002.html +33 -28
  175. data/spec/templates/examples/method003.html +70 -64
  176. data/spec/templates/examples/method004.html +13 -9
  177. data/spec/templates/examples/method005.html +38 -32
  178. data/spec/templates/examples/module001.html +343 -339
  179. data/spec/templates/examples/module002.html +147 -124
  180. data/spec/templates/examples/module003.html +94 -81
  181. data/spec/templates/examples/module004.html +40 -33
  182. data/spec/templates/helpers/base_helper_spec.rb +91 -95
  183. data/spec/templates/helpers/html_helper_spec.rb +276 -279
  184. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +16 -15
  185. data/spec/templates/helpers/markup/rdoc_markup_spec.rb +27 -34
  186. data/spec/templates/helpers/markup_helper_spec.rb +57 -57
  187. data/spec/templates/helpers/method_helper_spec.rb +20 -20
  188. data/spec/templates/helpers/shared_signature_examples.rb +33 -31
  189. data/spec/templates/helpers/text_helper_spec.rb +6 -6
  190. data/spec/templates/method_spec.rb +7 -7
  191. data/spec/templates/module_spec.rb +7 -7
  192. data/spec/templates/onefile_spec.rb +7 -7
  193. data/spec/templates/section_spec.rb +66 -69
  194. data/spec/templates/spec_helper.rb +1 -1
  195. data/spec/templates/tag_spec.rb +5 -5
  196. data/spec/templates/template_spec.rb +158 -158
  197. data/spec/verifier_spec.rb +52 -52
  198. data/templates/default/fulldoc/html/css/full_list.css +32 -31
  199. data/templates/default/fulldoc/html/css/style.css +212 -77
  200. data/templates/default/fulldoc/html/frames.erb +6 -15
  201. data/templates/default/fulldoc/html/full_list.erb +14 -21
  202. data/templates/default/fulldoc/html/full_list_class.erb +1 -1
  203. data/templates/default/fulldoc/html/full_list_file.erb +6 -4
  204. data/templates/default/fulldoc/html/full_list_method.erb +8 -6
  205. data/templates/default/fulldoc/html/js/app.js +100 -76
  206. data/templates/default/fulldoc/html/js/full_list.js +170 -135
  207. data/templates/default/fulldoc/html/setup.rb +50 -7
  208. data/templates/default/layout/html/breadcrumb.erb +0 -2
  209. data/templates/default/layout/html/headers.erb +2 -1
  210. data/templates/default/layout/html/layout.erb +16 -10
  211. data/templates/default/layout/html/script_setup.erb +1 -2
  212. data/templates/default/layout/html/search.erb +7 -2
  213. data/templates/default/layout/html/setup.rb +16 -0
  214. data/templates/default/method/html/header.erb +7 -6
  215. data/templates/default/module/html/attribute_summary.erb +1 -1
  216. data/templates/default/module/html/box_info.erb +24 -18
  217. data/templates/default/module/html/constant_summary.erb +9 -11
  218. data/templates/default/module/html/item_summary.erb +1 -1
  219. data/templates/default/module/html/method_summary.erb +1 -1
  220. data/templates/guide/fulldoc/html/setup.rb +1 -1
  221. data/yard.gemspec +1 -2
  222. metadata +10 -7
  223. data/spec/handlers/examples/private_class_method_handler_001.rb.txt +0 -9
  224. data/spec/handlers/examples/private_class_method_handler_002.rb.txt +0 -18
  225. 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::AliasHandler do
4
- it "should allow defining of aliases (rb_define_alias)" do
4
+ it "allows defining of aliases (rb_define_alias)" do
5
5
  parse <<-eof
6
6
  /* FOO */
7
7
  VALUE foo(VALUE x) { int value = x; }
@@ -12,11 +12,11 @@ describe YARD::Handlers::C::AliasHandler do
12
12
  }
13
13
  eof
14
14
 
15
- Registry.at('Foo#bar').should be_is_alias
16
- Registry.at('Foo#bar').docstring.should == 'FOO'
15
+ expect(Registry.at('Foo#bar')).to be_is_alias
16
+ expect(Registry.at('Foo#bar').docstring).to eq 'FOO'
17
17
  end
18
18
 
19
- it "should allow defining of aliases (rb_define_alias) of attributes" do
19
+ it "allows defining of aliases (rb_define_alias) of attributes" do
20
20
  parse <<-eof
21
21
  /* FOO */
22
22
  VALUE foo(VALUE x) { int value = x; }
@@ -27,7 +27,7 @@ describe YARD::Handlers::C::AliasHandler do
27
27
  }
28
28
  eof
29
29
 
30
- Registry.at('Foo#foo').should be_reader
31
- Registry.at('Foo#foo?').should be_is_alias
30
+ expect(Registry.at('Foo#foo')).to be_reader
31
+ expect(Registry.at('Foo#foo?')).to be_is_alias
32
32
  end
33
33
  end
@@ -14,27 +14,27 @@ describe YARD::Handlers::C::AttributeHandler do
14
14
  eof
15
15
  end
16
16
 
17
- it "should handle readonly attribute (rb_define_attr)" do
17
+ it "handles readonly attribute (rb_define_attr)" do
18
18
  run(1, 0)
19
- Registry.at('Foo#foo').should be_reader
20
- Registry.at('Foo#foo=').should be_nil
19
+ expect(Registry.at('Foo#foo')).to be_reader
20
+ expect(Registry.at('Foo#foo=')).to be nil
21
21
  end
22
22
 
23
- it "should handle writeonly attribute (rb_define_attr)" do
23
+ it "handles writeonly attribute (rb_define_attr)" do
24
24
  run(0, 1)
25
- Registry.at('Foo#foo').should be_nil
26
- Registry.at('Foo#foo=').should be_writer
25
+ expect(Registry.at('Foo#foo')).to be nil
26
+ expect(Registry.at('Foo#foo=')).to be_writer
27
27
  end
28
28
 
29
- it "should handle readwrite attribute (rb_define_attr)" do
29
+ it "handles readwrite attribute (rb_define_attr)" do
30
30
  run(1, 1)
31
- Registry.at('Foo#foo').should be_reader
32
- Registry.at('Foo#foo=').should be_writer
31
+ expect(Registry.at('Foo#foo')).to be_reader
32
+ expect(Registry.at('Foo#foo=')).to be_writer
33
33
  end
34
34
 
35
- it "should handle commented writeonly attribute (/* rb_define_attr */)" do
35
+ it "handles commented writeonly attribute (/* rb_define_attr */)" do
36
36
  run(1, 1, true)
37
- Registry.at('Foo#foo').should be_reader
38
- Registry.at('Foo#foo=').should be_writer
37
+ expect(Registry.at('Foo#foo')).to be_reader
38
+ expect(Registry.at('Foo#foo=')).to be_writer
39
39
  end
40
40
  end
@@ -1,63 +1,76 @@
1
1
  require File.dirname(__FILE__) + "/spec_helper"
2
2
 
3
3
  describe YARD::Handlers::C::ClassHandler do
4
- it "should register classes" do
4
+ it "registers classes" do
5
5
  parse_init 'cFoo = rb_define_class("Foo", rb_cObject);'
6
- Registry.at('Foo').type.should == :class
6
+ expect(Registry.at('Foo').type).to eq :class
7
7
  end
8
8
 
9
- it "should register classes under namespaces" do
10
- parse_init 'cFoo = rb_define_class_under(cBar, "Foo", rb_cObject);'
11
- Registry.at('Bar::Foo').type.should == :class
9
+ it "registers classes under namespaces" do
10
+ parse_init <<-EOF
11
+ cBar = rb_define_class("Bar", rb_cObject);
12
+ cFoo = rb_define_class_under(cBar, "Foo", rb_cObject);
13
+ EOF
14
+ expect(Registry.at('Bar::Foo').type).to eq :class
12
15
  end
13
16
 
14
- it "should remember symbol defined with class" do
17
+ it "remembers symbol defined with class" do
15
18
  parse_init(<<-eof)
16
19
  cXYZ = rb_define_class("Foo", rb_cObject);
17
20
  rb_define_method(cXYZ, "bar", bar, 0);
18
21
  eof
19
- Registry.at('Foo').type.should == :class
20
- Registry.at('Foo#bar').should_not be_nil
22
+ expect(Registry.at('Foo').type).to eq :class
23
+ expect(Registry.at('Foo#bar')).not_to be nil
21
24
  end
22
25
 
23
- it "should lookup superclass symbol name" do
26
+ it "looks up superclass symbol name" do
24
27
  parse_init(<<-eof)
25
28
  cXYZ = rb_define_class("Foo", rb_cObject);
26
29
  cBar = rb_define_class("Bar", cXYZ);
27
30
  eof
28
- Registry.at('Bar').superclass.should == Registry.at('Foo')
31
+ expect(Registry.at('Bar').superclass).to eq Registry.at('Foo')
29
32
  end
30
33
 
31
- it "should user superclass symbol name as proxy if not found" do
34
+ it "uses superclass symbol name as proxy if not found" do
32
35
  parse_init(<<-eof)
33
36
  // cXYZ = rb_define_class("Foo", rb_cObject);
34
37
  cBar = rb_define_class("Bar", cXYZ);
35
38
  eof
36
- Registry.at('Bar').superclass.should == P('XYZ')
39
+ expect(Registry.at('Bar').superclass).to eq P('XYZ')
37
40
  end
38
41
 
39
- it "should not associate declaration comments as class docstring" do
42
+ it "does not associate declaration comments as class docstring" do
40
43
  parse_init(<<-eof)
41
44
  /* Docstring! */
42
45
  cFoo = rb_define_class("Foo", cObject);
43
46
  eof
44
- Registry.at('Foo').docstring.should be_blank
47
+ expect(Registry.at('Foo').docstring).to be_blank
45
48
  end
46
49
 
47
- it "should associate a file with the declaration" do
50
+ it "associates a file with the declaration" do
48
51
  parse_init(<<-eof)
49
52
  cFoo = rb_define_class("Foo", cObject);
50
53
  eof
51
- Registry.at('Foo').file.should == '(stdin)'
52
- Registry.at('Foo').line.should == 2
54
+ expect(Registry.at('Foo').file).to eq '(stdin)'
55
+ expect(Registry.at('Foo').line).to eq 2
53
56
  end
54
57
 
55
- it "should properly handle Proxy superclasses" do
58
+ it "properly handles Proxy superclasses" do
56
59
  parse_init <<-eof
57
- cFoo = rb_define_class_under(mFoo, "Bar", rb_cBar);
60
+ mFoo = rb_define_module("Foo");
61
+ cBar = rb_define_class_under(mFoo, "Bar", rb_cBar);
58
62
  eof
59
- Registry.at('Foo::Bar').type.should == :class
60
- Registry.at('Foo::Bar').superclass.should == P('Bar')
61
- Registry.at('Foo::Bar').superclass.type.should == :class
63
+ expect(Registry.at('Foo::Bar').type).to eq :class
64
+ expect(Registry.at('Foo::Bar').superclass).to eq P('Bar')
65
+ expect(Registry.at('Foo::Bar').superclass.type).to eq :class
66
+ end
67
+
68
+ it "resolves namespace variable names across multiple files" do
69
+ parse_multi_file_init(
70
+ 'cBar = rb_define_class_under(cFoo, "Bar", rb_cObject);',
71
+ 'cFoo = rb_define_class("Foo", rb_cObject);'
72
+ )
73
+
74
+ expect(Registry.at('Foo::Bar').type).to eq :class
62
75
  end
63
76
  end
@@ -1,15 +1,17 @@
1
1
  require File.dirname(__FILE__) + "/spec_helper"
2
2
 
3
3
  describe YARD::Handlers::C::ConstantHandler do
4
- it "should register constants" do
4
+ it "registers constants" do
5
5
  parse_init <<-eof
6
6
  mFoo = rb_define_module("Foo");
7
7
  rb_define_const(mFoo, "FOO", ID2SYM(100));
8
+ rb_define_global_const("BAR", ID2SYM(100));
8
9
  eof
9
- Registry.at('Foo::FOO').type.should == :constant
10
+ expect( Registry.at('Foo::FOO').type).to eq :constant
11
+ expect( Registry.at('BAR').type).to eq :constant
10
12
  end
11
13
 
12
- it "should look for override comments" do
14
+ it "looks for override comments" do
13
15
  parse <<-eof
14
16
  /* Document-const: FOO
15
17
  * Document-const: Foo::BAR
@@ -23,46 +25,46 @@ describe YARD::Handlers::C::ConstantHandler do
23
25
  }
24
26
  eof
25
27
  foo = Registry.at('Foo::FOO')
26
- foo.type.should == :constant
27
- foo.docstring.should == 'Foo bar!'
28
- foo.value.should == 'ID2SYM(100)'
29
- foo.file.should == '(stdin)'
30
- foo.line.should == 8
28
+ expect(foo.type).to eq :constant
29
+ expect(foo.docstring).to eq 'Foo bar!'
30
+ expect(foo.value).to eq 'ID2SYM(100)'
31
+ expect(foo.file).to eq '(stdin)'
32
+ expect(foo.line).to eq 8
31
33
  bar = Registry.at('Foo::BAR')
32
- bar.type.should == :constant
33
- bar.docstring.should == 'Foo bar!'
34
- bar.file.should == '(stdin)'
35
- bar.line.should == 9
36
- bar.value.should == 'ID2SYM(101)'
34
+ expect(bar.type).to eq :constant
35
+ expect(bar.docstring).to eq 'Foo bar!'
36
+ expect(bar.file).to eq '(stdin)'
37
+ expect(bar.line).to eq 9
38
+ expect(bar.value).to eq 'ID2SYM(101)'
37
39
  end
38
40
 
39
- it "should use comment attached to declaration as fallback" do
41
+ it "uses comment attached to declaration as fallback" do
40
42
  parse_init <<-eof
41
43
  mFoo = rb_define_module("Foo");
42
44
  rb_define_const(mFoo, "FOO", ID2SYM(100)); // foobar!
43
45
  eof
44
46
  foo = Registry.at('Foo::FOO')
45
- foo.value.should == 'ID2SYM(100)'
46
- foo.docstring.should == 'foobar!'
47
+ expect(foo.value).to eq 'ID2SYM(100)'
48
+ expect(foo.docstring).to eq 'foobar!'
47
49
  end
48
50
 
49
- it "should allow the form VALUE: DOCSTRING to document value" do
51
+ it "allows the form VALUE: DOCSTRING to document value" do
50
52
  parse_init <<-eof
51
53
  mFoo = rb_define_module("Foo");
52
54
  rb_define_const(mFoo, "FOO", ID2SYM(100)); // 100: foobar!
53
55
  eof
54
56
  foo = Registry.at('Foo::FOO')
55
- foo.value.should == '100'
56
- foo.docstring.should == 'foobar!'
57
+ expect(foo.value).to eq '100'
58
+ expect(foo.docstring).to eq 'foobar!'
57
59
  end
58
60
 
59
- it "should allow escaping of backslashes in VALUE: DOCSTRING syntax" do
61
+ it "allows escaping of backslashes in VALUE: DOCSTRING syntax" do
60
62
  parse_init <<-eof
61
63
  mFoo = rb_define_module("Foo");
62
64
  rb_define_const(mFoo, "FOO", ID2SYM(100)); // 100\\:x\\:y: foobar:x!
63
65
  eof
64
66
  foo = Registry.at('Foo::FOO')
65
- foo.value.should == '100:x:y'
66
- foo.docstring.should == 'foobar:x!'
67
+ expect(foo.value).to eq '100:x:y'
68
+ expect(foo.docstring).to eq 'foobar:x!'
67
69
  end
68
70
  end
@@ -1,47 +1,47 @@
1
1
  require File.dirname(__FILE__) + "/spec_helper"
2
2
 
3
3
  describe YARD::Handlers::C::InitHandler do
4
- it "should add documentation in Init_ClassName() to ClassName" do
4
+ it "adds documentation in Init_ClassName() to ClassName" do
5
5
  parse(<<-eof)
6
6
  // Bar!
7
7
  void Init_A() {
8
8
  rb_cA = rb_define_class("A", rb_cObject);
9
9
  }
10
10
  eof
11
- Registry.at('A').docstring.should == 'Bar!'
11
+ expect(Registry.at('A').docstring).to eq 'Bar!'
12
12
  end
13
13
 
14
- it "should not add documentation if ClassName is not created in Init" do
14
+ it "does not add documentation if ClassName is not created in Init" do
15
15
  parse(<<-eof)
16
16
  // Bar!
17
17
  void Init_A() {
18
18
  }
19
19
  eof
20
- Registry.at('A').should be_nil
20
+ expect(Registry.at('A')).to be nil
21
21
  end
22
22
 
23
- it "should not overwrite override comment" do
23
+ it "does not overwrite override comment" do
24
24
  parse(<<-eof)
25
25
  /* Document-class: A
26
26
  * Foo!
27
27
  */
28
28
 
29
29
  // Bar!
30
- void Init_A() {
30
+ static SWIGEXPORT void Init_A() {
31
31
  rb_cA = rb_define_class("A", rb_cObject);
32
32
  }
33
33
  eof
34
- Registry.at('A').docstring.should == 'Foo!'
34
+ expect(Registry.at('A').docstring).to eq 'Foo!'
35
35
  end
36
36
 
37
- it "should check non-Init methods for declarations too" do
37
+ it "checks non-Init methods for declarations too" do
38
38
  parse(<<-eof)
39
39
  void foo(int x, int y, char *name) {
40
40
  rb_cB = rb_define_class("B", rb_cObject);
41
41
  rb_define_method(rb_cB, "foo", foo_impl, 0);
42
42
  }
43
43
  eof
44
- Registry.at('B').should be_a(CodeObjects::ClassObject)
45
- Registry.at('B#foo').should be_a(CodeObjects::MethodObject)
44
+ expect(Registry.at('B')).to be_a(CodeObjects::ClassObject)
45
+ expect(Registry.at('B#foo')).to be_a(CodeObjects::MethodObject)
46
46
  end
47
47
  end
@@ -1,34 +1,34 @@
1
1
  require File.dirname(__FILE__) + "/spec_helper"
2
2
 
3
3
  describe YARD::Handlers::C::MethodHandler do
4
- it "should register methods" do
4
+ it "registers methods" do
5
5
  parse_init <<-eof
6
6
  mFoo = rb_define_module("Foo");
7
7
  rb_define_method(mFoo, "bar", bar, 0);
8
8
  eof
9
- Registry.at('Foo#bar').should_not be_nil
10
- Registry.at('Foo#bar').visibility.should == :public
9
+ expect(Registry.at('Foo#bar')).not_to be nil
10
+ expect(Registry.at('Foo#bar').visibility).to eq :public
11
11
  end
12
12
 
13
- it "should register private methods" do
13
+ it "registers private methods" do
14
14
  parse_init <<-eof
15
15
  mFoo = rb_define_module("Foo");
16
16
  rb_define_private_method(mFoo, "bar", bar, 0);
17
17
  eof
18
- Registry.at('Foo#bar').should_not be_nil
19
- Registry.at('Foo#bar').visibility.should == :private
18
+ expect(Registry.at('Foo#bar')).not_to be nil
19
+ expect(Registry.at('Foo#bar').visibility).to eq :private
20
20
  end
21
21
 
22
- it "should register singleton methods" do
22
+ it "registers singleton methods" do
23
23
  parse_init <<-eof
24
24
  mFoo = rb_define_module("Foo");
25
25
  rb_define_singleton_method(mFoo, "bar", bar, 0);
26
26
  eof
27
- Registry.at('Foo.bar').should_not be_nil
28
- Registry.at('Foo.bar').visibility.should == :public
27
+ expect(Registry.at('Foo.bar')).not_to be nil
28
+ expect(Registry.at('Foo.bar').visibility).to eq :public
29
29
  end
30
30
 
31
- it "should register module functions" do
31
+ it "registers module functions" do
32
32
  parse <<-eof
33
33
  /* DOCSTRING
34
34
  * @return [String] foo!
@@ -42,24 +42,24 @@ describe YARD::Handlers::C::MethodHandler do
42
42
  eof
43
43
  bar_c = Registry.at('Foo.bar')
44
44
  bar_i = Registry.at('Foo#bar')
45
- bar_c.should be_module_function
46
- bar_c.visibility.should == :public
47
- bar_c.docstring.should == "DOCSTRING"
48
- bar_c.tag(:return).object.should == bar_c
49
- bar_c.source.should == "static VALUE bar(VALUE self) { x(); y(); z(); }"
50
- bar_i.should_not be_module_function
51
- bar_i.visibility.should == :private
52
- bar_i.docstring.should == "DOCSTRING"
53
- bar_i.tag(:return).object.should == bar_i
54
- bar_i.source.should == bar_c.source
55
- end
56
-
57
- it "should register global functions into Kernel" do
45
+ expect(bar_c).to be_module_function
46
+ expect(bar_c.visibility).to eq :public
47
+ expect(bar_c.docstring).to eq "DOCSTRING"
48
+ expect(bar_c.tag(:return).object).to eq bar_c
49
+ expect(bar_c.source).to eq "static VALUE bar(VALUE self) { x(); y(); z(); }"
50
+ expect(bar_i).not_to be_module_function
51
+ expect(bar_i.visibility).to eq :private
52
+ expect(bar_i.docstring).to eq "DOCSTRING"
53
+ expect(bar_i.tag(:return).object).to eq bar_i
54
+ expect(bar_i.source).to eq bar_c.source
55
+ end
56
+
57
+ it "registers global functions into Kernel" do
58
58
  parse_init 'rb_define_global_function("bar", bar, 0);'
59
- Registry.at('Kernel#bar').should_not be_nil
59
+ expect(Registry.at('Kernel#bar')).not_to be nil
60
60
  end
61
61
 
62
- it "should look for symbol containing method source" do
62
+ it "looks for symbol containing method source" do
63
63
  parse <<-eof
64
64
  static VALUE foo(VALUE self) { x(); y(); z(); }
65
65
  VALUE bar() { a(); b(); c(); }
@@ -71,15 +71,15 @@ describe YARD::Handlers::C::MethodHandler do
71
71
  eof
72
72
  foo = Registry.at('Foo#foo')
73
73
  bar = Registry.at('Foo#bar')
74
- foo.source.should == "static VALUE foo(VALUE self) { x(); y(); z(); }"
75
- foo.file.should == '(stdin)'
76
- foo.line.should == 1
77
- bar.source.should == "VALUE bar() { a(); b(); c(); }"
78
- bar.file.should == '(stdin)'
79
- bar.line.should == 2
74
+ expect(foo.source).to eq "static VALUE foo(VALUE self) { x(); y(); z(); }"
75
+ expect(foo.file).to eq '(stdin)'
76
+ expect(foo.line).to eq 1
77
+ expect(bar.source).to eq "VALUE bar() { a(); b(); c(); }"
78
+ expect(bar.file).to eq '(stdin)'
79
+ expect(bar.line).to eq 2
80
80
  end
81
81
 
82
- it "should find docstrings attached to method symbols" do
82
+ it "finds docstrings attached to method symbols" do
83
83
  parse <<-eof
84
84
  /* DOCSTRING */
85
85
  static VALUE foo(VALUE self) { x(); y(); z(); }
@@ -89,10 +89,10 @@ describe YARD::Handlers::C::MethodHandler do
89
89
  }
90
90
  eof
91
91
  foo = Registry.at('Foo#foo')
92
- foo.docstring.should == 'DOCSTRING'
92
+ expect(foo.docstring).to eq 'DOCSTRING'
93
93
  end
94
94
 
95
- it "should use declaration comments as docstring if there are no others" do
95
+ it "uses declaration comments as docstring if there are no others" do
96
96
  parse <<-eof
97
97
  static VALUE foo(VALUE self) { x(); y(); z(); }
98
98
  void Init_Foo() {
@@ -104,17 +104,17 @@ describe YARD::Handlers::C::MethodHandler do
104
104
  }
105
105
  eof
106
106
  foo = Registry.at('Foo#foo')
107
- foo.docstring.should == 'DOCSTRING'
107
+ expect(foo.docstring).to eq 'DOCSTRING'
108
108
  bar = Registry.at('Foo#bar')
109
- bar.docstring.should == 'DOCSTRING!'
109
+ expect(bar.docstring).to eq 'DOCSTRING!'
110
110
  end
111
111
 
112
- it "should look for symbols in other file" do
112
+ it "looks for symbols in other file" do
113
113
  other = <<-eof
114
114
  /* DOCSTRING! */
115
115
  static VALUE foo() { x(); }
116
116
  eof
117
- File.should_receive(:read).with('other.c').and_return(other)
117
+ expect(File).to receive(:read).with('other.c').and_return(other)
118
118
  parse <<-eof
119
119
  void Init_Foo() {
120
120
  mFoo = rb_define_module("Foo");
@@ -122,14 +122,14 @@ describe YARD::Handlers::C::MethodHandler do
122
122
  }
123
123
  eof
124
124
  foo = Registry.at('Foo#foo')
125
- foo.docstring.should == 'DOCSTRING!'
126
- foo.file.should == 'other.c'
127
- foo.line.should == 2
128
- foo.source.should == 'static VALUE foo() { x(); }'
125
+ expect(foo.docstring).to eq 'DOCSTRING!'
126
+ expect(foo.file).to eq 'other.c'
127
+ expect(foo.line).to eq 2
128
+ expect(foo.source).to eq 'static VALUE foo() { x(); }'
129
129
  end
130
130
 
131
- it "should allow extra file to include /'s and other filename characters" do
132
- File.should_receive(:read).at_least(1).times.with('ext/a-file.c').and_return(<<-eof)
131
+ it "allows extra file to include /'s and other filename characters" do
132
+ expect(File).to receive(:read).at_least(1).times.with('ext/a-file.c').and_return(<<-eof)
133
133
  /* FOO */
134
134
  VALUE foo(VALUE x) { int value = x; }
135
135
 
@@ -140,12 +140,12 @@ describe YARD::Handlers::C::MethodHandler do
140
140
  rb_define_method(rb_cFoo, "foo", foo, 1); /* in ext/a-file.c */
141
141
  rb_define_global_function("bar", bar, 1); /* in ext/a-file.c */
142
142
  eof
143
- Registry.at('Foo#foo').docstring.should == 'FOO'
144
- Registry.at('Kernel#bar').docstring.should == 'BAR'
143
+ expect(Registry.at('Foo#foo').docstring).to eq 'FOO'
144
+ expect(Registry.at('Kernel#bar').docstring).to eq 'BAR'
145
145
  end
146
146
 
147
- it "should warn if other file can't be found" do
148
- log.should_receive(:warn).with(/Missing source file `other.c' when parsing Foo#foo/)
147
+ it "warns if other file can't be found" do
148
+ expect(log).to receive(:warn).with(/Missing source file `other.c' when parsing Foo#foo/)
149
149
  parse <<-eof
150
150
  void Init_Foo() {
151
151
  mFoo = rb_define_module("Foo");
@@ -154,7 +154,7 @@ describe YARD::Handlers::C::MethodHandler do
154
154
  eof
155
155
  end
156
156
 
157
- it "should look at override comments for docstring" do
157
+ it "looks at override comments for docstring" do
158
158
  parse <<-eof
159
159
  /* Document-method: Foo::foo
160
160
  * Document-method: new
@@ -171,12 +171,12 @@ describe YARD::Handlers::C::MethodHandler do
171
171
  rb_define_method(mBar, "baz", foo, 0);
172
172
  }
173
173
  eof
174
- Registry.at('Foo#foo').docstring.should == 'Foo bar!'
175
- Registry.at('Foo#initialize').docstring.should == 'Foo bar!'
176
- Registry.at('Foo::Bar#baz').docstring.should == 'Foo bar!'
174
+ expect(Registry.at('Foo#foo').docstring).to eq 'Foo bar!'
175
+ expect(Registry.at('Foo#initialize').docstring).to eq 'Foo bar!'
176
+ expect(Registry.at('Foo::Bar#baz').docstring).to eq 'Foo bar!'
177
177
  end
178
178
 
179
- it "should look at overrides in other files" do
179
+ it "looks at overrides in other files" do
180
180
  other = <<-eof
181
181
  /* Document-method: Foo::foo
182
182
  * Document-method: new
@@ -184,7 +184,7 @@ describe YARD::Handlers::C::MethodHandler do
184
184
  * Foo bar!
185
185
  */
186
186
  eof
187
- File.should_receive(:read).with('foo/bar/other.c').and_return(other)
187
+ expect(File).to receive(:read).with('foo/bar/other.c').and_return(other)
188
188
  src = <<-eof
189
189
  void Init_Foo() {
190
190
  mFoo = rb_define_module("Foo");
@@ -195,12 +195,12 @@ describe YARD::Handlers::C::MethodHandler do
195
195
  }
196
196
  eof
197
197
  parse(src, 'foo/bar/baz/init.c')
198
- Registry.at('Foo#foo').docstring.should == 'Foo bar!'
199
- Registry.at('Foo#initialize').docstring.should == 'Foo bar!'
200
- Registry.at('Foo::Bar#baz').docstring.should == 'Foo bar!'
198
+ expect(Registry.at('Foo#foo').docstring).to eq 'Foo bar!'
199
+ expect(Registry.at('Foo#initialize').docstring).to eq 'Foo bar!'
200
+ expect(Registry.at('Foo::Bar#baz').docstring).to eq 'Foo bar!'
201
201
  end
202
202
 
203
- it "should add return tag on methods ending in '?'" do
203
+ it "adds return tag on methods ending in '?'" do
204
204
  parse <<-eof
205
205
  /* DOCSTRING */
206
206
  static VALUE foo(VALUE self) { x(); y(); z(); }
@@ -210,11 +210,11 @@ describe YARD::Handlers::C::MethodHandler do
210
210
  }
211
211
  eof
212
212
  foo = Registry.at('Foo#foo?')
213
- foo.docstring.should == 'DOCSTRING'
214
- foo.tag(:return).types.should == ['Boolean']
213
+ expect(foo.docstring).to eq 'DOCSTRING'
214
+ expect(foo.tag(:return).types).to eq ['Boolean']
215
215
  end
216
216
 
217
- it "should not add return tag if return tags exist" do
217
+ it "does not add return tag if return tags exist" do
218
218
  parse <<-eof
219
219
  // @return [String] foo
220
220
  static VALUE foo(VALUE self) { x(); y(); z(); }
@@ -224,16 +224,101 @@ describe YARD::Handlers::C::MethodHandler do
224
224
  }
225
225
  eof
226
226
  foo = Registry.at('Foo#foo?')
227
- foo.tag(:return).types.should == ['String']
227
+ expect(foo.tag(:return).types).to eq ['String']
228
228
  end
229
229
 
230
- it "should handle casted method names" do
230
+ it "handles casted method names" do
231
231
  parse_init <<-eof
232
232
  mFoo = rb_define_module("Foo");
233
233
  rb_define_method(mFoo, "bar", (METHOD)bar, 0);
234
234
  rb_define_global_function("baz", (METHOD)baz, 0);
235
235
  eof
236
- Registry.at('Foo#bar').should_not be_nil
237
- Registry.at('Kernel#baz').should_not be_nil
236
+ expect(Registry.at('Foo#bar')).not_to be nil
237
+ expect(Registry.at('Kernel#baz')).not_to be nil
238
+ end
239
+
240
+ it "extracts at regular method parameters from C function signatures" do
241
+ parse <<-eof
242
+ static VALUE noargs_func(VALUE self) { return Qnil; }
243
+ static VALUE twoargs_func(VALUE self, VALUE a, VALUE b) { return a; }
244
+ void Init_Foo() {
245
+ mFoo = rb_define_module("Foo");
246
+ rb_define_method(mFoo, "noargs", noargs_func, 0);
247
+ rb_define_method(mFoo, "twoargs", twoargs_func, 2);
248
+ }
249
+ eof
250
+ expect(Registry.at('Foo#noargs').parameters).to be_empty
251
+ expect(Registry.at('Foo#twoargs').parameters).to eq [['a', nil], ['b', nil]]
252
+ end
253
+
254
+ it "extracts at varargs method parameters from C function signatures" do
255
+ parse <<-eof
256
+ static VALUE varargs_func(int argc, VALUE *argv, VALUE self) { return self; }
257
+ /* let's see if parser is robust in the face of strange spacing */
258
+ static VALUE varargs_func2( int argc , VALUE
259
+ * argv ,VALUE self )
260
+
261
+ {return self;}
262
+ void Init_Foo() {
263
+ mFoo = rb_define_module("Foo");
264
+ rb_define_method(mFoo, "varargs", varargs_func, -1);
265
+ rb_define_method( mFoo ,"varargs2",varargs_func2 ,-1);
266
+ }
267
+ eof
268
+ expect(Registry.at('Foo#varargs').parameters).to eq [['*args', nil]]
269
+ expect(Registry.at('Foo#varargs2').parameters).to eq [['*args', nil]]
270
+ end
271
+
272
+ it "is not too strict or too loose about matching override comments to methods" do
273
+ parse <<-eof
274
+ /* Document-method: Foo::foo
275
+ * Document-method: new
276
+ * Document-method: Foo::Bar#baz
277
+ * Foo bar!
278
+ */
279
+
280
+ void Init_Foo() {
281
+ mFoo = rb_define_module("Foo");
282
+ mBar = rb_define_module_under(mFoo, "Bar");
283
+
284
+ rb_define_method(mFoo, "foo", foo, 0);
285
+ rb_define_singleton_method(mFoo, "foo", foo, 0);
286
+ rb_define_method(mBar, "foo", foo, 0);
287
+ rb_define_singleton_method(mBar, "foo", foo, 0);
288
+
289
+ rb_define_method(mFoo, "initialize", foo, 0);
290
+ rb_define_method(mBar, "initialize", foo, 0);
291
+
292
+ rb_define_method(mFoo, "baz", foo, 0);
293
+ rb_define_singleton_method(mFoo, "baz", foo, 0);
294
+ rb_define_method(mBar, "baz", foo, 0);
295
+ rb_define_singleton_method(mBar, "baz", foo, 0);
296
+ }
297
+ eof
298
+ expect(Registry.at('Foo#foo').docstring).to eq 'Foo bar!'
299
+ expect(Registry.at('Foo.foo').docstring).to eq 'Foo bar!'
300
+ expect(Registry.at('Foo::Bar#foo').docstring).to be_empty
301
+ expect(Registry.at('Foo::Bar.foo').docstring).to be_empty
302
+ expect(Registry.at('Foo#initialize').docstring).to eq 'Foo bar!'
303
+ expect(Registry.at('Foo::Bar#initialize').docstring).to eq 'Foo bar!'
304
+ expect(Registry.at('Foo#baz').docstring).to be_empty
305
+ expect(Registry.at('Foo.baz').docstring).to be_empty
306
+ expect(Registry.at('Foo::Bar#baz').docstring).to eq 'Foo bar!'
307
+ expect(Registry.at('Foo::Bar.baz').docstring).to be_empty
308
+ end
309
+
310
+ it "recognizes core Ruby classes and modules provided by ruby.h" do
311
+ parse_init <<-eof
312
+ rb_define_method(rb_cFixnum, "popcount", fix_popcount, 0);
313
+ rb_define_private_method(rb_mKernel, "pp", obj_pp, 0);
314
+ rb_define_method(rb_mEnumerable, "to_hash", enum_to_hash, 0);
315
+ eof
316
+ expect(Registry.at('Fixnum').type).to eq :class
317
+ expect(Registry.at('Fixnum#popcount').type).to eq :method
318
+ expect(Registry.at('Object').type).to eq :class
319
+ # Methods defined on Kernel are treated as if they were defined on Object
320
+ expect(Registry.at('Object#pp').type).to eq :method
321
+ expect(Registry.at('Enumerable').type).to eq :module
322
+ expect(Registry.at('Enumerable#to_hash').type).to eq :method
238
323
  end
239
324
  end