yard 0.9.23 → 0.9.27

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 (257) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +0 -0
  3. data/.gitattributes +4 -0
  4. data/.github/FUNDING.yml +3 -0
  5. data/.github/ISSUE_TEMPLATE.md +6 -6
  6. data/.github/PULL_REQUEST_TEMPLATE.md +5 -5
  7. data/.github/workflows/ci.yml +30 -0
  8. data/.github/workflows/gem.yml +19 -0
  9. data/.gitignore +0 -0
  10. data/.rspec +0 -0
  11. data/.rubocop.yml +37 -24
  12. data/.yardopts +0 -0
  13. data/.yardopts_guide +0 -0
  14. data/.yardopts_i18n +0 -0
  15. data/CHANGELOG.md +50 -4
  16. data/CONTRIBUTING.md +2 -2
  17. data/Gemfile +5 -3
  18. data/README.md +97 -102
  19. data/Rakefile +2 -3
  20. data/lib/yard/cli/diff.rb +4 -1
  21. data/lib/yard/cli/server.rb +22 -13
  22. data/lib/yard/cli/stats.rb +2 -0
  23. data/lib/yard/cli/yardoc.rb +2 -1
  24. data/lib/yard/code_objects/method_object.rb +1 -1
  25. data/lib/yard/code_objects/namespace_mapper.rb +30 -3
  26. data/lib/yard/code_objects/proxy.rb +2 -1
  27. data/lib/yard/globals.rb +1 -1
  28. data/lib/yard/handlers/c/base.rb +35 -0
  29. data/lib/yard/handlers/ruby/method_handler.rb +1 -1
  30. data/lib/yard/handlers/ruby/mixin_handler.rb +7 -2
  31. data/lib/yard/handlers/ruby/module_function_handler.rb +15 -3
  32. data/lib/yard/parser/ruby/ast_node.rb +2 -2
  33. data/lib/yard/parser/ruby/ruby_parser.rb +7 -5
  34. data/lib/yard/parser/ruby/token_resolver.rb +3 -1
  35. data/lib/yard/parser/source_parser.rb +1 -1
  36. data/lib/yard/registry_resolver.rb +10 -24
  37. data/lib/yard/registry_store.rb +1 -1
  38. data/lib/yard/serializers/yardoc_serializer.rb +1 -1
  39. data/lib/yard/server/commands/base.rb +2 -2
  40. data/lib/yard/server/commands/library_command.rb +1 -1
  41. data/lib/yard/tags/directives.rb +10 -1
  42. data/lib/yard/templates/helpers/html_helper.rb +15 -5
  43. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +5 -4
  44. data/lib/yard/templates/helpers/markup_helper.rb +2 -1
  45. data/lib/yard/templates/section.rb +1 -3
  46. data/lib/yard/version.rb +1 -1
  47. data/lib/yard.rb +3 -0
  48. data/samus.json +15 -46
  49. data/tasks/prepare_tag.rake +45 -0
  50. data/tasks/update_error_map.rake +53 -0
  51. data/templates/default/fulldoc/html/css/style.css +1 -0
  52. data/yard.gemspec +3 -2
  53. metadata +23 -207
  54. data/.travis.yml +0 -52
  55. data/spec/cli/command_parser_spec.rb +0 -43
  56. data/spec/cli/command_spec.rb +0 -36
  57. data/spec/cli/config_spec.rb +0 -148
  58. data/spec/cli/diff_spec.rb +0 -254
  59. data/spec/cli/display_spec.rb +0 -30
  60. data/spec/cli/gems_spec.rb +0 -81
  61. data/spec/cli/graph_spec.rb +0 -18
  62. data/spec/cli/help_spec.rb +0 -22
  63. data/spec/cli/i18n_spec.rb +0 -107
  64. data/spec/cli/list_spec.rb +0 -8
  65. data/spec/cli/markup_types_spec.rb +0 -22
  66. data/spec/cli/server_spec.rb +0 -324
  67. data/spec/cli/stats_spec.rb +0 -96
  68. data/spec/cli/yard_on_yard_spec.rb +0 -38
  69. data/spec/cli/yardoc_spec.rb +0 -896
  70. data/spec/cli/yri_spec.rb +0 -101
  71. data/spec/code_objects/base_spec.rb +0 -485
  72. data/spec/code_objects/class_object_spec.rb +0 -226
  73. data/spec/code_objects/code_object_list_spec.rb +0 -36
  74. data/spec/code_objects/constants_spec.rb +0 -116
  75. data/spec/code_objects/extra_file_object_spec.rb +0 -161
  76. data/spec/code_objects/macro_object_spec.rb +0 -150
  77. data/spec/code_objects/method_object_spec.rb +0 -184
  78. data/spec/code_objects/module_object_spec.rb +0 -142
  79. data/spec/code_objects/namespace_object_spec.rb +0 -171
  80. data/spec/code_objects/proxy_spec.rb +0 -147
  81. data/spec/code_objects/spec_helper.rb +0 -3
  82. data/spec/config_spec.rb +0 -171
  83. data/spec/core_ext/array_spec.rb +0 -13
  84. data/spec/core_ext/file_spec.rb +0 -72
  85. data/spec/core_ext/hash_spec.rb +0 -14
  86. data/spec/core_ext/insertion_spec.rb +0 -37
  87. data/spec/core_ext/module_spec.rb +0 -9
  88. data/spec/core_ext/string_spec.rb +0 -42
  89. data/spec/core_ext/symbol_hash_spec.rb +0 -89
  90. data/spec/docstring_parser_spec.rb +0 -280
  91. data/spec/docstring_spec.rb +0 -373
  92. data/spec/handlers/alias_handler_spec.rb +0 -82
  93. data/spec/handlers/attribute_handler_spec.rb +0 -96
  94. data/spec/handlers/base_spec.rb +0 -216
  95. data/spec/handlers/c/alias_handler_spec.rb +0 -34
  96. data/spec/handlers/c/attribute_handler_spec.rb +0 -41
  97. data/spec/handlers/c/class_handler_spec.rb +0 -78
  98. data/spec/handlers/c/constant_handler_spec.rb +0 -71
  99. data/spec/handlers/c/init_handler_spec.rb +0 -48
  100. data/spec/handlers/c/method_handler_spec.rb +0 -327
  101. data/spec/handlers/c/mixin_handler_spec.rb +0 -44
  102. data/spec/handlers/c/module_handler_spec.rb +0 -71
  103. data/spec/handlers/c/override_comment_handler_spec.rb +0 -47
  104. data/spec/handlers/c/path_handler_spec.rb +0 -36
  105. data/spec/handlers/c/spec_helper.rb +0 -23
  106. data/spec/handlers/c/struct_handler_spec.rb +0 -16
  107. data/spec/handlers/class_condition_handler_spec.rb +0 -87
  108. data/spec/handlers/class_handler_spec.rb +0 -247
  109. data/spec/handlers/class_method_handler_shared_examples.rb +0 -133
  110. data/spec/handlers/class_variable_handler_spec.rb +0 -12
  111. data/spec/handlers/constant_handler_spec.rb +0 -112
  112. data/spec/handlers/decorator_handler_methods_spec.rb +0 -393
  113. data/spec/handlers/dsl_handler_spec.rb +0 -226
  114. data/spec/handlers/examples/alias_handler_001.rb.txt +0 -46
  115. data/spec/handlers/examples/attribute_handler_001.rb.txt +0 -32
  116. data/spec/handlers/examples/class_condition_handler_001.rb.txt +0 -69
  117. data/spec/handlers/examples/class_handler_001.rb.txt +0 -120
  118. data/spec/handlers/examples/class_variable_handler_001.rb.txt +0 -10
  119. data/spec/handlers/examples/constant_handler_001.rb.txt +0 -35
  120. data/spec/handlers/examples/dsl_handler_001.rb.txt +0 -156
  121. data/spec/handlers/examples/exception_handler_001.rb.txt +0 -59
  122. data/spec/handlers/examples/extend_handler_001.rb.txt +0 -19
  123. data/spec/handlers/examples/method_condition_handler_001.rb.txt +0 -10
  124. data/spec/handlers/examples/method_handler_001.rb.txt +0 -128
  125. data/spec/handlers/examples/mixin_handler_001.rb.txt +0 -40
  126. data/spec/handlers/examples/module_handler_001.rb.txt +0 -29
  127. data/spec/handlers/examples/private_constant_handler_001.rb.txt +0 -8
  128. data/spec/handlers/examples/process_handler_001.rb.txt +0 -11
  129. data/spec/handlers/examples/visibility_handler_001.rb.txt +0 -36
  130. data/spec/handlers/examples/yield_handler_001.rb.txt +0 -54
  131. data/spec/handlers/exception_handler_spec.rb +0 -49
  132. data/spec/handlers/extend_handler_spec.rb +0 -28
  133. data/spec/handlers/legacy_base_spec.rb +0 -128
  134. data/spec/handlers/method_condition_handler_spec.rb +0 -15
  135. data/spec/handlers/method_handler_spec.rb +0 -214
  136. data/spec/handlers/mixin_handler_spec.rb +0 -60
  137. data/spec/handlers/module_function_handler_spec.rb +0 -106
  138. data/spec/handlers/module_handler_spec.rb +0 -35
  139. data/spec/handlers/private_class_method_handler_spec.rb +0 -11
  140. data/spec/handlers/private_constant_handler_spec.rb +0 -25
  141. data/spec/handlers/processor_spec.rb +0 -35
  142. data/spec/handlers/public_class_method_handler_spec.rb +0 -11
  143. data/spec/handlers/ruby/base_spec.rb +0 -95
  144. data/spec/handlers/ruby/legacy/base_spec.rb +0 -84
  145. data/spec/handlers/spec_helper.rb +0 -33
  146. data/spec/handlers/visibility_handler_spec.rb +0 -44
  147. data/spec/handlers/yield_handler_spec.rb +0 -52
  148. data/spec/i18n/locale_spec.rb +0 -81
  149. data/spec/i18n/message_spec.rb +0 -52
  150. data/spec/i18n/messages_spec.rb +0 -67
  151. data/spec/i18n/pot_generator_spec.rb +0 -295
  152. data/spec/i18n/text_spec.rb +0 -184
  153. data/spec/logging_spec.rb +0 -44
  154. data/spec/options_spec.rb +0 -171
  155. data/spec/parser/base_spec.rb +0 -24
  156. data/spec/parser/c_parser_spec.rb +0 -236
  157. data/spec/parser/examples/array.c.txt +0 -6267
  158. data/spec/parser/examples/example1.rb.txt +0 -8
  159. data/spec/parser/examples/extrafile.c.txt +0 -8
  160. data/spec/parser/examples/file.c.txt +0 -28
  161. data/spec/parser/examples/multifile.c.txt +0 -22
  162. data/spec/parser/examples/namespace.cpp.txt +0 -68
  163. data/spec/parser/examples/override.c.txt +0 -424
  164. data/spec/parser/examples/parse_in_order_001.rb.txt +0 -2
  165. data/spec/parser/examples/parse_in_order_002.rb.txt +0 -2
  166. data/spec/parser/examples/tag_handler_001.rb.txt +0 -8
  167. data/spec/parser/ruby/ast_node_spec.rb +0 -33
  168. data/spec/parser/ruby/legacy/statement_list_spec.rb +0 -299
  169. data/spec/parser/ruby/legacy/token_list_spec.rb +0 -79
  170. data/spec/parser/ruby/ruby_parser_spec.rb +0 -508
  171. data/spec/parser/ruby/token_resolver_spec.rb +0 -165
  172. data/spec/parser/source_parser_spec.rb +0 -727
  173. data/spec/parser/tag_parsing_spec.rb +0 -17
  174. data/spec/rake/yardoc_task_spec.rb +0 -118
  175. data/spec/registry_spec.rb +0 -463
  176. data/spec/registry_store_spec.rb +0 -327
  177. data/spec/rubygems/doc_manager_spec.rb +0 -112
  178. data/spec/serializers/data/serialized_yardoc/checksums +0 -1
  179. data/spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat +0 -0
  180. data/spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat +0 -0
  181. data/spec/serializers/data/serialized_yardoc/objects/Foo.dat +0 -0
  182. data/spec/serializers/data/serialized_yardoc/objects/root.dat +0 -0
  183. data/spec/serializers/data/serialized_yardoc/proxy_types +0 -2
  184. data/spec/serializers/file_system_serializer_spec.rb +0 -145
  185. data/spec/serializers/spec_helper.rb +0 -2
  186. data/spec/serializers/yardoc_serializer_spec.rb +0 -78
  187. data/spec/server/adapter_spec.rb +0 -39
  188. data/spec/server/commands/base_spec.rb +0 -91
  189. data/spec/server/commands/library_command_spec.rb +0 -39
  190. data/spec/server/doc_server_helper_spec.rb +0 -72
  191. data/spec/server/doc_server_serializer_spec.rb +0 -60
  192. data/spec/server/rack_adapter_spec.rb +0 -21
  193. data/spec/server/router_spec.rb +0 -123
  194. data/spec/server/spec_helper.rb +0 -22
  195. data/spec/server/static_caching_spec.rb +0 -47
  196. data/spec/server/webrick_servlet_spec.rb +0 -20
  197. data/spec/server_spec.rb +0 -19
  198. data/spec/spec_helper.rb +0 -212
  199. data/spec/tags/default_factory_spec.rb +0 -168
  200. data/spec/tags/default_tag_spec.rb +0 -11
  201. data/spec/tags/directives_spec.rb +0 -463
  202. data/spec/tags/library_spec.rb +0 -48
  203. data/spec/tags/overload_tag_spec.rb +0 -53
  204. data/spec/tags/ref_tag_list_spec.rb +0 -53
  205. data/spec/tags/types_explainer_spec.rb +0 -203
  206. data/spec/templates/class_spec.rb +0 -45
  207. data/spec/templates/constant_spec.rb +0 -41
  208. data/spec/templates/engine_spec.rb +0 -131
  209. data/spec/templates/examples/class001.html +0 -308
  210. data/spec/templates/examples/class001.txt +0 -36
  211. data/spec/templates/examples/class002.html +0 -39
  212. data/spec/templates/examples/constant001.txt +0 -25
  213. data/spec/templates/examples/constant002.txt +0 -7
  214. data/spec/templates/examples/constant003.txt +0 -11
  215. data/spec/templates/examples/method001.html +0 -137
  216. data/spec/templates/examples/method001.txt +0 -35
  217. data/spec/templates/examples/method002.html +0 -91
  218. data/spec/templates/examples/method002.txt +0 -20
  219. data/spec/templates/examples/method003.html +0 -165
  220. data/spec/templates/examples/method003.txt +0 -45
  221. data/spec/templates/examples/method004.html +0 -48
  222. data/spec/templates/examples/method004.txt +0 -10
  223. data/spec/templates/examples/method005.html +0 -105
  224. data/spec/templates/examples/method005.txt +0 -33
  225. data/spec/templates/examples/method006.html +0 -108
  226. data/spec/templates/examples/method006.txt +0 -20
  227. data/spec/templates/examples/module001.dot +0 -33
  228. data/spec/templates/examples/module001.html +0 -833
  229. data/spec/templates/examples/module001.txt +0 -33
  230. data/spec/templates/examples/module002.html +0 -341
  231. data/spec/templates/examples/module003.html +0 -202
  232. data/spec/templates/examples/module004.html +0 -394
  233. data/spec/templates/examples/module005.html +0 -82
  234. data/spec/templates/examples/tag001.txt +0 -82
  235. data/spec/templates/helpers/base_helper_spec.rb +0 -171
  236. data/spec/templates/helpers/html_helper_spec.rb +0 -687
  237. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +0 -65
  238. data/spec/templates/helpers/markup/rdoc_markup_spec.rb +0 -84
  239. data/spec/templates/helpers/markup_helper_spec.rb +0 -136
  240. data/spec/templates/helpers/method_helper_spec.rb +0 -107
  241. data/spec/templates/helpers/module_helper_spec.rb +0 -35
  242. data/spec/templates/helpers/shared_signature_examples.rb +0 -126
  243. data/spec/templates/helpers/text_helper_spec.rb +0 -65
  244. data/spec/templates/markup_processor_integrations/asciidoctor_spec.rb +0 -60
  245. data/spec/templates/markup_processor_integrations/integration_spec_helper.rb +0 -46
  246. data/spec/templates/markup_processor_integrations/rdoc_markdown_spec.rb +0 -59
  247. data/spec/templates/markup_processor_integrations/rdoc_spec.rb +0 -39
  248. data/spec/templates/markup_processor_integrations/redcarpet_spec.rb +0 -59
  249. data/spec/templates/markup_processor_integrations/redcloth_spec.rb +0 -48
  250. data/spec/templates/method_spec.rb +0 -118
  251. data/spec/templates/module_spec.rb +0 -203
  252. data/spec/templates/onefile_spec.rb +0 -66
  253. data/spec/templates/section_spec.rb +0 -144
  254. data/spec/templates/spec_helper.rb +0 -76
  255. data/spec/templates/tag_spec.rb +0 -52
  256. data/spec/templates/template_spec.rb +0 -410
  257. data/spec/verifier_spec.rb +0 -106
