summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/render/context.rs4
-rw-r--r--src/librustdoc/html/render/mod.rs87
-rw-r--r--src/librustdoc/html/render/print_item.rs5
-rw-r--r--src/librustdoc/html/static/main.js4
-rw-r--r--src/librustdoc/html/static/rustdoc.css80
-rw-r--r--src/librustdoc/html/static/themes/ayu.css3
-rw-r--r--src/librustdoc/html/static/themes/dark.css3
-rw-r--r--src/librustdoc/html/static/themes/light.css3
8 files changed, 117 insertions, 72 deletions
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 1898f5feed2..84c5b5dd604 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -527,7 +527,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
         };
         let sidebar = if let Some(ref version) = self.cache.crate_version {
             format!(
-                "<p class=\"location\">Crate {}</p>\
+                "<h2 class=\"location\">Crate {}</h2>\
                      <div class=\"block version\">\
                          <p>Version {}</p>\
                      </div>\
@@ -554,7 +554,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
         page.root_path = "./";
 
         let mut style_files = self.shared.style_files.clone();
-        let sidebar = "<p class=\"location\">Settings</p><div class=\"sidebar-elems\"></div>";
+        let sidebar = "<h2 class=\"location\">Settings</h2><div class=\"sidebar-elems\"></div>";
         style_files.push(StylePath { path: PathBuf::from("settings.css"), disabled: false });
         let v = layout::render(
             &self.shared.layout,
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 53112c87fdc..0b14c327e47 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -1214,7 +1214,7 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
                     if out.is_empty() {
                         write!(
                             &mut out,
-                            "<h3 class=\"notable\">Notable traits for {}</h3>\
+                            "<div class=\"notable\">Notable traits for {}</div>\
                              <code class=\"content\">",
                             impl_.for_.print(cx)
                         );
@@ -1370,7 +1370,7 @@ fn render_impl(
                         "<div id=\"{}\" class=\"{}{} has-srclink\">",
                         id, item_type, in_trait_class,
                     );
-                    w.write_str("<code>");
+                    w.write_str("<h4 class=\"code-header\">");
                     render_assoc_item(
                         w,
                         item,
@@ -1378,7 +1378,7 @@ fn render_impl(
                         ItemType::Impl,
                         cx,
                     );
-                    w.write_str("</code>");
+                    w.write_str("</h4>");
                     render_stability_since_raw(
                         w,
                         item.stable_since(tcx).as_deref(),
@@ -1396,9 +1396,10 @@ fn render_impl(
                 let id = cx.derive_id(source_id.clone());
                 write!(
                     w,
-                    "<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
+                    "<div id=\"{}\" class=\"{}{} has-srclink\">",
                     id, item_type, in_trait_class
                 );
+                w.write_str("<h4 class=\"code-header\">");
                 assoc_type(
                     w,
                     item,
@@ -1408,7 +1409,7 @@ fn render_impl(
                     "",
                     cx,
                 );
-                w.write_str("</code>");
+                w.write_str("</h4>");
                 write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
                 w.write_str("</div>");
             }
@@ -1417,9 +1418,10 @@ fn render_impl(
                 let id = cx.derive_id(source_id.clone());
                 write!(
                     w,
-                    "<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
+                    "<div id=\"{}\" class=\"{}{} has-srclink\">",
                     id, item_type, in_trait_class
                 );
+                w.write_str("<h4 class=\"code-header\">");
                 assoc_const(
                     w,
                     item,
@@ -1429,7 +1431,7 @@ fn render_impl(
                     "",
                     cx,
                 );
-                w.write_str("</code>");
+                w.write_str("</h4>");
                 render_stability_since_raw(
                     w,
                     item.stable_since(tcx).as_deref(),
@@ -1444,7 +1446,8 @@ fn render_impl(
             clean::AssocTypeItem(ref bounds, ref default) => {
                 let source_id = format!("{}.{}", item_type, name);
                 let id = cx.derive_id(source_id.clone());
-                write!(w, "<div id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class,);
+                write!(w, "<div id=\"{}\" class=\"{}{}\">", id, item_type, in_trait_class,);
+                w.write_str("<h4 class=\"code-header\">");
                 assoc_type(
                     w,
                     item,
@@ -1454,7 +1457,7 @@ fn render_impl(
                     "",
                     cx,
                 );
-                w.write_str("</code>");
+                w.write_str("</h4>");
                 write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
                 w.write_str("</div>");
             }
@@ -1638,12 +1641,8 @@ fn render_impl_summary(
         format!(" data-aliases=\"{}\"", aliases.join(","))
     };
     if let Some(use_absolute) = use_absolute {
-        write!(
-            w,
-            "<div id=\"{}\" class=\"impl has-srclink\"{}>\
-                     <code class=\"in-band\">",
-            id, aliases
-        );
+        write!(w, "<div id=\"{}\" class=\"impl has-srclink\"{}>", id, aliases);
+        write!(w, "<h3 class=\"code-header in-band\">");
         write!(w, "{}", i.inner_impl().print(use_absolute, cx));
         if show_def_docs {
             for it in &i.inner_impl().items {
@@ -1654,12 +1653,12 @@ fn render_impl_summary(
                 }
             }
         }
-        w.write_str("</code>");
+        w.write_str("</h3>");
     } else {
         write!(
             w,
             "<div id=\"{}\" class=\"impl has-srclink\"{}>\
-                     <code class=\"in-band\">{}</code>",
+                     <h3 class=\"code-header in-band\">{}</h3>",
             id,
             aliases,
             i.inner_impl().print(false, cx)
@@ -1690,7 +1689,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
     {
         write!(
             buffer,
-            "<p class=\"location\">{}{}</p>",
+            "<h2 class=\"location\">{}{}</h2>",
             match *it.kind {
                 clean::StructItem(..) => "Struct ",
                 clean::TraitItem(..) => "Trait ",
@@ -1753,7 +1752,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
     // to navigate the documentation (though slightly inefficiently).
 
     if !it.is_mod() {
-        buffer.write_str("<p class=\"location\">Other items in<br>");
+        buffer.write_str("<h2 class=\"location\">Other items in<br>");
         for (i, name) in cx.current.iter().take(parentlen).enumerate() {
             if i > 0 {
                 buffer.write_str("::<wbr>");
@@ -1765,7 +1764,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
                 *name
             );
         }
-        buffer.write_str("</p>");
+        buffer.write_str("</h2>");
     }
 
     // Sidebar refers to the enclosing module, not this module.
@@ -1876,7 +1875,7 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
                 ret.sort();
 
                 out.push_str(
-                    "<a class=\"sidebar-title\" href=\"#implementations\">Methods</a>\
+                    "<h3 class=\"sidebar-title\"><a href=\"#implementations\">Methods</a></h3>\
                      <div class=\"sidebar-links\">",
                 );
                 for line in ret {
@@ -1941,24 +1940,24 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
 
             if !concrete_format.is_empty() {
                 out.push_str(
-                    "<a class=\"sidebar-title\" href=\"#trait-implementations\">\
-                        Trait Implementations</a>",
+                    "<h3 class=\"sidebar-title\"><a href=\"#trait-implementations\">\
+                        Trait Implementations</a></h3>",
                 );
                 write_sidebar_links(out, concrete_format);
             }
 
             if !synthetic_format.is_empty() {
                 out.push_str(
-                    "<a class=\"sidebar-title\" href=\"#synthetic-implementations\">\
-                        Auto Trait Implementations</a>",
+                    "<h3 class=\"sidebar-title\"><a href=\"#synthetic-implementations\">\
+                        Auto Trait Implementations</a></h3>",
                 );
                 write_sidebar_links(out, synthetic_format);
             }
 
             if !blanket_format.is_empty() {
                 out.push_str(
-                    "<a class=\"sidebar-title\" href=\"#blanket-implementations\">\
-                        Blanket Implementations</a>",
+                    "<h3 class=\"sidebar-title\"><a href=\"#blanket-implementations\">\
+                        Blanket Implementations</a></h3>",
                 );
                 write_sidebar_links(out, blanket_format);
             }
@@ -2010,7 +2009,7 @@ fn sidebar_deref_methods(cx: &Context<'_>, out: &mut Buffer, impl_: &Impl, v: &V
             if !ret.is_empty() {
                 write!(
                     out,
-                    "<a class=\"sidebar-title\" href=\"#deref-methods\">Methods from {}&lt;Target={}&gt;</a>",
+                    "<h3 class=\"sidebar-title\"><a href=\"#deref-methods\">Methods from {}&lt;Target={}&gt;</a></h3>",
                     Escape(&format!("{:#}", impl_.inner_impl().trait_.as_ref().unwrap().print(cx))),
                     Escape(&format!("{:#}", real_target.print(cx))),
                 );
@@ -2046,7 +2045,7 @@ fn sidebar_struct(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, s: &clea
     if !fields.is_empty() {
         if let CtorKind::Fictive = s.struct_type {
             sidebar.push_str(
-                "<a class=\"sidebar-title\" href=\"#fields\">Fields</a>\
+                "<h3 class=\"sidebar-title\"><a href=\"#fields\">Fields</a></h3>\
                 <div class=\"sidebar-links\">",
             );
 
@@ -2123,8 +2122,8 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean
     print_sidebar_section(
         buf,
         &t.items,
-        "<a class=\"sidebar-title\" href=\"#associated-types\">\
-            Associated Types</a><div class=\"sidebar-links\">",
+        "<h3 class=\"sidebar-title\"><a href=\"#associated-types\">\
+            Associated Types</a></h3><div class=\"sidebar-links\">",
         |m| m.is_associated_type(),
         |out, sym| write!(out, "<a href=\"#associatedtype.{0}\">{0}</a>", sym),
         "</div>",
@@ -2133,8 +2132,8 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean
     print_sidebar_section(
         buf,
         &t.items,
-        "<a class=\"sidebar-title\" href=\"#associated-const\">\
-            Associated Constants</a><div class=\"sidebar-links\">",
+        "<h3 class=\"sidebar-title\"><a href=\"#associated-const\">\
+            Associated Constants</a></h3><div class=\"sidebar-links\">",
         |m| m.is_associated_const(),
         |out, sym| write!(out, "<a href=\"#associatedconstant.{0}\">{0}</a>", sym),
         "</div>",
@@ -2143,8 +2142,8 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean
     print_sidebar_section(
         buf,
         &t.items,
-        "<a class=\"sidebar-title\" href=\"#required-methods\">\
-            Required Methods</a><div class=\"sidebar-links\">",
+        "<h3 class=\"sidebar-title\"><a href=\"#required-methods\">\
+            Required Methods</a></h3><div class=\"sidebar-links\">",
         |m| m.is_ty_method(),
         |out, sym| write!(out, "<a href=\"#tymethod.{0}\">{0}</a>", sym),
         "</div>",
@@ -2153,8 +2152,8 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean
     print_sidebar_section(
         buf,
         &t.items,
-        "<a class=\"sidebar-title\" href=\"#provided-methods\">\
-            Provided Methods</a><div class=\"sidebar-links\">",
+        "<h3 class=\"sidebar-title\"><a href=\"#provided-methods\">\
+            Provided Methods</a></h3><div class=\"sidebar-links\">",
         |m| m.is_method(),
         |out, sym| write!(out, "<a href=\"#method.{0}\">{0}</a>", sym),
         "</div>",
@@ -2176,8 +2175,8 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean
         if !res.is_empty() {
             res.sort();
             buf.push_str(
-                "<a class=\"sidebar-title\" href=\"#foreign-impls\">\
-                    Implementations on Foreign Types</a>\
+                "<h3 class=\"sidebar-title\"><a href=\"#foreign-impls\">\
+                    Implementations on Foreign Types</a></h3>\
                  <div class=\"sidebar-links\">",
             );
             for (name, id) in res.into_iter() {
@@ -2189,11 +2188,11 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean
 
     sidebar_assoc_items(cx, buf, it);
 
-    buf.push_str("<a class=\"sidebar-title\" href=\"#implementors\">Implementors</a>");
+    buf.push_str("<h3 class=\"sidebar-title\"><a href=\"#implementors\">Implementors</a></h3>");
     if t.is_auto {
         buf.push_str(
-            "<a class=\"sidebar-title\" \
-                href=\"#synthetic-implementors\">Auto Implementors</a>",
+            "<h3 class=\"sidebar-title\"><a \
+                href=\"#synthetic-implementors\">Auto Implementors</a></h3>",
         );
     }
 
@@ -2236,7 +2235,7 @@ fn sidebar_union(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, u: &clean
 
     if !fields.is_empty() {
         sidebar.push_str(
-            "<a class=\"sidebar-title\" href=\"#fields\">Fields</a>\
+            "<h3 class=\"sidebar-title\"><a href=\"#fields\">Fields</a></h3>\
             <div class=\"sidebar-links\">",
         );
 
@@ -2268,7 +2267,7 @@ fn sidebar_enum(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, e: &clean:
     if !variants.is_empty() {
         variants.sort_unstable();
         sidebar.push_str(&format!(
-            "<a class=\"sidebar-title\" href=\"#variants\">Variants</a>\
+            "<h3 class=\"sidebar-title\"><a href=\"#variants\">Variants</a></h3>\
              <div class=\"sidebar-links\">{}</div>",
             variants.join(""),
         ));
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 04464b622d7..aef516e3335 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -585,9 +585,10 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
         if toggled {
             write!(w, "<details class=\"rustdoc-toggle\" open><summary>");
         }
-        write!(w, "<div id=\"{}\" class=\"method has-srclink\"><code>", id);
+        write!(w, "<div id=\"{}\" class=\"method has-srclink\">", id);
+        write!(w, "<h4 class=\"code-header\">");
         render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
-        w.write_str("</code>");
+        w.write_str("</h4>");
         render_stability_since(w, m, t, cx.tcx());
         write_srclink(cx, m, w);
         w.write_str("</div>");
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 1a15a444a70..fe1ce2e8b5c 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -703,8 +703,10 @@ function hideThemeButtonState() {
                     }
                 }
 
-                var code = document.createElement("code");
+                var code = document.createElement("h3");
                 code.innerHTML = struct.text;
+                addClass(code, "code-header");
+                addClass(code, "in-band");
 
                 onEachLazy(code.getElementsByTagName("a"), function(elem) {
                     var href = elem.getAttribute("href");
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index d8684641a30..f801ef09c50 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -134,12 +134,25 @@ h1.fqn {
 h1.fqn > .in-band > a:hover {
 	text-decoration: underline;
 }
-h2, h3, h4 {
+#main > h2, #main > h3, #main > h4 {
 	border-bottom: 1px solid;
 }
-.impl, .method,
-.type:not(.container-rustdoc), .associatedconstant,
-.associatedtype {
+h3.code-header, h4.code-header {
+	font-size: 1em;
+	font-weight: 600;
+	border: none;
+	padding: 0;
+	margin: 0;
+}
+.impl,
+.impl-items .method,
+.methods .method,
+.impl-items .type,
+.methods .type,
+.impl-items .associatedconstant,
+.methods .associatedconstant,
+.impl-items .associatedtype,
+.methods .associatedtype {
 	flex-basis: 100%;
 	font-weight: 600;
 	margin-top: 16px;
@@ -190,7 +203,34 @@ summary {
 	outline: none;
 }
 
-code, pre, a.test-arrow {
+/* Fix some style changes due to normalize.css 8 */
+
+td,
+th {
+	padding: 0;
+}
+
+table {
+	border-collapse: collapse;
+}
+
+button,
+input,
+optgroup,
+select,
+textarea {
+	color: inherit;
+	font: inherit;
+	margin: 0;
+}
+
+/* end tweaks for normalize.css 8 */
+
+details:not(.rustdoc-toggle) summary {
+	margin-bottom: .6em;
+}
+
+code, pre, a.test-arrow, .code-header {
 	font-family: "Source Code Pro", monospace;
 }
 .docblock code, .docblock-short code {
@@ -296,6 +336,8 @@ nav.sub {
 	margin: 30px 10px 20px 10px;
 	text-align: center;
 	word-wrap: break-word;
+	font-weight: inherit;
+	padding: 0;
 }
 
 .sidebar .version {
@@ -348,6 +390,8 @@ nav.sub {
 	text-align: center;
 	font-size: 17px;
 	margin-bottom: 5px;
+	font-weight: inherit;
+	padding: 0;
 }
 
 .sidebar-links {
@@ -470,9 +514,10 @@ nav.sub {
 	font-weight: normal;
 }
 
-.method > code, .trait-impl > code, .invisible > code {
+.method > .code-header, .trait-impl > .code-header, .invisible > .code-header {
 	max-width: calc(100% - 41px);
 	display: block;
+	flex-grow: 1;
 }
 
 .invisible {
@@ -486,7 +531,7 @@ nav.sub {
 	padding: 0px;
 }
 
-.in-band > code {
+.in-band > code, .in-band > .code-header {
 	display: inline-block;
 }
 
@@ -581,7 +626,7 @@ nav.sub {
 .content .item-info {
 	position: relative;
 	margin-left: 33px;
-	margin-top: -13px;
+	margin-top: -6px;
 }
 
 .sub-variant > div > .item-info {
@@ -592,7 +637,7 @@ nav.sub {
 	content: '⬑';
 	font-size: 25px;
 	position: absolute;
-	top: -6px;
+	top: 0px;
 	left: -19px;
 }
 
@@ -686,7 +731,7 @@ a {
 }
 
 .invisible > .srclink,
-.method > code + .srclink {
+.method > .code-header + .srclink {
 	position: absolute;
 	top: 0;
 	right: 0;
@@ -908,7 +953,7 @@ body.blur > :not(#help) {
 .impl-items .since, .impl .since, .methods .since {
 	flex-grow: 0;
 	padding-left: 12px;
-	padding-right: 2px;
+	padding-right: 6px;
 	position: initial;
 }
 
@@ -1041,8 +1086,7 @@ a.test-arrow:hover{
 	display: block;
 }
 
-
-:target > code {
+:target > code, :target > .code-header {
 	opacity: 1;
 }
 
@@ -1577,15 +1621,18 @@ details.undocumented[open] > summary::before {
 		display: none;
 	}
 
+	/* We do NOT hide this element so that alternative device readers still have this information
+	   available. */
 	.sidebar-elems {
 		position: fixed;
 		z-index: 1;
-		left: 0;
 		top: 45px;
 		bottom: 0;
+		width: 246px;
+		/* We move the sidebar to the left by its own width so it doesn't appear. */
+		left: -246px;
 		overflow-y: auto;
 		border-right: 1px solid;
-		display: none;
 	}
 
 	.sidebar > .block.version {
@@ -1662,8 +1709,7 @@ details.undocumented[open] > summary::before {
 	}
 
 	.show-it {
-		display: block;
-		width: 246px;
+		left: 0;
 	}
 
 	.show-it > .block.items {
diff --git a/src/librustdoc/html/static/themes/ayu.css b/src/librustdoc/html/static/themes/ayu.css
index d220d8708a1..1fc648d76b9 100644
--- a/src/librustdoc/html/static/themes/ayu.css
+++ b/src/librustdoc/html/static/themes/ayu.css
@@ -133,7 +133,6 @@ pre, .rustdoc.source .example-wrap {
 	color: #708090;
 	background-color: rgba(255, 236, 164, 0.06);
 	padding-right: 4px;
-	border-right: 1px solid #ffb44c;
 }
 
 .docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
@@ -334,7 +333,7 @@ a.test-arrow:hover {
 	color: #999;
 }
 
-:target > code, :target > .in-band {
+:target, :target > * {
 	background: rgba(255, 236, 164, 0.06);
 	border-right: 3px solid rgba(255, 180, 76, 0.85);
 }
diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css
index 6385a763f2e..3105a99de1e 100644
--- a/src/librustdoc/html/static/themes/dark.css
+++ b/src/librustdoc/html/static/themes/dark.css
@@ -282,9 +282,8 @@ a.test-arrow:hover{
 	color: #999;
 }
 
-:target > code, :target > .in-band {
+:target, :target > * {
 	background-color: #494a3d;
-	border-right: 3px solid #bb7410;
 }
 
 pre.compile_fail {
diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css
index c19d5bfc317..10fde92dcb8 100644
--- a/src/librustdoc/html/static/themes/light.css
+++ b/src/librustdoc/html/static/themes/light.css
@@ -275,9 +275,8 @@ a.test-arrow:hover{
 	color: #999;
 }
 
-:target > code, :target > .in-band {
+:target, :target > * {
 	background: #FDFFD3;
-	border-right: 3px solid #ffb44c;
 }
 
 pre.compile_fail {