From e395fd12ddbad32d48db1e40cf57d25b035712a9 Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Mon, 12 Dec 2016 17:41:39 +0000 Subject: [PATCH] rustdoc: Fix invalid HTML in stability notices `em` tags cannot contain `p` tags so just use a `div` instead. --- src/librustdoc/html/render.rs | 15 ++++++++++----- src/librustdoc/html/static/rustdoc.css | 8 ++++---- src/librustdoc/html/static/styles/main.css | 8 ++------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index e721b66779fff..6120eb8b78e90 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1655,8 +1655,13 @@ fn document_full(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result { } fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result { - for stability in short_stability(item, cx, true) { - write!(w, "
{}
", stability)?; + let stabilities = short_stability(item, cx, true); + if !stabilities.is_empty() { + write!(w, "
")?; + for stability in stabilities { + write!(w, "{}", stability)?; + } + write!(w, "
")?; } Ok(()) } @@ -1855,7 +1860,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec{}", text)) + stability.push(format!("
{}
", text)) }; if stab.level == stability::Unstable { @@ -1880,7 +1885,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec{}", text)) + stability.push(format!("
{}
", text)) }; } else if let Some(depr) = item.deprecation.as_ref() { let note = if show_reason && !depr.note.is_empty() { @@ -1895,7 +1900,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec{}", text)) + stability.push(format!("
{}
", text)) } stability diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 7ee184c089ca4..a1370cfc95b50 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -523,20 +523,20 @@ body.blur > :not(#help) { padding: 20px; } -em.stab { - display: inline-block; +.stab { + display: table; border-width: 1px; border-style: solid; padding: 3px; margin-bottom: 5px; font-size: 90%; - font-style: normal; } -em.stab p { +.stab p { display: inline; } .module-item .stab { + display: inline; border-width: 0; padding: 0; margin: 0; diff --git a/src/librustdoc/html/static/styles/main.css b/src/librustdoc/html/static/styles/main.css index 6a9a24f69960a..862d6d12b9ad9 100644 --- a/src/librustdoc/html/static/styles/main.css +++ b/src/librustdoc/html/static/styles/main.css @@ -30,10 +30,6 @@ h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.t background-color: white; } -div.stability > em > code { - background-color: initial; -} - .docblock code, .docblock-short code { background-color: #F5F5F5; } @@ -129,5 +125,5 @@ a.test-arrow { background-color: white; } -em.stab.unstable { background: #FFF5D6; border-color: #FFC600; } -em.stab.deprecated { background: #F3DFFF; border-color: #7F0087; } +.stab.unstable { background: #FFF5D6; border-color: #FFC600; } +.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }