diff --git a/Configurations.md b/Configurations.md index dc91a3d255a7..7557b3637f13 100644 --- a/Configurations.md +++ b/Configurations.md @@ -1978,9 +1978,9 @@ fn main() { } ``` -## `format_code_in_doc_comments` +## `format_doc_comments` -Format code snippet included in doc comments. +Format doc comments. - **Default value**: `false` - **Possible values**: `true`, `false` diff --git a/src/comment.rs b/src/comment.rs index 0a3062583c58..b8dcae235210 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -353,7 +353,7 @@ fn identify_comment( trim_left_preserve_layout(first_group, shape.indent, config)? } else if !config.normalize_comments() && !config.wrap_comments() - && !config.format_code_in_doc_comments() + && !config.format_doc_comments() { light_rewrite_comment(first_group, shape.indent, config, is_doc_comment) } else { @@ -656,7 +656,7 @@ impl<'a> CommentRewrite<'a> { _ => { let mut config = self.fmt.config.clone(); config.set().wrap_comments(false); - if config.format_code_in_doc_comments() { + if config.format_doc_comments() { if let Some(s) = crate::format_code_block(&self.code_block_buffer, &config) { diff --git a/src/config/mod.rs b/src/config/mod.rs index f04074e4f328..c0221e93e025 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -37,7 +37,7 @@ create_config! { // Comments. macros, and strings wrap_comments: bool, false, false, "Break comments to fit on the line"; - format_code_in_doc_comments: bool, false, false, "Format the code snippet in doc comments."; + format_doc_comments: bool, false, false, "Format doc comments."; comment_width: usize, 80, false, "Maximum length of comments. No effect unless wrap_comments = true"; normalize_comments: bool, false, false, "Convert /* */ comments to // comments where possible"; diff --git a/tests/source/doc-comment-with-example.rs b/tests/source/doc-comment-with-example.rs index e74ceefd1958..58d98acfa255 100644 --- a/tests/source/doc-comment-with-example.rs +++ b/tests/source/doc-comment-with-example.rs @@ -1,4 +1,4 @@ -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true /// Foo /// diff --git a/tests/source/invalid-rust-code-in-doc-comment.rs b/tests/source/invalid-rust-code-in-doc-comment.rs index 835b0261b760..6d33dcfce552 100644 --- a/tests/source/invalid-rust-code-in-doc-comment.rs +++ b/tests/source/invalid-rust-code-in-doc-comment.rs @@ -1,4 +1,4 @@ -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true /// ```rust /// if (true) { … } diff --git a/tests/source/issue-2520.rs b/tests/source/issue-2520.rs index 5a23f10430d1..9ea522c4fe4e 100644 --- a/tests/source/issue-2520.rs +++ b/tests/source/issue-2520.rs @@ -1,5 +1,5 @@ // rustfmt-normalize_comments: true -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true //! ```rust //! println!( "hello, world" ); diff --git a/tests/source/issue-2523.rs b/tests/source/issue-2523.rs index 491d5c38fc22..71aed6ac5351 100644 --- a/tests/source/issue-2523.rs +++ b/tests/source/issue-2523.rs @@ -1,5 +1,5 @@ // rustfmt-normalize_comments: true -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true // Do not unindent macro calls in comment with unformattable syntax. //! ```rust diff --git a/tests/source/issue-3055/original.rs b/tests/source/issue-3055/original.rs index ad505547ac02..eaf00afa3d38 100644 --- a/tests/source/issue-3055/original.rs +++ b/tests/source/issue-3055/original.rs @@ -1,5 +1,5 @@ // rustfmt-wrap_comments: true -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true /// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc commodo ultricies dui. /// diff --git a/tests/source/itemized-blocks/no_wrap.rs b/tests/source/itemized-blocks/no_wrap.rs index a7b6a10a0105..a0c546ad18e1 100644 --- a/tests/source/itemized-blocks/no_wrap.rs +++ b/tests/source/itemized-blocks/no_wrap.rs @@ -1,5 +1,5 @@ // rustfmt-normalize_comments: true -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true //! This is a list: //! * Outer diff --git a/tests/source/itemized-blocks/wrap.rs b/tests/source/itemized-blocks/wrap.rs index 955cc698b79f..14fc8daa2e9d 100644 --- a/tests/source/itemized-blocks/wrap.rs +++ b/tests/source/itemized-blocks/wrap.rs @@ -1,5 +1,5 @@ // rustfmt-wrap_comments: true -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true // rustfmt-max_width: 50 //! This is a list: diff --git a/tests/target/doc-comment-with-example.rs b/tests/target/doc-comment-with-example.rs index c5a4e779ea22..bec931d13c78 100644 --- a/tests/target/doc-comment-with-example.rs +++ b/tests/target/doc-comment-with-example.rs @@ -1,4 +1,4 @@ -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true /// Foo /// diff --git a/tests/target/invalid-rust-code-in-doc-comment.rs b/tests/target/invalid-rust-code-in-doc-comment.rs index f8479d4e3451..2593410a4189 100644 --- a/tests/target/invalid-rust-code-in-doc-comment.rs +++ b/tests/target/invalid-rust-code-in-doc-comment.rs @@ -1,4 +1,4 @@ -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true /// ```rust /// if (true) { … } diff --git a/tests/target/issue-2520.rs b/tests/target/issue-2520.rs index 7c134d3972ba..7d22b2b665a7 100644 --- a/tests/target/issue-2520.rs +++ b/tests/target/issue-2520.rs @@ -1,5 +1,5 @@ // rustfmt-normalize_comments: true -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true //! ```rust //! println!("hello, world"); diff --git a/tests/target/issue-2523.rs b/tests/target/issue-2523.rs index 612f93249acf..c0118e537803 100644 --- a/tests/target/issue-2523.rs +++ b/tests/target/issue-2523.rs @@ -1,5 +1,5 @@ // rustfmt-normalize_comments: true -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true // Do not unindent macro calls in comment with unformattable syntax. //! ```rust diff --git a/tests/target/issue-3055/original.rs b/tests/target/issue-3055/original.rs index de27ccfb344e..1fb35d506820 100644 --- a/tests/target/issue-3055/original.rs +++ b/tests/target/issue-3055/original.rs @@ -1,5 +1,5 @@ // rustfmt-wrap_comments: true -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true /// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc /// commodo ultricies dui. diff --git a/tests/target/itemized-blocks/no_wrap.rs b/tests/target/itemized-blocks/no_wrap.rs index de8856382726..a1f9c39a1150 100644 --- a/tests/target/itemized-blocks/no_wrap.rs +++ b/tests/target/itemized-blocks/no_wrap.rs @@ -1,5 +1,5 @@ // rustfmt-normalize_comments: true -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true //! This is a list: //! * Outer diff --git a/tests/target/itemized-blocks/wrap.rs b/tests/target/itemized-blocks/wrap.rs index a4907303c9e1..967a38b91ae8 100644 --- a/tests/target/itemized-blocks/wrap.rs +++ b/tests/target/itemized-blocks/wrap.rs @@ -1,5 +1,5 @@ // rustfmt-wrap_comments: true -// rustfmt-format_code_in_doc_comments: true +// rustfmt-format_doc_comments: true // rustfmt-max_width: 50 //! This is a list: