-
Notifications
You must be signed in to change notification settings - Fork 883
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
Trying to skip formatting in doc comments #5623
Comments
Thanks for reaching out! You're right, it would definitely be useful to document under what conditions we'll actually run rustfmt on your doc comments. We should probably update the docs for That being said, before running rustfmt on the code in your doc comments we first check to see if there are any attributes that would indicate that it's not rust code. We support the rustdoc attributes, and we'll only run rustfmt on the code block if it's annotated with one of "rust", "should_panic", "no_run", "edition2015", "edition2018", "edition2021", or if there are no attributes since we assume that the code block contains rust code in that case. We'll ignore the code block if it contains any other kind of attribute. For example, "ignore", "compile_fail", or "text". For some immediate relief to your issue you could write something like this: /// ```ignore
/// use core::primitive;
///
/// let y = 0;
/// ```
fn main() {} or even something like this: /// ```some_random_attribute_so_rustfmt_ignores_the_code
/// use core::primitive;
///
/// let y = 0;
/// ```
fn main() {} |
There's definitely an issue when calling Lines 737 to 743 in ee2bed9
linking tracking issue for |
In a recent nightly,
rustfmt
withformat_code_in_doc_comments = true
started working and fixed some stuff. However, there was a place where I wanted to skip the formatting. This code:will result in
I presume the above behavior is a bug.
Independently, is there a way of skipping doc formatting without
#![rustfmt::skip]
appearing? I feel like I've seen some tag you can attach to the triple backticks, but it is not documented prominently.The text was updated successfully, but these errors were encountered: