Skip to content

Commit 5bd7525

Browse files
Rollup merge of #128014 - GuillaumeGomez:stab-in-doc-blocks, r=notriddle
Fix stab display in doc blocks Went across this bug randomly: ![Screenshot from 2024-07-20 22-09-49](https://github.com/user-attachments/assets/89fdf427-b00e-4fcb-9d57-078bcb1bacd9) With the fixed CSS: ![Screenshot from 2024-07-20 22-10-14](https://github.com/user-attachments/assets/eda9a1a6-6a12-408f-bd3a-25bb3397d163) r? ```@notriddle```
2 parents 6af66e8 + 84db684 commit 5bd7525

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,10 @@ pre, .rustdoc.src .example-wrap {
831831
background: var(--table-alt-row-background-color);
832832
}
833833

834+
.docblock .stab, .docblock-short .stab {
835+
display: inline-block;
836+
}
837+
834838
/* "where ..." clauses with block display are also smaller */
835839
div.where {
836840
white-space: pre-wrap;

tests/rustdoc-gui/source-code-page-code-scroll.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
33
set-window-size: (800, 1000)
44
// "scrollWidth" should be superior than "clientWidth".
5-
assert-property: ("body", {"scrollWidth": 1047, "clientWidth": 800})
5+
assert-property: ("body", {"scrollWidth": 1114, "clientWidth": 800})
66

77
// Both properties should be equal (ie, no scroll on the code block).
8-
assert-property: (".example-wrap .rust", {"scrollWidth": 933, "clientWidth": 933})
8+
assert-property: (".example-wrap .rust", {"scrollWidth": 1000, "clientWidth": 1000})

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated
2020
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
2121
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
2222
23-
Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code>
24-
</span>.
25-
Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code>
26-
</span>.
23+
Finally, you can use `quz` only on <span class="stab portability" data-span="1"><code>Unix or x86-64
24+
</code></span>.
25+
Finally, you can use `quz` only on <span class="stab portability" data-span="2"><code>Unix or x86-64
26+
</code></span>.
2727
*/
2828

2929
use std::convert::AsRef;

tests/rustdoc-gui/stab-in-doc.goml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This test ensure that `stab` elements if used in doc blocks are not breaking the text layout.
2+
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
3+
// We make the window wide enough for the two stabs who are looking into to be on the same line.
4+
set-window-size: (1100, 600)
5+
compare-elements-position: (
6+
".top-doc .docblock span[data-span='1']",
7+
".top-doc .docblock span[data-span='2']",
8+
["y"],
9+
)

0 commit comments

Comments
 (0)