Don’t warn in titles in DOC_MARKDOWN

This commit is contained in:
mcarton 2016-05-05 21:42:59 +02:00
parent cc2774df60
commit 3ce60e9731
2 changed files with 18 additions and 0 deletions

View File

@ -126,6 +126,7 @@ pub fn check_doc(cx: &EarlyContext, valid_idents: &[String], doc: &str, span: Sp
span
}
let mut new_line = true;
let len = doc.len();
let mut chars = doc.char_indices().peekable();
let mut current_word_begin = 0;
@ -133,6 +134,9 @@ pub fn check_doc(cx: &EarlyContext, valid_idents: &[String], doc: &str, span: Sp
match chars.next() {
Some((_, c)) => {
match c {
'#' if new_line => { // dont warn on titles
current_word_begin = jump_to!(chars, '\n', len);
}
'`' => {
current_word_begin = jump_to!(chars, '`', len);
}
@ -182,6 +186,8 @@ pub fn check_doc(cx: &EarlyContext, valid_idents: &[String], doc: &str, span: Sp
current_word_begin = jump_to!(@next_char, chars, len);
}
}
new_line = c == '\n' || (new_line && c.is_whitespace());
}
None => break,
}

View File

@ -108,6 +108,18 @@ fn main() {
test_units();
}
/// ## CamelCaseThing
/// Talks about `CamelCaseThing`. Titles should be ignored, see issue #897.
///
/// # CamelCaseThing
///
/// Not a title #897 CamelCaseThing
//~^ ERROR: you should put `CamelCaseThing` between ticks
/// be_sure_we_got_to_the_end_of_it
//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
fn issue897() {
}
/// I am confused by brackets? (`x_y`)
/// I am confused by brackets? (foo `x_y`)
/// I am confused by brackets? (`x_y` foo)