Skip to content

Commit

Permalink
Rollup merge of rust-lang#103793 - notriddle:notriddle/rustdoc-toggle…
Browse files Browse the repository at this point in the history
…-in-impl-items, r=GuillaumeGomez

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

Fixes rust-lang#103782

## Before

![image](https://user-images.githubusercontent.com/1593513/198943087-8cab8b25-2092-49d6-89b4-caa2989dedf0.png)

## After

![image](https://user-images.githubusercontent.com/1593513/198943111-bc08c2d6-f058-4362-b999-0caf09eb93bf.png)
  • Loading branch information
Yuki Okushi authored Nov 1, 2022
2 parents ff89cec + 492ee6a commit 2c7f137
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
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 @@ -1968,24 +1968,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() {}
}
}

0 comments on commit 2c7f137

Please sign in to comment.