Conversation
|
🚀 Preview deployment available at: https://7770c6cf.rdoc-6cd.pages.dev (commit: 7b82009) |
251f5db to
be86678
Compare
a469122 to
bfcd437
Compare
be86678 to
4b26c40
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for RBS type signatures in RDoc by extracting inline #: annotations during parsing, optionally loading signatures from .rbs files, and rendering those signatures in both HTML (Aliki theme) and ri terminal output.
Changes:
- Extract
#:type signatures from comment blocks in the Prism parser and attach them toRDoc::MethodAttrobjects. - Load/merge signatures from RBS sources into the store (without overwriting inline annotations) and add type-name linking in HTML output.
- Render signatures in Aliki HTML +
ri, update marshal formats, and bump runtime requirements (Ruby >= 3.2, addrbsdependency).
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
lib/rdoc/parser/prism_ruby.rb |
Extracts/validates inline #: signatures and attaches them to methods/attrs. |
lib/rdoc/rbs_support.rb |
New RBS integration: validation, signature loading, and HTML linking. |
lib/rdoc/store.rb |
Adds signature merge logic and cached type-name lookup for linking. |
lib/rdoc/generator/aliki.rb |
Exposes type_signature_html helper for templates (linked type names). |
lib/rdoc/generator/template/aliki/class.rhtml |
Renders type signatures for methods and attributes in HTML output. |
lib/rdoc/generator/template/aliki/css/rdoc.css |
Styles signature blocks and linked type names. |
lib/rdoc/generator/template/aliki/js/aliki.js |
Avoids wrapping signature <pre> blocks with “copy” UI. |
lib/rdoc/ri/driver.rb |
Prints method type signatures in ri output. |
lib/rdoc/code_object/method_attr.rb |
Adds type_signature storage + line splitting helper. |
lib/rdoc/code_object/any_method.rb |
Bumps marshal version and persists type_signature. |
lib/rdoc/code_object/attr.rb |
Bumps marshal version and persists type_signature. |
lib/rdoc/rdoc.rb |
Loads RBS signatures after store completion and merges into objects. |
rdoc.gemspec |
Bumps Ruby minimum to 3.2, adds rbs dependency, bumps prism minimum. |
Gemfile |
Always includes mini_racer on MRI (Ruby >= 3.2 now required). |
.github/workflows/test.yml |
Aligns CI with Ruby >= 3.2 and updated Prism versions. |
test/rdoc/parser/prism_ruby_test.rb |
Adds Prism-only tests for inline signature extraction. |
test/rdoc/rbs_support_test.rb |
New tests for validation, loading, and HTML linking. |
test/rdoc/rdoc_store_test.rb |
Tests signature merging + type_name_lookup behavior/caching. |
test/rdoc/ri/driver_test.rb |
Tests ri output includes a type signature. |
test/rdoc/code_object/any_method_test.rb |
Tests marshal persistence for method type signatures. |
test/rdoc/code_object/attr_test.rb |
Tests marshal persistence for attribute type signatures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
599eacc to
1034e9b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Do I understand correctly that the sorbet type signature will not work with this implementation? |
|
Yes, because it's not a official signature syntax for Ruby. |
Does this mean that JRuby can't use RDoc with this? |
|
@kou Unfortunately, yes. It's essentially a decision between:
Given that I want to make RBS support a key feature of future RDoc and directly encourage gems to write more RBS signatures, I think 1 is a more reasonable decision. |
|
@headius I assumed JRuby doesn't support |
Add `rbs` and its dependency `logger` to the bundled gem load paths in `tool/rdoc-srcdir`, and add the compiled extension path from `.bundle/extensions/` so the `rbs_extension` C extension can be found. This is needed because `make html` runs with `--disable-gems`, so RubyGems cannot resolve the extension path automatically. The extension is already compiled by `make build-ext` (which `make html` depends on via `main`), it just wasn't discoverable. Required for ruby/rdoc#1665 to work with `make html` in ruby/ruby.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RBS 4.0 requires Ruby >= 3.2. Bump RDoc's own minimum to match and add `rbs >= 4.0.0` as a gemspec dependency. Bump prism minimum to `>= 1.6.0` (required by rbs). Drop JRuby from CI matrix (rbs has a C extension that cannot build on it).
Add support for displaying RBS type signatures in both HTML and RI output. Type information is sourced from inline `#:` annotations (parsed by the Prism parser) and from `.rbs` files in the project's `sig/` directory plus RBS stdlib declarations. Implementation: - `RDoc::RbsHelper` module: loads RBS signatures, validates types, renders type signatures as HTML with linked type names - Parser extracts `#:` annotation lines via `RBS_SIG_LINE` constant, validates them, and attaches to `MethodAttr#type_signature` - `Store#merge_rbs_signatures` fills in signatures from `.rbs` files where inline annotations are absent - `Store#type_name_lookup` maps qualified and unambiguous unqualified names to documentation paths for type linking - Aliki theme: type signatures render as styled `<pre>` blocks under method headings, with linked type names using `a.rbs-type` class - RI driver: type signatures display as verbatim blocks - `MARSHAL_VERSION` bumped to 4 for `AnyMethod` and `Attr`
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Skipping the ambiguity check when `cm.name == cm.full_name` let a nested class (e.g. `Gem::SafeMarshal::Elements::String`) register itself as the unqualified `String` in `unqualified_names`, which then overwrote the core `String` entry during the final `lookup.merge!`. Remove the skip so top-level classes participate in ambiguity detection — the second sighting now correctly marks the name ambiguous and deletes it from `unqualified_names`, leaving `lookup["String"]` pointing at the core class's path.
…n attr keys Three fixes for `merge_rbs_signatures` and the surrounding freshness flow: - `rdoc.rb` now records `sig/*.rbs` mtimes alongside Ruby files in `@last_modified` and forces a full reparse when only signatures changed. The cached HTML pipeline keeps no in-memory class data across runs, so without this `merge_rbs_signatures` would run on an empty store. Also surfaces `rbs_signature_files`/`watch_files` for the live server's watcher. - `store.rb` now propagates merged RBS signatures to aliases immediately during assignment by walking `method_attr.aliases`, and tracks assigned objects so a re-merge in the live-server reload path can clear stale signatures without nuking inline `#:` annotations. - `rbs_helper.rb` keys singleton attributes as `Klass.attr` and instance attributes as `Klass#attr`, mirroring the method key format and preventing a singleton attr from clobbering an instance attr (or vice versa) when both share a name. Drive-by cleanups while in the area: fold `.rbs` into `remove_unparseable`'s extension regex; collapse the two identical `rbs_*_key` helpers into one `rbs_key`; drop a redundant `File.directory?` guard before `Dir[]`.
…tale clearing Three small fixes around `load_rbs_signatures` and the helper that walks RBS declarations: - `rbs_helper.rb` now emits both `Class.foo` and `Class#foo` keys when an RBS member's kind is `:singleton_instance` (i.e. `def self?.foo`). RDoc generates both a singleton and a private instance method for module-function-style definitions, so the previous singleton-only key left the instance method without type signature lines. - `rdoc.rb` widens the rescue in `load_rbs_signatures` from `RBS::ParsingError` to `RBS::BaseError`. Loader-level failures (duplicate declarations, generic-arity mismatches, etc.) inherit from `RBS::BaseError` / `RBS::LoadingError` rather than `ParsingError`, so they previously aborted documentation generation instead of warning and continuing. - `rdoc.rb` also calls `@store.clear_rbs_signatures` in the rescue. In server mode a previous successful load may have populated the long-lived store; without clearing, a now-broken sig file leaves stale `type_signature_lines` showing on regenerated pages alongside the warning.
Summary
#:annotations and.rbsfiles (including RBS stdlib)Details
New module:
RDoc::RbsHelpersig/directories and stdlib declarations viaRBS::EnvironmentLoader#:annotations usingRBS::Parser, warns with file:line on invalid signaturesa.rbs-typeParser integration (
PrismRuby)#:annotation lines from comments viaRBS_SIG_LINEconstantMethodAttr#type_signature_lines.rbsfile signaturesStore
merge_rbs_signaturesfills in type signatures from loaded.rbsfiles where no inline annotation existstype_name_lookupbuilds a cached name-to-path map for type linking; ambiguous unqualified names are excluded to avoid wrong linksDisplay
<pre>blocks with dotted separator; attribute signatures render inline after the[RW]badgeSerialization
MARSHAL_VERSIONbumped to 4 for bothAnyMethodandAttr(additive — appendstype_signature_linesto marshal array)CI/Dependencies
rbs4.0)rbs >= 4.0.0andprism >= 1.6.0dependenciesrbshas a C extension); TruffleRuby retained (verified working)