Skip to content

Commit

Permalink
Improve rustdoc css of "source" and "since" elements
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed May 5, 2016
1 parent 083c395 commit cdca084
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,7 @@ fn render_stability_since_raw<'a>(w: &mut fmt::Formatter,
containing_ver: Option<&'a str>) -> fmt::Result {
if let Some(v) = ver {
if containing_ver != ver && v.len() > 0 {
write!(w, "<span class=\"since\">{}</span>",
write!(w, "<div class=\"since\">{}</div>",
v)?
}
}
Expand Down Expand Up @@ -2545,13 +2545,16 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
render_header: bool, outer_version: Option<&str>) -> fmt::Result {
if render_header {
write!(w, "<h3 class='impl'><span class='in-band'><code>{}</code>", i.inner_impl())?;
let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]);
render_stability_since_raw(w, since, outer_version)?;
write!(w, "</span><span class='out-of-band'>")?;
let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]);
if let Some(l) = (Item { item: &i.impl_item, cx: cx }).href() {
write!(w, "<div class='ghost'></div>")?;
render_stability_since_raw(w, since, outer_version)?;
write!(w, "<a id='src-{}' class='srclink' \
href='{}' title='{}'>[src]</a>",
i.impl_item.def_id.index.as_usize(), l, "goto source code")?;
} else {
render_stability_since_raw(w, since, outer_version)?;
}
write!(w, "</span>")?;
write!(w, "</h3>\n")?;
Expand Down
38 changes: 34 additions & 4 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):no
h1.fqn {
border-bottom: 1px dashed;
margin-top: 0;
position: relative;
}
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
border-bottom: 1px solid;
Expand All @@ -105,6 +106,7 @@ h3.impl, h3.method, h4.method, h3.type, h4.type {
font-weight: 600;
margin-top: 10px;
margin-bottom: 10px;
position: relative;
}
h3.impl, h3.method, h3.type {
margin-top: 15px;
Expand Down Expand Up @@ -265,25 +267,39 @@ nav.sub {

.content .out-of-band {
font-size: 23px;
width: 40%;
margin: 0px;
padding: 0px;
text-align: right;
display: inline-block;
font-weight: normal;
position: absolute;
right: 0;
}

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

h4 > code, h3 > code {
position: inherit;
}

.in-band, code {
z-index: 5;
}

.content .in-band {
width: 60%;
margin: 0px;
padding: 0px;
display: inline-block;
}

#main { position: relative; }
#main > .since {
top: inherit;
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.content table {
border-spacing: 0 5px;
border-collapse: separate;
Expand Down Expand Up @@ -503,11 +519,13 @@ em.stab p {
opacity: 0.65;
}

span.since {
float: right;
.since {
font-weight: normal;
font-size: initial;
color: grey;
position: absolute;
right: 0;
top: 0;
}

.variants_table {
Expand Down Expand Up @@ -602,7 +620,19 @@ a.test-arrow {
color: #999;
}

.ghost {
display: none;
}

.ghost + .since {
position: initial;
display: table-cell;
}

.since + .srclink {
display: table-cell;
padding-left: 10px;
}

/* Media Queries */

Expand Down
3 changes: 3 additions & 0 deletions src/librustdoc/html/static/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ h1.fqn {
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
border-bottom-color: #DDDDDD;
}
.in-band, code {
background-color: white;
}

.docblock code {
background-color: #F5F5F5;
Expand Down

0 comments on commit cdca084

Please sign in to comment.