Skip to content

rbs-inline#3933

Open
kddnewton wants to merge 2 commits intomainfrom
todos
Open

rbs-inline#3933
kddnewton wants to merge 2 commits intomainfrom
todos

Conversation

@kddnewton
Copy link
Collaborator

@kddnewton kddnewton commented Feb 18, 2026

Generate RBS through inline annotations instead of through maintaining separate RBS files.

I have wanted this for a while, but frankly it has been daunting to try to convert the whole codebase, and previously Steep would just hang. It looks like it has gotten better to the point where this is now possible. The typecheck:steep codebase will now first extract out inline type annotations and put them into the sig directory. You can effectively ignore all files in that directory for the purposes of review.

At present, this means basically the entire codebase is typechecked with steep, except the translation directory which depends on type signatures for parser/ripper/ruby_parser which do not exist.

@kddnewton kddnewton force-pushed the todos branch 4 times, most recently from 6508059 to df740be Compare February 18, 2026 04:42
@eregon
Copy link
Member

eregon commented Feb 18, 2026

Nice!

@Earlopain
Copy link
Collaborator

rdoc doesn't seem to really handle this which I find kind of sad since I just cleaned it all up. The type annotations are put into method docs and the magic comment appears like 20 times on the main page

@kddnewton
Copy link
Collaborator Author

@Earlopain ahh you're right, that's pretty ugly. I'll see if I can modify RDoc in some way before merging this.

@kddnewton
Copy link
Collaborator Author

Turns out there's a special syntax in RDoc where you can use #-- to mark part of the comment as private so it won't show up in the docs. I added that to all of the annotations and now it should be the same. @Earlopain can you check if this is better for you?

@Earlopain
Copy link
Collaborator

Earlopain commented Feb 18, 2026

I didn't know about that syntax, TIL. Unfortunatly rdoc doesn't ignore the rbs_inline comments, so I applied the same thing to them. I think rdoc should just do this by itself (github.com/ruby/rdoc/issues/1614) but for now it doesn't. Without, it looks like this
image

(typed sneaked in for some reason, which wasn't present before. I ignored that as well)

@Earlopain
Copy link
Collaborator

BTW, can we generate rbi signatures with this instead of handwriting them? There's https://github.com/Shopify/spoom?tab=readme-ov-file#translate-sigs-between-rbi-and-rbs, maybe we don't need to have them in two places

gem "steep", ">= 1.7.0.dev.1"
gem "tapioca"
gem "test-unit"
gem "tsort" # until rbs is bumped
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know what's up with dependabot but you can just manually bump rbs and this is not necessary anymore.

desc "Generate RBS with rbs-inline"
task rbs_inline: :templates do
with_gemfile do
sh "bundle", "exec", "rbs-inline", "lib", "--output", "lib"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be checked in CI or be part of the release process?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments