Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiline doc comments #3114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jschwe
Copy link
Contributor

@jschwe jschwe commented Feb 5, 2025

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

@oberrich
Copy link

oberrich commented Feb 5, 2025

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

@jschwe
Copy link
Contributor Author

jschwe commented Feb 6, 2025

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.

@oberrich
Copy link

oberrich commented Feb 7, 2025

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?

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.

Bindgen produces #[doc = "foo\nbar"] doc comments instead of multiline doc comments
2 participants