yard 0.9.27 → 0.9.29

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 (223) hide show
  1. checksums.yaml +4 -4
  2. data/LEGAL +29 -1
  3. data/LICENSE +1 -1
  4. data/lib/yard/autoload.rb +2 -1
  5. data/lib/yard/cli/command.rb +1 -1
  6. data/lib/yard/cli/stats.rb +2 -1
  7. data/lib/yard/cli/yardoc.rb +3 -2
  8. data/lib/yard/code_objects/base.rb +4 -1
  9. data/lib/yard/config.rb +5 -1
  10. data/lib/yard/docstring_parser.rb +1 -1
  11. data/lib/yard/handlers/ruby/attribute_handler.rb +1 -1
  12. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +1 -1
  13. data/lib/yard/handlers/ruby/method_handler.rb +1 -1
  14. data/lib/yard/handlers/ruby/mixin_handler.rb +13 -6
  15. data/lib/yard/i18n/locale.rb +1 -1
  16. data/lib/yard/i18n/message.rb +2 -2
  17. data/lib/yard/i18n/messages.rb +1 -1
  18. data/lib/yard/i18n/pot_generator.rb +1 -1
  19. data/lib/yard/options.rb +1 -1
  20. data/lib/yard/parser/ruby/ast_node.rb +7 -0
  21. data/lib/yard/parser/ruby/ruby_parser.rb +8 -2
  22. data/lib/yard/registry_resolver.rb +2 -1
  23. data/lib/yard/server/commands/base.rb +1 -1
  24. data/lib/yard/server/http_utils.rb +512 -0
  25. data/lib/yard/server/rack_adapter.rb +24 -12
  26. data/lib/yard/tags/tag.rb +2 -2
  27. data/lib/yard/tags/types_explainer.rb +1 -1
  28. data/lib/yard/templates/helpers/html_helper.rb +1 -1
  29. data/lib/yard/templates/helpers/method_helper.rb +3 -1
  30. data/lib/yard/templates/template.rb +3 -1
  31. data/lib/yard/version.rb +1 -1
  32. data/lib/yard.rb +3 -0
  33. metadata +5 -208
  34. data/.dockerignore +0 -2
  35. data/.gitattributes +0 -4
  36. data/.github/FUNDING.yml +0 -3
  37. data/.github/ISSUE_TEMPLATE.md +0 -33
  38. data/.github/PULL_REQUEST_TEMPLATE.md +0 -12
  39. data/.github/workflows/ci.yml +0 -30
  40. data/.github/workflows/gem.yml +0 -19
  41. data/.gitignore +0 -14
  42. data/.rspec +0 -2
  43. data/.rubocop.yml +0 -112
  44. data/.yardopts +0 -26
  45. data/.yardopts_guide +0 -19
  46. data/.yardopts_i18n +0 -23
  47. data/CHANGELOG.md +0 -827
  48. data/CODE_OF_CONDUCT.md +0 -15
  49. data/CONTRIBUTING.md +0 -140
  50. data/Dockerfile.samus +0 -28
  51. data/Gemfile +0 -34
  52. data/Rakefile +0 -36
  53. data/SECURITY.md +0 -26
  54. data/benchmarks/builtins_vs_eval.rb +0 -24
  55. data/benchmarks/concat_vs_join.rb +0 -13
  56. data/benchmarks/erb_vs_erubis.rb +0 -54
  57. data/benchmarks/format_args.rb +0 -47
  58. data/benchmarks/generation.rb +0 -38
  59. data/benchmarks/marshal_vs_dbm.rb +0 -64
  60. data/benchmarks/parsing.rb +0 -46
  61. data/benchmarks/pathname_vs_string.rb +0 -51
  62. data/benchmarks/rdoc_vs_yardoc.rb +0 -11
  63. data/benchmarks/registry_store_types.rb +0 -49
  64. data/benchmarks/ri_vs_yri.rb +0 -19
  65. data/benchmarks/ripper_parser.rb +0 -13
  66. data/benchmarks/splat_vs_flatten.rb +0 -13
  67. data/benchmarks/template_erb.rb +0 -23
  68. data/benchmarks/template_format.rb +0 -7
  69. data/benchmarks/template_profile.rb +0 -18
  70. data/benchmarks/yri_cache.rb +0 -20
  71. data/docs/CodeObjects.md +0 -115
  72. data/docs/GettingStarted.md +0 -679
  73. data/docs/Handlers.md +0 -152
  74. data/docs/Overview.md +0 -61
  75. data/docs/Parser.md +0 -191
  76. data/docs/Tags.md +0 -283
  77. data/docs/TagsArch.md +0 -123
  78. data/docs/Templates.md +0 -496
  79. data/docs/WhatsNew.md +0 -1245
  80. data/docs/images/code-objects-class-diagram.png +0 -0
  81. data/docs/images/handlers-class-diagram.png +0 -0
  82. data/docs/images/overview-class-diagram.png +0 -0
  83. data/docs/images/parser-class-diagram.png +0 -0
  84. data/docs/images/tags-class-diagram.png +0 -0
  85. data/docs/templates/default/fulldoc/html/full_list_tag.erb +0 -9
  86. data/docs/templates/default/fulldoc/html/setup.rb +0 -6
  87. data/docs/templates/default/layout/html/setup.rb +0 -9
  88. data/docs/templates/default/layout/html/tag_list.erb +0 -11
  89. data/docs/templates/default/yard_tags/html/list.erb +0 -18
  90. data/docs/templates/default/yard_tags/html/setup.rb +0 -26
  91. data/docs/templates/plugin.rb +0 -70
  92. data/po/ja.po +0 -31108
  93. data/samus.json +0 -49
  94. data/tasks/prepare_tag.rake +0 -45
  95. data/tasks/update_error_map.rake +0 -53
  96. data/templates/default/class/dot/setup.rb +0 -7
  97. data/templates/default/class/dot/superklass.erb +0 -3
  98. data/templates/default/class/html/constructor_details.erb +0 -8
  99. data/templates/default/class/html/setup.rb +0 -2
  100. data/templates/default/class/html/subclasses.erb +0 -4
  101. data/templates/default/class/setup.rb +0 -36
  102. data/templates/default/class/text/setup.rb +0 -12
  103. data/templates/default/class/text/subclasses.erb +0 -5
  104. data/templates/default/constant/text/header.erb +0 -11
  105. data/templates/default/constant/text/setup.rb +0 -4
  106. data/templates/default/docstring/html/abstract.erb +0 -4
  107. data/templates/default/docstring/html/deprecated.erb +0 -1
  108. data/templates/default/docstring/html/index.erb +0 -5
  109. data/templates/default/docstring/html/note.erb +0 -6
  110. data/templates/default/docstring/html/private.erb +0 -4
  111. data/templates/default/docstring/html/returns_void.erb +0 -1
  112. data/templates/default/docstring/html/text.erb +0 -1
  113. data/templates/default/docstring/html/todo.erb +0 -6
  114. data/templates/default/docstring/setup.rb +0 -52
  115. data/templates/default/docstring/text/abstract.erb +0 -2
  116. data/templates/default/docstring/text/deprecated.erb +0 -2
  117. data/templates/default/docstring/text/index.erb +0 -2
  118. data/templates/default/docstring/text/note.erb +0 -4
  119. data/templates/default/docstring/text/private.erb +0 -2
  120. data/templates/default/docstring/text/returns_void.erb +0 -1
  121. data/templates/default/docstring/text/text.erb +0 -1
  122. data/templates/default/docstring/text/todo.erb +0 -4
  123. data/templates/default/fulldoc/html/css/common.css +0 -1
  124. data/templates/default/fulldoc/html/css/full_list.css +0 -58
  125. data/templates/default/fulldoc/html/css/style.css +0 -497
  126. data/templates/default/fulldoc/html/frames.erb +0 -17
  127. data/templates/default/fulldoc/html/full_list.erb +0 -37
  128. data/templates/default/fulldoc/html/full_list_class.erb +0 -2
  129. data/templates/default/fulldoc/html/full_list_file.erb +0 -7
  130. data/templates/default/fulldoc/html/full_list_method.erb +0 -10
  131. data/templates/default/fulldoc/html/js/app.js +0 -314
  132. data/templates/default/fulldoc/html/js/full_list.js +0 -216
  133. data/templates/default/fulldoc/html/js/jquery.js +0 -4
  134. data/templates/default/fulldoc/html/setup.rb +0 -241
  135. data/templates/default/layout/dot/header.erb +0 -6
  136. data/templates/default/layout/dot/setup.rb +0 -15
  137. data/templates/default/layout/html/breadcrumb.erb +0 -11
  138. data/templates/default/layout/html/files.erb +0 -11
  139. data/templates/default/layout/html/footer.erb +0 -5
  140. data/templates/default/layout/html/headers.erb +0 -15
  141. data/templates/default/layout/html/index.erb +0 -2
  142. data/templates/default/layout/html/layout.erb +0 -24
  143. data/templates/default/layout/html/listing.erb +0 -4
  144. data/templates/default/layout/html/objects.erb +0 -32
  145. data/templates/default/layout/html/script_setup.erb +0 -4
  146. data/templates/default/layout/html/search.erb +0 -13
  147. data/templates/default/layout/html/setup.rb +0 -89
  148. data/templates/default/method/html/header.erb +0 -17
  149. data/templates/default/method/setup.rb +0 -4
  150. data/templates/default/method/text/header.erb +0 -1
  151. data/templates/default/method_details/html/header.erb +0 -3
  152. data/templates/default/method_details/html/method_signature.erb +0 -25
  153. data/templates/default/method_details/html/source.erb +0 -10
  154. data/templates/default/method_details/setup.rb +0 -11
  155. data/templates/default/method_details/text/header.erb +0 -10
  156. data/templates/default/method_details/text/method_signature.erb +0 -12
  157. data/templates/default/method_details/text/setup.rb +0 -11
  158. data/templates/default/module/dot/child.erb +0 -1
  159. data/templates/default/module/dot/dependencies.erb +0 -3
  160. data/templates/default/module/dot/header.erb +0 -6
  161. data/templates/default/module/dot/info.erb +0 -14
  162. data/templates/default/module/dot/setup.rb +0 -15
  163. data/templates/default/module/html/attribute_details.erb +0 -10
  164. data/templates/default/module/html/attribute_summary.erb +0 -8
  165. data/templates/default/module/html/box_info.erb +0 -43
  166. data/templates/default/module/html/children.erb +0 -8
  167. data/templates/default/module/html/constant_summary.erb +0 -17
  168. data/templates/default/module/html/defines.erb +0 -3
  169. data/templates/default/module/html/header.erb +0 -5
  170. data/templates/default/module/html/inherited_attributes.erb +0 -14
  171. data/templates/default/module/html/inherited_constants.erb +0 -8
  172. data/templates/default/module/html/inherited_methods.erb +0 -19
  173. data/templates/default/module/html/item_summary.erb +0 -40
  174. data/templates/default/module/html/method_details_list.erb +0 -9
  175. data/templates/default/module/html/method_summary.erb +0 -14
  176. data/templates/default/module/html/methodmissing.erb +0 -12
  177. data/templates/default/module/html/pre_docstring.erb +0 -1
  178. data/templates/default/module/setup.rb +0 -167
  179. data/templates/default/module/text/children.erb +0 -10
  180. data/templates/default/module/text/class_meths_list.erb +0 -8
  181. data/templates/default/module/text/extends.erb +0 -8
  182. data/templates/default/module/text/header.erb +0 -7
  183. data/templates/default/module/text/includes.erb +0 -8
  184. data/templates/default/module/text/instance_meths_list.erb +0 -8
  185. data/templates/default/module/text/setup.rb +0 -13
  186. data/templates/default/onefile/html/files.erb +0 -5
  187. data/templates/default/onefile/html/headers.erb +0 -6
  188. data/templates/default/onefile/html/layout.erb +0 -17
  189. data/templates/default/onefile/html/readme.erb +0 -3
  190. data/templates/default/onefile/html/setup.rb +0 -62
  191. data/templates/default/root/dot/child.erb +0 -3
  192. data/templates/default/root/dot/setup.rb +0 -6
  193. data/templates/default/root/html/setup.rb +0 -2
  194. data/templates/default/tags/html/example.erb +0 -11
  195. data/templates/default/tags/html/index.erb +0 -3
  196. data/templates/default/tags/html/option.erb +0 -24
  197. data/templates/default/tags/html/overload.erb +0 -14
  198. data/templates/default/tags/html/see.erb +0 -8
  199. data/templates/default/tags/html/tag.erb +0 -20
  200. data/templates/default/tags/setup.rb +0 -57
  201. data/templates/default/tags/text/example.erb +0 -12
  202. data/templates/default/tags/text/index.erb +0 -1
  203. data/templates/default/tags/text/option.erb +0 -20
  204. data/templates/default/tags/text/overload.erb +0 -19
  205. data/templates/default/tags/text/see.erb +0 -11
  206. data/templates/default/tags/text/tag.erb +0 -13
  207. data/templates/guide/class/html/setup.rb +0 -2
  208. data/templates/guide/docstring/html/setup.rb +0 -2
  209. data/templates/guide/fulldoc/html/css/style.css +0 -108
  210. data/templates/guide/fulldoc/html/js/app.js +0 -33
  211. data/templates/guide/fulldoc/html/setup.rb +0 -74
  212. data/templates/guide/layout/html/layout.erb +0 -81
  213. data/templates/guide/layout/html/setup.rb +0 -25
  214. data/templates/guide/method/html/header.erb +0 -18
  215. data/templates/guide/method/html/setup.rb +0 -22
  216. data/templates/guide/module/html/header.erb +0 -7
  217. data/templates/guide/module/html/method_list.erb +0 -5
  218. data/templates/guide/module/html/setup.rb +0 -27
  219. data/templates/guide/onefile/html/files.erb +0 -4
  220. data/templates/guide/onefile/html/setup.rb +0 -6
  221. data/templates/guide/onefile/html/toc.erb +0 -3
  222. data/templates/guide/tags/html/setup.rb +0 -9
  223. data/yard.gemspec +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0e3a62dcbb66515f56fe9a2cb919aa97881dced6e7cf052a7ce0201ff9222cf
