From 51e658f966a2c57d9d637747b457a5f9e087ec8d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 26 Jul 2022 21:34:56 +0200 Subject: [PATCH 1/2] Fix display of item info and unify their height --- src/librustdoc/html/static/css/rustdoc.css | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 70b7a47bcd58b..1ade33e4fcc7d 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1111,7 +1111,14 @@ table, } .item-info .stab { - display: inline-block; + width: fit-content; + /* This min-height is needed to unify the height of the stab elements because some of them + have emojis. + */ + min-height: 36px; + display: flex; + align-items: center; + white-space: pre-wrap; } .stab { padding: 3px; @@ -1121,6 +1128,7 @@ table, } .stab p { display: inline; + margin: 0; } .stab .emoji { From 9903f41b01b56479698796c9cfcab6bac2f862a4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 26 Jul 2022 21:40:01 +0200 Subject: [PATCH 2/2] Add GUI test for item info position --- src/test/rustdoc-gui/item-info-width.goml | 8 ------ src/test/rustdoc-gui/item-info.goml | 32 +++++++++++++++++++++++ src/test/rustdoc-gui/src/lib2/lib.rs | 3 +++ 3 files changed, 35 insertions(+), 8 deletions(-) delete mode 100644 src/test/rustdoc-gui/item-info-width.goml create mode 100644 src/test/rustdoc-gui/item-info.goml diff --git a/src/test/rustdoc-gui/item-info-width.goml b/src/test/rustdoc-gui/item-info-width.goml deleted file mode 100644 index 8b6d355a8f1a7..0000000000000 --- a/src/test/rustdoc-gui/item-info-width.goml +++ /dev/null @@ -1,8 +0,0 @@ -// This test ensures that the item information don't take 100% of the width if unnecessary. -goto: file://|DOC_PATH|/lib2/struct.Foo.html -// We set a fixed size so there is no chance of "random" resize. -size: (1100, 800) -// We check that ".item-info" is bigger than its content. -assert-css: (".item-info", {"width": "790px"}) -assert-css: (".item-info .stab", {"width": "289px"}) -assert-position: (".item-info .stab", {"x": 295}) diff --git a/src/test/rustdoc-gui/item-info.goml b/src/test/rustdoc-gui/item-info.goml new file mode 100644 index 0000000000000..50c45b76bd630 --- /dev/null +++ b/src/test/rustdoc-gui/item-info.goml @@ -0,0 +1,32 @@ +// This test ensures a few things for item info elements. +goto: file://|DOC_PATH|/lib2/struct.Foo.html +// Ensuring that the item information don't take 100% of the width if unnecessary. +// We set a fixed size so there is no chance of "random" resize. +size: (1100, 800) +// We check that ".item-info" is bigger than its content. +assert-css: (".item-info", {"width": "790px"}) +assert-css: (".item-info .stab", {"width": "289px"}) +assert-position: (".item-info .stab", {"x": 295}) + +// Now we ensure that they're not rendered on the same line. +goto: file://|DOC_PATH|/lib2/trait.Trait.html +// We first ensure that there are two item info on the trait. +assert-count: ("#main-content > .item-info .stab", 2) +// They should not have the same `y` position! +compare-elements-position-false: ( + "#main-content > .item-info .stab:nth-of-type(1)", + "#main-content > .item-info .stab:nth-of-type(2)", + ("y"), +) +// But they should have the same `x` position. +compare-elements-position: ( + "#main-content > .item-info .stab:nth-of-type(1)", + "#main-content > .item-info .stab:nth-of-type(2)", + ("x"), +) +// They are supposed to have the same height too. +compare-elements-css: ( + "#main-content > .item-info .stab:nth-of-type(1)", + "#main-content > .item-info .stab:nth-of-type(2)", + ["height"], +) diff --git a/src/test/rustdoc-gui/src/lib2/lib.rs b/src/test/rustdoc-gui/src/lib2/lib.rs index 4546449e10291..87f91be3ac82c 100644 --- a/src/test/rustdoc-gui/src/lib2/lib.rs +++ b/src/test/rustdoc-gui/src/lib2/lib.rs @@ -30,10 +30,13 @@ impl Foo { pub fn a_method(&self) {} } +#[doc(cfg(feature = "foo-method"))] +#[deprecated = "Whatever [`Foo::a_method`](#method.a_method)"] pub trait Trait { type X; const Y: u32; + #[deprecated = "Whatever [`Foo`](#tadam)"] fn foo() {} }