jaredsmith
jaredsmith

Reputation: 7563

What is the directory structure for adding Sorbet RBIs to a gem?

I have a gem I want to add types to (either by submitting a PR or by forking to use just in my project), but the documentation does not give any more guidance other than to create an /rbi folder.

Thinking out loud, should it mirror the files in lib/ with added type signatures, or should it be one large file (per version?) like the signatures in sorbet-typed?

I don't know of any gems doing this yet, and the documentation doesn't mention it either.

Upvotes: 3

Views: 361

Answers (1)

James Healy
James Healy

Reputation: 15168

I recently went through this process for one of my gems - pdf-reader. It was my first experience with sorbet (so I'm no expert), and I also noticed the lack of documentation for the specific use case of adding types to a gem.

I ended up generating the initial rbi file using parlour, which put them all into a single file: https://github.com/yob/pdf-reader/blob/480aa240a531cd6f97a46a29279f19025821e886/rbi/pdf-reader.rbi

Sorbet seems happy with that, so I haven't changed it.

Upvotes: 3

Related Questions