Skip to content

Commit 66f33df

Browse files
authored
Rollup merge of #103364 - notriddle:notriddle/toggles, r=jsha
rustdoc: clean up rustdoc-toggle CSS
2 parents 1b2f594 + 526c1d3 commit 66f33df

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

src/librustdoc/html/static/css/rustdoc.css

+4-10
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,7 @@ details.dir-entry a {
15361536
https://developer.mozilla.org/en-US/docs/Web/CSS/contain */
15371537
details.rustdoc-toggle {
15381538
contain: layout;
1539+
position: relative;
15391540
}
15401541

15411542
/* The hideme class is used on summary tags that contain a span with
@@ -1629,10 +1630,6 @@ details.rustdoc-toggle[open] > summary.hideme {
16291630
position: absolute;
16301631
}
16311632

1632-
details.rustdoc-toggle {
1633-
position: relative;
1634-
}
1635-
16361633
details.rustdoc-toggle[open] > summary.hideme > span {
16371634
display: none;
16381635
}
@@ -1983,8 +1980,8 @@ in storage.js
19831980
}
19841981
}
19851982

1986-
.method-toggle summary,
1987-
.implementors-toggle summary,
1983+
.method-toggle > summary,
1984+
.implementors-toggle > summary,
19881985
.impl,
19891986
#implementors-list > .docblock,
19901987
.impl-items > section,
@@ -1993,10 +1990,7 @@ in storage.js
19931990
margin-bottom: 0.75em;
19941991
}
19951992

1996-
.method-toggle[open]:not(:last-child) {
1997-
margin-bottom: 2em;
1998-
}
1999-
1993+
.method-toggle[open]:not(:last-child),
20001994
.implementors-toggle[open]:not(:last-child) {
20011995
margin-bottom: 2em;
20021996
}

src/test/rustdoc-gui/docblock-details.goml

+11
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ assert-property: (".top-doc .docblock summary h4", {"offsetHeight": "33"})
2121
assert-css: (".top-doc .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"})
2222
// So `33 + 15 + 5` == `53`
2323
assert-property: (".top-doc .docblock summary", {"offsetHeight": "53"})
24+
25+
// We now check the `<summary>` on a method.
26+
assert-css: (
27+
".method-toggle .docblock summary h4",
28+
{"border-bottom-width": "0px"},
29+
)
30+
// This allows to ensure that summary is on one line only!
31+
assert-property: (".method-toggle .docblock summary h4", {"offsetHeight": "30"})
32+
assert-css: (".method-toggle .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"})
33+
// So `30 + 15 + 5` == `50`
34+
assert-property: (".method-toggle .docblock summary", {"offsetHeight": "50"})

src/test/rustdoc-gui/src/test_docs/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ pub mod details {
317317
/// <div>I'm the content of the details!</div>
318318
/// </details>
319319
pub struct Details;
320+
321+
impl Details {
322+
/// We check the appearance of the `<details>`/`<summary>` in here.
323+
///
324+
/// ## Hello
325+
///
326+
/// <details>
327+
/// <summary><h4>I'm a summary</h4></summary>
328+
/// <div>I'm the content of the details!</div>
329+
/// </details>
330+
pub fn method() {}
331+
}
320332
}
321333

322334
pub mod doc_block_table {

0 commit comments

Comments
 (0)