Conversation
The `rdoc -C` coverage report previously displayed undocumented items
using Ruby syntax (`class ... end`, `def ...; end`). For C source files
like Ruby's object.c, this made the output appear as if the C file was
being treated as a Ruby script.
Replace with a file-centric listing that groups undocumented items by
source file and type:
object.c:
Class:
Refinement
Method:
Module#name object.c:135
Undocumented params: mod.name->stringornil
- Group items by source file, sorted alphabetically
- Within each file, group by type (Class, Module, Constant, Attribute, Method)
- Sort items by line number within each type group
- Use ClassName#method / ClassName.method notation
- Show clickable file:line references, column-aligned
- Return plain strings from report/summary instead of Markup objects
|
🚀 Preview deployment available at: https://8ac7ce2e.rdoc-6cd.pages.dev (commit: 793635c) |
There was a problem hiding this comment.
Pull request overview
This PR refactors RDoc’s coverage reporting to be file-centric and plain-text based (instead of building RDoc::Markup trees), aiming to make coverage output more concise and clearer—especially for C source files.
Changes:
- Reworked
RDoc::Stats#reportto emit a file/type grouped text report and introduced shared constants for type ordering and the “Great Job!” message. - Updated
RDoc::Stats#summary(and the CLI printing path) to output plain strings directly, removingRDoc::Markup::ToRdocconversions. - Revised and expanded stats tests to validate the new output format, including new sorting/grouping scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/rdoc/rdoc_stats_test.rb | Updates expectations to the new file-centric text format and adds new tests for ordering/grouping. |
| lib/rdoc/stats.rb | Implements the new report format and removes markup-element construction in favor of plain strings. |
| lib/rdoc/rdoc.rb | Prints coverage report and summary as strings (no Markup conversion). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| report = @s.report | ||
|
|
||
| expected = | ||
| doc( | ||
| para('The following items are not documented:'), | ||
| blank_line, | ||
| verb( | ||
| "class C # is documented\n", | ||
| "\n", | ||
| " attr_accessor :a # in file file.rb\n", | ||
| "\n", | ||
| "end\n"), | ||
| blank_line) | ||
|
|
||
| assert_equal expected, report | ||
| assert_match "file.rb:\n Attribute:\n C#a\n", report | ||
| end |
There was a problem hiding this comment.
assert_match/refute_match in test-unit expects a Regexp; passing a String (as done here) will raise TypeError (String#=~ requires a Regexp). Use assert_includes(report, "...") for substring checks, or convert the expected text to a Regexp (escaping as needed). Similar string-pattern assert_match calls appear throughout this test file and will need the same adjustment.
| # programmer convenience constructs | ||
| assert_match 'class Object', report.accept(to_rdoc) | ||
| # Constant aliases are skipped in the report | ||
| refute_match 'CA', @s.report |
There was a problem hiding this comment.
refute_match in test-unit expects a Regexp; passing 'CA' as a String will raise TypeError. Prefer refute_match(/CA/, @s.report) or refute_includes(@s.report, 'CA') (the latter is usually clearer for substring checks).
| refute_match 'CA', @s.report | |
| refute_includes @s.report, 'CA' |
| report = @s.report | ||
|
|
||
| assert_equal expected, report | ||
| assert_match " Method:\n C#m1\n Undocumented params: p2\n", report | ||
| end |
There was a problem hiding this comment.
Same issue as above: assert_match requires a Regexp, but this passes a multi-line String. Use assert_includes(report, ...) or a Regexp with the correct escaping/newline handling (e.g., /.../m) so the assertion actually runs under test-unit.
Summary
Before (Ruby pseudo-code format)
After (file-centric format)
C source file output (Ruby's object.c)
No more
class Refinement ... endpseudo-code that makes it look like the C file is being treated as a Ruby script.Accuracy verification
Coverage metrics are unchanged for projects other than RDoc itself: