soutaro / rbs-inline

Inline RBS type declaration
MIT License
250 stars 8 forks source link

Multi-line support #150

Open KieranP opened 6 days ago

KieranP commented 6 days ago

Support for defining method attributes over multiple lines

# @rbs attrs: {
#   x: Integer?,
#   y: Integer?,
#   w: Integer?,
#   l: Integer?,
#   h: Integer?,
# }
tk0miya commented 5 days ago

Just FYI: rbs-inline expects one or more spaces for continued lines:

Therefore this is valid.

# @rbs attrs: {
#     x: Integer?,
#     y: Integer?,
#     w: Integer?,
#     l: Integer?,
#     h: Integer?,
#   }
KieranP commented 5 days ago

@tk0miya Hmm, interesting. When all my ruby code is indented by two spaces, why do the @rbs comments require at least 3 space and to be not synced up (the closing brace is in a different column than the @ of @rbs? :-/ It would be much cleaner IMO if the first example worked.

Edit: Infact it works with the attrs being indented by two spaces, it's only the last brace that needs to be indented one more than it should be. So for now, I'll use:

# @rbs attrs: {
#   x: Integer?,
#   y: Integer?,
#   w: Integer?,
#   l: Integer?,
#   h: Integer?,
#  }
ParadoxV5 commented 5 days ago

It’s because the expectation was essentially:

# @rbs attrs:
#   {
#     x: Integer?,
#     y: Integer?,
#     w: Integer?,
#     l: Integer?,
#     h: Integer?,
#   }

A better example from the @rbs! docs:

# @rbs!
#   attr_accessor id (): Integer
#   attr_accessor name (): String