4
- data.tar.gz: 06714cb7f3e754d10fb2e784c0a0d49a5fee20aaee75778565daea8b61c453c1
3
+ metadata.gz: 93d48bef3450842c6170694239357d0748b8db9318df37d7cefbcb7d988f46d8
4
+ data.tar.gz: 93f395f5fdde5e0ecea8c495a79a924cdf358bcdbd75e042a014a21f3985004e
5
5
  SHA512:
6
- metadata.gz: 4a993609ba381fdc0419ac8332605b10a3995ff818626c20e64095f4f845e28297d38a81c890aa95a187ca8fd7d8e7d9f291d7251ac96ba1bee7a5a249f2db3d
7
- data.tar.gz: f71cc60bc0fbe36419f8f142e07bbee5fd19b9e539099256bb644f1f61f57e9fa61c96ff95e879d584bdb48b3f988d5e945277acbc6e0f083cf1a6c8584c45df
6
+ metadata.gz: 9eba5a49a6479e64a37fc19dbbc71249c2a493a6d61685c27930d938c6917b02076d5f8aa3fd2d56f1a2deb3fd7ca6f8be6da9cf9abd4ff5bb7e5ee2f420fbdd
7
+ data.tar.gz: 414b657d30ed57f3c7d53a77a1a7c89fdc11eff1effcb9c1f17da5c9efe6bc486bf363aa43b0a9970a012c79d6cbe1a28eac855387ede7780100d0218ec82fb0
data/LEGAL CHANGED
@@ -4,7 +4,7 @@ LEGAL NOTICE INFORMATION
4
4
  All the files in this distribution are covered under either the MIT
5
5
  license (see the file LICENSE) except some files mentioned below.
6
6
 
7
- lib/parser/ruby/legacy/ruby_lex.rb:
7
+ lib/yard/parser/ruby/legacy/ruby_lex.rb:
8
8
 
9
9
  This file is under the Ruby license. YARD uses a modified version of it.
10
10
 
@@ -64,3 +64,31 @@ lib/parser/ruby/legacy/ruby_lex.rb:
64
64
  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
65
65
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
66
66
  PURPOSE.
67
+
68
+ lib/yard/server/http_utils.rb:
69
+
70
+ This file is vendored and slightly modified from WEBrick because it was
71
+ removed from Ruby core in Ruby 3.x.
72
+
73
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
74
+
75
+ Redistribution and use in source and binary forms, with or without
76
+ modification, are permitted provided that the following conditions
77
+ are met:
78
+ 1. Redistributions of source code must retain the above copyright
79
+ notice, this list of conditions and the following disclaimer.
80
+ 2. Redistributions in binary form must reproduce the above copyright
81
+ notice, this list of conditions and the following disclaimer in the
82
+ documentation and/or other materials provided with the distribution.
83
+
84
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
85
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
87
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
88
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94
+ SUCH DAMAGE.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007-2018 Loren Segal
1
+ Copyright (c) 2007-2022 Loren Segal
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/lib/yard/autoload.rb CHANGED
@@ -170,7 +170,6 @@ module YARD
170
170
 
