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

wrap_comments is not applied to code in doc comments #6186

Open
Hoodad opened this issue Jun 5, 2024 · 4 comments
Open

wrap_comments is not applied to code in doc comments #6186

Hoodad opened this issue Jun 5, 2024 · 4 comments
Labels
a-comments only-with-option requires a non-default option value to reproduce

Comments

@Hoodad
Copy link

Hoodad commented Jun 5, 2024

Hello!

I just came across the wonderful (currently unstable) commands comment_width & wrap_comments which I happily applied to a larger codebase and thought this is the end to comments spanning longer then 100 in width. But to my surprise after pushing the change I noticed not all comments was formatted. It appears that code that is within a triple tick section done below will not be formatted.

/// ```rust
/// pub struct ImportantData {
///     // This text will however not be formatted to adhere to the max length of comments even tough it will end up on the doc page just like other comments.
///     some_field: u32,
/// }
/// ```

This ends up looking bad in the source code as well on the doc page. The output can be seen in the screenshot below.

image

Is this expected? If so is there a way around this limitation, I have looked at the available commands to rustfmt but haven't found anything.

I have put together a minimal example of the issue here

@ytmimi
Copy link
Contributor

ytmimi commented Jun 5, 2024

It's the use of the ignore attribute. rustfmt treats that as "don't format this code".

@ytmimi ytmimi closed this as not planned Won't fix, can't repro, duplicate, stale Jun 5, 2024
@Hoodad
Copy link
Author

Hoodad commented Jun 6, 2024

Sorry I should have clarified, I tested that first and even without the ignore attribute the comment isn't formatted.

@Hoodad
Copy link
Author

Hoodad commented Jun 10, 2024

@ytmimi I updated the example to show that the problem still persists with different attributes like rust

@ytmimi ytmimi reopened this Jun 10, 2024
@ytmimi ytmimi changed the title Example code not being formatted wrap_comments is not applied to code in doc comments Jun 10, 2024
@ytmimi ytmimi added a-comments only-with-option requires a non-default option value to reproduce labels Jun 10, 2024
@ytmimi
Copy link
Contributor

ytmimi commented Jun 10, 2024

Linking the tracking issue for wrap_comments #3347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-comments only-with-option requires a non-default option value to reproduce
Projects
None yet
Development

No branches or pull requests

2 participants