about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-03-11 09:08:57 +0000
committerbors <bors@rust-lang.org>2021-03-11 09:08:57 +0000
commitea16128233c6bc7ab6ad8e6c68860f778ba33ad9 (patch)
treea1b6d1d9c64eb25c5413a9162bcca74f52470af0
parent04fce73196638cbb203e2b0dd2a16230ff6e265b (diff)
parent40adb9aeab84f1d1e757af838a4210f6e7b57292 (diff)
downloadrust-ea16128233c6bc7ab6ad8e6c68860f778ba33ad9.tar.gz
rust-ea16128233c6bc7ab6ad8e6c68860f778ba33ad9.zip
Auto merge of #82947 - GuillaumeGomez:fix-nojs-style-issues, r=Nemo157
Fix nojs style issues

There are two issues fixed here:
 1. The position of "{version}" and "[src]" spans.
 2. The position of attributes (on top of functions)

Please note that these issues only happen if you have disabled javascript.

Before:

![Screenshot from 2021-03-09 20-45-54](https://user-images.githubusercontent.com/3050060/110534652-9e048e00-811f-11eb-979e-6d85545edd65.png)

After:

![Screenshot from 2021-03-09 21-01-32](https://user-images.githubusercontent.com/3050060/110534667-a1981500-811f-11eb-8a19-32f4d5381a2b.png)

In the last commit, I added a test to enforce the attributes position. I need to think how to enforce it for the spans but that can comes later on.

r? `@Nemo157`
-rw-r--r--src/librustdoc/html/static/noscript.css10
-rw-r--r--src/librustdoc/html/static/rustdoc.css2
-rw-r--r--src/test/rustdoc-gui/lib.rs5
-rw-r--r--src/test/rustdoc-gui/nojs-attr-pos.goml5
4 files changed, 21 insertions, 1 deletions
diff --git a/src/librustdoc/html/static/noscript.css b/src/librustdoc/html/static/noscript.css
index ffa1a7639ab..c9fed989ec0 100644
--- a/src/librustdoc/html/static/noscript.css
+++ b/src/librustdoc/html/static/noscript.css
@@ -23,3 +23,13 @@ rules.
 #main .impl-items .hidden {
 	display: block !important;
 }
+
+#main .impl-items h4.hidden {
+	/* Without this rule, the version and the "[src]" span aren't on the same line as the header. */
+	display: flex !important;
+}
+
+#main .attributes {
+	/* Since there is no toggle (the "[-]") when JS is disabled, no need for this margin either. */
+	margin-left: 0 !important;
+}
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index 94c231cb33a..996e0f95d08 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -1343,7 +1343,7 @@ h4 > .notable-traits {
 @media (min-width: 701px) {
 	/* In case there is no documentation before a code block, we need to add some margin at the top
 	to prevent an overlay between the "collapse toggle" and the information tooltip.
-	However, it's needed needed with smaller screen width because the doc/code block is always put
+	However, it's not needed with smaller screen width because the doc/code block is always put
 	"one line" below. */
 	.information:first-child > .tooltip {
 		margin-top: 16px;
diff --git a/src/test/rustdoc-gui/lib.rs b/src/test/rustdoc-gui/lib.rs
index 3c996f5b65c..15d8dcc6e84 100644
--- a/src/test/rustdoc-gui/lib.rs
+++ b/src/test/rustdoc-gui/lib.rs
@@ -27,6 +27,11 @@ pub fn foo() {}
 /// Just a normal struct.
 pub struct Foo;
 
+impl Foo {
+    #[must_use]
+    pub fn must_use(&self) -> bool { true }
+}
+
 /// Just a normal enum.
 pub enum WhoLetTheDogOut {
     /// Woof!
diff --git a/src/test/rustdoc-gui/nojs-attr-pos.goml b/src/test/rustdoc-gui/nojs-attr-pos.goml
new file mode 100644
index 00000000000..35daa4cb9e3
--- /dev/null
+++ b/src/test/rustdoc-gui/nojs-attr-pos.goml
@@ -0,0 +1,5 @@
+// Check that the attributes are well positioned when javascript is disabled (since
+// there is no toggle to display)
+javascript: false
+goto: file://|DOC_PATH|/struct.Foo.html
+assert: (".attributes", {"margin-left": "0px"})