rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

Fix multiline doc comments

Open jschwe opened this issue 10 months ago • 4 comments

Use str::lines() to split the doc comment into one #[doc] block per comment line.

Note: The diff is large, but it's all just the test expectations for the comments being updated. The actual change is -1 + 3 lines.

Fixes #3073

jschwe avatar Feb 05 '25 13:02 jschwe

Could we add an option for users to choose their preferred style?

rich-ayr avatar Feb 05 '25 16:02 rich-ayr

Could we add an option for users to choose their preferred style?

Could you elaborate what you mean with preferred style? I think the current policy is to leave it up to rustfmt / prettyplease to format the output according to the users preferences.

jschwe avatar Feb 06 '25 14:02 jschwe

Could we add an option for users to choose their preferred style?

Could you elaborate what you mean with preferred style? I think the current policy is to leave it up to rustfmt / prettyplease to format the output according to the users preferences.

So the only cases this impacts is where no formatter is set?

I've changed how comments are processed slightly in the attributes implementation, it will run all attributes through prettyplease and collapse all comments into a single #[doc = "..."] tag right before calling the process_attributes callback. Do you think this change will survive the new behavior?

rich-ayr avatar Feb 07 '25 02:02 rich-ayr

@emilio Would you accept this PR to fix multiline doc comments? If yes I would go ahead and rebase the test expectations. There was a request by @rich-ayr to add an option to keep the current behavior (of a single #[doc = "..."] tag), and it would be good to have a maintainers opinion on that before I implement any changes.

jschwe avatar Dec 03 '25 12:12 jschwe