option to enforce ordering for attributes and doc comments
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
There are two orderings possible with items that have both attributes and doc comments
/// doc comment
#[attribute]
fn foo() {}
#[attribute]
/// doc comment
fn foo() {}
A random twitter poll that I cannot find anymore made it clear that option 1 is significantly more popular than option 2 and some people (myself included) would prefer if we just settled on one of these variants and consistently enforced that style.
The proposed feature is to add a check for items that have both a doc comment and attributes and to format them all consistently. There should be an option to select either style. I believe that the former should be the default setting.
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 by locating rustfmt's handling of items with both attributes and doc comments, along with its existing configuration options and tests. Implement the proposed check with selectable ordering, using the preferred doc-comment-first style as the default; done means both variants are formatted consistently according to that option.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100