From 655798558e2ba9801fc055a536a59dbbffa23c88 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 21 May 2022 13:57:52 +0200 Subject: [PATCH 1/3] Improve display of `
` in doc blocks --- src/librustdoc/html/static/css/rustdoc.css | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index d0229bdb5f23c..ed22a1a353e46 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -158,8 +158,8 @@ h1.fqn { Underlines elsewhere in the documentation break up visual flow and tend to invert section hierarchies. */ h2, -.top-doc h3, -.top-doc h4 { +.top-doc .docblock > h3, +.top-doc .docblock > h4 { border-bottom: 1px solid; } h3.code-header { @@ -1669,6 +1669,18 @@ details.rustdoc-toggle[open] > summary.hideme::after { content: "Collapse"; } +.docblock details summary { + display: flex; + list-style: none; + align-items: center; +} +.docblock details[open] summary::before { + content: "► "; +} +.docblock details[open] summary::before { + content: "▼ "; +} + /* Media Queries */ @media (min-width: 701px) { From 07596fefc114335c5f4c8cc3ed5b7361b17cf91b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 21 May 2022 15:05:19 +0200 Subject: [PATCH 2/3] Fix display of `
`/`` in doc blocks --- src/librustdoc/html/static/css/rustdoc.css | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index ed22a1a353e46..c7e1330e86acf 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1669,16 +1669,9 @@ details.rustdoc-toggle[open] > summary.hideme::after { content: "Collapse"; } -.docblock details summary { - display: flex; - list-style: none; - align-items: center; -} -.docblock details[open] summary::before { - content: "► "; -} -.docblock details[open] summary::before { - content: "▼ "; +/* This is needed in docblocks to have the "▶" element to be on the same line. */ +.docblock summary > * { + display: inline-block; } /* Media Queries */ From b8db8cc10f5d3a28d75f89680f2734e24cd1490c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 21 May 2022 15:05:56 +0200 Subject: [PATCH 3/3] Add GUI test for `
`/`` display --- src/test/rustdoc-gui/docblock-details.goml | 23 ++++++++++++++++++++++ src/test/rustdoc-gui/src/test_docs/lib.rs | 12 +++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/test/rustdoc-gui/docblock-details.goml diff --git a/src/test/rustdoc-gui/docblock-details.goml b/src/test/rustdoc-gui/docblock-details.goml new file mode 100644 index 0000000000000..2edbf1e4e2d8c --- /dev/null +++ b/src/test/rustdoc-gui/docblock-details.goml @@ -0,0 +1,23 @@ +// This ensures that the `
`/`` elements are displayed as expected. +goto: file://|DOC_PATH|/test_docs/details/struct.Details.html +show-text: true +local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} +reload: + +// We first check that the headers in the `.top-doc` doc block still have their +// bottom border. +assert-text: (".top-doc .docblock > h3", "Hello") +assert-css: ( + ".top-doc .docblock > h3", + {"border-bottom": "1px solid rgb(221, 221, 221)"}, +) +// We now check that the `` doesn't have a bottom border and has the correct display. +assert-css: ( + ".top-doc .docblock summary h4", + {"border-bottom": "0px none rgb(221, 221, 221)"}, +) +// This allows to ensure that summary is on one line only! +assert-property: (".top-doc .docblock summary h4", {"offsetHeight": "33"}) +assert-css: (".top-doc .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"}) +// So `33 + 15 + 5` == `53` +assert-property: (".top-doc .docblock summary", {"offsetHeight": "53"}) diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index b6fe9eb2565bd..aa2f78289bea2 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -277,3 +277,15 @@ pub use macros::*; #[doc(alias = "AliasForTheStdReexport")] pub use ::std as TheStdReexport; + +pub mod details { + /// We check the appearance of the `
`/`` in here. + /// + /// ## Hello + /// + ///
+ ///

I'm a summary

+ ///
I'm the content of the details!
+ ///
+ pub struct Details; +}