Closed DalenW closed 1 year ago
Same problem. It doesn't support rbs 3
Temporary fix:
Add gem 'rbs', '~> 2'
or gem 'rbs_rails', git: 'https://github.com/mrdev023/rbs_rails.git', branch: 'master'
in Gemfile
@DalenW
EDIT:
# parse_signature return 3 elements
def self.parse_signature(source)
buf = buffer(source)
dirs, decls = _parse_signature(buf, buf.last_position)
[buf, dirs, decls]
end
# And write filter by type
def write(contents)
dirs = contents.select {|c| c.is_a?(AST::Directives::Base) } #: Array[AST::Directives::t]
decls = contents.select {|c| c.is_a?(AST::Declarations::Base) } #: Array[AST::Declarations::t]
[...]
end
# It can be fixed with this code
def format_rbs(rbs)
decls = RBS::Parser.parse_signature(rbs)
decls = decls[1] + decls[2] if RBS::VERSION.start_with? '3.'
StringIO.new.tap do |io|
RBS::Writer.new(out: io).write(decls)
end.string
end
Thanks for the fix! I'll have to give it a try when I get a chance.
This issue has been fixed so I close it.
Somewhere along the line, RBS rails now generates blank model RBS files. I updated an old public repo I had to demonstrate this. (ignore the terrible code lol)
https://github.com/M6Securities/manius-market/pull/57
Everything is running at the latest version. I did a little bit of digging, and it seems the issue is with this:
Whatever
RBS::Writer
is generating, is blank. I don't know much else beyond that.