@@ -1,36 +0,0 @@
1
- class Testing
2
- def pub; end
3
-
4
- private
5
-
6
- def priv; end
7
- def notpriv; end
8
- def notpriv2; end
9
- def notpriv?; end
10
-
11
- protected
12
-
13
- def prot; end
14
-
15
- public
16
-
17
- def pub2; end
18
-
19
- protected :notpriv, 'notpriv2', :notpriv?
20
-
21
- private name
22
- private *argument
23
- private *(method_call)
24
-
25
- def Foo; end
26
- private :Foo
27
-
28
- private def decpriv; end
29
-
30
- private
31
-
32
- class Bar; end
33
- module Baz; end
34
-
35
- private :not_exist!
36
- end
@@ -1,54 +0,0 @@
1
- class Testing
2
- # Ignore yields outside methods
3
- yield x, y, z
4
-
5
- # Should document this
6
- def mymethod
7
- yield
8
- end
9
-
10
- # Has yield and yieldparam documentation
11
- # @yield [a, b] Blah
12
- # @yieldparam a Blah
13
- # @yieldparam b Blah
14
- def mymethod2
15
- yield(b, a) # Yield something else
16
- end
17
-
18
- # Has yield documentation only
19
- # @yield [a, b]
20
- def mymethod3
21
- yield self # Should not be changed
22
- end
23
-
24
- # Has yieldparam documentation only
25
- # @yieldparam _self BLAH
26
- def mymethod4
27
- yield self
28
- end
29
-
30
- # Some weird possibilities..
31
- # Document it all.
32
-
33
-
34
- def mymethod5
35
- yield :a, b, self, File.read('file', 'w'), CONSTANT if x == 2
36
- end
37
-
38
- def mymethod6
39
- yield(b, a)
40
- end
41
-
42
- def mymethod7
43
- yield a
44
- yield b
45
- end
46
-
47
- def mymethod8
48
- yield self
49
- end
50
-
51
- def mymethod9
52
- yield super
53
- end
54
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- RSpec.describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ExceptionHandler" do
5
- before(:all) { parse_file :exception_handler_001, __FILE__ }
6
-
7
- it "does not document an exception outside of a method" do
8
- expect(P('Testing').has_tag?(:raise)).to be false
9
- end
10
-
11
- it "documents a valid raise" do
12
- expect(P('Testing#mymethod').tag(:raise).types).to eq ['ArgumentError']
13
- end
14
-
15
- it "only documents non-dynamic raises" do
16
- expect(P('Testing#mymethod2').tag(:raise)).to be nil
17
- expect(P('Testing#mymethod6').tag(:raise)).to be nil
18
- expect(P('Testing#mymethod7').tag(:raise)).to be nil
19
- end
20
-
21
- it "treats ConstantName.new as a valid exception class" do
22
- expect(P('Testing#mymethod8').tag(:raise).types).to eq ['ExceptionClass']
23
- end
24
-
25
- it "does not document a method with an existing @raise tag" do
26
- expect(P('Testing#mymethod3').tag(:raise).types).to eq ['A']
27
- end
28
-
29
- it "only documents the first raise message of a method (limitation of exception handler)" do
30
- expect(P('Testing#mymethod4').tag(:raise).types).to eq ['A']
31
- end
32
-
33
- it "handles complex class names" do
34
- expect(P('Testing#mymethod5').tag(:raise).types).to eq ['YARD::Parser::UndocumentableError']
35
- end
36
-
37
- it "ignores any raise calls on a receiver" do
38
- expect(P('Testing#mymethod9').tag(:raise)).to be nil
39
- end
40
-
41
- it "handles raise expressions that are method calls" do
42
- expect(P('Testing#mymethod10').tag(:raise)).to be nil
43
- expect(P('Testing#mymethod11').tag(:raise)).to be nil
44
- end
45
-
46
- it "ignores empty raise call" do
47
- expect(P('Testing#mymethod12').tag(:raise)).to be nil
48
- end
49
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- RSpec.describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ExtendHandler" do
5
- before(:all) { parse_file :extend_handler_001, __FILE__ }
6
-
7
- it "includes modules at class scope" do
8
- expect(Registry.at(:B).class_mixins).to eq [P(:A)]
9
- expect(Registry.at(:B).instance_mixins).to be_empty
10
- end
11
-
12
- it "handles a module extending itself" do
13
- expect(Registry.at(:C).class_mixins).to eq [P(:C)]
14
- expect(Registry.at(:C).instance_mixins).to be_empty
15
- end
16
-
17
- it "extends module with correct namespace" do
18
- expect(Registry.at('Q::R::S').class_mixins.first.path).to eq 'A'
19
- end
20
-
21
- it "does not allow extending self if object is a class" do
22
- undoc_error "class Foo; extend self; end"
23
- end
24
-
25
- it "adds mixins from extend calls to constants" do
26
- expect(P('FromConstant').class_mixins).to eq [P('A')]
27
- end
28
- end
@@ -1,128 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- include Parser::Ruby::Legacy
5
-
6
- RSpec.describe YARD::Handlers::Ruby::Legacy::Base, "#tokval" do
7
- before { @handler = Handlers::Ruby::Legacy::Base.new(nil, nil) }
8
-
9
- def tokval(code, *types)
10
- @handler.send(:tokval, TokenList.new(code).first, *types)
11
- end
12
-
13
- it "returns the String's value without quotes" do
14
- expect(tokval('"hello"')).to eq "hello"
15
- end
16
-
17
- it "does not allow interpolated strings with TkSTRING" do
18
- expect(tokval('"#{c}"', RubyToken::TkSTRING)).to be nil
19
- end
20
-
21
- it "returns a Symbol's value as a String (as if it was done via :name.to_sym)" do
22
- expect(tokval(':sym')).to eq :sym
23
- end
24
-
25
- it "returns nil for any non accepted type" do
26
- expect(tokval('identifier')).to be nil
27
- expect(tokval(':sym', RubyToken::TkId)).to be nil
28
- end
29
-
30
- it "accepts TkVal tokens by default" do
31
- expect(tokval('2.5')).to eq 2.5
32
- expect(tokval(':sym')).to eq :sym
33
- end
34
-
35
- it "accepts any ID type if TkId is set" do
36
- expect(tokval('variable', RubyToken::TkId)).to eq "variable"
37
- expect(tokval('CONSTANT', RubyToken::TkId)).to eq "CONSTANT"
38
- end
39
-
40
- it "allows extra token types to be accepted" do
41
- expect(tokval('2.5', RubyToken::TkFLOAT)).to eq 2.5
42
- expect(tokval('2', RubyToken::TkFLOAT)).to be nil
43
- expect(tokval(':symbol', RubyToken::TkFLOAT)).to be nil
44
- end
45
-
46
- it "allows :string for any string type" do
47
- expect(tokval('"hello"', :string)).to eq "hello"
48
- expect(tokval('"#{c}"', :string)).to eq '#{c}'
49
- end
50
-
51
- it "does not include interpolated strings when using :attr" do
52
- expect(tokval('"#{c}"', :attr)).to be nil
53
- end
54
-
55
- it "allows any number type with :number" do
56
- expect(tokval('2.5', :number)).to eq 2.5
57
- expect(tokval('2', :number)).to eq 2
58
- end
59
-
60
- it "allows method names with :identifier" do
61
- expect(tokval('methodname?', :identifier)).to eq "methodname?"
62
- end
63
-
64
- # it "obeys documentation expectations" do docspec end
65
- end
66
-
67
- RSpec.describe YARD::Handlers::Base, "#tokval_list" do
68
- before { @handler = Handlers::Ruby::Legacy::Base.new(nil, nil) }
69
-
70
- def tokval_list(code, *types)
71
- @handler.send(:tokval_list, TokenList.new(code), *types)
72
- end
73
-
74
- it "returns the list of tokvalues" do
75
- expect(tokval_list(":a, :b, \"\#{c}\", 'd'", :attr)).to eq [:a, :b, 'd']
76
- expect(tokval_list(":a, :b, File.read(\"\#{c}\", ['w']), :d",
77
- RubyToken::Token)).to eq [:a, :b, 'File.read("#{c}", [\'w\'])', :d]
78
- end
79
-
80
- it "tries to skip any invalid tokens" do
81
- expect(tokval_list(":a, :b, \"\#{c}\", :d", :attr)).to eq [:a, :b, :d]
82
- expect(tokval_list(":a, :b, File.read(\"\#{c}\", 'w', File.open { }), :d", :attr)).to eq [:a, :b, :d]
83
- expect(tokval_list("CONST1, identifier, File.read(\"\#{c}\", 'w', File.open { }), CONST2",
84
- RubyToken::TkId)).to eq ['CONST1', 'identifier', 'CONST2']
85
- end
86
-
87
- it "ignores a token if another invalid token is read before a comma" do
88
- expect(tokval_list(":a, :b XYZ, :c", RubyToken::TkSYMBOL)).to eq [:a, :c]
89
- end
90
-
91
- it "stops on most keywords" do
92
- expect(tokval_list(':a rescue :x == 5', RubyToken::Token)).to eq [:a]
93
- end
94
-
95
- it "handles ignore parentheses that begin the token list" do
96
- expect(tokval_list('(:a, :b, :c)', :attr)).to eq [:a, :b, :c]
97
- end
98
-
99
- it "ends when a closing parenthesis was found" do
100
- expect(tokval_list(':a, :b, :c), :d', :attr)).to eq [:a, :b, :c]
101
- end
102
-
103
- it "ignores parentheses around items in a list" do
104
- expect(tokval_list(':a, (:b), :c, (:d TEST), :e, [:f], :g', :attr)).to eq [:a, :b, :c, :e, :g]
105
- expect(tokval_list(':a, (((:f)))', :attr)).to eq [:a, :f]
106
- expect(tokval_list(':a, ([:f]), :c)', RubyToken::Token)).to eq [:a, '[:f]', :c]
107
- end
108
-
109
- it "does not stop on a true/false/self keyword (cannot handle nil)" do
110
- expect(tokval_list(':a, true, :b, self, false, :c, nil, File, super, if, XYZ',
111
- RubyToken::Token)).to eq [:a, true, :b, 'self', false, :c, 'File', 'super']
112
- end
113
-
114
- it "ignores invalid commas" do
115
- expect(tokval_list(":a, :b, , :d")).to eq [:a, :b, :d]
116
- end
117
-
118
- it "returns an empty list if no matches were found" do
119
- expect(tokval_list('attr_accessor :x')).to eq []
120
- end
121
-
122
- it "treats {} as a valid value" do
123
- # FIXME: tokval_list destroys extra spaces surrounding the '=' in
124
- # this situation. This is technically a design flaw of the
125
- # tokval parser, but this is now the expected behaviour.
126
- expect(tokval_list("opts = {}", :all)).to eq ["opts={}"]
127
- end
128
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- RSpec.describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MethodConditionHandler" do
5
- before(:all) { parse_file :method_condition_handler_001, __FILE__ }
6
-
7
- it "does not parse regular if blocks in methods" do
8
- expect(Registry.at('#b')).to be nil
9
- end
10
-
11
- it "parses if/unless blocks in the form X if COND" do
12
- expect(Registry.at('#c')).not_to be nil
13
- expect(Registry.at('#d')).not_to be nil
14
- end
15
- end
@@ -1,214 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- RSpec.describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MethodHandler" do
5
- before(:all) do
6
- log.enter_level(Logger::ERROR) do
7
- parse_file :method_handler_001, __FILE__
8
- end
9
- end
10
-
11
- it "adds methods to parent's #meths list" do
12
- expect(P(:Foo).meths).to include(P("Foo#method1"))
13
- end
14
-
15
- it "parses and adds class methods (self.method2)" do
16
- expect(P(:Foo).meths).to include(P("Foo.method2"))
17
- end
18
-
19
- it "parses and adds class methods from other namespaces (String.hello)" do
20
- expect(P("String.hello")).to be_instance_of(CodeObjects::MethodObject)
21
- end
22
-
23
- [:[], :[]=, :allowed?, :/, :=~, :==, :`, :|, :*, :&, :%, :'^', :-@, :+@, :'~@'].each do |name|
24
- it "allows valid method #{name}" do
25
- expect(Registry.at("Foo##{name}")).not_to be nil
26
- end
27
- end
28
-
29
- it "allows self.methname" do
30
- expect(Registry.at("Foo.new")).not_to be nil
31
- end
32
-
33
- it "marks dynamic methods as such" do
34
- expect(P('Foo#dynamic').dynamic?).to be true
35
- end
36
-
37
- it "shows that a method is explicitly defined (if it was originally defined implicitly by attribute)" do
38
- expect(P('Foo#method1').is_explicit?).to be true
39
- end
40
-
41
- it "handles parameters" do
42
- expect(P('Foo#[]').parameters).to eq [['key', "'default'"]]
43
- expect(P('Foo#/').parameters).to eq [['x', "File.new('x', 'w')"], ['y', '2']]
44
- end
45
-
46
- it "handles multiline parameters" do
47
- YARD.parse_string <<-EOF
48
- class Bar
49
- def multiline_params(x,
50
- y, z, zz = 'zz',
51
- *foo,
52
- a: 'a', b: 'b',
53
- c: 'c',
54
- **bar,
55
- &blk
56
- )
57
- end
58
- end
59
- EOF
60
-
61
- sig = "def multiline_params(x, y, z, zz = 'zz', *foo, a: 'a', b: 'b', c: 'c', **bar, &blk)"
62
- expect(P('Bar#multiline_params').signature).to eq sig
63
- end if YARD.ruby2?
64
-
65
- it "handles method signature with no parameters" do
66
- YARD.parse_string "class Bar; def foo; end end"
67
- expect(P('Bar#foo').signature).to eq 'def foo'
68
- end
69
-
70
- it "handles opts = {} as parameter" do
71
- expect(P('Foo#optsmeth').parameters).to eq [['x', nil], ['opts', '{}']]
72
- end
73
-
74
- it "handles &block as parameter" do
75
- expect(P('Foo#blockmeth').parameters).to eq [['x', nil], ['&block', nil]]
76
- end
77
-
78
- it "handles double splats" do
79
- expect(P('Foo#d_splat').parameters).to eq [["reg", nil], ["**opts", nil]]
80
- expect(P('Foo#d_unnamed_splat').parameters).to eq []
81
- end
82
-
83
- it "handles overloads" do
84
- meth = P('Foo#foo')
85
-
86
- o1 = meth.tags(:overload).first
87
- expect(o1.name).to eq :bar
88
- expect(o1.parameters).to eq [['a', nil], ['b', "1"]]
89
- expect(o1.tag(:return).type).to eq "String"
90
-
91
- o2 = meth.tags(:overload)[1]
92
- expect(o2.name).to eq :baz
93
- expect(o2.parameters).to eq [['b', nil], ['c', nil]]
94
- expect(o2.tag(:return).type).to eq "Fixnum"
95
-
96
- o3 = meth.tags(:overload)[2]
97
- expect(o3.name).to eq :bang
98
- expect(o3.parameters).to eq [['d', nil], ['e', nil]]
99
- expect(o3.docstring).to be_empty
100
- expect(o3.docstring).to be_blank
101
- end
102
-
103
- it "sets a return tag if not set on #initialize" do
104
- meth = P('Foo#initialize')
105
-
106
- expect(meth).to have_tag(:return)
107
- expect(meth.tag(:return).types).to eq ["Foo"]
108
- expect(meth.tag(:return).text).to eq "a new instance of Foo"
109
- end
110
-
111
- %w(inherited included method_added method_removed method_undefined).each do |meth|
112
- it "sets @private tag on #{meth} callback method if no docstring is set" do
113
- expect(P('Foo.' + meth)).to have_tag(:private)
114
- end
115
- end
116
-
117
- it "does not set @private tag on extended callback method since docstring is set" do
118
- expect(P('Foo.extended')).not_to have_tag(:private)
119
- end
120
-
121
- it "adds @return [Boolean] tag to methods ending in ? without return types" do
122
- meth = P('Foo#boolean?')
123
- expect(meth).to have_tag(:return)
124
- expect(meth.tag(:return).types).to eq ['Boolean']
125
- end
126
-
127
- it "adds Boolean type to return tag without types" do
128
- meth = P('Foo#boolean2?')
129
- expect(meth).to have_tag(:return)
130
- expect(meth.tag(:return).types).to eq ['Boolean']
131
- end
132
-
133
- it "does not change return type for method ending in ? with return types set" do
134
- meth = P('Foo#boolean3?')
135
- expect(meth).to have_tag(:return)
136
- expect(meth.tag(:return).types).to eq ['NotBoolean', 'nil']
137
- end
138
-
139
- it "does not change return type for method ending in ? with return types set by @overload" do
140
- meth = P('Foo#rainy?')
141
- expect(meth).to have_tag(:overload)
142
- expect(meth.tag(:overload)).to have_tag(:return)
143
- expect(meth).not_to have_tag(:return)
144
- end
145
-
146
- it "adds method writer to existing attribute" do
147
- expect(Registry.at('Foo#attr_name')).to be_reader
148
- expect(Registry.at('Foo#attr_name=')).to be_writer
149
- end
150
-
151
- it "adds method reader to existing attribute" do
152
- expect(Registry.at('Foo#attr_name2')).to be_reader
153
- expect(Registry.at('Foo#attr_name2=')).to be_writer
154
- end
155
-
156
- it "generates an options parameter if @option refers to an undocumented parameter" do
157
- meth = P('Foo#auto_opts')
158
- expect(meth).to have_tag(:param)
159
- expect(meth.tag(:param).name).to eq "opts"
160
- expect(meth.tag(:param).types).to eq ["Hash"]
161
- end
162
-
163
- it "raises an undocumentable error when a method is defined on an object instance" do
164
- undoc_error "error = Foo; def error.at(foo) end"
165
- expect(Registry.at('error')).to be nil
166
- end
167
-
168
- it "allows class method to be defined on constant reference object" do
169
- expect(Registry.at('Foo.meth_on_const')).not_to be nil
170
- expect(Registry.at('Foo.meth2_on_const')).not_to be nil
171
- end
172
-
173
- it "copies alias information on method (re-)definition to new method" do
174
- expect(Registry.at('D').aliases).to be_empty
175
- expect(Registry.at('D#b').is_alias?).to be false
176
- expect(Registry.at('D#a').is_alias?).to be false
177
- end
178
-
179
- it "adds macros for class methods" do
180
- macro = CodeObjects::MacroObject.find('prop')
181
- expect(macro).not_to be nil
182
- expect(macro.macro_data).to eq "@!method $1(value)\n$3\n@return [$2]"
183
- expect(macro.method_object).to eq Registry.at('E.property')
184
- expect(macro).to be_attached
185
- obj = Registry.at('E#foo')
186
- expect(obj).not_to be nil
187
- expect(obj.docstring).to eq 'create a foo'
188
- expect(obj.signature).to eq 'def foo(value)'
189
- expect(obj.tag(:return).types).to eq ['String']
190
- end
191
-
192
- it "handles macros on any object" do
193
- macro = CodeObjects::MacroObject.find('xyz')
194
- expect(macro).not_to be nil
195
- expect(macro.macro_data).to eq '@!method $1'
196
- end
197
-
198
- it "skips macros on instance methods" do
199
- expect(Registry.at('E#a')).to be nil
200
- end
201
-
202
- it "warns if the macro name is invalid" do
203
- expect(log).to receive(:warn).with(/Invalid directive.*@!macro/)
204
- YARD.parse_string "class Foo\n# @!macro\ndef self.foo; end\nend"
205
- end
206
-
207
- it "handles 'def end' methods" do
208
- obj = Registry.at('F::A#foo')
209
- expect(obj).not_to be nil
210
- obj = Registry.at('F::A#bar')
211
- expect(obj).not_to be nil
212
- expect(obj.docstring).to eq 'PASS'
213
- end
214
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- RSpec.describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MixinHandler" do
5
- before(:all) { parse_file :mixin_handler_001, __FILE__ }
6
-
7
- it "handles includes from classes or modules" do
8
- expect(Registry.at(:X).instance_mixins).to include(P(:A))
9
- expect(Registry.at(:Y).instance_mixins).to include(P(:A))
10
- end
11
-
12
- it "handles includes in class << self" do
13
- expect(Registry.at(:Y).class_mixins).to include(P(:A))
14
- end
15
-
16
- it "handles includes for modules that don't yet exist" do
17
- expect(Registry.at(:X).instance_mixins).to include(P(nil, :NOTEXIST))
18
- end
19
-
20
- it "sets the type of non-existing modules to :module" do
21
- o = Registry.at(:X).instance_mixins.find {|obj| obj.name == :NOTEXIST }
22
- expect(o.type).to eq :module
23
- end
24
-
25
- it "handles includes with multiple parameters" do
26
- expect(Registry.at(:X)).not_to be nil
27
- end
28
-
29
- it "handles complex include statements" do
30
- expect(P(:Y).instance_mixins).to include(P('B::C'))
31
- expect(P(:Y).instance_mixins).to include(P(:B))
32
- end
33
-
34
- it "treats a mixed in Constant by taking its value as the real object name" do
35
- expect(P(:Y).instance_mixins).to include(Registry.at('B::D'))
36
- end
37
-
38
- it "adds includes in the correct order when include is given multiple arguments" do
39
- expect(P(:Z).instance_mixins).to eq [P(:A), P(:B)]
40
- end
41
-
42
- it "avoids including self for unresolved mixins of the same name" do
43
- expect(P("ABC::DEF::FOO").mixins).to eq [P("ABC::FOO")]
44
- expect(P("ABC::DEF::BAR").mixins).to eq [P("ABC::BAR")]
45
- end
46
-
47
- it "raises undocumentable error if argument is variable" do
48
- undoc_error "module X; include invalid; end"
49
- expect(Registry.at('X').mixins).to eq []
50
- end
51
-
52
- it "parses all other arguments before erroring out on undocumentable error" do
53
- undoc_error "module X; include invalid, Y; end"
54
- expect(Registry.at('X').mixins).to eq [P('Y')]
55
- end
56
-
57
- it "adds mixins from include calls to constants" do
58
- expect(P('FromConstant').instance_mixins).to eq [P('A')]
59
- end
60
- end
@@ -1,106 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- RSpec.describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}VisibilityHandler" do
5
- after { Registry.clear }
6
-
7
- def assert_module_function(namespace, name)
8
- klass = Registry.at("#{namespace}.#{name}")
9
- instance = Registry.at("#{namespace}##{name}")
10
- expect(klass).not_to be nil
11
- expect(instance).not_to be nil
12
- expect(klass).to be_module_function
13
- expect(instance).not_to be_module_function
14
- expect(klass.visibility).to eq :public
15
- expect(instance.visibility).to eq :private
16
- end
17
-
18
- it "is able to create a module function with parameters" do
19
- YARD.parse_string <<-eof
20
- module Foo
21
- def bar; end
22
- def baz; end
23
-
24
- module_function :bar, :baz
25
- end
26
- eof
27
- assert_module_function('Foo', 'bar')
28
- assert_module_function('Foo', 'baz')
29
- end
30
-
31
- it "is able to set scope for duration of block without params" do
32
- YARD.parse_string <<-eof
33
- module Foo
34
- def qux; end
35
-
36
- module_function
37
-
38
- def bar; end
39
- def baz; end
40
- end
41
- eof
42
- expect(Registry.at('Foo.qux')).to be nil
43
- assert_module_function('Foo', 'bar')
44
- assert_module_function('Foo', 'baz')
45
- end
46
-
47
- # @bug gh-563
48
- it "copies tags to module function properly" do
49
- YARD.parse_string <<-eof
50
- module Foo
51
- # @param [String] foo bar
52
- # @option foo [String] bar (nil) baz
53
- # @return [void]
54
- def bar(foo); end
55
- module_function :bar
56
- end
57
- eof
58
- assert_module_function('Foo', 'bar')
59
- o = Registry.at('Foo.bar')
60
- expect(o.tag(:param).types).to eq ['String']
61
- expect(o.tag(:param).name).to eq 'foo'
62
- expect(o.tag(:param).text).to eq 'bar'
63
- expect(o.tag(:option).name).to eq 'foo'
64
- expect(o.tag(:option).pair.types).to eq ['String']
65
- expect(o.tag(:option).pair.defaults).to eq ['nil']
66
- expect(o.tag(:option).pair.text).to eq 'baz'
67
- expect(o.tag(:return).types).to eq ['void']
68
- end
69
-
70
- it "handles all method names in parameters" do
71
- YARD.parse_string <<-eof
72
- module Foo
73
- def -(t); end
74
- def ==(other); end
75
- def a?; end
76
- module_function :-, '==', :a?
77
- end
78
- eof
79
- assert_module_function('Foo', '-')
80
- assert_module_function('Foo', '==')
81
- assert_module_function('Foo', 'a?')
82
- end
83
-
84
- it "only accepts strings and symbols" do
85
- YARD.parse_string <<-eof
86
- module Foo
87
- module_function name
88
- module_function *argument
89
- module_function *(method_call)
90
- end
91
- eof
92
- expect(Registry.at('Foo#name')).to be nil
93
- expect(Registry.at('Foo#argument')).to be nil
94
- expect(Registry.at('Foo#method_call')).to be nil
95
- end
96
-
97
- it "handles constants passed in as symbols" do
98
- YARD.parse_string <<-eof
99
- module Foo
100
- def Foo; end
101
- module_function :Foo
102
- end
103
- eof
104
- assert_module_function('Foo', 'Foo')
105
- end
106
- end