Skip to content

Commit 84e1aa2

Browse files
authored
Rollup merge of #95684 - GuillaumeGomez:fix-item-info-overflow, r=notriddle
rustdoc: Fix item info display overflow I came across this issue when reading local `Iterator` docs (reproduced in this screenshot): ![Screenshot from 2022-04-05 17-45-13](https://user-images.githubusercontent.com/3050060/161798150-769ee838-4768-4df8-9d34-b02eb8104eed.png) The problem comes from the fact that `span` isn't `display: block` by default. Since `item-info` was already present on `<div>` in other places, I moved the last one to `div` as well. r? `@notriddle`
2 parents 823bf76 + 41b0247 commit 84e1aa2

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.4
1+
0.8.5

src/librustdoc/html/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ pub(crate) fn render_impl_summary(
17721772
let is_trait = i.inner_impl().trait_.is_some();
17731773
if is_trait {
17741774
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
1775-
write!(w, "<span class=\"item-info\">{}</span>", portability);
1775+
write!(w, "<div class=\"item-info\">{}</div>", portability);
17761776
}
17771777
}
17781778

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This test ensures that the "item-info" elements don't overflow.
2+
goto: file://|DOC_PATH|/lib2/struct.LongItemInfo.html
3+
// We set a fixed size so there is no chance of "random" resize.
4+
size: (1200, 870)
5+
// Logically, the "item-decl" and the "item-info" should have the same scroll width.
6+
compare-elements-property: (".docblock.item-decl", ".item-info", ["scrollWidth"])
7+
assert-property: (".item-info", {"scrollWidth": "890"})
8+
// Just to be sure we're comparing the correct "item-info":
9+
assert-text: (
10+
".item-info",
11+
"This is supported on Android or Linux or Emscripten or DragonFly BSD",
12+
STARTS_WITH,
13+
)
14+
15+
// Checking the "item-info" on an impl block as well:
16+
goto: file://|DOC_PATH|/lib2/struct.LongItemInfo2.html
17+
compare-elements-property: (
18+
"#impl-SimpleTrait .item-info",
19+
"#impl-SimpleTrait + .docblock",
20+
["scrollWidth"],
21+
)
22+
assert-property: ("#impl-SimpleTrait .item-info", {"scrollWidth": "866"})
23+
// Just to be sure we're comparing the correct "item-info":
24+
assert-text: (
25+
"#impl-SimpleTrait .item-info",
26+
"This is supported on Android or Linux or Emscripten or DragonFly BSD",
27+
STARTS_WITH,
28+
)

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

+10
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,13 @@ pub struct HasALongTraitWithParams {}
120120
pub trait LongTraitWithParamsBananaBananaBanana<T> {}
121121

122122
impl LongTraitWithParamsBananaBananaBanana<usize> for HasALongTraitWithParams {}
123+
124+
#[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))]
125+
pub struct LongItemInfo;
126+
127+
pub trait SimpleTrait {}
128+
pub struct LongItemInfo2;
129+
130+
/// Some docs.
131+
#[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))]
132+
impl SimpleTrait for LongItemInfo2 {}

0 commit comments

Comments
 (0)