Rollup merge of #92795 - jsha:link-to-top, r=GuillaumeGomez
Link sidebar "location" heading to top of page This makes it easy, when you are scrolled far down in a page, to jump back to the top. Demo: https://rustdoc.crud.net/jsha/link-to-top/std/string/struct.String.html r? ``@GuillaumeGomez``
This commit is contained in:
commit
869b7bc5e7
2 changed files with 8 additions and 1 deletions
|
@ -1736,7 +1736,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
|
||||||
{
|
{
|
||||||
write!(
|
write!(
|
||||||
buffer,
|
buffer,
|
||||||
"<h2 class=\"location\">{}{}</h2>",
|
"<h2 class=\"location\"><a href=\"#\">{}{}</a></h2>",
|
||||||
match *it.kind {
|
match *it.kind {
|
||||||
clean::StructItem(..) => "Struct ",
|
clean::StructItem(..) => "Struct ",
|
||||||
clean::TraitItem(..) => "Trait ",
|
clean::TraitItem(..) => "Trait ",
|
||||||
|
|
|
@ -22,6 +22,13 @@ click: "#structs + .item-table .item-left > a"
|
||||||
assert-count: (".sidebar .location", 2)
|
assert-count: (".sidebar .location", 2)
|
||||||
// We check that there is no crate listed outside of the top level.
|
// We check that there is no crate listed outside of the top level.
|
||||||
assert-false: ".sidebar-elems > .crate"
|
assert-false: ".sidebar-elems > .crate"
|
||||||
|
|
||||||
|
click: ".sidebar-links a"
|
||||||
|
assert-property: ("html", {"scrollTop": "389"})
|
||||||
|
|
||||||
|
click: ".sidebar h2.location"
|
||||||
|
assert-property: ("html", {"scrollTop": "0"})
|
||||||
|
|
||||||
// We now go back to the crate page to click on the "lib2" crate link.
|
// We now go back to the crate page to click on the "lib2" crate link.
|
||||||
goto: file://|DOC_PATH|/test_docs/index.html
|
goto: file://|DOC_PATH|/test_docs/index.html
|
||||||
click: ".sidebar-elems .crate > ul > li:first-child > a"
|
click: ".sidebar-elems .crate > ul > li:first-child > a"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue