lib/yard/handlers/ruby/visibility_handler.rb in yard-0.9.36 vs lib/yard/handlers/ruby/visibility_handler.rb in yard-0.9.37
- old
+ new
@@ -11,12 +11,24 @@
process do
return if (ident = statement.jump(:ident)) == statement
case statement.type
when :var_ref, :vcall
self.visibility = ident.first.to_sym
- when :fcall, :command
+ when :command
+ if RUBY_VERSION >= '3.' && is_attribute_method?(statement.parameters.first)
+ parse_block(statement.parameters.first, visibility: ident.first.to_sym)
+ return
+ end
process_decorator do |method|
method.visibility = ident.first if method.respond_to? :visibility=
end
+ when :fcall
+ process_decorator do |method|
+ method.visibility = ident.first if method.respond_to? :visibility=
+ end
end
+ end
+
+ def is_attribute_method?(node)
+ node.type == :command && node.jump(:ident).first.to_s =~ /^attr_(accessor|writer|reader)$/
end
end