Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<details>/<summary> UI fixes #97249

Merged
merged 3 commits into from
Jul 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1669,6 +1669,11 @@ details.rustdoc-toggle[open] > summary.hideme::after {
content: "Collapse";
}

/* This is needed in docblocks to have the "▶" element to be on the same line. */
.docblock summary > * {
display: inline-block;
}

/* Media Queries */

@media (min-width: 701px) {
Expand Down
23 changes: 23 additions & 0 deletions src/test/rustdoc-gui/docblock-details.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// This ensures that the `<details>`/`<summary>` 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 `<summary>` 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"})
12 changes: 12 additions & 0 deletions src/test/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,15 @@ pub use macros::*;

#[doc(alias = "AliasForTheStdReexport")]
pub use ::std as TheStdReexport;

pub mod details {
/// We check the appearance of the `<details>`/`<summary>` in here.
///
/// ## Hello
///
/// <details>
/// <summary><h4>I'm a summary</h4></summary>
/// <div>I'm the content of the details!</div>
/// </details>
pub struct Details;
}