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::MixinHandler do
4
- it "should add includes to modules or classes" do
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).should == [foo]
16
- baz.mixins(:instance).should == [foo]
15
+ expect(bar.mixins(:instance)).to eq [foo]
16
+ expect(baz.mixins(:instance)).to eq [foo]
17
17
  end
18
18
 
19
- it "should add include as proxy if symbol lookup fails" do
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).should == [P('XYZ')]
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 "should register modules" do
4
+ it "registers modules" do
5
5
  parse_init 'mFoo = rb_define_module("Foo");'
6
- Registry.at('Foo').type.should == :module
6
+ expect(Registry.at('Foo').type).to eq :module
7
7
  end
8
8
 
9
- it "should register classes under namespaces" do
10
- parse_init 'mFoo = rb_define_module_under(mBar, "Foo");'
11
- Registry.at('Bar::Foo').type.should == :module
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 "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_module("Foo");
17
20
  rb_define_method(cXYZ, "bar", bar, 0);
18
21
  eof
19
- Registry.at('Foo').type.should == :module
20
- Registry.at('Foo#bar').should_not be_nil
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 "should not associate declaration comments as module docstring" do
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.should be_blank
31
+ expect(Registry.at('Foo').docstring).to be_blank
29
32
  end
30
33
 
31
- it "should associate a file with the declaration" do
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.should == '(stdin)'
36
- Registry.at('Foo').line.should == 2
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 "should raise undoc error if a class is defined under a namespace that cannot be resolved" do
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 "should raise undoc error if a module is defined under a namespace that cannot be resolved" do
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 "should handle Document-#{type}" do
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.should == type
14
- Registry.at('A').docstring.should == 'Foo bar baz'
15
- Registry.at('A').file.should == '(stdin)'
16
- Registry.at('A').line.should == 2
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 "should handle multiple class/module combinations" do
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.should == 'Foo bar baz'
29
- Registry.at('B').docstring.should == 'Foo bar baz'
30
- Registry.at('C').docstring.should == 'Foo bar baz'
31
- Registry.at('C').type == :module
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 "should handle Document-class with inheritance" do
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.should == :class
43
- obj.docstring.should == 'Foo bar baz'
44
- obj.superclass.should == P('B')
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 'should track variable names defined under namespaces' do
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').should_not be_nil
11
- Registry.at('Foo::Bar#foo').should_not be_nil
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 'should track variable names defined under namespaces' do
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').should_not be_nil
22
- Registry.at('Foo::Bar::Baz#foo').should_not be_nil
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 "should handle rb_path2class() calls" do
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').should_not be_nil
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 "should handle Struct class definitions" do
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.should == :class
13
- Registry.at('Range').superclass.should == P(:Foo)
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}").should_not be_nil }
8
- names.each {|name| Registry.at("A##{name}not").should be_nil }
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
- lambda { StubbedSourceParser.parse_string(code) }.should_not raise_error
12
+ expect { StubbedSourceParser.parse_string(code) }.not_to raise_error
13
13
  end
14
14
 
15
- it "should parse all unless blocks for complex conditions" do
15
+ it "parses all unless blocks for complex conditions" do
16
16
  verify_method :g
17
17
  end
18
18
 
19
- it "should not parse conditionals inside methods" do
19
+ it "does not parse conditionals inside methods" do
20
20
  verify_method :h
21
21
  end
22
22
 
23
- it "should only parse then block if condition is literal value `true`" do
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 "should only parse then block if condition is literal integer != 0" do
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 "should invert block to parse for literal condition if it's an unless block" do
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 "should handle conditions such as 'defined? VALUE'" do
35
+ it "handles conditions such as 'defined? VALUE'" do
36
36
  verify_method :j, :k
37
37
  end
38
38
 
39
- it "should parse all if/elsif blocks for complex conditions" do
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 "should only parse else block if condition is literal value `false`" do
43
+ it "parses else block if condition is literal value `false`" do
44
44
  verify_method :q
45
45
  end
46
46
 
47
- it "should only parse else block if condition is literal integer == 0" do
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 "should maintain visibility and scope state inside condition" do
52
- Registry.at('A#m').visibility.should == :private
53
- Registry.at('A#mnot').visibility.should == :private
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 "should not fail on complex conditions" do
57
- log.should_not_receive(:warn)
58
- log.should_not_receive(:error)
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 "should parse a class block with docstring" do
7
- P("A").docstring.should == "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 "should handle complex class names" do
11
- P("A::B::C").should_not == nil
10
+ it "handles complex class names" do
11
+ expect(P("A::B::C")).not_to eq nil
12
12
  end
13
13
 
14
- it "should handle the subclassing syntax" do
15
- P("A::B::C").superclass.should == P(:String)
16
- P("A::X").superclass.should == Registry.at("A::B::C")
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 "should interpret class << self as a class level block" do
20
- P("A.classmethod1").should_not == nil
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 "should interpret class << ClassName as a class level block in ClassName's namespace" do
24
- P("A::B::C.Hello").should be_instance_of(CodeObjects::MethodObject)
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 "should make visibility public when parsing a block" do
28
- P("A::B::C#method1").visibility.should == :public
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 "should set superclass type to :class if it is a Proxy" do
32
- P("A::B::C").superclass.type.should == :class
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 "should look for a superclass before creating the class if it shares the same name" do
36
- P('B::A').superclass.should == P('A')
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 "should handle class definitions in the form ::ClassName" do
40
- Registry.at("MyRootClass").should_not be_nil
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 "should handle superclass as a constant-style method (camping style < R /path/)" do
44
- P('Test1').superclass.should == P(:R)
45
- P('Test2').superclass.should == P(:R)
46
- P('Test6').superclass.should == P(:NotDelegateClass)
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 "should handle superclass with OStruct.new or Struct.new syntax (superclass should be OStruct/Struct)" do
50
- P('Test3').superclass.should == P(:Struct)
51
- P('Test4').superclass.should == P(:OStruct)
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 "should handle DelegateClass(CLASSNAME) superclass syntax" do
55
- P('Test5').superclass.should == P(:Array)
54
+ it "handles DelegateClass(CLASSNAME) superclass syntax" do
55
+ expect(P('Test5').superclass).to eq P(:Array)
56
56
  end