171
171
  module Ruby # Ruby parsing components.
172
172
  module Legacy # Handles Ruby parsing in Ruby 1.8.
173
- autoload :RipperParser, __p('parser/ruby/legacy/ruby_parser')
174
173
  autoload :RubyParser, __p('parser/ruby/legacy/ruby_parser')
175
174
  autoload :RubyToken, __p('parser/ruby/legacy/ruby_lex')
176
175
  autoload :Statement, __p('parser/ruby/legacy/statement')
@@ -180,6 +179,7 @@ module YARD
180
179
 
181
180
  autoload :AstNode, __p('parser/ruby/ast_node')
182
181
  autoload :RubyParser, __p('parser/ruby/ruby_parser')
182
+ autoload :RipperParser, __p('parser/ruby/ruby_parser')
183
183
  autoload :TokenResolver, __p('parser/ruby/token_resolver')
184
184
  end
185
185
 
@@ -236,6 +236,7 @@ module YARD
236
236
  autoload :FinishRequest, __p('server/adapter')
237
237
  autoload :LibraryVersion, __p('server/library_version')
238
238
  autoload :NotFoundError, __p('server/adapter')
239
+ autoload :HTTPUtils, __p('server/http_utils')
239
240
  autoload :RackAdapter, __p('server/rack_adapter')
