ruby / rbs

Type Signature for Ruby
Other
1.94k stars 212 forks source link

[Request] rbs prototype should leverage yard comments #357

Open kamaradclimber opened 4 years ago

kamaradclimber commented 4 years ago

rbs prototype rb command is useful to boostrap a rbs file. It would be convenient to have yard comment parsed and used when generating signature.

For instance, taking this example from the yard documentation:

# Converts the object into textual markup given a specific format.
#
# @param format [Symbol] the format type, `:text` or `:html`
# @return [String] the object converted into the expected format.
def to_format(format)
  # format the object
end

rbs prototype rb current returns:

class Object
  # Converts the object into textual markup given a specific format.
  #
  # @param format [Symbol] the format type, `:text` or `:html`
  # @return [String] the object converted into the expected format.
  def to_format: (untyped format) -> nil
end

whereas it could return something richer similar to:

class Object
  # Converts the object into textual markup given a specific format.
  #
  # @param format [Symbol] the format type, `:text` or `:html`
  # @return [String] the object converted into the expected format.
  def to_format: (Symbol format) -> String
end

The reasoning behind this feature would be to allow some users to maintain signature within ruby file using an existing and known syntax (yard) and get the benefit from rbs.

mucaho commented 2 years ago

3rd party solutions are available: sord and yard2steep-

Would be great if this project could collaborate with or integrate them!