Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustfmt doc code blocks with multiple comma-separated attributes
Added test covering this. Chose to treat the code block as rust if and only if all of the comma-separated attributes are rust-valid. Chose to allow/preserve whitespace around commas Fixes #3158
- Loading branch information
1 parent
a806883
commit b10ab51
Showing
3 changed files
with
171 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// rustfmt-format_code_in_doc_comments: true | ||
|
||
/// Should format | ||
/// ```rust | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Should format | ||
/// ```rust,should_panic | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Should format | ||
/// ```rust,should_panic,edition2018 | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Should format | ||
/// ```rust , should_panic , edition2018 | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Should not format | ||
/// ```ignore | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Should not format (not all are rust) | ||
/// ```rust,ignore | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Should not format (rust compile_fail) | ||
/// ```compile_fail | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Should not format (rust compile_fail) | ||
/// ```rust,compile_fail | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Various unspecified ones that should format | ||
/// ``` | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// ```, | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// ```,,,,, | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// ```,,, rust ,, | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Should not format | ||
/// ```,,, rust , ignore, | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Few empty ones | ||
/// ``` | ||
/// ``` | ||
/// | ||
/// ```rust | ||
/// ``` | ||
/// | ||
/// ```ignore | ||
/// ``` | ||
fn foo() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// rustfmt-format_code_in_doc_comments: true | ||
|
||
/// Should format | ||
/// ```rust | ||
/// assert!(false); | ||
/// ``` | ||
/// | ||
/// Should format | ||
/// ```rust,should_panic | ||
/// assert!(false); | ||
/// ``` | ||
/// | ||
/// Should format | ||
/// ```rust,should_panic,edition2018 | ||
/// assert!(false); | ||
/// ``` | ||
/// | ||
/// Should format | ||
/// ```rust , should_panic , edition2018 | ||
/// assert!(false); | ||
/// ``` | ||
/// | ||
/// Should not format | ||
/// ```ignore | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Should not format (not all are rust) | ||
/// ```rust,ignore | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Should not format (rust compile_fail) | ||
/// ```compile_fail | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Should not format (rust compile_fail) | ||
/// ```rust,compile_fail | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Various unspecified ones that should format | ||
/// ``` | ||
/// assert!(false); | ||
/// ``` | ||
/// | ||
/// ```, | ||
/// assert!(false); | ||
/// ``` | ||
/// | ||
/// ```,,,,, | ||
/// assert!(false); | ||
/// ``` | ||
/// | ||
/// ```,,, rust ,, | ||
/// assert!(false); | ||
/// ``` | ||
/// | ||
/// Should not format | ||
/// ```,,, rust , ignore, | ||
/// assert!( false ); | ||
/// ``` | ||
/// | ||
/// Few empty ones | ||
/// ``` | ||
/// ``` | ||
/// | ||
/// ```rust | ||
/// ``` | ||
/// | ||
/// ```ignore | ||
/// ``` | ||
fn foo() {} |