240
241
  autoload :RackMiddleware, __p('server/rack_adapter')
241
242
  autoload :Router, __p('server/router')
@@ -70,7 +70,7 @@ module YARD
70
70
  load(file)
71
71
  rescue LoadError => load_exception
72
72
  log.error "The file `#{file}' could not be loaded:\n#{load_exception}"
73
- exit
73
+ exit 1
74
74
  end
75
75
 
76
76
  # Callback when an unrecognize option is parsed
@@ -225,7 +225,8 @@ module YARD
225
225
  end
226
226
 
227
227
  opts.on('--query QUERY', "Only includes objects that match a specific query") do |query|
228
- options[:verifier].add_expressions(query.taint)
228
+ query.taint if query.respond_to?(:taint)
229
+ options[:verifier].add_expressions(query)
229
230
  end
230
231
  end
231
232
  end
@@ -334,7 +334,7 @@ module YARD
334
334
  private
335
335
 
336
336
  # Generates output for objects
337
- # @param [Hash, nil] checksums if supplied, a list of checkums for files.
337
+ # @param [Hash, nil] checksums if supplied, a list of checksums for files.
338
338
  # @return [void]
339
339
  # @since 0.5.1
340
340
  def run_generate(checksums)
@@ -650,7 +650,8 @@ module YARD
650
650
 
