Skip to content

wrap_comments is not applied to code in doc comments #6186

Open
@Hoodad

Description

@Hoodad

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions