mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Rollup merge of #102521 - notriddle:notriddle/impl-items-section, r=GuillaumeGomez
rustdoc: add missing margin to no-docblock methods
Fixes another regression caused by 8846c0853d
, this time fixing the appearance of methods that have no docblock (we didn't notice this one because libstd docs *always* have docblocks).
See how it looks at https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc/clean/types/enum.Type.html#implementations
<details>
# Before
![image](https://user-images.githubusercontent.com/1593513/193318777-2bc082fb-6579-4bd8-a0e3-d23a32b4820f.png)
# After
![image](https://user-images.githubusercontent.com/1593513/193318968-b6ccacad-940b-4ed3-a0ae-dcf2079c2bae.png)
</details>
See how it looks at https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc/clean/types/trait.AttributesExt.html
<details>
# Before
![image](https://user-images.githubusercontent.com/1593513/193319636-7ff9c99e-0208-462c-99de-7672e92ce4d6.png)
# After
![image](https://user-images.githubusercontent.com/1593513/193322675-403bd165-7394-43e2-8ab4-d1f364666093.png)
</details>
This commit is contained in:
commit
2fadfe0284
@ -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(
|
||||
@ -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);
|
||||
|
@ -2006,7 +2006,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;
|
||||
}
|
||||
|
||||
|
8
src/test/rustdoc-gui/no-docblock.goml
Normal file
8
src/test/rustdoc-gui/no-docblock.goml
Normal file
@ -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})
|
@ -6,7 +6,7 @@ assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
||||
|
||||
// Scroll down.
|
||||
scroll-to: "//h2[@id='blanket-implementations']"
|
||||
assert-window-property: {"pageYOffset": "639"}
|
||||
assert-window-property: {"pageYOffset": "651"}
|
||||
|
||||
// Open the sidebar menu.
|
||||
click: ".sidebar-menu-toggle"
|
||||
@ -21,11 +21,11 @@ assert-window-property: {"pageYOffset": "0"}
|
||||
// Close the sidebar menu. Make sure the scroll position gets restored.
|
||||
click: ".sidebar-menu-toggle"
|
||||
wait-for-css: (".sidebar", {"left": "-1000px"})
|
||||
assert-window-property: {"pageYOffset": "639"}
|
||||
assert-window-property: {"pageYOffset": "651"}
|
||||
|
||||
// Now test that scrollability returns when the browser window is just resized.
|
||||
click: ".sidebar-menu-toggle"
|
||||
wait-for-css: (".sidebar", {"left": "0px"})
|
||||
assert-window-property: {"pageYOffset": "0"}
|
||||
size: (900, 600)
|
||||
assert-window-property: {"pageYOffset": "639"}
|
||||
assert-window-property: {"pageYOffset": "651"}
|
||||
|
@ -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) {}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<div id="associatedconstant.YOLO" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#16">source</a><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></div>
|
||||
<section id="associatedconstant.YOLO" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#16">source</a><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>
|
@ -1 +1 @@
|
||||
<div id="method.bar" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fnname">bar</a>()</h4></div>
|
||||
<section id="method.bar" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fnname">bar</a>()</h4></section>
|
@ -1 +1 @@
|
||||
<div id="tymethod.foo" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fnname">foo</a>()</h4></div>
|
||||
<section id="tymethod.foo" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fnname">foo</a>()</h4></section>
|
@ -1 +1 @@
|
||||
<div id="associatedtype.T" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#13">source</a><h4 class="code-header">type <a href="#associatedtype.T" class="associatedtype">T</a></h4></div>
|
||||
<section id="associatedtype.T" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#13">source</a><h4 class="code-header">type <a href="#associatedtype.T" class="associatedtype">T</a></h4></section>
|
@ -18,10 +18,10 @@ pub struct S<T>(T);
|
||||
// @has - '//pre[@class="rust trait"]/code/span[@class="where"]' ': Clone'
|
||||
#[const_trait]
|
||||
pub trait Tr<T> {
|
||||
// @!has - '//div[@id="method.a"]/h4[@class="code-header"]' '~const'
|
||||
// @has - '//div[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone'
|
||||
// @!has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const'
|
||||
// @has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
|
||||
// @!has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const'
|
||||
// @has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone'
|
||||
// @!has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const'
|
||||
// @has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
|
||||
fn a<A: ~const Clone + ~const Destruct>()
|
||||
where
|
||||
Option<A>: ~const Clone + ~const Destruct,
|
||||
|
Loading…
Reference in New Issue
Block a user