Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1d9c998

Browse files
committedAug 20, 2024·
rustdoc: add three-column layout for large desktops
This commit adds a floating TOC box to the right, leaving the sibling/module/crate navigation on the left. This kicks in at a size a little below 1920x1080, where desktops with very wide monitors are: it's also around the point where the content area can be full width while allowing two sidebars. It only kicks in if the browser supports grid layouts, but that should be most of them, and we can't get rid of the two-column layout anyway, since it's the layout you get on something like a portrait iPad. This design, where it can be used, is meant to clearly split up the table of contents and the site navigation, so the right side floating box has the same color as the page while the left sidebar does not. It also pushes it down further, so that it's not as high as the search bar, though that's a bit more subtle than the color.
1 parent bead042 commit 1d9c998

File tree

9 files changed

+243
-73
lines changed

9 files changed

+243
-73
lines changed
 

‎src/librustdoc/html/static/css/rustdoc.css

Lines changed: 133 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ xmlns="http://www.w3.org/2000/svg" fill="black" height="18px">\
3434
</g></svg>');
3535
--button-left-margin: 4px;
3636
--button-border-radius: 2px;
37+
/* Used to manage the big screen three column layout */
38+
--width-limiter-width: 960px;
39+
--desktop-grid-column-gap: 45px;
40+
--container-border-radius: 6px;
41+
/* height of header, plus header margin, plus top logo section */
42+
--desktop-grid-toc-top: calc((1.25 * 1.5rem) + 76px + 23px);
43+
--desktop-grid-toc-max-width: 512px;
3744
}
3845

3946
/* See FiraSans-LICENSE.txt for the Fira Sans license. */
@@ -336,7 +343,7 @@ button#toggle-all-docs {
336343
main {
337344
position: relative;
338345
flex-grow: 1;
339-
padding: 10px 15px 40px 45px;
346+
padding: 10px 15px 40px var(--desktop-grid-column-gap);
340347
min-width: 0; /* avoid growing beyond the size limit */
341348
}
342349

@@ -345,7 +352,7 @@ main {
345352
}
346353

347354
.width-limiter {
348-
max-width: 960px;
355+
max-width: var(--width-limiter-width);
349356
margin-right: auto;
350357
}
351358

