[Request] rbs prototype should leverage yard comments
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.2k
- Forks
- 256
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 37
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the rbs prototype rb command and trace how Ruby method comments and signatures are currently read. Investigate how YARD @param and @return annotations could map to the generated RBS signature, using the to_format example as the expected behavior. Done means the example produces Symbol and String instead of untyped and nil, with coverage for the parsing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100