Skip to content

Parse RBS files as RDoc input#1728

Open
st0012 wants to merge 12 commits into
ruby:masterfrom
st0012:codex/native-rbs-parser
Open

Parse RBS files as RDoc input#1728
st0012 wants to merge 12 commits into
ruby:masterfrom
st0012:codex/native-rbs-parser

Conversation

@st0012

@st0012 st0012 commented Jun 14, 2026

Copy link
Copy Markdown
Member

Problem

RDoc already supports parser classes that register handled file names through parse_files_matching, but .rbs documentation parsing currently comes from the rbs gem's rdoc/discover hook, which defines RDoc::Parser::RBS and delegates to RBS::RDocPlugin::Parser at runtime (discovery hook, plugin parser). That leaves RBS documentation generation coupled to a separately released plugin even though RDoc already uses RBS for type-signature display (ruby/rdoc#1665), and internal RDoc API changes can break the plugin independently of RDoc releases (ruby/rdoc#1711).

Solution

  • Add RDoc::Parser::RBS inside RDoc, adapted from the existing RBS plugin parser, so .rbs files are registered as RDoc input and common RBS declarations/members become RDoc code objects (RBS plugin parser, PR diff).
  • Extend existing Ruby-source documentation when matching RBS declarations are parsed, while still generating documentation for classes, modules, methods, attributes, and constants that only appear in RBS (PR diff).
  • Keep RDoc's existing sig/**/*.rbs type-signature loading path and skip the released rbs discovery hook when RDoc's parser is available, so RubyGems discovery does not replace the in-tree parser (ruby/rdoc#1665, discovery hook, PR diff).

@st0012 st0012 requested a deployment to fork-preview-protection June 14, 2026 16:44 — with GitHub Actions Waiting
@st0012 st0012 marked this pull request as ready for review June 14, 2026 16:48
Copilot AI review requested due to automatic review settings June 14, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds a built-in RDoc::Parser::RBS so .rbs files can be parsed as first-class RDoc inputs (instead of relying on the rbs gem’s runtime rdoc/discover hook), while also refining how sig/**/*.rbs files are auto-discovered and reloaded for type-signature merging and live preview.

Changes:

  • Introduces lib/rdoc/parser/rbs.rb and registers it so .rbs files are parsed directly by RDoc.
  • Separates “auto-discovered signature files” (sig/**/*.rbs) from explicitly selected .rbs documentation inputs for signature loading + live-reload bookkeeping.
  • Refactors live server change detection/reload flow and extends RDoc::Context to support qualified module/constant paths.

Reviewed changes

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

Show a summary per file
File Description
test/rdoc/rdoc_server_test.rb Extends live-reload tests to cover parsing/reloading .rbs docs + signatures.
test/rdoc/rdoc_rdoc_test.rb Adds integration tests for explicit .rbs inputs, auto-discovery rules, and skipping released rbs discovery hook.
test/rdoc/rdoc_context_test.rb Adds coverage for qualified/absolute module additions and constant owner resolution helpers.
test/rdoc/parser/rbs_test.rb New unit tests for the built-in RBS parser mapping into RDoc code objects.
lib/rdoc/server.rb Refactors watcher change tracking and adds dedicated RBS signature reload path.
lib/rdoc/rdoc.rb Renames/refines auto-discovered signature loading APIs and skips released rbs discovery hook.
lib/rdoc/parser/rbs.rb New built-in .rbs parser implementation.
lib/rdoc/parser.rb Requires the new RBS parser so it registers with RDoc::Parser.
lib/rdoc/code_object/context.rb Adds helpers to build module paths + support qualified names in add_module.

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

Comment thread lib/rdoc/parser/rbs.rb
Comment thread lib/rdoc/server.rb
@st0012 st0012 temporarily deployed to fork-preview-protection June 14, 2026 17:13 — with GitHub Actions Inactive
@matzbot

matzbot commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

🚀 Preview deployment available at: https://1553d19f.rdoc-6cd.pages.dev (commit: 13804b7)

Copilot AI review requested due to automatic review settings June 14, 2026 21:20
@st0012 st0012 deployed to fork-preview-protection June 14, 2026 21:20 — with GitHub Actions Active

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread lib/rdoc/server.rb
Comment thread README.md

@soutaro soutaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks Stan! 🎉
I haven't reviewed all of the implementation line by line (I cannot!), but looks great to replace existing RDoc plugin in rbs-gem!

@st0012 st0012 requested a deployment to fork-preview-protection June 20, 2026 12:52 — with GitHub Actions Waiting
Copilot AI review requested due to automatic review settings June 20, 2026 13:10
@st0012 st0012 requested a deployment to fork-preview-protection June 20, 2026 13:10 — with GitHub Actions Waiting

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread lib/rdoc/parser/rbs.rb
Comment thread lib/rdoc/parser/rbs.rb
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.

4 participants