Skip to content

rustdoc: add missing margin to no-docblock methods #102521

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

Merged
merged 4 commits into from
Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
if toggled {
write!(w, "<details class=\"rustdoc-toggle method-toggle\" open><summary>");
}
write!(w, "<div id=\"{}\" class=\"method has-srclink\">", id);
write!(w, "<section id=\"{}\" class=\"method has-srclink\">", id);
render_rightside(w, cx, m, t, RenderMode::Normal);
write!(w, "<h4 class=\"code-header\">");
render_assoc_item(
Expand All @@ -730,7 +730,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
RenderMode::Normal,
);
w.write_str("</h4>");
w.write_str("</div>");
w.write_str("</section>");
if toggled {
write!(w, "</summary>");
w.push_buffer(content);
Expand Down
5 changes: 4 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,10 @@ in storage.js plus the media query with (min-width: 701px)
.method-toggle summary,
.implementors-toggle summary,
.impl,
#implementors-list > .docblock {
#implementors-list > .docblock,
.impl-items > section,
.methods > section
{
margin-bottom: 0.75em;
}

Expand Down
8 changes: 8 additions & 0 deletions src/test/rustdoc-gui/no-docblock.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This test checks that there are margins applied to methods with no docblocks.
goto: file://|DOC_PATH|/test_docs/trait.TraitWithNoDocblocks.html
// Check that the two methods are more than 24px apart.
compare-elements-position-near-false: ("//*[@id='tymethod.first_fn']", "//*[@id='tymethod.second_fn']", {"y": 24})

goto: file://|DOC_PATH|/test_docs/struct.TypeWithNoDocblocks.html
// Check that the two methods are more than 24px apart.
compare-elements-position-near-false: ("//*[@id='method.first_fn']", "//*[@id='method.second_fn']", {"y": 24})
12 changes: 12 additions & 0 deletions src/test/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,15 @@ impl<R: std::io::Read> std::iter::Iterator for NotableStructWithLongName<R> {

fn next(&mut self) -> Option<Self::Item> { () }
}

pub trait TraitWithNoDocblocks {
fn first_fn(&self);
fn second_fn(&self);
}

pub struct TypeWithNoDocblocks;

impl TypeWithNoDocblocks {
pub fn first_fn(&self) {}
pub fn second_fn(&self) {}
}