diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-09-30 23:38:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-30 23:38:27 +0200 |
| commit | 2fadfe0284370a31a453b8e90b9eb357475164f5 (patch) | |
| tree | 1c21fb853d1cdc2708b8be0980a371a354860787 | |
| parent | eaf1c7a0da0bb86eeaf983b8ad05ae471477bb84 (diff) | |
| parent | 8308c4bd359c4d300475055d67d5e1b0f6cd6856 (diff) | |
| download | rust-2fadfe0284370a31a453b8e90b9eb357475164f5.tar.gz rust-2fadfe0284370a31a453b8e90b9eb357475164f5.zip | |
Rollup merge of #102521 - notriddle:notriddle/impl-items-section, r=GuillaumeGomez
rustdoc: add missing margin to no-docblock methods Fixes another regression caused by 8846c0853d8687fda0e5f23f6687b03b243980ee, 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  # After  </details> See how it looks at https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc/clean/types/trait.AttributesExt.html <details> # Before  # After  </details>
| -rw-r--r-- | src/librustdoc/html/render/print_item.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/html/static/css/rustdoc.css | 5 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/no-docblock.goml | 8 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/sidebar-mobile-scroll.goml | 6 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src/test_docs/lib.rs | 12 | ||||
| -rw-r--r-- | src/test/rustdoc/anchors.no_const_anchor.html | 2 | ||||
| -rw-r--r-- | src/test/rustdoc/anchors.no_trait_method_anchor.html | 2 | ||||
| -rw-r--r-- | src/test/rustdoc/anchors.no_tymethod_anchor.html | 2 | ||||
| -rw-r--r-- | src/test/rustdoc/anchors.no_type_anchor.html | 2 | ||||
| -rw-r--r-- | src/test/rustdoc/rfc-2632-const-trait-impl.rs | 8 |
10 files changed, 37 insertions, 14 deletions
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 9f6b6b52536..7bd0dbf9325 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -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); diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 9e991cc03a0..2076c88bb02 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -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; } diff --git a/src/test/rustdoc-gui/no-docblock.goml b/src/test/rustdoc-gui/no-docblock.goml new file mode 100644 index 00000000000..2408be4534b --- /dev/null +++ b/src/test/rustdoc-gui/no-docblock.goml @@ -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}) diff --git a/src/test/rustdoc-gui/sidebar-mobile-scroll.goml b/src/test/rustdoc-gui/sidebar-mobile-scroll.goml index 9af7c636a0c..6cb492cfc64 100644 --- a/src/test/rustdoc-gui/sidebar-mobile-scroll.goml +++ b/src/test/rustdoc-gui/sidebar-mobile-scroll.goml @@ -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"} diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 1c066206c1f..0281973c1ba 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -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) {} +} diff --git a/src/test/rustdoc/anchors.no_const_anchor.html b/src/test/rustdoc/anchors.no_const_anchor.html index 4da1ffead2a..75e67330a3e 100644 --- a/src/test/rustdoc/anchors.no_const_anchor.html +++ b/src/test/rustdoc/anchors.no_const_anchor.html @@ -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> \ No newline at end of file +<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> \ No newline at end of file diff --git a/src/test/rustdoc/anchors.no_trait_method_anchor.html b/src/test/rustdoc/anchors.no_trait_method_anchor.html index 6b78c7c811a..d7bd525ff0f 100644 --- a/src/test/rustdoc/anchors.no_trait_method_anchor.html +++ b/src/test/rustdoc/anchors.no_trait_method_anchor.html @@ -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> \ No newline at end of file +<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> \ No newline at end of file diff --git a/src/test/rustdoc/anchors.no_tymethod_anchor.html b/src/test/rustdoc/anchors.no_tymethod_anchor.html index c08f4427cf6..e668e5e4db1 100644 --- a/src/test/rustdoc/anchors.no_tymethod_anchor.html +++ b/src/test/rustdoc/anchors.no_tymethod_anchor.html @@ -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> \ No newline at end of file +<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> \ No newline at end of file diff --git a/src/test/rustdoc/anchors.no_type_anchor.html b/src/test/rustdoc/anchors.no_type_anchor.html index ba8e65443ec..2c66d5aa315 100644 --- a/src/test/rustdoc/anchors.no_type_anchor.html +++ b/src/test/rustdoc/anchors.no_type_anchor.html @@ -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> \ No newline at end of file +<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> \ No newline at end of file diff --git a/src/test/rustdoc/rfc-2632-const-trait-impl.rs b/src/test/rustdoc/rfc-2632-const-trait-impl.rs index 8bd402291aa..602ee1b1b1f 100644 --- a/src/test/rustdoc/rfc-2632-const-trait-impl.rs +++ b/src/test/rustdoc/rfc-2632-const-trait-impl.rs @@ -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, |
