Skip to content

Commit 514e77b

Browse files
authored
Rollup merge of rust-lang#102447 - notriddle:notriddle/method-toggle, r=jsha
rustdoc: add method spacing to trait methods More cleanup for 8846c08, this time in trait layouts when things are collapsed. This PR makes two changes to the appearance of trait pages: * It adds the `method-toggle` class to method toggles on traits, making the DOM more consistent with type pages (which already have this class). ## Before ![image](https://user-images.githubusercontent.com/1593513/192914353-ed17e1eb-df1d-480b-9998-3b5e8283b0ee.png) ## After ![image](https://user-images.githubusercontent.com/1593513/192914570-bdd0f2e1-5254-4e2e-9576-a797b82b3b3b.png) * It adds a bottom margin to docblocks nested directly in the implementors list, giving it a similar appearance to if it was nested within a toggle. ## Before ![image](https://user-images.githubusercontent.com/1593513/192914503-1c3f39d5-690f-44ec-8f11-385302477d04.png) ## After ![image](https://user-images.githubusercontent.com/1593513/192914702-cbce4b3b-5cc6-49dc-b7f8-73be9e76791c.png)
2 parents d29b695 + 0b9b4b7 commit 514e77b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/librustdoc/html/render/print_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
716716
document(&mut content, cx, m, Some(t), HeadingOffset::H5);
717717
let toggled = !content.is_empty();
718718
if toggled {
719-
write!(w, "<details class=\"rustdoc-toggle\" open><summary>");
719+
write!(w, "<details class=\"rustdoc-toggle method-toggle\" open><summary>");
720720
}
721721
write!(w, "<div id=\"{}\" class=\"method has-srclink\">", id);
722722
render_rightside(w, cx, m, t, RenderMode::Normal);

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,8 @@ in storage.js plus the media query with (min-width: 701px)
20142014

20152015
.method-toggle summary,
20162016
.implementors-toggle summary,
2017-
.impl {
2017+
.impl,
2018+
#implementors-list > .docblock {
20182019
margin-bottom: 0.75em;
20192020
}
20202021

src/test/rustdoc/toggle-trait-fn.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
// summary. Trait methods with no documentation should not be wrapped.
55
//
66
// @has foo/trait.Foo.html
7-
// @has - '//details[@class="rustdoc-toggle"]//summary//h4[@class="code-header"]' 'is_documented()'
8-
// @!has - '//details[@class="rustdoc-toggle"]//summary//h4[@class="code-header"]' 'not_documented()'
9-
// @has - '//details[@class="rustdoc-toggle"]//*[@class="docblock"]' 'is_documented is documented'
10-
// @has - '//details[@class="rustdoc-toggle"]//summary//h4[@class="code-header"]' 'is_documented_optional()'
11-
// @!has - '//details[@class="rustdoc-toggle"]//summary//h4[@class="code-header"]' 'not_documented_optional()'
12-
// @has - '//details[@class="rustdoc-toggle"]//*[@class="docblock"]' 'is_documented_optional is documented'
7+
// @has - '//details[@class="rustdoc-toggle method-toggle"]//summary//h4[@class="code-header"]' 'is_documented()'
8+
// @!has - '//details[@class="rustdoc-toggle method-toggle"]//summary//h4[@class="code-header"]' 'not_documented()'
9+
// @has - '//details[@class="rustdoc-toggle method-toggle"]//*[@class="docblock"]' 'is_documented is documented'
10+
// @has - '//details[@class="rustdoc-toggle method-toggle"]//summary//h4[@class="code-header"]' 'is_documented_optional()'
11+
// @!has - '//details[@class="rustdoc-toggle method-toggle"]//summary//h4[@class="code-header"]' 'not_documented_optional()'
12+
// @has - '//details[@class="rustdoc-toggle method-toggle"]//*[@class="docblock"]' 'is_documented_optional is documented'
1313
pub trait Foo {
1414
fn not_documented();
1515

0 commit comments

Comments
 (0)