Skip to content

Display RBS type signatures in documentation#1665

Draft
st0012 wants to merge 2 commits intosignature-card-designfrom
integrate-rbs
Draft

Display RBS type signatures in documentation#1665
st0012 wants to merge 2 commits intosignature-card-designfrom
integrate-rbs

Conversation

@st0012
Copy link
Copy Markdown
Member

@st0012 st0012 commented Mar 30, 2026

Summary

Extract #: inline RBS annotations from comments and display them alongside method/attribute documentation in RDoc's HTML output.

  • Parse #: annotation lines from comment blocks during Prism parsing, store as type_signature on MethodAttr
  • Load type signatures from sig/ directory and RBS core types via RBS::EnvironmentLoader (inline annotations take priority)
  • Validate annotations through RBS::Parser with warnings for invalid syntax
  • Server-side type name linking using RBS parser locations — type names link to their documentation pages
  • Render type signatures in the aliki theme with a dotted separator between call_seq and type sigs
  • Display type signatures in ri terminal output
  • Add rbs >= 4.0.0 as a gemspec dependency, bump minimum Ruby to 3.2

Builds on #1669 (signature card design).

Screenshots

Screenshot 2026-04-02 at 18 31 13

Implementation

Area Details
Data model type_signature accessor on MethodAttr, Marshal v4
Parser extract_type_signature! in PrismRuby, validates via both parse_method_type and parse_type
sig/ loading RDoc::RbsSupport.load_signatures via RBS::EnvironmentLoader, merged after store.complete
Type linking Server-side via RbsSupport.signature_to_html using RBS parser AST locations, decoupled from generator via block
Display Aliki theme — template, CSS; tertiary color, tight line-height, dotted separator, scaled on mobile
RI output render_method_type_signature in ri/driver.rb
Caching Store#type_name_lookup built once, invalidated on complete
Tests Parser, marshal, RBS support, type linking, ri output

Follow-up work

  • Merge RBS sigs with method params: Type signatures could be merged with call_seq parameters (e.g., showing typed params with default values). Deferred — significantly more complex.
  • JRuby/TruffleRuby support: RBS has a C extension that cannot build on these platforms. Dropped from CI for now. Future work: make rbs an optional dependency with graceful degradation.

@matzbot
Copy link
Copy Markdown
Collaborator

matzbot commented Mar 30, 2026

🚀 Preview deployment available at: https://c26bfbb0.rdoc-6cd.pages.dev (commit: bfcd437)

@st0012 st0012 changed the base branch from master to signature-card-design April 2, 2026 17:29
@st0012 st0012 force-pushed the signature-card-design branch from 251f5db to be86678 Compare April 2, 2026 18:05
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 and TruffleRuby from CI
matrix (rbs has a C extension that cannot build on them).
@st0012 st0012 force-pushed the integrate-rbs branch 3 times, most recently from d25f6ba to a469122 Compare April 2, 2026 18:25
Add `type_signature` accessor to `MethodAttr`. During Prism parsing,
extract `#:` annotation lines from comment blocks and store them on
methods and attributes. Bump Marshal to v4 for RI serialization.

Render type signatures in the aliki theme with server-side type name
linking via `RbsSupport.signature_to_html`. Uses the RBS parser to
extract type name locations precisely for linking to documentation
pages. Validate annotations through `RBS::Parser` — invalid sigs
emit a warning but are still displayed.

Load additional signatures from `sig/` directories and RBS core
types via `RBS::EnvironmentLoader`. Display type signatures in `ri`
terminal output.
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.

2 participants