-
Notifications
You must be signed in to change notification settings - Fork 889
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
It should be possible to run rustfmt _only_ on doc comments #5345
Comments
This feels a bit like a particular solution to a problem that I'm not sure I fully understand even after glancing through the comments on the upstream PR. Was the motivating scenario a desire to use a different/shorter width limit for code in doc comments, independent of the overall |
Yes, because, as I said, rustdoc renders code with a pretty large font (this is good), and it tends to need much shorter line length restrictions. Most docs i've encountered in the wild manually wrap to a much shorter limit because of this, and now that rustfmt supports formatting doc comments it feels like we should perhaps support that automatically too? |
Thanks for confirming and clarifying. Though technically possible, I don't think it's going to be practical to try to go down the path of an entirely separate, doc comment only formatting mode (I can elaborate if need be). What would be more straightforward is a new option that allows for controlling the width limit of code blocks separate from the other two options so that a shorter width limit could be set explicitly for those code blocks, e.g. a new Do you feel like that would provide a sufficient resolution to the need to be able to force wrapping more aggressively in doc code blocks? |
I think so, yes! I don't think the general feature is as necessary |
Have opened #5359 to track implementation of the discussed option, will keep this separate and open as the articulation of the problem-to-be-solved. Will revisit once the option is available to confirm it will suffice, and close this if so. |
doc_comment_code_block_width was added in the v1.5.1 release, and should be available on nightly now! |
Thanks for triaging all these issues Yacin! However, going to reopen this actually to give the team time to test drive the solution and see whether it actually allows them to address the original problem. Let us know if/how it's working out for you Manish |
Thanks! |
It works pretty nicely! Setting it to 80 seems quite ideal for us. |
There's a new
format_code_in_doc_comments
config which is quite useful and nice.However, it formats the entire codebase, including non-doc comment code. This can cause challenges since it's quite likely folks may want a separate set of configs for doc comments: chief of which would be line length restrictions. Rustdoc renders code blocks with a pretty large font and typically the code is written with far more wrapping.
It would be nice to be able to run rustfmt twice, once for regular code, once for doc comments, with different settings, perhaps with a
format_code_in_doc_comments_only
flag.The text was updated successfully, but these errors were encountered: