From df0904750dc7ef332930f77610e12ab03b28e9fd Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 2 Sep 2022 10:54:40 -0700 Subject: [PATCH 1/3] rustdoc: remove unused CSS selector `.methods > .item-info` It was added with e08a84a0c18739417a50c3e46917ced5037244eb (actually, it was called `.methods > .stability` at the time) and was directly nested that way. But with the switch to `
`, the code has changed drastically out from under it, to the point where you have to go out of your way to actually get it to render this way, and the result looks overly-tight and weird alongside the normal version where this code is not reachable. --- src/librustdoc/html/static/css/rustdoc.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index c7a9f247e20..c4a1728151d 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -782,10 +782,6 @@ pre, .rustdoc.source .example-wrap { margin-left: 40px; } -.methods > .item-info, .content .impl-items > .item-info { - margin-top: -8px; -} - .impl-items { flex-basis: 100%; } From 6f95c89c4d65a5579295e6490c4fa70e08424fcb Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 2 Sep 2022 11:50:19 -0700 Subject: [PATCH 2/3] rustdoc: remove incorrect CSS rule causing misaligned item-info --- src/librustdoc/html/static/css/rustdoc.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index c4a1728151d..90c86750425 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -778,10 +778,6 @@ pre, .rustdoc.source .example-wrap { margin-bottom: .6em; } -.content .impl-items > .item-info { - margin-left: 40px; -} - .impl-items { flex-basis: 100%; } From 0f29824760eefd74aba742fc2c287c2d3901bd63 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 2 Sep 2022 12:15:06 -0700 Subject: [PATCH 3/3] rustdoc: put in rule to get alignment in desktop and mobile layouts --- src/librustdoc/html/static/css/rustdoc.css | 5 +++++ src/test/rustdoc-gui/item-info-alignment.goml | 10 ++++++++++ src/test/rustdoc-gui/src/lib2/lib.rs | 10 ++++++++++ 3 files changed, 25 insertions(+) create mode 100644 src/test/rustdoc-gui/item-info-alignment.goml diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 90c86750425..147d2260964 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -2007,6 +2007,11 @@ in storage.js plus the media query with (min-width: 701px) #main-content > div > details.rustdoc-toggle > summary::before { left: -11px; } + + /* Align summary-nested and unnested item-info gizmos. */ + .content .impl-items > .item-info { + margin-left: 34px; + } } @media print { diff --git a/src/test/rustdoc-gui/item-info-alignment.goml b/src/test/rustdoc-gui/item-info-alignment.goml new file mode 100644 index 00000000000..4d7b5045f7c --- /dev/null +++ b/src/test/rustdoc-gui/item-info-alignment.goml @@ -0,0 +1,10 @@ +// This test ensures that the "item-info" looks about the same +// whether or not it's inside a toggle. +goto: file://|DOC_PATH|/lib2/struct.ItemInfoAlignmentTest.html + +// First, we try it in "desktop" mode. +size: (1200, 870) +compare-elements-position: (".impl-items > .item-info", "summary > .item-info", ("x")) +// Next, we try it in "mobile" mode (max-width: 700px). +size: (650, 650) +compare-elements-position: (".impl-items > .item-info", "summary > .item-info", ("x")) diff --git a/src/test/rustdoc-gui/src/lib2/lib.rs b/src/test/rustdoc-gui/src/lib2/lib.rs index 7f3172878bf..5a151ed7b68 100644 --- a/src/test/rustdoc-gui/src/lib2/lib.rs +++ b/src/test/rustdoc-gui/src/lib2/lib.rs @@ -170,3 +170,13 @@ where type Output; fn index(&self, index: Idx) -> &Self::Output; } + +pub struct ItemInfoAlignmentTest; + +impl ItemInfoAlignmentTest { + /// This method has docs + #[deprecated] + pub fn foo() {} + #[deprecated] + pub fn bar() {} +}