From fad5f51183fad999b5d346735e91cf08990e5132 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 25 Oct 2024 23:06:52 +0200 Subject: Always display first line of impl blocks even when collapsed --- src/librustdoc/html/static/css/rustdoc.css | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/librustdoc/html/static/css') diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 90aa5904daf..52b3710ef16 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -2210,6 +2210,29 @@ details.toggle[open] > summary::after { content: "Collapse"; } +details.toggle:not([open]) > summary .docblock { + max-height: calc(1.5em + 0.75em); + overflow-y: hidden; +} +details.toggle:not([open]) > summary .docblock::after { + content: ''; + position: absolute; + bottom: 0; + left: 0; + right: 0; + pointer-events: none; + background: linear-gradient( + to top, + var(--scrape-example-code-wrapper-background-start), + var(--scrape-example-code-wrapper-background-end) + ); + height: 0.7em; + z-index: 1; +} +details.toggle > summary .docblock { + margin-top: 0.75em; +} + /* This is needed in docblocks to have the "▶" element to be on the same line. */ .docblock summary > * { display: inline-block; -- cgit 1.4.1-3-g733a5 From 448d9adc3804fcd7ecc7e89529b8565754028b91 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 29 Oct 2024 15:44:25 +0100 Subject: Use text ellipsis instead of bottom blurring --- src/librustdoc/html/static/css/rustdoc.css | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/librustdoc/html/static/css') diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 52b3710ef16..cc69a2c4dad 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -2214,20 +2214,25 @@ details.toggle:not([open]) > summary .docblock { max-height: calc(1.5em + 0.75em); overflow-y: hidden; } -details.toggle:not([open]) > summary .docblock::after { - content: ''; +details.toggle:not([open]) > summary .docblock > :first-child { + max-width: calc(100% - 1em); + overflow: hidden; + width: fit-content; + white-space: nowrap; + position: relative; + padding-right: 1em; +} +details.toggle:not([open]) > summary .docblock > :first-child::after { + content: "…"; position: absolute; - bottom: 0; - left: 0; right: 0; - pointer-events: none; - background: linear-gradient( - to top, - var(--scrape-example-code-wrapper-background-start), - var(--scrape-example-code-wrapper-background-end) - ); - height: 0.7em; + top: 0; + bottom: 0; z-index: 1; + background-color: var(--main-background-color); + /* In case this ends up in a heading or a `` item. */ + font-weight: normal; + font: 1rem/1.5 "Source Serif 4", NanumBarunGothic, serif; } details.toggle > summary .docblock { margin-top: 0.75em; -- cgit 1.4.1-3-g733a5 From 90feb9a64514b949b9a986e07c8eb14e4a5ca923 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 19 Nov 2024 22:11:28 +0100 Subject: Improve positioning of "..." in collapsed impl block --- src/librustdoc/html/static/css/rustdoc.css | 11 ++++++++--- tests/rustdoc-gui/impl-block-doc.goml | 9 +++++++++ .../rustdoc-gui/source-code-page-code-scroll.goml | 4 ++-- tests/rustdoc-gui/src/test_docs/lib.rs | 22 ++++++++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) (limited to 'src/librustdoc/html/static/css') diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index cc69a2c4dad..27496381b2c 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -2215,7 +2215,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; @@ -2230,10 +2230,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 `` 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; } diff --git a/tests/rustdoc-gui/impl-block-doc.goml b/tests/rustdoc-gui/impl-block-doc.goml index 6c7d7f4cbc1..906ce1a37c6 100644 --- a/tests/rustdoc-gui/impl-block-doc.goml +++ b/tests/rustdoc-gui/impl-block-doc.goml @@ -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|) diff --git a/tests/rustdoc-gui/source-code-page-code-scroll.goml b/tests/rustdoc-gui/source-code-page-code-scroll.goml index 31ab281d6ce..60012db6c8c 100644 --- a/tests/rustdoc-gui/source-code-page-code-scroll.goml +++ b/tests/rustdoc-gui/source-code-page-code-scroll.goml @@ -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}) diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index bdb958bf0e1..91aa2c3fae5 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -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() {} +} -- cgit 1.4.1-3-g733a5