Skip to content

Commit 3f92ff3

Browse files
committed
Change rustdoc style so fully qualified names do not overlap src links
A type's fully qualified name will now wrap once it gets to the `[-][src]` link aligned against the right edge of the content area. Previously the two would overlap and the name would only wrap when hitting the edge of the content area. The `[-][src]` link will main at the top of the header.
1 parent 9f9ac89 commit 3f92ff3

File tree

2 files changed

+32
-35
lines changed

2 files changed

+32
-35
lines changed

src/librustdoc/html/render.rs

+30-30
Original file line numberDiff line numberDiff line change
@@ -1613,14 +1613,14 @@ impl fmt::Display for AllTypes {
16131613
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
16141614
write!(f,
16151615
"<h1 class='fqn'>\
1616-
<span class='in-band'>List of all items</span>\
16171616
<span class='out-of-band'>\
16181617
<span id='render-detail'>\
16191618
<a id=\"toggle-all-docs\" href=\"javascript:void(0)\" title=\"collapse all docs\">\
16201619
[<span class='inner'>&#x2212;</span>]\
16211620
</a>\
16221621
</span>
16231622
</span>
1623+
<span class='in-band'>List of all items</span>\
16241624
</h1>")?;
16251625
print_entries(f, &self.structs, "Structs", "structs")?;
16261626
print_entries(f, &self.enums, "Enums", "enums")?;
@@ -2068,7 +2068,34 @@ impl<'a> fmt::Display for Item<'a> {
20682068
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
20692069
debug_assert!(!self.item.is_stripped());
20702070
// Write the breadcrumb trail header for the top
2071-
write!(fmt, "<h1 class='fqn'><span class='in-band'>")?;
2071+
write!(fmt, "<h1 class='fqn'><span class='out-of-band'>")?;
2072+
if let Some(version) = self.item.stable_since() {
2073+
write!(fmt, "<span class='since' title='Stable since Rust version {0}'>{0}</span>",
2074+
version)?;
2075+
}
2076+
write!(fmt,
2077+
"<span id='render-detail'>\
2078+
<a id=\"toggle-all-docs\" href=\"javascript:void(0)\" \
2079+
title=\"collapse all docs\">\
2080+
[<span class='inner'>&#x2212;</span>]\
2081+
</a>\
2082+
</span>")?;
2083+
2084+
// Write `src` tag
2085+
//
2086+
// When this item is part of a `pub use` in a downstream crate, the
2087+
// [src] link in the downstream documentation will actually come back to
2088+
// this page, and this link will be auto-clicked. The `id` attribute is
2089+
// used to find the link to auto-click.
2090+
if self.cx.shared.include_sources && !self.item.is_primitive() {
2091+
if let Some(l) = self.src_href() {
2092+
write!(fmt, "<a class='srclink' href='{}' title='{}'>[src]</a>",
2093+
l, "goto source code")?;
2094+
}
2095+
}
2096+
2097+
write!(fmt, "</span>")?; // out-of-band
2098+
write!(fmt, "<span class='in-band'>")?;
20722099
match self.item.inner {
20732100
clean::ModuleItem(ref m) => if m.is_crate {
20742101
write!(fmt, "Crate ")?;
@@ -2105,34 +2132,7 @@ impl<'a> fmt::Display for Item<'a> {
21052132
write!(fmt, "<a class=\"{}\" href=''>{}</a>",
21062133
self.item.type_(), self.item.name.as_ref().unwrap())?;
21072134

2108-
write!(fmt, "</span>")?; // in-band
2109-
write!(fmt, "<span class='out-of-band'>")?;
2110-
if let Some(version) = self.item.stable_since() {
2111-
write!(fmt, "<span class='since' title='Stable since Rust version {0}'>{0}</span>",
2112-
version)?;
2113-
}
2114-
write!(fmt,
2115-
"<span id='render-detail'>\
2116-
<a id=\"toggle-all-docs\" href=\"javascript:void(0)\" \
2117-
title=\"collapse all docs\">\
2118-
[<span class='inner'>&#x2212;</span>]\
2119-
</a>\
2120-
</span>")?;
2121-
2122-
// Write `src` tag
2123-
//
2124-
// When this item is part of a `pub use` in a downstream crate, the
2125-
// [src] link in the downstream documentation will actually come back to
2126-
// this page, and this link will be auto-clicked. The `id` attribute is
2127-
// used to find the link to auto-click.
2128-
if self.cx.shared.include_sources && !self.item.is_primitive() {
2129-
if let Some(l) = self.src_href() {
2130-
write!(fmt, "<a class='srclink' href='{}' title='{}'>[src]</a>",
2131-
l, "goto source code")?;
2132-
}
2133-
}
2134-
2135-
write!(fmt, "</span></h1>")?; // out-of-band
2135+
write!(fmt, "</span></h1>")?; // in-band
21362136

21372137
match self.item.inner {
21382138
clean::ModuleItem(ref m) =>

src/librustdoc/html/static/rustdoc.css

+2-5
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.important), h4
9797
h1.fqn {
9898
border-bottom: 1px dashed;
9999
margin-top: 0;
100-
position: relative;
100+
overflow: auto;
101101
}
102102
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) {
103103
border-bottom: 1px solid;
@@ -352,14 +352,11 @@ nav.sub {
352352
}
353353

354354
.content .out-of-band {
355+
float: right;
355356
font-size: 23px;
356357
margin: 0px;
357358
padding: 0px;
358-
text-align: right;
359-
display: inline-block;
360359
font-weight: normal;
361-
position: absolute;
362-
right: 0;
363360
}
364361

365362
h3.impl > .out-of-band {

0 commit comments

Comments
 (0)