Skip to content

Commit 3fa897d

Browse files
authored
Rollup merge of #89632 - GuillaumeGomez:fix-docblock-code, r=jsha
Fix docblock code display on mobile Fixes #89618. Before: ![Screenshot from 2021-10-07 12-01-37](https://user-images.githubusercontent.com/3050060/136363624-72bedddd-b45e-48a0-89b4-6563612f8677.png) After: ![Screenshot from 2021-10-07 20-17-21](https://user-images.githubusercontent.com/3050060/136440704-fa9ffa68-8e94-46a7-b556-c41aa5153750.png) r? `@jsha`
2 parents 2bfbf97 + d4f3cf0 commit 3fa897d

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -1969,4 +1969,8 @@ details.undocumented[open] > summary::before {
19691969
.docblock {
19701970
margin-left: 12px;
19711971
}
1972+
1973+
.docblock code {
1974+
overflow-wrap: anywhere;
1975+
}
19721976
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// If we have a long `<code>`, we need to ensure that it'll be fully displayed on mobile, meaning
2+
// that it'll be on two lines.
3+
emulate: "iPhone 8" // it has the following size: (375, 667)
4+
goto: file://|DOC_PATH|/test_docs/long_code_block/index.html
5+
// We now check that the block is on two lines:
6+
show-text: true // We need to enable text draw to be able to have the "real" size
7+
// Little explanations for this test: if the text wasn't displayed on two lines, it would take
8+
// around 20px (which is the font size).
9+
assert-property: (".docblock p > code", {"offsetHeight": "42"})

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

+3
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,6 @@ pub type SomeType = u32;
120120
pub mod huge_amount_of_consts {
121121
include!(concat!(env!("OUT_DIR"), "/huge_amount_of_consts.rs"));
122122
}
123+
124+
/// Very long code text `hereIgoWithLongTextBecauseWhyNotAndWhyWouldntI`.
125+
pub mod long_code_block {}

0 commit comments

Comments
 (0)