651
651
  opts.on('--query QUERY', "Only show objects that match a specific query") do |query|
652
652
  next if YARD::Config.options[:safe_mode]
653
- options.verifier.add_expressions(query.taint)
653
+ query.taint if query.respond_to?(:taint)
654
+ options.verifier.add_expressions(query)
654
655
  end
655
656
 
656
657
  opts.on('--title TITLE', 'Add a specific title to HTML documents') do |title|
@@ -434,7 +434,10 @@ module YARD
434
434
  #
435
435
  # @return [Symbol] the type of code object this represents
436
436
  def type
437
- self.class.name.split('::').last.gsub(/Object$/, '').downcase.to_sym
437
+ obj_name = self.class.name.split('::').last
438
+ obj_name.gsub!(/Object$/, '')
439
+ obj_name.downcase!
440
+ obj_name.to_sym
438
441
  end
439
442
 
440
443
  # Represents the unique path of the object. The default implementation
data/lib/yard/config.rb CHANGED
@@ -236,7 +236,11 @@ module YARD
236
236
  def self.read_config_file
237
237
  if File.file?(CONFIG_FILE)
238
238
  require 'yaml'
239
- YAML.load_file(CONFIG_FILE)
239
+ if YAML.respond_to?(:safe_load_file)
240
+ YAML.safe_load_file(CONFIG_FILE, permitted_classes: [SymbolHash, Symbol])
241
+ else
242
+ YAML.load_file(CONFIG_FILE)
243
+ end
240
244
  else
241
245
  {}
242
246
  end
@@ -8,7 +8,7 @@ module YARD
8
8
  #
9
9
  # == Subclassing Notes
10
10
  #
11
- # The DocstringParser can be subclassed and subtituted during parsing by
11
+ # The DocstringParser can be subclassed and substituted during parsing by
12
12
  # setting the {Docstring.default_parser} attribute with the name of the
13
13
  # subclass. This allows developers to change the way docstrings are
14
14
  # parsed, allowing for completely different docstring syntaxes.
@@ -52,7 +52,7 @@ class YARD::Handlers::Ruby::AttributeHandler < YARD::Handlers::Ruby::Base
52
52
  register(o)
53
53
  o.docstring = doc if o.docstring.blank?(false)
54
54
 
55
- # Regsiter the object explicitly
55
+ # Register the object explicitly
56
56
  namespace.attributes[scope][name][type] = o
57
57
  else
58
58
  obj = namespace.children.find {|other| other.name == meth.to_sym && other.scope == scope }
@@ -51,7 +51,7 @@ class YARD::Handlers::Ruby::Legacy::AttributeHandler < YARD::Handlers::Ruby::Leg
51
51
  register(o)
52
52
  o.docstring = doc if o.docstring.blank?(false)
53
53
 
54
- # Regsiter the object explicitly
54
+ # Register the object explicitly
55
55
  namespace.attributes[scope][name][type] = o
56
56
  else
57
57
  obj = namespace.children.find {|other| other.name == meth.to_sym && other.scope == scope }
