-
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.
doc_link_code: add check for
text
[adjacent
] style links
This is the lint described at rust-lang/rust#136308 (comment) that recommends using HTML to nest links inside code.
- Loading branch information
Showing
6 changed files
with
292 additions
and
0 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
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,52 @@ | ||
#![warn(clippy::doc_link_code)] | ||
|
||
//! Test case for code links that are adjacent to code text. | ||
//! | ||
//! This is not an example: `first``second` | ||
//! | ||
//! Neither is this: [`first`](x) | ||
//! | ||
//! Neither is this: [`first`](x) `second` | ||
//! | ||
//! Neither is this: [first](x)`second` | ||
//! | ||
//! This is: <code>[first](x)second</code> | ||
//~^ ERROR: adjacent | ||
//! | ||
//! So is this <code>first[second](x)</code> | ||
//~^ ERROR: adjacent | ||
//! | ||
//! So is this <code>[first](x)[second](x)</code> | ||
//~^ ERROR: adjacent | ||
//! | ||
//! So is this <code>[first](x)[second](x)[third](x)</code> | ||
//~^ ERROR: adjacent | ||
//! | ||
//! So is this <code>[first](x)second[third](x)</code> | ||
//~^ ERROR: adjacent | ||
|
||
/// Test case for code links that are adjacent to code text. | ||
/// | ||
/// This is not an example: `first``second` arst | ||
/// | ||
/// Neither is this: [`first`](x) arst | ||
/// | ||
/// Neither is this: [`first`](x) `second` arst | ||
/// | ||
/// Neither is this: [first](x)`second` arst | ||
/// | ||
/// This is: <code>[first](x)second</code> arst | ||
//~^ ERROR: adjacent | ||
/// | ||
/// So is this <code>first[second](x)</code> arst | ||
//~^ ERROR: adjacent | ||
/// | ||
/// So is this <code>[first](x)[second](x)</code> arst | ||
//~^ ERROR: adjacent | ||
/// | ||
/// So is this <code>[first](x)[second](x)[third](x)</code> arst | ||
//~^ ERROR: adjacent | ||
/// | ||
/// So is this <code>[first](x)second[third](x)</code> arst | ||
//~^ ERROR: adjacent | ||
pub struct WithTrailing; |
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,52 @@ | ||
#![warn(clippy::doc_link_code)] | ||
|
||
//! Test case for code links that are adjacent to code text. | ||
//! | ||
//! This is not an example: `first``second` | ||
//! | ||
//! Neither is this: [`first`](x) | ||
//! | ||
//! Neither is this: [`first`](x) `second` | ||
//! | ||
//! Neither is this: [first](x)`second` | ||
//! | ||
//! This is: [`first`](x)`second` | ||
//~^ ERROR: adjacent | ||
//! | ||
//! So is this `first`[`second`](x) | ||
//~^ ERROR: adjacent | ||
//! | ||
//! So is this [`first`](x)[`second`](x) | ||
//~^ ERROR: adjacent | ||
//! | ||
//! So is this [`first`](x)[`second`](x)[`third`](x) | ||
//~^ ERROR: adjacent | ||
//! | ||
//! So is this [`first`](x)`second`[`third`](x) | ||
//~^ ERROR: adjacent | ||
|
||
/// Test case for code links that are adjacent to code text. | ||
/// | ||
/// This is not an example: `first``second` arst | ||
/// | ||
/// Neither is this: [`first`](x) arst | ||
/// | ||
/// Neither is this: [`first`](x) `second` arst | ||
/// | ||
/// Neither is this: [first](x)`second` arst | ||
/// | ||
/// This is: [`first`](x)`second` arst | ||
//~^ ERROR: adjacent | ||
/// | ||
/// So is this `first`[`second`](x) arst | ||
//~^ ERROR: adjacent | ||
/// | ||
/// So is this [`first`](x)[`second`](x) arst | ||
//~^ ERROR: adjacent | ||
/// | ||
/// So is this [`first`](x)[`second`](x)[`third`](x) arst | ||
//~^ ERROR: adjacent | ||
/// | ||
/// So is this [`first`](x)`second`[`third`](x) arst | ||
//~^ ERROR: adjacent | ||
pub struct WithTrailing; |
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,124 @@ | ||
error: code link adjacent to code text | ||
--> tests/ui/doc/link_adjacent.rs:13:14 | ||
| | ||
LL | //! This is: [`first`](x)`second` | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: separate code snippets will be shown with a gap | ||
= note: `-D clippy::doc-link-code` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::doc_link_code)]` | ||
help: wrap the entire group in `<code>` tags | ||
| | ||
LL | //! This is: <code>[first](x)second</code> | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: code link adjacent to code text | ||
--> tests/ui/doc/link_adjacent.rs:16:16 | ||
| | ||
LL | //! So is this `first`[`second`](x) | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: separate code snippets will be shown with a gap | ||
help: wrap the entire group in `<code>` tags | ||
| | ||
LL | //! So is this <code>first[second](x)</code> | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: code link adjacent to code text | ||
--> tests/ui/doc/link_adjacent.rs:19:16 | ||
| | ||
LL | //! So is this [`first`](x)[`second`](x) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: separate code snippets will be shown with a gap | ||
help: wrap the entire group in `<code>` tags | ||
| | ||
LL | //! So is this <code>[first](x)[second](x)</code> | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: code link adjacent to code text | ||
--> tests/ui/doc/link_adjacent.rs:22:16 | ||
| | ||
LL | //! So is this [`first`](x)[`second`](x)[`third`](x) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: separate code snippets will be shown with a gap | ||
help: wrap the entire group in `<code>` tags | ||
| | ||
LL | //! So is this <code>[first](x)[second](x)[third](x)</code> | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: code link adjacent to code text | ||
--> tests/ui/doc/link_adjacent.rs:25:16 | ||
| | ||
LL | //! So is this [`first`](x)`second`[`third`](x) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: separate code snippets will be shown with a gap | ||
help: wrap the entire group in `<code>` tags | ||
| | ||
LL | //! So is this <code>[first](x)second[third](x)</code> | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: code link adjacent to code text | ||
--> tests/ui/doc/link_adjacent.rs:38:14 | ||
| | ||
LL | /// This is: [`first`](x)`second` arst | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: separate code snippets will be shown with a gap | ||
help: wrap the entire group in `<code>` tags | ||
| | ||
LL | /// This is: <code>[first](x)second</code> arst | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: code link adjacent to code text | ||
--> tests/ui/doc/link_adjacent.rs:41:16 | ||
| | ||
LL | /// So is this `first`[`second`](x) arst | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: separate code snippets will be shown with a gap | ||
help: wrap the entire group in `<code>` tags | ||
| | ||
LL | /// So is this <code>first[second](x)</code> arst | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: code link adjacent to code text | ||
--> tests/ui/doc/link_adjacent.rs:44:16 | ||
| | ||
LL | /// So is this [`first`](x)[`second`](x) arst | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: separate code snippets will be shown with a gap | ||
help: wrap the entire group in `<code>` tags | ||
| | ||
LL | /// So is this <code>[first](x)[second](x)</code> arst | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: code link adjacent to code text | ||
--> tests/ui/doc/link_adjacent.rs:47:16 | ||
| | ||
LL | /// So is this [`first`](x)[`second`](x)[`third`](x) arst | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: separate code snippets will be shown with a gap | ||
help: wrap the entire group in `<code>` tags | ||
| | ||
LL | /// So is this <code>[first](x)[second](x)[third](x)</code> arst | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: code link adjacent to code text | ||
--> tests/ui/doc/link_adjacent.rs:50:16 | ||
| | ||
LL | /// So is this [`first`](x)`second`[`third`](x) arst | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: separate code snippets will be shown with a gap | ||
help: wrap the entire group in `<code>` tags | ||
| | ||
LL | /// So is this <code>[first](x)second[third](x)</code> arst | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: aborting due to 10 previous errors | ||
|