`wrap_comments` is not applied to code in doc comments
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
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.
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked minimal example and reproduce the behavior using wrap_comments and comment_width. Trace how rustfmt handles fenced code in doc comments, then verify that comments inside the fence are wrapped consistently with other doc comments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100