1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/rdoc] Fix call-seq for aliased method with similar names

deduplicate_call_seq has a bug that skips call-seq for methods where the
alias is a prefix of the method name. For example, if the alias name is
"each" and the current method name is "each_line", then
deduplicate_call_seq will skip all call-seq for "each_line" since it
will believe that it is for the alias.

https://github.com/ruby/rdoc/commit/1148988ccc
This commit is contained in:
Peter Zhu 2022-07-15 17:39:21 -04:00 committed by git
parent a74634de10
commit dd362a786a
2 changed files with 16 additions and 2 deletions

View file

@ -350,12 +350,12 @@ class RDoc::AnyMethod < RDoc::MethodAttr
ignore << is_alias_for.name
ignore.concat is_alias_for.aliases.map(&:name)
end
ignore.map! { |n| n =~ /\A\[/ ? n[0, 1] : n}
ignore.map! { |n| n =~ /\A\[/ ? /\[.*\]/ : n}
ignore.delete(method_name)
ignore = Regexp.union(ignore)
matching = entries.reject do |entry|
entry =~ /^\w*\.?#{ignore}/ or
entry =~ /^\w*\.?#{ignore}[$\(\s]/ or
entry =~ /\s#{ignore}\s/
end

View file

@ -51,6 +51,20 @@ method(a, b) { |c, d| ... }
assert_equal 'foo', m.call_seq
end
def test_call_seq_alias_for
a = RDoc::AnyMethod.new nil, "each"
m = RDoc::AnyMethod.new nil, "each_line"
a.call_seq = <<-CALLSEQ
each(foo)
each_line(foo)
CALLSEQ
m.is_alias_for = a
assert_equal "each_line(foo)", m.call_seq
end
def test_full_name
assert_equal 'C1::m', @c1.method_list.first.full_name
end