Don't lint autolinks in doc_markdown

This commit is contained in:
mcarton 2017-06-18 23:00:14 +02:00
parent 06280e838b
commit e40c270d4f
3 changed files with 23 additions and 2 deletions

View file

@ -195,16 +195,26 @@ fn check_doc<'a, Events: Iterator<Item = (usize, pulldown_cmark::Event<'a>)>>(
use pulldown_cmark::Tag::*; use pulldown_cmark::Tag::*;
let mut in_code = false; let mut in_code = false;
let mut in_link = None;
for (offset, event) in docs { for (offset, event) in docs {
match event { match event {
Start(CodeBlock(_)) | Start(Code) => in_code = true, Start(CodeBlock(_)) | Start(Code) => in_code = true,
End(CodeBlock(_)) | End(Code) => in_code = false, End(CodeBlock(_)) | End(Code) => in_code = false,
Start(_tag) | End(_tag) => (), // We don't care about other tags Start(Link(link, _)) => in_link = Some(link),
End(Link(_, _)) => in_link = None,
Start(_tag) | End(_tag) => (), // We don't care about other tags
Html(_html) | InlineHtml(_html) => (), // HTML is weird, just ignore it Html(_html) | InlineHtml(_html) => (), // HTML is weird, just ignore it
SoftBreak => (), SoftBreak => (),
HardBreak => (), HardBreak => (),
FootnoteReference(text) | Text(text) => { FootnoteReference(text) | Text(text) => {
if Some(&text) == in_link.as_ref() {
// Probably a link of the form `<http://example.com>`
// Which are represented as a link to "http://example.com" with
// text "http://example.com" by pulldown-cmark
continue;
}
if !in_code { if !in_code {
let index = match spans.binary_search_by(|c| c.0.cmp(&offset)) { let index = match spans.binary_search_by(|c| c.0.cmp(&offset)) {
Ok(o) => o, Ok(o) => o,

View file

@ -159,3 +159,8 @@ fn issue_1469() {}
*This would also be an error under a strict common mark interpretation *This would also be an error under a strict common mark interpretation
*/ */
fn issue_1920() {} fn issue_1920() {}
/// Ok: <http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels>
///
/// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
fn issue_1832() {}

View file

@ -156,5 +156,11 @@ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the doc
138 | /// be_sure_we_got_to_the_end_of_it 138 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 26 previous errors error: you should put `http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels` between ticks in the documentation
--> $DIR/doc.rs:165:13
|
165 | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 27 previous errors