diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-10-16 21:41:10 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-10-16 21:41:10 +0200 |
| commit | 11b2b08ba9bdf7d3759666a3b05711b0a6c20484 (patch) | |
| tree | 12f6ad35e3fe4a81ff20a2a30d345de7bb3ecf88 /src | |
| parent | ba4e8d7db311b8a43a446cc20c30e4680b94c5d3 (diff) | |
| download | rust-11b2b08ba9bdf7d3759666a3b05711b0a6c20484.tar.gz rust-11b2b08ba9bdf7d3759666a3b05711b0a6c20484.zip | |
Display rustdoc pulldown switch warnings everytime
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/render.rs | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 3c789cb3a15..d538428a7e9 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1826,37 +1826,32 @@ fn render_markdown(w: &mut fmt::Formatter, prefix: &str, scx: &SharedContext) -> fmt::Result { - // We only emit warnings if the user has opted-in to Pulldown rendering. - let output = if render_type == RenderType::Pulldown { - // Save the state of USED_ID_MAP so it only gets updated once even - // though we're rendering twice. - let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone()); - let hoedown_output = format!("{}", Markdown(md_text, RenderType::Hoedown)); - USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map); - let pulldown_output = format!("{}", Markdown(md_text, RenderType::Pulldown)); - let mut differences = html_diff::get_differences(&pulldown_output, &hoedown_output); - differences.retain(|s| { - match *s { - html_diff::Difference::NodeText { ref elem_text, - ref opposite_elem_text, - .. } - if elem_text.split_whitespace().eq(opposite_elem_text.split_whitespace()) => { - false - } - _ => true, + // Save the state of USED_ID_MAP so it only gets updated once even + // though we're rendering twice. + let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone()); + let hoedown_output = format!("{}", Markdown(md_text, RenderType::Hoedown)); + USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map); + let pulldown_output = format!("{}", Markdown(md_text, RenderType::Pulldown)); + let mut differences = html_diff::get_differences(&pulldown_output, &hoedown_output); + differences.retain(|s| { + match *s { + html_diff::Difference::NodeText { ref elem_text, + ref opposite_elem_text, + .. } + if elem_text.split_whitespace().eq(opposite_elem_text.split_whitespace()) => { + false } - }); - - if !differences.is_empty() { - scx.markdown_warnings.borrow_mut().push((span, md_text.to_owned(), differences)); + _ => true, } + }); - pulldown_output - } else { - format!("{}", Markdown(md_text, RenderType::Hoedown)) - }; + if !differences.is_empty() { + scx.markdown_warnings.borrow_mut().push((span, md_text.to_owned(), differences)); + } - write!(w, "<div class='docblock'>{}{}</div>", prefix, output) + write!(w, "<div class='docblock'>{}{}</div>", + prefix, + if render_type == RenderType::Pulldown { pulldown_output } else { hoedown_output }) } fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLink, |
