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

rustdoc: add margins to all impl-item toggles, not just methods #103793

Merged
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
14 changes: 8 additions & 6 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1961,24 +1961,26 @@ in storage.js
}
}

.method-toggle > summary,
.implementors-toggle > summary,
.impl,
#implementors-list > .docblock,
.impl-items > section,
.methods > section
.impl-items > .rustdoc-toggle > summary,
.methods > section,
.methods > .rustdoc-toggle > summary
{
margin-bottom: 0.75em;
}

.method-toggle[open]:not(:last-child),
.impl-items > .rustdoc-toggle[open]:not(:last-child),
.methods > .rustdoc-toggle[open]:not(:last-child),
.implementors-toggle[open]:not(:last-child) {
margin-bottom: 2em;
}

#trait-implementations-list .method-toggle:not(:last-child),
#synthetic-implementations-list .method-toggle:not(:last-child),
#blanket-implementations-list .method-toggle:not(:last-child) {
#trait-implementations-list .impl-items > .rustdoc-toggle:not(:last-child),
#synthetic-implementations-list .impl-items > .rustdoc-toggle:not(:last-child),
#blanket-implementations-list .impl-items > .rustdoc-toggle:not(:last-child) {
margin-bottom: 1em;
}

Expand Down
17 changes: 17 additions & 0 deletions src/test/rustdoc-gui/method-margins.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
goto: "file://" + |DOC_PATH| + "/test_docs/trait_members/struct.HasTrait.html#impl-TraitMembers-for-HasTrait"

assert-count: ("#trait-implementations-list > .rustdoc-toggle", 1)

compare-elements-css: (
// compare margin on type with margin on method
"#trait-implementations-list .impl-items > .rustdoc-toggle:nth-child(1) > summary",
"#trait-implementations-list .impl-items > .rustdoc-toggle:nth-child(2) > summary",
["margin"]
)

compare-elements-css: (
// compare margin on type with margin on method
"#trait-implementations-list .impl-items > .rustdoc-toggle:nth-child(1)",
"#trait-implementations-list .impl-items > .rustdoc-toggle:nth-child(2)",
["margin"]
)
17 changes: 17 additions & 0 deletions src/test/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,20 @@ pub trait TraitWithoutGenerics {

fn foo();
}

pub mod trait_members {
pub trait TraitMembers {
/// Some type
type Type;
/// Some function
fn function();
/// Some other function
fn function2();
}
pub struct HasTrait;
impl TraitMembers for HasTrait {
type Type = u8;
fn function() {}
fn function2() {}
}
}