Skip to content

Commit 2f0f052

Browse files
Improve positioning of "..." in collapsed impl block
1 parent 5943329 commit 2f0f052

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,7 @@ details.toggle:not([open]) > summary .docblock {
22002200
overflow-y: hidden;
22012201
}
22022202
details.toggle:not([open]) > summary .docblock > :first-child {
2203-
max-width: calc(100% - 1em);
2203+
max-width: 100%;
22042204
overflow: hidden;
22052205
width: fit-content;
22062206
white-space: nowrap;
@@ -2215,10 +2215,15 @@ details.toggle:not([open]) > summary .docblock > :first-child::after {
22152215
bottom: 0;
22162216
z-index: 1;
22172217
background-color: var(--main-background-color);
2218-
/* In case this ends up in a heading or a `<code>` item. */
2219-
font-weight: normal;
22202218
font: 1rem/1.5 "Source Serif 4", NanumBarunGothic, serif;
2219+
/* To make it look a bit better and not have it stuck to the preceding element. */
2220+
padding-left: 0.2em;
22212221
}
2222+
details.toggle:not([open]) > summary .docblock > div:first-child::after {
2223+
/* This is to make the "..." always appear at the bottom. */
2224+
padding-top: calc(1.5em + 0.75em - 1.2rem);
2225+
}
2226+
22222227
details.toggle > summary .docblock {
22232228
margin-top: 0.75em;
22242229
}

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

Lines changed: 9 additions & 0 deletions
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/src/test_docs/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,3 +669,24 @@ impl ImplDoc {
669669
impl ImplDoc {
670670
pub fn bar2() {}
671671
}
672+
673+
/// | 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 |
674+
/// |-|-|-|
675+
/// | bla | bli | blob |
676+
impl ImplDoc {
677+
pub fn bar3() {}
678+
}
679+
680+
/// # h1
681+
///
682+
/// bla
683+
impl ImplDoc {
684+
pub fn bar4() {}
685+
}
686+
687+
/// * list
688+
/// * list
689+
/// * list
690+
impl ImplDoc {
691+
pub fn bar5() {}
692+
}

0 commit comments

Comments
 (0)