Skip to content

Commit

Permalink
Rollup merge of #89632 - GuillaumeGomez:fix-docblock-code, r=jsha
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
matthiaskrgr authored Oct 10, 2021
2 parents 2bfbf97 + d4f3cf0 commit 3fa897d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1969,4 +1969,8 @@ details.undocumented[open] > summary::before {
.docblock {
margin-left: 12px;
}

.docblock code {
overflow-wrap: anywhere;
}
}
9 changes: 9 additions & 0 deletions src/test/rustdoc-gui/docblock-big-code-mobile.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// If we have a long `<code>`, we need to ensure that it'll be fully displayed on mobile, meaning
// that it'll be on two lines.
emulate: "iPhone 8" // it has the following size: (375, 667)
goto: file://|DOC_PATH|/test_docs/long_code_block/index.html
// We now check that the block is on two lines:
show-text: true // We need to enable text draw to be able to have the "real" size
// Little explanations for this test: if the text wasn't displayed on two lines, it would take
// around 20px (which is the font size).
assert-property: (".docblock p > code", {"offsetHeight": "42"})
3 changes: 3 additions & 0 deletions src/test/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,6 @@ pub type SomeType = u32;
pub mod huge_amount_of_consts {
include!(concat!(env!("OUT_DIR"), "/huge_amount_of_consts.rs"));
}

/// Very long code text `hereIgoWithLongTextBecauseWhyNotAndWhyWouldntI`.
pub mod long_code_block {}

0 comments on commit 3fa897d

Please sign in to comment.