Add a way to mark a method as deprecated in inline RBS
For editor support in the Ruby LSP, it'd be great if this were standardized by rbs. See also https://github.com/Shopify/ruby-lsp/issues/1773
I see that there are deprecation signatures in RBS syntax that are generally standardized: https://github.com/ruby/rbs/blob/031f319726752e74499fc7036c9593a3b5d87ed0/sig/definition.rbs#L100
But is there a way to do this in an inline RBS signature? Should there be? Should we consider a @deprecated tag at the start of a comment line to be the standard way to do this, to match YARD/JSDoc and all the gems that already use this syntax?
class Foo
# @deprecated Use #new_thing instead.
#: -> String
def old_thing
return 'bad'
end
#: -> String
def new_thing
return 'better'
end
end
I see that there is one example of an inline comment for a deprecated method, in the tests, but I don't think it technically means anything here.
https://github.com/ruby/rbs/blob/031f319726752e74499fc7036c9593a3b5d87ed0/test/rbs/inline_parser_test.rb#L1305-L1306
I am very much looking forward to Inline RBS! :)
The rbs-inline provides syntax for annotations.
https://github.com/soutaro/rbs-inline/wiki/Syntax-guide#rbs-annotations
In this case, you can write it like this.
# @rbs %a{deprecated: Use #new_thing instead.}
#: -> String
def old_thing
return 'bad'
end
However, please note that this is an experimental feature, and parsing is not yet implemented in the rbs repo.
Does that work with #: style, or only @rbs?
It seems that the #: style is already supported after trying it out.
#: %a{deprecated: Use #new_thing instead.} -> String
def old_thing
return 'bad'
end
However, it does not seem to be written in the any document...