Skip to content

Commit

Permalink
Improve positioning of "..." in collapsed impl block
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 20, 2024
1 parent 5943329 commit 5ff686a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,7 @@ details.toggle:not([open]) > summary .docblock {
overflow-y: hidden;
}
details.toggle:not([open]) > summary .docblock > :first-child {
max-width: calc(100% - 1em);
max-width: 100%;
overflow: hidden;
width: fit-content;
white-space: nowrap;
Expand All @@ -2215,10 +2215,15 @@ details.toggle:not([open]) > summary .docblock > :first-child::after {
bottom: 0;
z-index: 1;
background-color: var(--main-background-color);
/* In case this ends up in a heading or a `<code>` item. */
font-weight: normal;
font: 1rem/1.5 "Source Serif 4", NanumBarunGothic, serif;
/* To make it look a bit better and not have it stuck to the preceding element. */
padding-left: 0.2em;
}
details.toggle:not([open]) > summary .docblock > div:first-child::after {
/* This is to make the "..." always appear at the bottom. */
padding-top: calc(1.5em + 0.75em - 1.2rem);
}

details.toggle > summary .docblock {
margin-top: 0.75em;
}
Expand Down
9 changes: 9 additions & 0 deletions tests/rustdoc-gui/impl-block-doc.goml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ assert: (|impl_y| + |impl_height|) <= (|doc_y| + |doc_height|)
call-function: ("compare-size-and-pos", {"nth_impl": 2})
// The second impl block has a short line.
assert: (|impl_y| + |impl_height|) >= (|doc_y| + |doc_height|)

// FIXME: Needs `if` condition to make this test check that `padding-top` on the "..." element
// is as expected for tables.
call-function: ("compare-size-and-pos", {"nth_impl": 3})
assert: (|impl_y| + |impl_height|) >= (|doc_y| + |doc_height|)
call-function: ("compare-size-and-pos", {"nth_impl": 4})
assert: (|impl_y| + |impl_height|) >= (|doc_y| + |doc_height|)
call-function: ("compare-size-and-pos", {"nth_impl": 5})
assert: (|impl_y| + |impl_height|) >= (|doc_y| + |doc_height|)
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/source-code-page-code-scroll.goml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
set-window-size: (800, 1000)
// "scrollWidth" should be superior than "clientWidth".
assert-property: ("body", {"scrollWidth": 1114, "clientWidth": 800})
assert-property: ("body", {"scrollWidth": 1776, "clientWidth": 800})

// Both properties should be equal (ie, no scroll on the code block).
assert-property: (".example-wrap .rust", {"scrollWidth": 1000, "clientWidth": 1000})
assert-property: (".example-wrap .rust", {"scrollWidth": 1662, "clientWidth": 1662})
22 changes: 22 additions & 0 deletions tests/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,3 +669,25 @@ impl ImplDoc {
impl ImplDoc {
pub fn bar2() {}
}

// ignore-tidy-linelength
/// | 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 |
/// |-|-|-|
/// | bla | bli | blob |
impl ImplDoc {
pub fn bar3() {}
}

/// # h1
///
/// bla
impl ImplDoc {
pub fn bar4() {}
}

/// * list
/// * list
/// * list
impl ImplDoc {
pub fn bar5() {}
}

0 comments on commit 5ff686a

Please sign in to comment.