@@ -369,6 +376,7 @@ pre {
369376
}
370377
pre.item-decl {
371378
overflow-x: auto;
379+
border-radius: var(--container-border-radius);
372380
}
373381
/* This rule allows to have scrolling on the X axis. */
374382
.item-decl .type-contents-toggle {
@@ -460,7 +468,7 @@ img {
460468
.sidebar-resizing .sidebar {
461469
position: fixed;
462470
}
463-
.sidebar-resizing > body {
471+
.sidebar-resizing .rustdoc {
464472
padding-left: var(--resizing-sidebar-width);
465473
}
466474

@@ -534,7 +542,7 @@ img {
534542
scrollbar-width: initial;
535543
scrollbar-color: var(--scrollbar-color);
536544
}
537-
.sidebar {
545+
.sidebar, #rustdoc-toc section, #rustdoc-modnav section {
538546
scrollbar-width: thin;
539547
scrollbar-color: var(--scrollbar-color);
540548
}
@@ -543,17 +551,24 @@ img {
543551
::-webkit-scrollbar {
544552
width: 12px;
545553
}
546-
.sidebar::-webkit-scrollbar {
554+
.sidebar::-webkit-scrollbar,
555+
#rustdoc-toc section::-webkit-scrollbar,
556+
#rustdoc-modnav section::-webkit-scrollbar {
547557
width: 8px;
548558
}
549559
::-webkit-scrollbar-track {
550560
-webkit-box-shadow: inset 0;
551561
background-color: var(--scrollbar-track-background-color);
552562
}
553-
.sidebar::-webkit-scrollbar-track {
563+
.sidebar::-webkit-scrollbar-track,
564+
#rustdoc-toc section::-webkit-scrollbar-track,
565+
#rustdoc-modnav section::-webkit-scrollbar-track {
554566
background-color: var(--scrollbar-track-background-color);
555567
}
556-
::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb {
568+
::-webkit-scrollbar-thumb,
569+
.sidebar::-webkit-scrollbar-thumb,
570+
#rustdoc-toc section::-webkit-scrollbar-thumb,
571+
#rustdoc-modnav section::-webkit-scrollbar-thumb {
557572
background-color: var(--scrollbar-thumb-background-color);
558573
}
559574

@@ -742,7 +757,7 @@ ul.block, .block li, .block ul {
742757
overflow-wrap: break-word;
743758
}
744759

745-
.sidebar-crate + .version {
760+
.sidebar > .version {
746761
margin-top: -1rem;
747762
margin-bottom: 1rem;
748763
}
@@ -758,7 +773,7 @@ ul.block, .block li, .block ul {
758773
}
759774

760775
.rustdoc .example-wrap > pre {
761-
border-radius: 6px;
776+
border-radius: var(--container-border-radius);
762777
}
763778

764779
/* For the last child of a div, the margin will be taken care of
@@ -2006,6 +2021,115 @@ However, it's not needed with smaller screen width because the doc/code block is
20062021

20072022
/* Media Queries */
20082023

2024+
/* Very-large-screen mode. */
2025+
@supports (display: grid) and (display: contents) {
2026+
@media (min-width: 1600px) {
2027+
.rustdoc:not(.src) {
2028+
display: grid;
2029+
grid-template-columns:
2030+
var(--desktop-sidebar-width)
2031+
var(--width-limiter-width)
2032+
minmax(0, 1fr);
2033+
grid-template-rows: min-content 1fr;
2034+
grid-template-areas:
2035+
"sidebar-title main sidebar-cratenav"
2036+
"sidebar-modnav main sidebar-toc";
2037+
grid-column-gap: var(--desktop-grid-column-gap);
2038+
}
2039+
.sidebar-resizing .rustdoc:not(.src) {
2040+
padding-left: 0;
2041+
}
2042+
.hide-sidebar .rustdoc:not(.src) {
2043+
grid-template-columns:
2044+
var(--width-limiter-width)
2045+
minmax(0, 1fr);
2046+
grid-template-rows: minmax(min-content, calc(64px + 0.75rem)) 1fr;
2047+
grid-template-areas:
2048+
"main sidebar-cratenav"
2049+
"main sidebar-toc";
2050+
padding-left: var(--desktop-grid-column-gap);
2051+
}
2052+
.rustdoc:not(.src) .sidebar,
2053+
.rustdoc:not(.src) main {
2054+
display: contents;
2055+
}
2056+
.width-limiter {
2057+
grid-area: main;
2058+
width: var(--width-limiter-width);
2059+
--desktop-sidebar-width: 0;
2060+
}
2061+
.rustdoc:not(.src) nav.sub {
2062+
padding-top: 10px;
2063+
}
2064+
.rustdoc:not(.src) .doc-sidebar-title {
2065+
grid-area: sidebar-title;
2066+
background: var(--sidebar-background-color);
2067+
position: sticky;
2068+
top: 0;
2069+
}
2070+
.rustdoc:not(.src) .sidebar-crate {
2071+
margin-bottom: 0.5rem;
2072+
}
2073+
.rustdoc:not(.src) #rustdoc-toc,
2074+
.rustdoc:not(.src) #rustdoc-cratenav {
2075+
grid-area: sidebar-toc;
2076+
background: var(--main-background-color);
2077+
padding-left: 0;
2078+
}
2079+
.rustdoc:not(.src) #rustdoc-cratenav {
2080+
grid-area: sidebar-cratenav;
2081+
align-self: middle;
2082+
}
2083+
.rustdoc:not(.src) #rustdoc-modnav {
2084+
grid-area: sidebar-modnav;
2085+
background: var(--sidebar-background-color);
2086+
padding-left: 0;
2087+
}
2088+
.rustdoc:not(.src) #rustdoc-modnav .in-crate {
2089+
display: none;
2090+
}
2091+
.rustdoc:not(.src) #rustdoc-toc section,
2092+
.rustdoc:not(.src) #rustdoc-modnav section {
2093+
position: sticky;
2094+
top: 0;
2095+
bottom: 0;
2096+
overflow-y: scroll;
2097+
overscroll-behavior: contain;
2098+
max-height: 100vh;
2099+
padding-left: 24px;
2100+
}
2101+
.rustdoc:not(.src) #rustdoc-toc .location,
2102+
.rustdoc:not(.src) #rustdoc-modnav h2 {
2103+
margin-top: 0;
2104+
}
2105+
.rustdoc:not(.src) #rustdoc-modnav section {
2106+
top: calc(64px + 0.75rem);
2107+
height: calc(100vh - 64px - 0.75rem);
2108+
background: var(--sidebar-background-color);
2109+
}
2110+
.rustdoc:not(.src) #rustdoc-modnav section.scrolled {
2111+
border-top: solid 1px var(--border-color);
2112+
}
2113+
.rustdoc:not(.src) #rustdoc-toc section {
2114+
max-height: calc(100vh - (2 * var(--desktop-grid-toc-top)));
2115+
top: var(--desktop-grid-toc-top);
2116+
margin: 0 var(--desktop-grid-column-gap) var(--desktop-grid-column-gap) 0;
2117+
border: solid 1px var(--border-color);
2118+
padding: 14px 0 14px var(--sidebar-elems-left-padding);
2119+
border-radius: var(--container-border-radius);
2120+
max-width: var(--desktop-grid-toc-max-width);
2121+
}
2122+
.rustdoc:not(.src) #rustdoc-cratenav .block:last-child,
2123+
.rustdoc:not(.src) #rustdoc-toc .block:last-child {
2124+
margin-bottom: 0;
2125+
}
2126+
.rustdoc:not(.src) #rustdoc-cratenav a:hover,
2127+
.rustdoc:not(.src) #rustdoc-toc a:hover {
2128+
background-color: var(--sidebar-background-color);
2129+
}
2130+
}
2131+
}
2132+
20092133
/* Make sure all the buttons line wrap at the same time */
20102134
@media (max-width: 850px) {
20112135
#search-tabs .count {

‎src/librustdoc/html/static/js/main.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ function preLoadCss(cssUrl) {
499499
if (!window.SIDEBAR_ITEMS) {
500500
return;
501501
}
502-
const sidebar = document.getElementById("rustdoc-modnav");
502+
const sidebar = document.querySelector("#rustdoc-modnav section");
503503

504504
/**
505505
* Append to the sidebar a "block" of links - a heading along with a list (`<ul>`) of items.
@@ -539,8 +539,9 @@ function preLoadCss(cssUrl) {
539539
const li = document.createElement("li");
540540
// Don't "optimize" this to just use `path`.
541541
// We want the browser to normalize this into an absolute URL.
542-
if (link.href === current_page) {
543-
li.classList.add("current");
542+
if (link.href.toString() === current_page) {
543+
link.className = "current";
544+
li.className = "current";
544545
}
545546
li.appendChild(link);
546547
ul.appendChild(li);
@@ -885,7 +886,7 @@ function preLoadCss(cssUrl) {
885886
if (!window.ALL_CRATES) {
886887
return;
887888
}
888-
const sidebarElems = document.getElementById("rustdoc-modnav");
889+
const sidebarElems = document.querySelector("#rustdoc-modnav section");
889890
if (!sidebarElems) {
890891
return;
891892
}
@@ -1549,6 +1550,23 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
15491550
// At half-way past the minimum size, vanish the sidebar entirely
15501551
const SIDEBAR_VANISH_THRESHOLD = SIDEBAR_MIN / 2;
15511552

1553+
// When running in grid layout mode, we have to change sizes
1554+
// on the parent element. Otherwise, we can resize the sidebar
1555+
// independently.
1556+
//
1557+
// This is less bad than it otherwise would be, since if you are in grid
1558+
// mode, resizing the sidebar will resize the floating TOC, not the huge
1559+
// content area.
1560+
let gridMode = window.getComputedStyle(document.querySelector(".rustdoc")).display === "grid";
1561+
1562+
// Scroll border between modnav and logo lockup (this is only used in gridmode).
1563+
const modNavSection = document.querySelector("#rustdoc-modnav section");
1564+
if (modNavSection) {
1565+
modNavSection.onscroll = function() {
1566+
(this.scrollTop === 0 ? removeClass : addClass)(this, "scrolled");
1567+
};
1568+
}
1569+
15521570
// Toolbar button to show the sidebar.
15531571
//
15541572
// On small, "mobile-sized" viewports, it's not persistent and it
@@ -1669,6 +1687,9 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
16691687
updateLocalStorage("desktop-sidebar-width", size);
16701688
sidebar.style.setProperty("--desktop-sidebar-width", size + "px");
16711689
resizer.style.setProperty("--desktop-sidebar-width", size + "px");
1690+
if (gridMode) {
1691+
document.documentElement.style.setProperty("--desktop-sidebar-width", size + "px");
1692+
}
16721693
}
16731694
}
16741695

@@ -1720,6 +1741,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
17201741
if (window.innerWidth < RUSTDOC_MOBILE_BREAKPOINT) {
17211742
return;
17221743
}
1744+
gridMode = window.getComputedStyle(document.querySelector(".rustdoc")).display === "grid";
17231745
stopResize();
17241746
if (desiredSidebarSize >= (window.innerWidth - BODY_MIN)) {
17251747
changeSidebarSize(window.innerWidth - BODY_MIN);

‎src/librustdoc/html/templates/page.html

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,24 @@
8787
{% endif %}
8888
<nav class="sidebar"> {# #}
8989
{% if page.css_class != "src" %}
90-
<div class="sidebar-crate">
91-
{% if !layout.logo.is_empty() || page.rust_logo %}
92-
<a class="logo-container" href="{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html"> {# #}
93-
{% if page.rust_logo %}
94-
<img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {# #}
95-
{% else if !layout.logo.is_empty() %}
96-
<img src="{{layout.logo}}" alt="logo"> {# #}
90+
<div class="doc-sidebar-title">
91+
<div class="sidebar-crate">
92+
{% if !layout.logo.is_empty() || page.rust_logo %}
93+
<a class="logo-container" href="{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html"> {# #}
94+
{% if page.rust_logo %}
95+
<img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {# #}
96+
{% else if !layout.logo.is_empty() %}
97+
<img src="{{layout.logo}}" alt="logo"> {# #}
98+
{% endif %}
99+
</a> {# #}
97100
{% endif %}
98-
</a> {# #}
99-
{% endif %}
100-
<h2> {# #}
101-
<a href="{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html">{{display_krate|wrapped|safe}}</a> {# #}
102-
{% if !display_krate_version_number.is_empty() %}
103-
<span class="version">{{+ display_krate_version_number}}</span>
104-
{% endif %}
105-
</h2> {# #}
101+
<h2> {# #}
102+
<a href="{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html">{{display_krate|wrapped|safe}}</a> {# #}
103+
{% if !display_krate_version_number.is_empty() %}
104+
<span class="version">{{+ display_krate_version_number}}</span>
105+
{% endif %}
106+
</h2> {# #}
107+
</div> {# #}
106108
</div> {# #}
107109
{% if !display_krate_version_extra.is_empty() %}
108110
<div class="version">{{+ display_krate_version_extra}}</div> {# #}

‎src/librustdoc/html/templates/sidebar.html

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
<div class="sidebar-elems">
2-
{% if is_crate %}
3-
<ul class="block"> {# #}
1+
{% if is_crate %}
2+
<div class="sidebar-elems" id="rustdoc-cratenav">
3+
<ul class="block">
44
<li><a id="all-types" href="all.html">All Items</a></li> {# #}
55
</ul>
6-
{% endif %}
7-
8-
{% if self.should_render_blocks() %}
9-
<section id="rustdoc-toc">
6+
</div>
7+
{% endif %}
8+
{% if self.should_render_blocks() %}
9+
<div class="sidebar-elems" id="rustdoc-toc">
10+
<section>
1011
{% if !title.is_empty() %}
1112
<h2 class="location"> {# #}
1213
<a href="#">{{title_prefix}}{{title|wrapped|safe}}</a> {# #}
@@ -52,12 +53,14 @@ <h3> {# #}
5253
{% endif %}
5354
{% endfor %}
5455
</section>
55-
{% endif %}
56-
<div id="rustdoc-modnav">
56+
</div>
57+
{% endif %}
58+
<div class="sidebar-elems" id="rustdoc-modnav">
59+
<section>
5760
{% if !path.is_empty() %}
5861
<h2{% if parent_is_crate +%} class="in-crate"{% endif %}> {# #}
5962
<a href="{% if is_mod %}../{% endif %}index.html">In {{+ path|wrapped|safe}}</a> {# #}
6063
</h2>
6164
{% endif %}
62-
</div> {# #}
65+
</section> {# #}
6366
</div>

‎tests/rustdoc-gui/sidebar-modnav-position.goml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
// because the sibling module nav is in exactly the same place every time,
1010
// it's very easy to find and switch between pages that way.
1111

12+
// First, in tablet-ish mode
1213
go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html"
14+
set-window-size: (1280, 800)
1315
show-text: true
1416
set-local-storage: {"rustdoc-hide-toc": "true"}
1517

@@ -19,26 +21,43 @@ define-function: (
1921
block {
2022
go-to: "file://" + |DOC_PATH| + |url|
2123
// Checking results colors.
22-
assert-position: ("#rustdoc-modnav > h2", {"x": |h2_x|, "y": |h2_y|})
24+
assert-position: ("#rustdoc-modnav > section > h2", {"x": |h2_x|, "y": |h2_y|})
2325
assert-position: (
24-
"#rustdoc-modnav > ul:first-of-type > li:first-of-type",
26+
"#rustdoc-modnav > section > ul:first-of-type > li:first-of-type",
2527
{"x": |x|, "y": |y|}
2628
)
2729
},
2830
)
2931

3032
// First, at test_docs root
3133
go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html"
32-
store-position: ("#rustdoc-modnav > h2", {"x": h2_x, "y": h2_y})
33-
store-position: ("#rustdoc-modnav > ul:first-of-type > li:first-of-type", {"x": x, "y": y})
34+
store-position: ("#rustdoc-modnav > section > h2", {"x": h2_x, "y": h2_y})
35+
store-position: ("#rustdoc-modnav > section > ul:first-of-type > li:first-of-type", {"x": x, "y": y})
3436
call-function: ("check-positions", {"url": "/test_docs/enum.WhoLetTheDogOut.html"})
3537
call-function: ("check-positions", {"url": "/test_docs/struct.StructWithPublicUndocumentedFields.html"})
3638
call-function: ("check-positions", {"url": "/test_docs/codeblock_sub/index.html"})
3739

3840
// Now in a submodule
3941
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/struct.Struct.html"
40-
store-position: ("#rustdoc-modnav > h2", {"x": h2_x, "y": h2_y})
41-
store-position: ("#rustdoc-modnav > ul:first-of-type > li:first-of-type", {"x": x, "y": y})
42+
store-position: ("#rustdoc-modnav > section > h2", {"x": h2_x, "y": h2_y})
43+
store-position: ("#rustdoc-modnav > section > ul:first-of-type > li:first-of-type", {"x": x, "y": y})
4244
call-function: ("check-positions", {"url": "/test_docs/fields/struct.Struct.html"})
4345
call-function: ("check-positions", {"url": "/test_docs/fields/union.Union.html"})
4446
call-function: ("check-positions", {"url": "/test_docs/fields/enum.Enum.html"})
47+
48+
// Now try similar, but in desktop-ish mode
49+
// Unlike in tablet mode, desktop mode pulls the TOC out of the main left sidebar into its own pane,
50+
// so modnav (which remains in the left sidebar) doesn't move regardless.
51+
// It also has the same position as the item-decl.
52+
set-local-storage: {"rustdoc-hide-toc": "false"}
53+
set-window-size: (1920, 1080)
54+
go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html"
55+
store-position: ("#rustdoc-modnav > section > h2", {"x": h2_x, "y": h2_y})
56+
store-position: ("#rustdoc-modnav > section > ul:first-of-type > li:first-of-type", {"x": x, "y": y})
57+
call-function: ("check-positions", {"url": "/test_docs/enum.WhoLetTheDogOut.html"})
58+
compare-elements-position: ("#rustdoc-toc > section", ".item-decl", ["y"])
59+
compare-elements-css: ("#rustdoc-toc > section", ".item-decl", ["border-radius"])
60+
call-function: ("check-positions", {"url": "/test_docs/struct.StructWithPublicUndocumentedFields.html"})
61+
compare-elements-position: ("#rustdoc-toc > section", ".item-decl", ["y"])
62+
compare-elements-css: ("#rustdoc-toc > section", ".item-decl", ["border-radius"])
63+
call-function: ("check-positions", {"url": "/test_docs/codeblock_sub/index.html"})

‎tests/rustdoc-gui/sidebar.goml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ call-function: (
4545

4646
call-function: ("switch-theme", {"theme": "light"})
4747

48-
assert-text: (".sidebar > .sidebar-crate > h2 > a", "test_docs")
48+
assert-text: (".sidebar-crate > h2 > a", "test_docs")
4949
// Crate root has no "location" element
5050
assert-count: (".sidebar .location", 0)
5151
assert-count: (".sidebar h2", 1)
@@ -69,7 +69,7 @@ assert-text: ("#structs + .item-table .item-name > a", "Foo")
6969
click: "#structs + .item-table .item-name > a"
7070

7171
// PAGE: struct.Foo.html
72-
assert-count: (".sidebar .sidebar-crate", 1)
72+
assert-count: (".sidebar-crate", 1)
7373
assert-count: (".sidebar .location", 1)
7474
assert-count: (".sidebar h2", 3)
7575
assert-text: (".sidebar-elems ul.block > li.current > a", "Foo")
@@ -91,7 +91,7 @@ click: ".sidebar-elems ul.crate > li:first-child > a"
9191
// PAGE: lib2/index.html
9292
go-to: "file://" + |DOC_PATH| + "/lib2/index.html"
9393
assert-property: (".sidebar", {"clientWidth": "200"})
94-
assert-text: (".sidebar > .sidebar-crate > h2 > a", "lib2")
94+
assert-text: (".sidebar-crate > h2 > a", "lib2")
9595
assert-count: (".sidebar .location", 0)
9696
// We check that we have the crates list and that the "current" on is now "lib2".
9797
assert-text: (".sidebar-elems ul.crate > li.current > a", "lib2")
@@ -108,7 +108,7 @@ click: "#functions + .item-table .item-name > a"
108108
// In items containing no items (like functions or constants) and in modules, we have no
109109
// "location" elements. Only the crate and optional parent module.
110110
// This page, being directly below the crate, only has its heading.
111-
assert-text: (".sidebar > .sidebar-crate > h2 > a", "lib2")
111+
assert-text: (".sidebar-crate > h2 > a", "lib2")
112112
assert-count: (".sidebar .location", 0)
113113
assert-count: (".sidebar h2", 1)
114114
assert-text: (".sidebar-elems ul.block > li.current > a", "foobar")
@@ -117,7 +117,7 @@ assert-false: ".sidebar-elems > .crate"
117117

118118
go-to: "./module/index.html"
119119
assert-property: (".sidebar", {"clientWidth": "200"})
120-
assert-text: (".sidebar > .sidebar-crate > h2 > a", "lib2")
120+
assert-text: (".sidebar-crate > h2 > a", "lib2")
121121
assert-text: (".sidebar .location", "Module module")
122122
assert-count: (".sidebar .location", 1)
123123
assert-text: (".sidebar-elems ul.block > li.current > a", "module")
@@ -126,19 +126,19 @@ assert-text: (".sidebar-elems ul.block > li.current > a", "module")
126126
// - Module name, followed by TOC for module headings
127127
// - "In crate [name]" parent pointer, followed by sibling navigation
128128
assert-count: (".sidebar h2", 3)
129-
assert-text: (".sidebar > .sidebar-elems > #rustdoc-modnav > h2", "In crate lib2")
130-
assert-property: (".sidebar > .sidebar-elems > #rustdoc-modnav > h2 > a", {
129+
assert-text: ("#rustdoc-modnav > section > h2", "In crate lib2")
130+
assert-property: ("#rustdoc-modnav > section > h2 > a", {
131131
"href": "/lib2/index.html",
132132
}, ENDS_WITH)
133133
// We check that we don't have the crate list.
134134
assert-false: ".sidebar-elems > .crate"
135135

136136
go-to: "./sub_module/sub_sub_module/index.html"
137137
assert-property: (".sidebar", {"clientWidth": "200"})
138-
assert-text: (".sidebar > .sidebar-crate > h2 > a", "lib2")
138+
assert-text: (".sidebar-crate > h2 > a", "lib2")
139139
assert-text: (".sidebar .location", "Module sub_sub_module")
140-
assert-text: (".sidebar > .sidebar-elems > #rustdoc-modnav > h2", "In lib2::module::sub_module")
141-
assert-property: (".sidebar > .sidebar-elems > #rustdoc-modnav > h2 > a", {
140+
assert-text: ("#rustdoc-modnav > section > h2", "In lib2::module::sub_module")
141+
assert-property: ("#rustdoc-modnav > section > h2 > a", {
142142
"href": "/module/sub_module/index.html",
143143
}, ENDS_WITH)
144144
assert-text: (".sidebar-elems ul.block > li.current > a", "sub_sub_module")
@@ -170,14 +170,14 @@ assert-property: (".sidebar", {"clientWidth": "200"})
170170

171171
// Checks that all.html and index.html have their sidebar link in the same place.
172172
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
173-
store-property: (".sidebar .sidebar-crate h2 a", {
173+
store-property: (".sidebar-crate h2 a", {
174174
"clientWidth": index_sidebar_width,
175175
"clientHeight": index_sidebar_height,
176176
"offsetTop": index_sidebar_y,
177177
"offsetLeft": index_sidebar_x,
178178
})
179179
go-to: "file://" + |DOC_PATH| + "/test_docs/all.html"
180-
assert-property: (".sidebar .sidebar-crate h2 a", {
180+
assert-property: (".sidebar-crate h2 a", {
181181
"clientWidth": |index_sidebar_width|,
182182
"clientHeight": |index_sidebar_height|,
183183
"offsetTop": |index_sidebar_y|,

‎tests/rustdoc/sidebar/module.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#![crate_name = "foo"]
22

33
//@ has 'foo/index.html'
4-
//@ has - '//section[@id="rustdoc-toc"]/h3' 'Crate Items'
4+
//@ has - '//div[@id="rustdoc-toc"]/section/h3' 'Crate Items'
55

66
//@ has 'foo/bar/index.html'
7-
//@ has - '//section[@id="rustdoc-toc"]/h3' 'Module Items'
7+
//@ has - '//div[@id="rustdoc-toc"]/section/h3' 'Module Items'
88
pub mod bar {
99
//@ has 'foo/bar/struct.Baz.html'
10-
//@ !has - '//section[@id="rustdoc-toc"]/h3' 'Module Items'
10+
//@ !has - '//div[@id="rustdoc-toc"]/section/h3' 'Module Items'
1111
pub struct Baz;
1212
}
1313

1414
//@ has 'foo/baz/index.html'
15-
//@ !has - '//section[@id="rustdoc-toc"]/h3' 'Module Items'
15+
//@ !has - '//div[@id="rustdoc-toc"]/section/h3' 'Module Items'
1616
pub mod baz {}

‎tests/rustdoc/sidebar/top-toc-html.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
1515
//@ has foo/index.html
1616
// User header
17-
//@ has - '//section[@id="rustdoc-toc"]/h3' 'Sections'
18-
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/@title' 'Basic link, emphasis, very emphasis and `code`'
19-
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]' 'Basic link, emphasis, very emphasis and code'
20-
//@ count - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/em' 0
21-
//@ count - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/a' 0
22-
//@ count - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/code' 1
23-
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/code' 'code'
17+
//@ has - '//div[@id="rustdoc-toc"]//h3' 'Sections'
18+
//@ has - '//div[@id="rustdoc-toc"]//ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/@title' 'Basic link, emphasis, very emphasis and `code`'
19+
//@ has - '//div[@id="rustdoc-toc"]//ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]' 'Basic link, emphasis, very emphasis and code'
20+
//@ count - '//div[@id="rustdoc-toc"]//ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/em' 0
21+
//@ count - '//div[@id="rustdoc-toc"]//ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/a' 0
22+
//@ count - '//div[@id="rustdoc-toc"]//ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/code' 1
23+
//@ has - '//div[@id="rustdoc-toc"]//ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/code' 'code'

‎tests/rustdoc/sidebar/top-toc-idmap.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
1717
//@ has foo/index.html
1818
// User header
19-
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#structs"]' 'Structs'
19+
//@ has - '//div[@id="rustdoc-toc"]//ul[@class="block top-toc"]/li/a[@href="#structs"]' 'Structs'
2020
//@ has - '//details[@class="toggle top-doc"]/div[@class="docblock"]/h2[@id="structs"]' 'Structs'
2121
// Built-in header
22-
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block"]/li/a[@href="#structs-1"]' 'Structs'
23-
//@ has - '//section[@id="main-content"]/h2[@id="structs-1"]' 'Structs'
22+
//@ has - '//div[@id="rustdoc-toc"]//ul[@class="block"]/li/a[@href="#structs-1"]' 'Structs'
23+
//@ has - '//section[@id="main-content"]//h2[@id="structs-1"]' 'Structs'
2424

2525
/// # Fields
2626
/// ## Fields
@@ -31,12 +31,12 @@
3131
3232
//@ has foo/struct.MyStruct.html
3333
// User header
34-
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#fields-1"]' 'Fields'
34+
//@ has - '//div[@id="rustdoc-toc"]//ul[@class="block top-toc"]/li/a[@href="#fields-1"]' 'Fields'
3535
//@ has - '//details[@class="toggle top-doc"]/div[@class="docblock"]/h2[@id="fields-1"]' 'Fields'
3636
// Only one level of nesting
37-
//@ count - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]//a' 2
37+
//@ count - '//div[@id="rustdoc-toc"]//ul[@class="block top-toc"]//a' 2
3838
// Built-in header
39-
//@ has - '//section[@id="rustdoc-toc"]/h3/a[@href="#fields"]' 'Fields'
39+
//@ has - '//div[@id="rustdoc-toc"]//h3/a[@href="#fields"]' 'Fields'
4040
//@ has - '//section[@id="main-content"]/h2[@id="fields"]' 'Fields'
4141

4242
pub struct MyStruct {

0 commit comments

Comments
 (0)
Please sign in to comment.