From 72db23817c378f1a075adbc6d17e0fae6ee277a3 Mon Sep 17 00:00:00 2001 From: sjh9714 <163989462+sjh9714@users.noreply.github.com> Date: Tue, 18 Aug 2026 10:14:53 +0900 Subject: [PATCH] Use inherited documentation when checking alias parameter coverage An alias has no comment of its own, so RDoc::Stats#undoc_params reported every parameter of an aliased method as undocumented even though RDoc::MethodAttr#documented? already resolves the inherited documentation. Fall back to the comment of #is_alias_for or #see when the method has none. --- lib/rdoc/stats.rb | 11 ++++++++++- test/rdoc/rdoc_stats_test.rb | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/stats.rb b/lib/rdoc/stats.rb index d41c97bf00..ec6fe43251 100644 --- a/lib/rdoc/stats.rb +++ b/lib/rdoc/stats.rb @@ -468,7 +468,16 @@ def undoc_params(method) return 0, [] if params.empty? - document = parse method.comment + comment = method.comment + + if comment.empty? + # An alias, or a method with a #see target, carries no comment of its + # own but inherits the documentation RDoc::MethodAttr#documented? uses. + inherited = method.is_alias_for || method.see + comment = inherited.comment if inherited + end + + document = parse comment tts = document.accept @formatter diff --git a/test/rdoc/rdoc_stats_test.rb b/test/rdoc/rdoc_stats_test.rb index ea2b851b38..884df24dd6 100644 --- a/test/rdoc/rdoc_stats_test.rb +++ b/test/rdoc/rdoc_stats_test.rb @@ -664,6 +664,21 @@ def test_undoc_params assert_equal %w[a], undoc end + def test_undoc_params_alias + method = RDoc::AnyMethod.new 'm' + method.params = '(a)' + method.comment = comment '+a+' + + aliased = RDoc::AnyMethod.new 'n' + aliased.params = '(a)' + aliased.is_alias_for = method + + total, undoc = @s.undoc_params aliased + + assert_equal 1, total + assert_empty undoc + end + def test_undoc_params_block method = RDoc::AnyMethod.new 'm' method.params = '(&a)'