diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-08-02 07:30:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-02 07:30:41 +0200 |
| commit | 96908527cafd0ea0c8bb9df138e1688fcf3edb0d (patch) | |
| tree | 4d27de1e52778ef90041ae5c0e21fc47853c4162 /src | |
| parent | 3357470fb73d6a6dbf636ec96e5eb4936cfe29f8 (diff) | |
| parent | 9903f41b01b56479698796c9cfcab6bac2f862a4 (diff) | |
| download | rust-96908527cafd0ea0c8bb9df138e1688fcf3edb0d.tar.gz rust-96908527cafd0ea0c8bb9df138e1688fcf3edb0d.zip | |
Rollup merge of #99779 - GuillaumeGomez:fix-item-info-pos-and-height, r=notriddle
Fix item info pos and height Fixes https://github.com/rust-lang/rust/issues/98266. Fixes https://github.com/rust-lang/rust/issues/98343. You can test it [here](https://rustdoc.crud.net/imperio/fix-item-info-pos-and-height/lib2/trait.Trait.html). Here is a screenshot of the result:  r? `@jsha`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/static/css/rustdoc.css | 10 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/item-info-width.goml | 8 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/item-info.goml | 32 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src/lib2/lib.rs | 3 |
4 files changed, 44 insertions, 9 deletions
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index aecc9aa879a..83fe14550cc 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 { 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 8b6d355a8f1..00000000000 --- 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 00000000000..50c45b76bd6 --- /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 4546449e102..87f91be3ac8 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() {} } |
