Skip to content

Commit cdca084

Browse files
Improve rustdoc css of "source" and "since" elements
1 parent 083c395 commit cdca084

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-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

+34-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,25 +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;
273274
font-weight: normal;
275+
position: absolute;
276+
right: 0;
274277
}
275278

276279
h3.impl > .out-of-band {
277280
font-size: 21px;
278281
}
279282

283+
h4 > code, h3 > code {
284+
position: inherit;
285+
}
286+
287+
.in-band, code {
288+
z-index: 5;
289+
}
290+
280291
.content .in-band {
281-
width: 60%;
282292
margin: 0px;
283293
padding: 0px;
284294
display: inline-block;
285295
}
286296

297+
#main { position: relative; }
298+
#main > .since {
299+
top: inherit;
300+
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
301+
}
302+
287303
.content table {
288304
border-spacing: 0 5px;
289305
border-collapse: separate;
@@ -503,11 +519,13 @@ em.stab p {
503519
opacity: 0.65;
504520
}
505521

506-
span.since {
507-
float: right;
522+
.since {
508523
font-weight: normal;
509524
font-size: initial;
510525
color: grey;
526+
position: absolute;
527+
right: 0;
528+
top: 0;
511529
}
512530

513531
.variants_table {
@@ -602,7 +620,19 @@ a.test-arrow {
602620
color: #999;
603621
}
604622

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

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

607637
/* Media Queries */
608638

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)