Skip to content

Commit 9690852

Browse files
authored
Rollup merge of #99779 - GuillaumeGomez:fix-item-info-pos-and-height, r=notriddle
Fix item info pos and height Fixes #98266. Fixes #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: ![Screenshot from 2022-07-26 21-55-53](https://user-images.githubusercontent.com/3050060/181100624-18b8b045-5c25-4c7c-9c44-97d55d29b675.png) r? `@jsha`
2 parents 3357470 + 9903f41 commit 9690852

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

src/librustdoc/html/static/css/rustdoc.css

+9-1
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,14 @@ table,
11111111
}
11121112

11131113
.item-info .stab {
1114-
display: inline-block;
1114+
width: fit-content;
1115+
/* This min-height is needed to unify the height of the stab elements because some of them
1116+
have emojis.
1117+
*/
1118+
min-height: 36px;
1119+
display: flex;
1120+
align-items: center;
1121+
white-space: pre-wrap;
11151122
}
11161123
.stab {
11171124
padding: 3px;
@@ -1121,6 +1128,7 @@ table,
11211128
}
11221129
.stab p {
11231130
display: inline;
1131+
margin: 0;
11241132
}
11251133

11261134
.stab .emoji {

src/test/rustdoc-gui/item-info-width.goml

-8
This file was deleted.

src/test/rustdoc-gui/item-info.goml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// This test ensures a few things for item info elements.
2+
goto: file://|DOC_PATH|/lib2/struct.Foo.html
3+
// Ensuring that the item information don't take 100% of the width if unnecessary.
4+
// We set a fixed size so there is no chance of "random" resize.
5+
size: (1100, 800)
6+
// We check that ".item-info" is bigger than its content.
7+
assert-css: (".item-info", {"width": "790px"})
8+
assert-css: (".item-info .stab", {"width": "289px"})
9+
assert-position: (".item-info .stab", {"x": 295})
10+
11+
// Now we ensure that they're not rendered on the same line.
12+
goto: file://|DOC_PATH|/lib2/trait.Trait.html
13+
// We first ensure that there are two item info on the trait.
14+
assert-count: ("#main-content > .item-info .stab", 2)
15+
// They should not have the same `y` position!
16+
compare-elements-position-false: (
17+
"#main-content > .item-info .stab:nth-of-type(1)",
18+
"#main-content > .item-info .stab:nth-of-type(2)",
19+
("y"),
20+
)
21+
// But they should have the same `x` position.
22+
compare-elements-position: (
23+
"#main-content > .item-info .stab:nth-of-type(1)",
24+
"#main-content > .item-info .stab:nth-of-type(2)",
25+
("x"),
26+
)
27+
// They are supposed to have the same height too.
28+
compare-elements-css: (
29+
"#main-content > .item-info .stab:nth-of-type(1)",
30+
"#main-content > .item-info .stab:nth-of-type(2)",
31+
["height"],
32+
)

src/test/rustdoc-gui/src/lib2/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ impl Foo {
3030
pub fn a_method(&self) {}
3131
}
3232

33+
#[doc(cfg(feature = "foo-method"))]
34+
#[deprecated = "Whatever [`Foo::a_method`](#method.a_method)"]
3335
pub trait Trait {
3436
type X;
3537
const Y: u32;
3638

39+
#[deprecated = "Whatever [`Foo`](#tadam)"]
3740
fn foo() {}
3841
}
3942

0 commit comments

Comments
 (0)