Skip to content

Commit b805939

Browse files
Rollup merge of rust-lang#132183 - GuillaumeGomez:code-in-docblock, r=notriddle
Fix code HTML items making big blocks if too long Encountered this bug randomly where `code` item in docblocks would look like this: ![Screenshot from 2024-10-26 15-44-46](https://github.com/user-attachments/assets/a9c1df9d-5007-49eb-a7dd-a2c381b2511e) With this fix it looks like this: ![image](https://github.com/user-attachments/assets/ea918595-5434-4781-b68c-6abd38689365) r? ``@notriddle``
2 parents 05f784c + 88f4425 commit b805939

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ pre, .rustdoc.src .example-wrap, .example-wrap .src-line-numbers {
959959
background: var(--table-alt-row-background-color);
960960
}
961961

962-
.docblock .stab, .docblock-short .stab {
962+
.docblock .stab, .docblock-short .stab, .docblock p code {
963963
display: inline-block;
964964
}
965965

tests/rustdoc-gui/check-stab-in-docblock.goml

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This test checks that using `.stab` attributes in `.docblock` elements doesn't
2-
// create scrollable paragraphs.
2+
// create scrollable paragraphs and is correctly displayed (not making weird blocks).
33
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
44
// Needs the text to be display to check for scrollable content.
55
show-text: true
@@ -31,3 +31,15 @@ assert-property: (
3131
".top-doc .docblock p:nth-of-type(3)",
3232
{"scrollHeight": |clientHeight|, "scrollWidth": |clientWidth|},
3333
)
34+
35+
// Ensure that `<code>` elements in code don't make big blocks.
36+
compare-elements-size-near: (
37+
"#reexport\.TheStdReexport > code",
38+
".docblock p span[data-span='1']",
39+
{"height": 1},
40+
)
41+
compare-elements-size-near: (
42+
"#reexport\.TheStdReexport > code",
43+
".docblock p span[data-span='2']",
44+
{"height": 1},
45+
)
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// If we have a long `<code>`, we need to ensure that it'll be fully displayed on mobile, meaning
22
// that it'll be on two lines.
3+
34
emulate: "iPhone 8" // it has the following size: (375, 667)
45
go-to: "file://" + |DOC_PATH| + "/test_docs/long_code_block/index.html"
5-
// We now check that the block is on two lines:
66
show-text: true // We need to enable text draw to be able to have the "real" size
7+
8+
// We now check that the block is on two lines:
79
// 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": "44"})
10+
// around 24px (which is the font size).
11+
assert-size: (".docblock p > code", {"height": 48})
1012

1113
// Same check, but where the long code block is also a link
1214
go-to: "file://" + |DOC_PATH| + "/test_docs/long_code_block_link/index.html"
13-
assert-property: (".docblock p > a > code", {"offsetHeight": "44"})
15+
assert-size: (".docblock p > a > code", {"height": 48})

0 commit comments

Comments
 (0)