about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-08-07 16:55:41 +0800
committerGitHub <noreply@github.com>2018-08-07 16:55:41 +0800
commit25e32903ef5bc8b9e4ea22f6d7c3017ceabd707c (patch)
tree9f009acb2f862391fad8f145f6f921c84bdc7146 /src
parentb1ca710c5d81df670653f571cb206d80ac7751b8 (diff)
parent3f92ff34b5a2fe8dd1a32aa27d437519e63782f0 (diff)
Rollup merge of #53060 - iliekturtles:rustdoc-style, r=GuillaumeGomez
Change rustdoc style so fully qualified name does not overlap src link

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.

Before:
![image](https://user-images.githubusercontent.com/5081378/43676506-cf548758-97c0-11e8-80a0-a812d8ea0eef.png)

After:
![image](https://user-images.githubusercontent.com/5081378/43676509-e78810a6-97c0-11e8-8cd4-b90bd5858a5f.png)
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/html/render.rs60
-rw-r--r--src/librustdoc/html/static/rustdoc.css7
2 files changed, 32 insertions, 35 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index c2978a62489..470aa2c10e9 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1613,7 +1613,6 @@ impl fmt::Display for AllTypes {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f,
 "<h1 class='fqn'>\
-     <span class='in-band'>List of all items</span>\
      <span class='out-of-band'>\
          <span id='render-detail'>\
              <a id=\"toggle-all-docs\" href=\"javascript:void(0)\" title=\"collapse all docs\">\
@@ -1621,6 +1620,7 @@ impl fmt::Display for AllTypes {
              </a>\
          </span>
      </span>
+     <span class='in-band'>List of all items</span>\
 </h1>")?;
         print_entries(f, &self.structs, "Structs", "structs")?;
         print_entries(f, &self.enums, "Enums", "enums")?;
@@ -2068,7 +2068,34 @@ impl<'a> fmt::Display for Item<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         debug_assert!(!self.item.is_stripped());
         // Write the breadcrumb trail header for the top
-        write!(fmt, "<h1 class='fqn'><span class='in-band'>")?;
+        write!(fmt, "<h1 class='fqn'><span class='out-of-band'>")?;
+        if let Some(version) = self.item.stable_since() {
+            write!(fmt, "<span class='since' title='Stable since Rust version {0}'>{0}</span>",
+                   version)?;
+        }
+        write!(fmt,
+               "<span id='render-detail'>\
+                   <a id=\"toggle-all-docs\" href=\"javascript:void(0)\" \
+                      title=\"collapse all docs\">\
+                       [<span class='inner'>&#x2212;</span>]\
+                   </a>\
+               </span>")?;
+
+        // Write `src` tag
+        //
+        // When this item is part of a `pub use` in a downstream crate, the
+        // [src] link in the downstream documentation will actually come back to
+        // this page, and this link will be auto-clicked. The `id` attribute is
+        // used to find the link to auto-click.
+        if self.cx.shared.include_sources && !self.item.is_primitive() {
+            if let Some(l) = self.src_href() {
+                write!(fmt, "<a class='srclink' href='{}' title='{}'>[src]</a>",
+                       l, "goto source code")?;
+            }
+        }
+
+        write!(fmt, "</span>")?; // out-of-band
+        write!(fmt, "<span class='in-band'>")?;
         match self.item.inner {
             clean::ModuleItem(ref m) => if m.is_crate {
                     write!(fmt, "Crate ")?;
@@ -2105,34 +2132,7 @@ impl<'a> fmt::Display for Item<'a> {
         write!(fmt, "<a class=\"{}\" href=''>{}</a>",
                self.item.type_(), self.item.name.as_ref().unwrap())?;
 
-        write!(fmt, "</span>")?; // in-band
-        write!(fmt, "<span class='out-of-band'>")?;
-        if let Some(version) = self.item.stable_since() {
-            write!(fmt, "<span class='since' title='Stable since Rust version {0}'>{0}</span>",
-                   version)?;
-        }
-        write!(fmt,
-               "<span id='render-detail'>\
-                   <a id=\"toggle-all-docs\" href=\"javascript:void(0)\" \
-                      title=\"collapse all docs\">\
-                       [<span class='inner'>&#x2212;</span>]\
-                   </a>\
-               </span>")?;
-
-        // Write `src` tag
-        //
-        // When this item is part of a `pub use` in a downstream crate, the
-        // [src] link in the downstream documentation will actually come back to
-        // this page, and this link will be auto-clicked. The `id` attribute is
-        // used to find the link to auto-click.
-        if self.cx.shared.include_sources && !self.item.is_primitive() {
-            if let Some(l) = self.src_href() {
-                write!(fmt, "<a class='srclink' href='{}' title='{}'>[src]</a>",
-                       l, "goto source code")?;
-            }
-        }
-
-        write!(fmt, "</span></h1>")?; // out-of-band
+        write!(fmt, "</span></h1>")?; // in-band
 
         match self.item.inner {
             clean::ModuleItem(ref m) =>
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index 496029e33fc..57a111daa89 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -97,7 +97,7 @@ h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.important), h4
 h1.fqn {
 	border-bottom: 1px dashed;
 	margin-top: 0;
-	position: relative;
+	overflow: auto;
 }
 h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) {
 	border-bottom: 1px solid;
@@ -352,14 +352,11 @@ nav.sub {
 }
 
 .content .out-of-band {
+	float: right;
 	font-size: 23px;
 	margin: 0px;
 	padding: 0px;
-	text-align: right;
-	display: inline-block;
 	font-weight: normal;
-	position: absolute;
-	right: 0;
 }
 
 h3.impl > .out-of-band {