Preserve inline comments inside sig blocks during RBS translation#901
Open
KaanOzkan wants to merge 1 commit into
Open
Preserve inline comments inside sig blocks during RBS translation#901KaanOzkan wants to merge 1 commit into
KaanOzkan wants to merge 1 commit into
Conversation
da8a668 to
36e1207
Compare
Morriar
reviewed
Apr 21, 2026
Morriar
reviewed
Apr 21, 2026
| assert_equal(<<~RBS, sorbet_sigs_to_rbs_comments(contents)) | ||
| # First param | ||
| # Second param | ||
| #: (Integer a, String b) -> void |
Contributor
There was a problem hiding this comment.
I think we should force multi line rendering when we find comments.
Consider this:
params(
# Some documentation
a: Integer
).void
def foo(a); endwhen translated we get this:
# Some documentation
#: (a) -> void
def foo(a); endit will look as if the documentation is about foo and not a.
Contributor
Author
There was a problem hiding this comment.
Hmm yeah this makes sense. I think we can either:
- Associate comments with parameters in
RBIand teachRBSPrinterabout outputting it - Keep doing the string post-processing in Spoom, similar to the new
add_inline_sig_comments. We could figure out the multiline aspect by looking at the indentation and insert the comment to the relevant line. We'd also need to add a new flag or setmax_line_lengthto 0 for theRBSPrinterto print multiline comment.
I'm leaning towards 1 since we're getting too much into the printing territory. Wdyt?
Comments inside `sig do params(...) end` blocks were silently dropped because the entire sig node byte range was replaced with the RBS string. Collect any comments within the sig node's range and prepend them to the output before the `#:` annotation.
36e1207 to
d6b6e91
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comments inside
sig do params(...) endblocks were silently dropped because the entire sig node byte range was replaced with the RBS string. Collect any comments within the sig node's range and prepend them to the output before the#:annotation.Resolves #900