diff options
| author | Seiichi Uchida <seuchida@gmail.com> | 2018-10-11 23:10:57 +0900 |
|---|---|---|
| committer | Seiichi Uchida <seuchida@gmail.com> | 2018-10-11 23:34:36 +0900 |
| commit | b2de57484835ee42567db3a1bf59f13ecc7fab33 (patch) | |
| tree | 41bfe37e7f9f48401d2457209d13e6e273819936 /src | |
| parent | 15717be9c51aeab30571f5f10e1f0c3be15ad1ba (diff) | |
Add format_doc_comments
Diffstat (limited to 'src')
| -rw-r--r-- | src/comment.rs | 9 | ||||
| -rw-r--r-- | src/config/mod.rs | 1 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/comment.rs b/src/comment.rs index 41301527653..213879e50a1 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -333,7 +333,10 @@ fn identify_comment( let rewritten_first_group = if !config.normalize_comments() && has_bare_lines && style.is_block_comment() { light_rewrite_block_comment_with_bare_lines(first_group, shape, config)? - } else if !config.normalize_comments() && !config.wrap_comments() { + } else if !config.normalize_comments() + && !config.wrap_comments() + && !config.format_doc_comments() + { light_rewrite_comment(first_group, shape.indent, config, is_doc_comment)? } else { rewrite_comment_inner( @@ -593,7 +596,7 @@ fn rewrite_comment_inner( _ if code_block_buffer.is_empty() => String::new(), _ => { let mut config = config.clone(); - config.set().wrap_comments(false); + config.set().format_doc_comments(false); match ::format_code_block(&code_block_buffer, &config) { Some(ref s) => trim_custom_comment_prefix(s), None => trim_custom_comment_prefix(&code_block_buffer), @@ -1622,7 +1625,7 @@ mod test { #[test] #[rustfmt::skip] - fn format_comments() { + fn format_doc_comments() { let mut wrap_normalize_config: ::config::Config = Default::default(); wrap_normalize_config.set().wrap_comments(true); wrap_normalize_config.set().normalize_comments(true); diff --git a/src/config/mod.rs b/src/config/mod.rs index a553bf2ee3c..98754eb0b60 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -46,6 +46,7 @@ create_config! { // Comments. macros, and strings wrap_comments: bool, false, false, "Break comments to fit on the line"; + 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"; |
