Skip to content

Preserve sig parameter comments#612

Open
KaanOzkan wants to merge 4 commits into
mainfrom
ko-sig-param-rbs-comments
Open

Preserve sig parameter comments#612
KaanOzkan wants to merge 4 commits into
mainfrom
ko-sig-param-rbs-comments

Conversation

@KaanOzkan

Copy link
Copy Markdown
Contributor

To be used by Shopify/spoom#901

@KaanOzkan KaanOzkan force-pushed the ko-sig-param-rbs-comments branch 3 times, most recently from 1c12951 to b24a431 Compare June 10, 2026 19:06
Comment thread test/rbi/parser_test.rb
params(
a: Integer, # `a` comment
b: String # `b` comment 1
# `b` comment 2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted to keep the existing RBI printer behaviour here so the comments are printed as trailing but we could also make it multiline like the RBS printer.

@KaanOzkan KaanOzkan marked this pull request as ready for review June 10, 2026 19:09
@KaanOzkan KaanOzkan requested a review from a team as a code owner June 10, 2026 19:09
@KaanOzkan KaanOzkan force-pushed the ko-sig-param-rbs-comments branch from 29b52dd to 15ffc31 Compare June 10, 2026 20:42
@KaanOzkan KaanOzkan marked this pull request as draft June 10, 2026 20:49
@KaanOzkan KaanOzkan force-pushed the ko-sig-param-rbs-comments branch from 15ffc31 to 11d51eb Compare June 10, 2026 20:51
@KaanOzkan KaanOzkan force-pushed the ko-sig-param-rbs-comments branch from 11d51eb to 2e5d08d Compare June 22, 2026 19:08
Moves `node_comments` and comment parsing onto the shared parser visitor so `TreeBuilder` and `SigBuilder` consume the same comment map.

This lets sig parameter parsing attach comments without leaving them behind as dangling node comments.
Attaches comments inside `params(...)` to the matching `RBI::SigParam` and makes `RBSPrinter` render printable param comments in multiline signatures.

This keeps parameter documentation attached to the emitted RBS parameter line instead of floating above the method.
Extends the multiline RBS path to handle comments on block sig params, including overloads and generic block-only signatures.

Comments are only printed when the block clause is emitted, so skipped `NilClass` block params do not leave detached comments or force multiline output.
Updates `rbi/rbi.rbi` after the parser and RBS printer changes.
@KaanOzkan KaanOzkan force-pushed the ko-sig-param-rbs-comments branch from 2e5d08d to 43ea118 Compare June 22, 2026 19:16
@KaanOzkan KaanOzkan marked this pull request as ready for review June 22, 2026 20:04
@KaanOzkan KaanOzkan requested a review from Morriar June 22, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant