Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docblock code display on mobile #89632

Merged
merged 2 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add that rule for all the layouts? If someone tries to break the record for longest symbol name we could allow breaking on desktop too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a rule for desktop, a bit less restrictive but that prevents it from being an issue there.

}
}
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 {}