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

Support for YARD convention of question marks to denote nilable types #160

Open ForeverZer0 opened 1 year ago

ForeverZer0 commented 1 year ago

Is your feature request related to a problem? Please describe. When documenting with YARD, one can simply add a ? suffix to a type in a @param or @return to indicate that the value may be nil. However, sord generates an error when this syntax is used and does not recognize the type or that it is nilable, but merely results in an error being generated.

For example:

# @param name [String?] The new name, or `nil` to reset the default name.
def rename(name)
  ...
end

Describe the solution you'd like That the YARD syntax be permitted and generate correct RBI/RBS.

Describe alternatives you've considered The use [Type,nil] works well enough and achieves the expected result, though it would be ideal to not have to alter existing YARD documentation and deviate from its conventions in order to make it compliant with sord.

Additional context N/A