@@ -97,7 +97,7 @@ class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
97
97
  params << ['**' + args.double_splat_param.source, nil]
98
98
  end
99
99
 
100
- params << ['&' + args.block_param.source, nil] if args.block_param
100
+ params << ['&' + args.block_param.source, nil] if args.block_param && !args.args_forward
101
101
 
102
102
  params
103
103
  end
@@ -26,22 +26,29 @@ class YARD::Handlers::Ruby::MixinHandler < YARD::Handlers::Ruby::Base
26
26
  raise YARD::Parser::UndocumentableError unless mixin.ref?
27
27
  raise YARD::Parser::UndocumentableError if mixin.first.type == :ident
28
28
 
29
- case obj = Proxy.new(namespace, mixin.source)
30
- when ConstantObject # If a constant is included, use its value as the real object
31
- obj = Proxy.new(namespace, obj.value, :module)
29
+ if mixin.type == :var_ref && mixin[0] == s(:kw, "self")
30
+ obj = namespace
32
31
  else
33
- obj = Proxy.new(namespace, mixin.source, :module)
32
+ case obj = Proxy.new(namespace, mixin.source)
33
+ when ConstantObject # If a constant is included, use its value as the real object
34
+ obj = Proxy.new(namespace, obj.value, :module)
35
+ else
36
+ obj = Proxy.new(namespace, mixin.source, :module)
37
+ end
34
38
  end
35
39
 
36
40
  rec = recipient(mixin)
37
- return if rec.nil? || rec.mixins(scope).include?(obj)
41
+ return if rec.nil?
42
+
43
+ ensure_loaded!(rec)
44
+ return if rec.mixins(scope).include?(obj)
38
45
 
39
46
  shift = statement.method_name(true) == :include ? :unshift : :push
40
47
  rec.mixins(scope).send(shift, obj)
41
48
  end
42
49
 
43
50
  def recipient(mixin)
44
- if statement[0].type == :const_path_ref
51
+ if statement[0].type == :const_path_ref || statement[0].type == :top_const_ref
45
52
  Proxy.new(namespace, statement[0].source)
46
53
  elsif statement[0].type == :var_ref && statement[0][0] != s(:kw, "self")
47
54
  statement[0][0].type == :const ?
@@ -57,7 +57,7 @@ module YARD
57
57
  end
58
58
 
59
59
  # @param [String] message the translation target message.
60
- # @return [String] translated message. If tarnslation isn't
60
+ # @return [String] translated message. If translation isn't
61
61
  # registered, the +message+ is returned.
62
62
  def translate(message)
63
63
  @messages[message] || message
@@ -8,7 +8,7 @@ module YARD
8
8
  #
9
9
  # @since 0.8.1
10
10
  class Message
11
- # @return [String] the message ID of the trnslation target message.
11
+ # @return [String] the message ID of the translation target message.
12
12
  attr_reader :id
13
13
 
14
14
  # @return [Set] the set of locations. Location is an array of
@@ -18,7 +18,7 @@ module YARD
18
18
  # @return [Set] the set of comments for the messages.
19
19
  attr_reader :comments
20
20
 
21
- # Creates a trasnlate target message for message ID +id+.
21
+ # Creates a translate target message for message ID +id+.
22
22
  #
23
23
  # @param [String] id the message ID of the translate target message.
24
24
  def initialize(id)
@@ -28,7 +28,7 @@ module YARD
28
28
  @messages[id]
29
29
  end
30
30
 
31
- # Registers a {Message}, the mssage ID of which is +id+. If
31
+ # Registers a {Message}, the message ID of which is +id+. If
32
32
  # corresponding +Message+ is already registered, the previously
33
33
  # registered object is returned.
34
34
  #
@@ -113,7 +113,7 @@ module YARD
113
113
  #
114
114
  # Locations of the +Message+ are used to generate the reference
