From 79bb6ec9ef9490ba74bce0c481d693c1d88db4b4 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 13 Dec 2022 16:55:45 -0700 Subject: [PATCH] rustdoc: add CSS margin between `impl` docblock and its items --- src/librustdoc/html/static/css/rustdoc.css | 1 + src/test/rustdoc-gui/impl-doc.goml | 9 +++++++++ src/test/rustdoc-gui/src/test_docs/lib.rs | 8 ++++++++ 3 files changed, 18 insertions(+) create mode 100644 src/test/rustdoc-gui/impl-doc.goml diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index d22d2f2edb0..210f1de8879 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1872,6 +1872,7 @@ in storage.js } .variants > .docblock, +.implementors-toggle > .docblock, .impl-items > .rustdoc-toggle[open]:not(:last-child), .methods > .rustdoc-toggle[open]:not(:last-child), .implementors-toggle[open]:not(:last-child) { diff --git a/src/test/rustdoc-gui/impl-doc.goml b/src/test/rustdoc-gui/impl-doc.goml new file mode 100644 index 00000000000..7322032b3f5 --- /dev/null +++ b/src/test/rustdoc-gui/impl-doc.goml @@ -0,0 +1,9 @@ +// A docblock on an impl must have a margin to separate it from the contents. +goto: "file://" + |DOC_PATH| + "/test_docs/struct.TypeWithImplDoc.html" + +// The text is about 24px tall, so if there's a margin, then their position will be >24px apart +compare-elements-position-near-false: ( + "#implementations-list > .implementors-toggle > .docblock > p", + "#implementations-list > .implementors-toggle > .impl-items", + {"y": 24} +) diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index d6eeab803df..902c10ef5b6 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -442,3 +442,11 @@ fn function() {} fn function2() {} } } + +pub struct TypeWithImplDoc; + +/// impl doc +impl TypeWithImplDoc { + /// fn doc + pub fn test_fn() {} +}