mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-19 18:34:08 +00:00
Isolate format_doc_comment with normalize_comments and wrap_comments.
This commit is contained in:
parent
a653e30d9f
commit
3300bb22a5
@ -656,9 +656,16 @@ impl<'a> CommentRewrite<'a> {
|
||||
_ => {
|
||||
let mut config = self.fmt.config.clone();
|
||||
config.set().wrap_comments(false);
|
||||
match crate::format_code_block(&self.code_block_buffer, &config) {
|
||||
Some(ref s) => trim_custom_comment_prefix(&s.snippet),
|
||||
None => trim_custom_comment_prefix(&self.code_block_buffer),
|
||||
if config.format_doc_comments() {
|
||||
if let Some(s) =
|
||||
crate::format_code_block(&self.code_block_buffer, &config)
|
||||
{
|
||||
trim_custom_comment_prefix(&s.snippet)
|
||||
} else {
|
||||
trim_custom_comment_prefix(&self.code_block_buffer)
|
||||
}
|
||||
} else {
|
||||
trim_custom_comment_prefix(&self.code_block_buffer)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-format_doc_comments: true
|
||||
|
||||
//! ```rust
|
||||
//! println!( "hello, world" );
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-format_doc_comments: true
|
||||
|
||||
// Do not unindent macro calls in comment with unformattable syntax.
|
||||
//! ```rust
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-format_doc_comments: true
|
||||
|
||||
/// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc commodo ultricies dui.
|
||||
///
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-format_doc_comments: true
|
||||
|
||||
//! This is a list:
|
||||
//! * Outer
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-format_doc_comments: true
|
||||
// rustfmt-max_width: 50
|
||||
|
||||
//! This is a list:
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-format_doc_comments: true
|
||||
|
||||
//! ```rust
|
||||
//! println!("hello, world");
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-format_doc_comments: true
|
||||
|
||||
// Do not unindent macro calls in comment with unformattable syntax.
|
||||
//! ```rust
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-format_doc_comments: true
|
||||
|
||||
/// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc
|
||||
/// commodo ultricies dui.
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-format_doc_comments: true
|
||||
|
||||
//! This is a list:
|
||||
//! * Outer
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-format_doc_comments: true
|
||||
// rustfmt-max_width: 50
|
||||
|
||||
//! This is a list:
|
||||
|
@ -8,7 +8,6 @@
|
||||
/// # #![cfg_attr(not(dox), no_std)]
|
||||
/// fn foo() { }
|
||||
/// ```
|
||||
///
|
||||
fn foo() {}
|
||||
|
||||
/// A long commment for wrapping
|
||||
|
Loading…
Reference in New Issue
Block a user