-
Notifications
You must be signed in to change notification settings - Fork 1k
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
chore: Format code in doc comments #3222
Conversation
This pull request has merge conflicts. Could you please resolve them @umgefahren? 🙏 |
Unstable options are unavailable on stable Rust, right? You can hack around that by passing the options via the commandline last time I checked :) We could do the same thing as we do for clippy and make a cargo alias for formatting. See here for example: https://github.com/Restioson/xtra/blob/master/.cargo/config.toml |
That"s a good idea. I was looking for passing with options and probably overlooked it. I will add a custom cargo fmt command alias. Although it should be noted that this feature is not bug-free. Last time I looked it could case an ICE on empty doc comment code blocks. |
This pull request has merge conflicts. Could you please resolve them @umgefahren? 🙏 |
@@ -1,3 +1,4 @@ | |||
[alias] | |||
# Temporary solution to have clippy config in a single place until https://github.com/rust-lang/rust-clippy/blob/master/doc/roadmap-2021.md#lintstoml-configuration is shipped. | |||
custom-clippy = "clippy --workspace --all-features --all-targets -- -A clippy::type_complexity -A clippy::pedantic -D warnings" | |||
custom-fmt = "fmt -- --config format_code_in_doc_comments=true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do this, I"d like to enforce it in CI as well.
That is not ideal but I don"t think it is a big issue. We can go back to regular rustfmt if it ever causes problems. |
It would be good to get some more opinions on this though. cc @libp2p/rust-libp2p-maintainers |
I think it makes sense! Can we also stage the |
We could, but it would be a bit inconsistent with how we do things in this repo. Since we could could configure clippy via |
Configuring clippy lints via a config file is unimplemented so we can"t use it. Activating unstable fmt options on stable Rust also doesn"t work so we can"t use it :) |
Description
I discovered there is an unstable option to format code in doc comments. Although the option is unstable the resulting changes seem very reasonable.
To reproduce:
rustfmt.toml
to project rootcargo fmt --all
Notes
As soon as this is stabilized, we should add it to our CI. Linking the PR here: rust-lang/rustfmt#3348
Links to any relevant issues
None.
Open Questions
None.
Change checklist