Skip to content

Commit

Permalink
rustdoc: apply pre-wrap CSS to code-wrapped links
Browse files Browse the repository at this point in the history
This is common syntax used for intra-doc links, so fixing it should help
with doc formatting.
  • Loading branch information
notriddle committed Dec 13, 2022
1 parent ed620cf commit e38d1e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,8 @@ ul.block, .block li {
text-overflow: ellipsis;
}
/* Wrap non-pre code blocks (`text`) but not (```text```). */
.docblock > :not(pre) > code,
.docblock-short > code {
.docblock :not(pre) > code,
.docblock-short code {
white-space: pre-wrap;
}

Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc-gui/docblock-big-code-mobile.goml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ show-text: true // We need to enable text draw to be able to have the "real" siz
// 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": "44"})

// Same check, but where the long code block is also a link
goto: "file://" + |DOC_PATH| + "/test_docs/long_code_block_link/index.html"
assert-property: (".docblock p > a > code", {"offsetHeight": "44"})
5 changes: 5 additions & 0 deletions src/test/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ pub mod huge_amount_of_consts {
/// Very long code text `hereIgoWithLongTextBecauseWhyNotAndWhyWouldntI`.
pub mod long_code_block {}

/// Very long code text [`hereIgoWithLongTextBecauseWhyNotAndWhyWouldntI`][lnk].
///
/// [lnk]: crate::long_code_block_link
pub mod long_code_block_link {}

#[macro_export]
macro_rules! repro {
() => {};
Expand Down

0 comments on commit e38d1e9

Please sign in to comment.