57
57
 
58
- it "should handle a superclass of the same name in the form ::ClassName" do
59
- P('Q::Logger').superclass.should == P(:Logger)
60
- P('Q::Foo').superclass.should_not == P('Q::Logger')
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 "should raise an UndocumentableError for invalid class '#{klass}'" do
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 "should raise an UndocumentableError for invalid superclass '#{klass}' but it should create the class." do
71
- YARD::CodeObjects::ClassObject.should_receive(:new).with(Registry.root, 'A')
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.should == P(:Object)
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 "should raise an UndocumentableError if the constant class reference 'class << SomeConstant' does not point to a valid class name" do
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).should be_nil
85
+ expect(Registry.at(klass)).to be nil
86
86
  end
87
87
  end
88
88
 
89
- it "should document 'class << SomeConstant' by using SomeConstant's value as a reference to the real class name" do
90
- Registry.at('String.classmethod').should_not be_nil
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 "should allow class << SomeRubyClass to create the class if it does not exist" do
94
- Registry.at('Symbol.toString').should_not be_nil
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 "should document 'class Exception' without running into superclass issues" do
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).should_not be_nil
102
+ expect(Registry.at(:Exception)).not_to be nil
103
103
  end
104
104
 
105
- it "should document 'class RT < XX::RT' with proper superclass even if XX::RT is a proxy" do
106
- Registry.at(:RT).should_not be_nil
107
- Registry.at(:RT).superclass.should == P('XX::RT')
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 "should not overwrite docstring with an empty one" do
111
- Registry.at(:Zebra).docstring.should == "Docstring 2"
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 "should turn 'class Const < Struct.new(:sym)' into class Const with attr :sym" do
114
+ it "turns 'class Const < Struct.new(:sym)' into class Const with attr :sym" do
115
115
  obj = Registry.at("Point")
116
- obj.should be_kind_of(CodeObjects::ClassObject)
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.should have_key(key)
120
- attrs[key][:read].should_not be_nil
121
- attrs[key][:write].should_not be_nil
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 "should turn 'class Const < Struct.new('Name', :sym)' into class Const with attr :sym" do
125
+ it "turns 'class Const < Struct.new('Name', :sym)' into class Const with attr :sym" do
126
126
  obj = Registry.at("AnotherPoint")
127
- obj.should be_kind_of(CodeObjects::ClassObject)
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.should have_key(key)
131
- attrs[key][:read].should_not be_nil
132
- attrs[key][:write].should_not be_nil
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").should be_nil
135
+ expect(Registry.at("XPoint")).to be nil
136
136
  end
137
137
 
138
- it "should create a Struct::Name class when class Const < Struct.new('Name', :sym) is found" do
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.should_not be_nil
140
+ expect(obj).not_to be nil
141
141
  end
142
142
 
143
- it "should attach attribtues to the generated Struct::Name class when Struct.new('Name') is used" do
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.should have_key(key)
148
- attrs[key][:read].should_not be_nil
149
- attrs[key][:write].should_not be_nil
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 "should use @attr to set attribute descriptions on Struct subclasses" do
153
+ it "uses @attr to set attribute descriptions on Struct subclasses" do
154
154
  obj = Registry.at("DoccedStruct#input")
155
- obj.docstring.should == "the input stream"
155
+ expect(obj.docstring).to eq "the input stream"
156
156
  end
157
157
 
158
- it "should use @attr to set attribute types on Struct subclasses" do
158
+ it "uses @attr to set attribute types on Struct subclasses" do
159
159
  obj = Registry.at("DoccedStruct#someproc")
160
- obj.should_not be_nil
161
- obj.tag(:return).should_not be_nil
162
- obj.tag(:return).types.should == ["Proc", "#call"]
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 "should default types unspecified by @attr to Object on Struct subclasses" do
165
+ it "defaults types unspecified by @attr to Object on Struct subclasses" do
166
166
  obj = Registry.at("DoccedStruct#mode")
167
- obj.should_not be_nil
168
- obj.tag(:return).should_not be_nil
169
- obj.tag(:return).types.should == ["Object"]
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 "should create parameters for writers of Struct subclass's attributes" do
172
+ it "creates parameters for writers of Struct subclass's attributes" do
173
173
  obj = Registry.at("DoccedStruct#input=")
174
- obj.tags(:param).size.should == 1
175
- obj.tag(:param).types.should == ["IO"]
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].should_not be_nil
184
- attrs[:first][:write].should_not be_nil
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].should_not be_nil
191
- attrs[:second][:write].should be_nil
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].should be_nil
198
- attrs[:third][:write].should_not be_nil
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.should == ["Fixnum"]
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.should == ["Array"]
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].should_not be_nil
215
- attrs[:fourth][:write].should_not be_nil
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.should == ["#read"]
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.should == ["IO"]
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.should == "returns a proc that reads"
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.should == "sets the proc that writes stuff"
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 "should inherit from a regular struct" do
239
- Registry.at('RegularStruct').superclass.should == P(:Struct)
240
- Registry.at('RegularStruct2').superclass.should == P(:Struct)
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 "should handle inheritance from 'self'" do
244
- Registry.at('Outer1::Inner1').superclass.should == Registry.at('Outer1')
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