Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: Fix invalid HTML in stability notices #38329

Merged
merged 1 commit into from
Dec 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<div class='stability'>{}</div>", stability)?;
let stabilities = short_stability(item, cx, true);
if !stabilities.is_empty() {
write!(w, "<div class='stability'>")?;
for stability in stabilities {
write!(w, "{}", stability)?;
}
write!(w, "</div>")?;
}
Ok(())
}
Expand Down Expand Up @@ -1855,7 +1860,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
String::new()
};
let text = format!("Deprecated{}{}", since, Markdown(&deprecated_reason));
stability.push(format!("<em class='stab deprecated'>{}</em>", text))
stability.push(format!("<div class='stab deprecated'>{}</div>", text))
};

if stab.level == stability::Unstable {
Expand All @@ -1880,7 +1885,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
String::new()
};
let text = format!("Unstable{}{}", unstable_extra, Markdown(&unstable_reason));
stability.push(format!("<em class='stab unstable'>{}</em>", text))
stability.push(format!("<div class='stab unstable'>{}</div>", text))
};
} else if let Some(depr) = item.deprecation.as_ref() {
let note = if show_reason && !depr.note.is_empty() {
Expand All @@ -1895,7 +1900,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
};

let text = format!("Deprecated{}{}", since, Markdown(&note));
stability.push(format!("<em class='stab deprecated'>{}</em>", text))
stability.push(format!("<div class='stab deprecated'>{}</div>", text))
}

stability
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions src/librustdoc/html/static/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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; }