Inline support on protoype

未关闭
#2,653 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
ruby
领域
tooling

调研方向

复现使用 lib/calculator.rb 和 bin/rbs 的 prototype rb,输出位于 sig/lib/calculator.rbs。首先运行该命令并跟踪 prototype 路径,查看为什么内联注释仍然是注释。生成的签名使用如图所示的 Integer 参数和返回类型即表示完成。

由索引模型根据 Issue 内容生成。

描述

I was hoping to use inline documentation to generate proper type signatures, but it doesn't seem to be working at the moment. I have a PR with everything set up to demonstrate here.

Here is the gist, though:

I expect that this calculator.rb file:

class Calculator
  # @rbs (Integer, Integer) -> Integer
  def add(a, b)
    a + b
  end
end

And after running this command:

bin/rbs prototype rb lib/calculator.rb > sig/lib/calculator.rbs

Would produce this sig/lib/calculator.rbs file:

class Calculator
  def add: (Integer a, Integer b) -> Integer
end

But at the moment, it produces this:

class Calculator
  # @rbs (Integer, Integer) -> Integer
  def add: (untyped a, untyped b) -> untyped
end

All this with the current specs:

❯ ruby --version
ruby 3.2.7 (2025-02-04 revision 02ec315244) [arm64-darwin23]
❯ bundle info rbs
  * rbs (4.0.0.dev.4 8a97819)
	Summary: Type signature for Ruby.
	Homepage: https://github.com/ruby/rbs
	Source Code: https://github.com/ruby/rbs.git
	Changelog: https://github.com/ruby/rbs/blob/master/CHANGELOG.md
	Path: /Users/aemadrid/.local/share/mise/installs/ruby/3.2.7/lib/ruby/gems/3.2.0/bundler/gems/rbs-8a97819d4419

Is this something that is in the works but not quite ready?

主要语言
Ruby
星标
2.2k
派生
263
平均合并
1 天 20 小时
30 天内合并 PR
64

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/rbs 的其他 Issue

查看 ruby/rbs 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。