Skip to content

Commit 526c1d3

Browse files
committed
rustdoc: prevent method summary margin from being applied to docblocks
1 parent 0dbf233 commit 526c1d3

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1980,8 +1980,8 @@ in storage.js
19801980
}
19811981
}
19821982

1983-
.method-toggle summary,
1984-
.implementors-toggle summary,
1983+
.method-toggle > summary,
1984+
.implementors-toggle > summary,
19851985
.impl,
19861986
#implementors-list > .docblock,
19871987
.impl-items > section,

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)