Is your feature request related to a problem? Please describe.
I would like an option to place Sorbet sigs in the source file, rather than a separate .rbi file, to make use of the sorbet-runtime.
Describe the solution you'd like
To use the example in the README, given:
module Example
class Person
# @param name [String] The name of the Person to create.
# @param age [Integer] The age of the Person to create.
# @return [Example::Person]
def initialize(name, age)
@name = name
@age = age
end
# @return [String]
attr_accessor :name
# @return [Integer]
attr_accessor :age
# @param possible_names [Array<String>] An array of potential names to choose from.
# @param possible_ages [Array<Integer>] An array of potential ages to choose from.
# @return [Example::Person]
def self.construct_randomly(possible_names, possible_ages)
Person.new(possible_names.sample, possible_ages.sample)
end
end
end
I would like to be able to transform the file into:
module Example
class Person
# @param name The name of the Person to create.
# @param age The age of the Person to create.
sig { params(name: String, age: Integer).void }
def initialize(name, age)
@name = name
@age = age
end
sig { returns(String) }
attr_accessor :name
sig { returns(Integer) }
attr_accessor :age
# @param possible_names An array of potential names to choose from.
# @param possible_ages An array of potential ages to choose from.
sig { params(possible_names: T::Array[String], possible_ages: T::Array[Integer]).returns(Example::Person) }
def self.construct_randomly(possible_names, possible_ages)
Person.new(possible_names.sample, possible_ages.sample)
end
end
end
Note that I've kept the docstrings, and only scrubbed the types from the YARD annotations, bc the yard-sorbetplugin can merge the two when generating YARD docs.
Is your feature request related to a problem? Please describe. I would like an option to place Sorbet
sig
s in the source file, rather than a separate .rbi file, to make use of the sorbet-runtime.Describe the solution you'd like To use the example in the README, given:
I would like to be able to transform the file into:
Note that I've kept the docstrings, and only scrubbed the types from the YARD annotations, bc the
yard-sorbet
plugin can merge the two when generating YARD docs.