Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 55d9f59

Browse files
committedDec 2, 2024
Improve positioning of "..." in collapsed impl block
1 parent 5c707df commit 55d9f59

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed
 

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -2215,7 +2215,7 @@ details.toggle:not([open]) > summary .docblock {
22152215
overflow-y: hidden;
22162216
}
22172217
details.toggle:not([open]) > summary .docblock > :first-child {
2218-
max-width: calc(100% - 1em);
2218+
max-width: 100%;
22192219
overflow: hidden;
22202220
width: fit-content;
22212221
white-space: nowrap;
@@ -2230,10 +2230,15 @@ details.toggle:not([open]) > summary .docblock > :first-child::after {
22302230
bottom: 0;
22312231
z-index: 1;
22322232
background-color: var(--main-background-color);
2233-
/* In case this ends up in a heading or a `<code>` item. */
2234-
font-weight: normal;
22352233
font: 1rem/1.5 "Source Serif 4", NanumBarunGothic, serif;
2234+
/* To make it look a bit better and not have it stuck to the preceding element. */
2235+
padding-left: 0.2em;
22362236
}
2237+
details.toggle:not([open]) > summary .docblock > div:first-child::after {
2238+
/* This is to make the "..." always appear at the bottom. */
2239+
padding-top: calc(1.5em + 0.75em - 1.2rem);
2240+
}
2241+
22372242
details.toggle > summary .docblock {
22382243
margin-top: 0.75em;
22392244
}

‎tests/rustdoc-gui/impl-block-doc.goml

+9
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ assert: (|impl_y| + |impl_height|) <= (|doc_y| + |doc_height|)
3131
call-function: ("compare-size-and-pos", {"nth_impl": 2})
3232
// The second impl block has a short line.
3333
assert: (|impl_y| + |impl_height|) >= (|doc_y| + |doc_height|)
34+
35+
// FIXME: Needs `if` condition to make this test check that `padding-top` on the "..." element
36+
// is as expected for tables.
37+
call-function: ("compare-size-and-pos", {"nth_impl": 3})
38+
assert: (|impl_y| + |impl_height|) >= (|doc_y| + |doc_height|)
39+
call-function: ("compare-size-and-pos", {"nth_impl": 4})
40+
assert: (|impl_y| + |impl_height|) >= (|doc_y| + |doc_height|)
41+
call-function: ("compare-size-and-pos", {"nth_impl": 5})
42+
assert: (|impl_y| + |impl_height|) >= (|doc_y| + |doc_height|)

‎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": 1114, "clientWidth": 800})
5+
assert-property: ("body", {"scrollWidth": 1776, "clientWidth": 800})
66

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

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

+22
Original file line numberDiff line numberDiff line change
@@ -669,3 +669,25 @@ impl ImplDoc {
669669
impl ImplDoc {
670670
pub fn bar2() {}
671671
}
672+
673+
// ignore-tidy-linelength
674+
/// | this::is::a::kinda::very::long::header::number::one | this::is::a::kinda::very::long::header::number::two | this::is::a::kinda::very::long::header::number::three |
675+
/// |-|-|-|
676+
/// | bla | bli | blob |
677+
impl ImplDoc {
678+
pub fn bar3() {}
679+
}
680+
681+
/// # h1
682+
///
683+
/// bla
684+
impl ImplDoc {
685+
pub fn bar4() {}
686+
}
687+
688+
/// * list
689+
/// * list
690+
/// * list
691+
impl ImplDoc {
692+
pub fn bar5() {}
693+
}

0 commit comments

Comments
 (0)
Failed to load comments.