Skip to content

Overhaul coverage report#1663

Open
st0012 wants to merge 1 commit intomasterfrom
file-centric-coverage
Open

Overhaul coverage report#1663
st0012 wants to merge 1 commit intomasterfrom
file-centric-coverage

Conversation

@st0012
Copy link
Copy Markdown
Member

@st0012 st0012 commented Mar 28, 2026

Summary

  • Make the coverage result more concise and useful
  • Make the output less confusing for C source files
  • Simplify implementation by decoupling it from RDoc's markup elements
  • Fix: reopened classes (defined across multiple files) are now reported under each file they appear in, not just the first

Before (Ruby pseudo-code format)

class RDoc::Generator::Darkfish # is documented

    # in file lib/rdoc/generator/darkfish.rb:744
    def generate_ancestor_list(ancestors, klass); end

    # in file lib/rdoc/generator/darkfish.rb:762
    def generate_class_link(klass, rel_prefix); end

end


class RDoc::Markup::ToAnsi # is documented

    # in file lib/rdoc/markup/to_ansi.rb:29
    ANSI_STYLE_CODES_OFF = nil

    # in file lib/rdoc/markup/to_ansi.rb:59
    def add_text(text); end

    # in file lib/rdoc/markup/to_ansi.rb:131
    def calculate_text_width(text); end

end

After (file-centric format)

lib/rdoc/generator/darkfish.rb:
  Method:
    RDoc::Generator::Darkfish#generate_ancestor_list                 lib/rdoc/generator/darkfish.rb:744
    RDoc::Generator::Darkfish#generate_class_link                    lib/rdoc/generator/darkfish.rb:762

lib/rdoc/markup/to_ansi.rb:
  Constant:
    RDoc::Markup::ToAnsi::ANSI_STYLE_CODES_OFF lib/rdoc/markup/to_ansi.rb:29
  Method:
    RDoc::Markup::ToAnsi#add_text             lib/rdoc/markup/to_ansi.rb:59
    RDoc::Markup::ToAnsi#calculate_text_width lib/rdoc/markup/to_ansi.rb:131

C source file output (Ruby's object.c)

object.c:
  Class:
    Refinement

No more class Refinement ... end pseudo-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:

Project Branch Master
IRB 117 items, 40 undoc (65.81%) 117 items, 40 undoc (65.81%)
Ruby 12110 items, 1472 undoc (87.84%) 12110 items, 1472 undoc (87.84%)

@matzbot
Copy link
Copy Markdown
Collaborator

matzbot commented Mar 28, 2026

🚀 Preview deployment available at: https://100b2e9d.rdoc-6cd.pages.dev (commit: 5c4b1b9)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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#report to 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, removing RDoc::Markup::ToRdoc conversions.
  • 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.

@st0012 st0012 force-pushed the file-centric-coverage branch 3 times, most recently from e41eb6b to 4d638a5 Compare April 12, 2026 12:12
@st0012 st0012 marked this pull request as ready for review April 12, 2026 12:13
Copilot AI review requested due to automatic review settings April 12, 2026 12:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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
@st0012 st0012 force-pushed the file-centric-coverage branch from 4d638a5 to 5c4b1b9 Compare April 12, 2026 13:16
@st0012 st0012 requested a review from nobu April 12, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants