AaronC81 / sord

Convert YARD docs to Sorbet RBI and Ruby 3/Steep RBS files
https://sord.aaronc.cc
MIT License
293 stars 18 forks source link

RBS constant in version.rb file gives untyped #145

Closed tobidelius closed 2 years ago

tobidelius commented 2 years ago

Describe the bug When running sord with: bundle exec sord --rbs types.rbs the VERSION constant gets untyped.

To Reproduce

$ bundle gem my_gem && cd my_gem
$ bundle add sord
$ bundle install
# add # @return [String] to the constant in `lib/my_gem/version.rb`
$ bundle exec sord --rbs types.rbs

Expected behavior

module MyGem
  VERSION: String
end

Actual behavior

module MyGem
  VERSION: untyped
end

Additional information Made the steps above for you https://github.com/iamsandelius/sord-version-constant

Generated .rbs is in types.rbs

I suspect it has to do with the module being defined twice but that's just swinging blind without diving deeper into it.

matmorel commented 2 years ago

It has been fixed by #130, you can use master as a workaround:

# Gemfile
source "https://rubygems.org"
gem "sord", git: "https://github.com/AaronC81/sord", branch: "master"
gemspec
bundle
bundle exec sord --rbs types.rbs
# types.rbs
module MyGem
  VERSION: String
end

Unfortunately this can't be placed in the my_gem.gemspec file until the next release.

tobidelius commented 2 years ago

@matmorel ohh I saw that PR and also that it was merge so long ago that I just assumed it was released after that. Thx.

AaronC81 commented 2 years ago

Sorry for the delay, everyone - just released Sord 4.0.0 to RubyGems, which includes this fix.

I'll close this issue since that should fix it without needing to use master, but please ping me if you're still having problems, and I'll get it sorted!