115
115
  # line that is started with "#: ". +relative_base_path+ passed
116
- # when the generater is created is prepended to each path in location.
116
+ # when the generator is created is prepended to each path in location.
117
117
  #
118
118
  # Comments of the +Message+ are used to generate the
119
119
  # translator-comment line that is started with "# ".
data/lib/yard/options.rb CHANGED
@@ -94,7 +94,7 @@ module YARD
94
94
  #
95
95
  # @example Setting an option with Hash syntax
96
96
  # options[:format] = :html # equivalent to: options.format = :html
97
- # @param [Symbol, String] key the optin to set
97
+ # @param [Symbol, String] key the option to set
98
98
  # @param [Object] value the value to set for the option
99
99
  # @return [Object] the value being set
100
100
  def []=(key, value) send("#{key}=", value) end
@@ -426,6 +426,13 @@ module YARD
426
426
  def block_param
427
427
  self[-1] ? self[-1][0] : nil
428
428
  end
429
+
430
+ def args_forward
431
+ # shape is (required, optional, rest, more, keyword, keyword_rest, block)
432
+ # Ruby 3.1 moves :args_forward from rest to keyword_rest
433
+ args_index = YARD.ruby31? ? -2 : 2
434
+ self[args_index].type == :args_forward if self[args_index]
435
+ end
429
436
  end
430
437
 
431
438
  class MethodCallNode < AstNode
@@ -133,6 +133,12 @@ module YARD
133
133
  AST_TOKENS = [:CHAR, :backref, :const, :cvar, :gvar, :heredoc_end, :ident,
134
134
  :int, :float, :ivar, :label, :period, :regexp_end, :tstring_content, :backtick]
135
135
 
136
+ COMMENT_SKIP_NODE_TYPES = [
137
+ :comment,
138
+ :void_stmt,
139
+ :list
140
+ ].freeze
141
+
136
142
  MAPPINGS.each do |k, v|
137
143
  if Array === v
138
144
  v.each {|vv| (REV_MAPPINGS[vv] ||= []) << k }
@@ -144,7 +150,7 @@ module YARD
144
150
  PARSER_EVENT_TABLE.each do |event, arity|
145
151
  node_class = AstNode.node_class_for(event)
146
152
 
147
- if /_new\z/ =~ event.to_s && arity == 0
153
+ if arity == 0 && /_new\z/ =~ event.to_s
148
154
  module_eval(<<-eof, __FILE__, __LINE__ + 1)
149
155
  def on_#{event}(*args)
150
156
  #{node_class}.new(:list, args, :listchar => charno...charno, :listline => lineno..lineno)
@@ -613,7 +619,7 @@ module YARD
613
619
 
614
620
  def insert_comments
615
621
  root.traverse do |node|
616
- next if [:comment, :void_stmt, :list].include?(node.type) || node.parent.type != :list
622
+ next if COMMENT_SKIP_NODE_TYPES.include?(node.type) || node.parent.type != :list
617
623
 
618
624
  # never attach comments to if/unless mod nodes
619
625
  if node.type == :if_mod || node.type == :unless_mod
@@ -132,7 +132,8 @@ module YARD
132
132
 
133
133
  path.scan(split_on_separators_match).each do |part, sep|
134
134
  cur_obj = nil
135
- pos += "#{part}#{sep}".length
135
+ pos += part.length
136
+ pos += sep.length
136
137
  parsed_end = pos == path.length
137
138
 
138
139
  if !last_obj || (!parsed_end && !last_obj.is_a?(CodeObjects::NamespaceObject))
@@ -119,7 +119,7 @@ module YARD
119
119
  # def run
120
120
  # self.body = 'ERROR! The System is down!'
121
121
  # self.status = 500
122
- # self.headers['Conten-Type'] = 'text/plain'
122
+ # self.headers['Content-Type'] = 'text/plain'
123
123
  # end
124
124
  # end
125
125
  #