简体   繁体   English

将 Sorbet RBI 添加到 gem 的目录结构是什么?

[英]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.我有一个我想添加类型的gem (通过提交 PR 或通过 fork 仅在我的项目中使用),但除了创建/rbi文件夹之外,文档没有提供更多指导。

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 ?大声思考,它应该镜像lib/中的文件并添加类型签名,还是应该像sorbet-typed中的签名一样是一个大文件(每个版本?)?

I don't know of any gems doing this yet, and the documentation doesn't mention it either.我还不知道有任何宝石这样做,文档也没有提到它。

I recently went through this process for one of my gems - pdf-reader.我最近为我的一个宝石 - pdf阅读器经历了这个过程。 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.这是我第一次使用冰糕(所以我不是专家),而且我还注意到缺少将类型添加到 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我最终使用parlor生成了初始 rbi 文件,将它们全部放入一个文件中: https ://github.com/yob/pdf-reader/blob/480aa240a531cd6f97a46a29279f19025821e886/rbi/pdf-reader.rbi

Sorbet seems happy with that, so I haven't changed it.冰糕似乎对此很满意,所以我没有改变它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM