-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #7357 - ebobrow:unbalanced-tick, r=xFrednet,flip1995
check for unbalanced tick pairs in doc-markdown lint fixes #6753 changelog: check for unbalanced tick pairs in doc-markdown lint
- Loading branch information
Showing
6 changed files
with
151 additions
and
15 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
File renamed without changes.
File renamed without changes.
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,36 @@ | ||
//! This file tests for the `DOC_MARKDOWN` lint, specifically cases | ||
//! where ticks are unbalanced (see issue #6753). | ||
#![allow(dead_code)] | ||
#![warn(clippy::doc_markdown)] | ||
|
||
/// This is a doc comment with `unbalanced_tick marks and several words that | ||
/// should be `encompassed_by` tick marks because they `contain_underscores`. | ||
/// Because of the initial `unbalanced_tick` pair, the error message is | ||
/// very `confusing_and_misleading`. | ||
fn main() {} | ||
|
||
/// This paragraph has `unbalanced_tick marks and should stop_linting. | ||
/// | ||
/// This paragraph is fine and should_be linted normally. | ||
/// | ||
/// Double unbalanced backtick from ``here to here` should lint. | ||
/// | ||
/// Double balanced back ticks ``start end`` is fine. | ||
fn multiple_paragraphs() {} | ||
|
||
/// ``` | ||
/// // Unbalanced tick mark in code block shouldn't warn: | ||
/// ` | ||
/// ``` | ||
fn in_code_block() {} | ||
|
||
/// # `Fine` | ||
/// | ||
/// ## not_fine | ||
/// | ||
/// ### `unbalanced | ||
/// | ||
/// - This `item has unbalanced tick marks | ||
/// - This item needs backticks_here | ||
fn other_markdown() {} |
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,64 @@ | ||
error: backticks are unbalanced | ||
--> $DIR/unbalanced_ticks.rs:7:1 | ||
| | ||
LL | / /// This is a doc comment with `unbalanced_tick marks and several words that | ||
LL | | /// should be `encompassed_by` tick marks because they `contain_underscores`. | ||
LL | | /// Because of the initial `unbalanced_tick` pair, the error message is | ||
LL | | /// very `confusing_and_misleading`. | ||
| |____________________________________^ | ||
| | ||
= note: `-D clippy::doc-markdown` implied by `-D warnings` | ||
= help: a backtick may be missing a pair | ||
|
||
error: backticks are unbalanced | ||
--> $DIR/unbalanced_ticks.rs:13:1 | ||
| | ||
LL | /// This paragraph has `unbalanced_tick marks and should stop_linting. | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: a backtick may be missing a pair | ||
|
||
error: you should put `should_be` between ticks in the documentation | ||
--> $DIR/unbalanced_ticks.rs:15:32 | ||
| | ||
LL | /// This paragraph is fine and should_be linted normally. | ||
| ^^^^^^^^^ | ||
|
||
error: backticks are unbalanced | ||
--> $DIR/unbalanced_ticks.rs:17:1 | ||
| | ||
LL | /// Double unbalanced backtick from ``here to here` should lint. | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: a backtick may be missing a pair | ||
|
||
error: you should put `not_fine` between ticks in the documentation | ||
--> $DIR/unbalanced_ticks.rs:30:8 | ||
| | ||
LL | /// ## not_fine | ||
| ^^^^^^^^ | ||
|
||
error: backticks are unbalanced | ||
--> $DIR/unbalanced_ticks.rs:32:1 | ||
| | ||
LL | /// ### `unbalanced | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: a backtick may be missing a pair | ||
|
||
error: backticks are unbalanced | ||
--> $DIR/unbalanced_ticks.rs:34:1 | ||
| | ||
LL | /// - This `item has unbalanced tick marks | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: a backtick may be missing a pair | ||
|
||
error: you should put `backticks_here` between ticks in the documentation | ||
--> $DIR/unbalanced_ticks.rs:35:23 | ||
| | ||
LL | /// - This item needs backticks_here | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 8 previous errors | ||
|