Skip to content

Commit c45d481

Browse files
committed
Rollup merge of rust-lang#33431 - GuillaumeGomez:issue-30416, r=steveklabnik
Update CSS for future rustdoc merge cc rust-lang#33382 r? @steveklabnik cc @Manishearth cc @birkenfeld
2 parents 57fa783 + cdca084 commit c45d481

File tree

3 files changed

+48
-7
lines changed

3 files changed

+48
-7
lines changed

src/librustdoc/html/render.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -2144,7 +2144,7 @@ fn render_stability_since_raw<'a>(w: &mut fmt::Formatter,
21442144
containing_ver: Option<&'a str>) -> fmt::Result {
21452145
if let Some(v) = ver {
21462146
if containing_ver != ver && v.len() > 0 {
2147-
write!(w, "<span class=\"since\">{}</span>",
2147+
write!(w, "<div class=\"since\">{}</div>",
21482148
v)?
21492149
}
21502150
}
@@ -2545,13 +2545,16 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
25452545
render_header: bool, outer_version: Option<&str>) -> fmt::Result {
25462546
if render_header {
25472547
write!(w, "<h3 class='impl'><span class='in-band'><code>{}</code>", i.inner_impl())?;
2548-
let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]);
2549-
render_stability_since_raw(w, since, outer_version)?;
25502548
write!(w, "</span><span class='out-of-band'>")?;
2549+
let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]);
25512550
if let Some(l) = (Item { item: &i.impl_item, cx: cx }).href() {
2551+
write!(w, "<div class='ghost'></div>")?;
2552+
render_stability_since_raw(w, since, outer_version)?;
25522553
write!(w, "<a id='src-{}' class='srclink' \
25532554
href='{}' title='{}'>[src]</a>",
25542555
i.impl_item.def_id.index.as_usize(), l, "goto source code")?;
2556+
} else {
2557+
render_stability_since_raw(w, since, outer_version)?;
25552558
}
25562559
write!(w, "</span>")?;
25572560
write!(w, "</h3>\n")?;

src/librustdoc/html/static/rustdoc.css

+39-4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):no
9797
h1.fqn {
9898
border-bottom: 1px dashed;
9999
margin-top: 0;
100+
position: relative;
100101
}
101102
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
102103
border-bottom: 1px solid;
@@ -105,6 +106,7 @@ h3.impl, h3.method, h4.method, h3.type, h4.type {
105106
font-weight: 600;
106107
margin-top: 10px;
107108
margin-bottom: 10px;
109+
position: relative;
108110
}
109111
h3.impl, h3.method, h3.type {
110112
margin-top: 15px;
@@ -265,20 +267,39 @@ nav.sub {
265267

266268
.content .out-of-band {
267269
font-size: 23px;
268-
width: 40%;
269270
margin: 0px;
270271
padding: 0px;
271272
text-align: right;
272273
display: inline-block;
274+
font-weight: normal;
275+
position: absolute;
276+
right: 0;
277+
}
278+
279+
h3.impl > .out-of-band {
280+
font-size: 21px;
281+
}
282+
283+
h4 > code, h3 > code {
284+
position: inherit;
285+
}
286+
287+
.in-band, code {
288+
z-index: 5;
273289
}
274290

275291
.content .in-band {
276-
width: 60%;
277292
margin: 0px;
278293
padding: 0px;
279294
display: inline-block;
280295
}
281296

297+
#main { position: relative; }
298+
#main > .since {
299+
top: inherit;
300+
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
301+
}
302+
282303
.content table {
283304
border-spacing: 0 5px;
284305
border-collapse: separate;
@@ -498,11 +519,13 @@ em.stab p {
498519
opacity: 0.65;
499520
}
500521

501-
span.since {
502-
float: right;
522+
.since {
503523
font-weight: normal;
504524
font-size: initial;
505525
color: grey;
526+
position: absolute;
527+
right: 0;
528+
top: 0;
506529
}
507530

508531
.variants_table {
@@ -597,7 +620,19 @@ a.test-arrow {
597620
color: #999;
598621
}
599622

623+
.ghost {
624+
display: none;
625+
}
626+
627+
.ghost + .since {
628+
position: initial;
629+
display: table-cell;
630+
}
600631

632+
.since + .srclink {
633+
display: table-cell;
634+
padding-left: 10px;
635+
}
601636

602637
/* Media Queries */
603638

src/librustdoc/html/static/styles/main.css

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ h1.fqn {
2626
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
2727
border-bottom-color: #DDDDDD;
2828
}
29+
.in-band, code {
30+
background-color: white;
31+
}
2932

3033
.docblock code {
3134
background-color: #F5F5F5;

0 commit comments

Comments
 (0)