rustdoc: use src consistently over source in code

The CSS uses an inconsistent mix of both. This commit switches
it to always use `src`.
This commit is contained in:
Michael Howell 2023-07-14 16:38:01 -07:00
parent ad963232d9
commit 34bc8fbea3
27 changed files with 129 additions and 129 deletions

View file

@ -1821,9 +1821,9 @@ fn render_rightside(
); );
if let Some(l) = src_href { if let Some(l) = src_href {
if has_stability { if has_stability {
write!(rightside, " · <a class=\"srclink\" href=\"{}\">source</a>", l) write!(rightside, " · <a class=\"src\" href=\"{}\">source</a>", l)
} else { } else {
write!(rightside, "<a class=\"srclink rightside\" href=\"{}\">source</a>", l) write!(rightside, "<a class=\"src rightside\" href=\"{}\">source</a>", l)
} }
} }
if has_stability && has_src_ref { if has_stability && has_src_ref {

View file

@ -227,7 +227,7 @@ impl SourceCollector<'_, '_> {
let desc = format!("Source of the Rust file `{}`.", filename.prefer_remapped()); let desc = format!("Source of the Rust file `{}`.", filename.prefer_remapped());
let page = layout::Page { let page = layout::Page {
title: &title, title: &title,
css_class: "source", css_class: "src",
root_path: &root_path, root_path: &root_path,
static_root_path: shared.static_root_path.as_deref(), static_root_path: shared.static_root_path.as_deref(),
description: &desc, description: &desc,

View file

@ -19,7 +19,7 @@ nav.sub {
display: none; display: none;
} }
.source .sidebar { .src .sidebar {
display: none; display: none;
} }

View file

@ -194,7 +194,7 @@ h1, h2, h3, h4, h5, h6,
.item-name > a, .item-name > a,
.out-of-band, .out-of-band,
span.since, span.since,
a.srclink, a.src,
#help-button > a, #help-button > a,
summary.hideme, summary.hideme,
.scraped-example-list, .scraped-example-list,
@ -206,7 +206,7 @@ ul.all-items {
#toggle-all-docs, #toggle-all-docs,
a.anchor, a.anchor,
.small-section-header a, .small-section-header a,
#source-sidebar a, #src-sidebar a,
.rust a, .rust a,
.sidebar h2 a, .sidebar h2 a,
.sidebar h3 a, .sidebar h3 a,
@ -315,7 +315,7 @@ main {
min-width: 0; /* avoid growing beyond the size limit */ min-width: 0; /* avoid growing beyond the size limit */
} }
.source main { .src main {
padding: 15px; padding: 15px;
} }
@ -350,10 +350,10 @@ pre.item-decl {
contain: initial; contain: initial;
} }
.source .content pre { .src .content pre {
padding: 20px; padding: 20px;
} }
.rustdoc.source .example-wrap pre.src-line-numbers { .rustdoc.src .example-wrap pre.src-line-numbers {
padding: 20px 0 20px 4px; padding: 20px 0 20px 4px;
} }
@ -392,7 +392,7 @@ img {
left: 0; left: 0;
} }
.rustdoc.source .sidebar { .rustdoc.src .sidebar {
flex-basis: 50px; flex-basis: 50px;
border-right: 1px solid; border-right: 1px solid;
overflow-x: hidden; overflow-x: hidden;
@ -402,7 +402,7 @@ img {
} }
.sidebar, .mobile-topbar, .sidebar-menu-toggle, .sidebar, .mobile-topbar, .sidebar-menu-toggle,
#src-sidebar-toggle, #source-sidebar { #src-sidebar-toggle, #src-sidebar {
background-color: var(--sidebar-background-color); background-color: var(--sidebar-background-color);
} }
@ -410,16 +410,16 @@ img {
background-color: var(--sidebar-background-color-hover); background-color: var(--sidebar-background-color-hover);
} }
.source .sidebar > *:not(#src-sidebar-toggle) { .src .sidebar > *:not(#src-sidebar-toggle) {
visibility: hidden; visibility: hidden;
} }
.source-sidebar-expanded .source .sidebar { .src-sidebar-expanded .src .sidebar {
overflow-y: auto; overflow-y: auto;
flex-basis: 300px; flex-basis: 300px;
} }
.source-sidebar-expanded .source .sidebar > *:not(#src-sidebar-toggle) { .src-sidebar-expanded .src .sidebar > *:not(#src-sidebar-toggle) {
visibility: visible; visibility: visible;
} }
@ -544,7 +544,7 @@ ul.block, .block li {
flex-grow: 1; flex-grow: 1;
} }
.rustdoc:not(.source) .example-wrap pre { .rustdoc:not(.src) .example-wrap pre {
overflow: auto hidden; overflow: auto hidden;
} }
@ -619,7 +619,7 @@ ul.block, .block li {
} }
.docblock code, .docblock-short code, .docblock code, .docblock-short code,
pre, .rustdoc.source .example-wrap { pre, .rustdoc.src .example-wrap {
background-color: var(--code-block-background-color); background-color: var(--code-block-background-color);
} }
@ -676,7 +676,7 @@ nav.sub {
height: 34px; height: 34px;
flex-grow: 1; flex-grow: 1;
} }
.source nav.sub { .src nav.sub {
margin: 0 0 15px 0; margin: 0 0 15px 0;
} }
@ -1074,7 +1074,7 @@ pre.rust .doccomment {
color: var(--code-highlight-doc-comment-color); color: var(--code-highlight-doc-comment-color);
} }
.rustdoc.source .example-wrap pre.rust a { .rustdoc.src .example-wrap pre.rust a {
background: var(--codeblock-link-background); background: var(--codeblock-link-background);
} }
@ -1301,22 +1301,22 @@ a.tooltip:hover::after {
align-items: stretch; align-items: stretch;
z-index: 10; z-index: 10;
} }
#source-sidebar { #src-sidebar {
width: 100%; width: 100%;
overflow: auto; overflow: auto;
} }
#source-sidebar > .title { #src-sidebar > .title {
font-size: 1.5rem; font-size: 1.5rem;
text-align: center; text-align: center;
border-bottom: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color);
margin-bottom: 6px; margin-bottom: 6px;
} }
#source-sidebar div.files > a:hover, details.dir-entry summary:hover, #src-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus { #src-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: var(--source-sidebar-background-hover); background-color: var(--src-sidebar-background-hover);
} }
#source-sidebar div.files > a.selected { #src-sidebar div.files > a.selected {
background-color: var(--source-sidebar-background-selected); background-color: var(--src-sidebar-background-selected);
} }
#src-sidebar-toggle > button { #src-sidebar-toggle > button {
font-size: inherit; font-size: inherit;
@ -1619,8 +1619,8 @@ in source-script.js
/* The source view uses a different design for the sidebar toggle, and doesn't have a topbar, /* The source view uses a different design for the sidebar toggle, and doesn't have a topbar,
so don't bump down the main content or the sidebar. */ so don't bump down the main content or the sidebar. */
.source main, .src main,
.rustdoc.source .sidebar { .rustdoc.src .sidebar {
top: 0; top: 0;
padding: 0; padding: 0;
height: 100vh; height: 100vh;
@ -1628,8 +1628,8 @@ in source-script.js
} }
.sidebar.shown, .sidebar.shown,
.source-sidebar-expanded .source .sidebar, .src-sidebar-expanded .src .sidebar,
.rustdoc:not(.source) .sidebar:focus-within { .rustdoc:not(.src) .sidebar:focus-within {
left: 0; left: 0;
} }
@ -1709,7 +1709,7 @@ in source-script.js
border-left: 0; border-left: 0;
} }
.source-sidebar-expanded #src-sidebar-toggle { .src-sidebar-expanded #src-sidebar-toggle {
left: unset; left: unset;
top: unset; top: unset;
width: unset; width: unset;
@ -1749,7 +1749,7 @@ in source-script.js
display: inline; display: inline;
} }
.source-sidebar-expanded .source .sidebar { .src-sidebar-expanded .src .sidebar {
max-width: 100vw; max-width: 100vw;
width: 100vw; width: 100vw;
} }
@ -1769,7 +1769,7 @@ in source-script.js
margin-left: 34px; margin-left: 34px;
} }
.source nav.sub { .src nav.sub {
margin: 0; margin: 0;
padding: var(--nav-sub-mobile-padding); padding: var(--nav-sub-mobile-padding);
} }
@ -1792,7 +1792,7 @@ in source-script.js
} }
@media print { @media print {
nav.sidebar, nav.sub, .out-of-band, a.srclink, #copy-path, nav.sidebar, nav.sub, .out-of-band, a.src, #copy-path,
details.toggle[open] > summary::before, details.toggle > summary::before, details.toggle[open] > summary::before, details.toggle > summary::before,
details.toggle.top-doc > summary { details.toggle.top-doc > summary {
display: none; display: none;

View file

@ -89,8 +89,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--crate-search-div-hover-filter: invert(98%) sepia(12%) saturate(81%) hue-rotate(343deg) --crate-search-div-hover-filter: invert(98%) sepia(12%) saturate(81%) hue-rotate(343deg)
brightness(113%) contrast(76%); brightness(113%) contrast(76%);
--crate-search-hover-border: #e0e0e0; --crate-search-hover-border: #e0e0e0;
--source-sidebar-background-selected: #14191f; --src-sidebar-background-selected: #14191f;
--source-sidebar-background-hover: #14191f; --src-sidebar-background-hover: #14191f;
--table-alt-row-background-color: #191f26; --table-alt-row-background-color: #191f26;
--codeblock-link-background: #333; --codeblock-link-background: #333;
--scrape-example-toggle-line-background: #999; --scrape-example-toggle-line-background: #999;
@ -107,7 +107,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
h1, h2, h3, h4, h1, h2, h3, h4,
h1 a, .sidebar h2 a, .sidebar h3 a, h1 a, .sidebar h2 a, .sidebar h3 a,
#source-sidebar > .title { #src-sidebar > .title {
color: #fff; color: #fff;
} }
h4 { h4 {
@ -124,15 +124,15 @@ h4 {
.docblock pre > code, .docblock pre > code,
pre, pre > code, pre, pre > code,
.item-info code, .item-info code,
.rustdoc.source .example-wrap { .rustdoc.src .example-wrap {
color: #e6e1cf; color: #e6e1cf;
} }
.sidebar .current, .sidebar .current,
.sidebar a:hover, .sidebar a:hover,
#source-sidebar div.files > a:hover, details.dir-entry summary:hover, #src-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus, #src-sidebar div.files > a:focus, details.dir-entry summary:focus,
#source-sidebar div.files > a.selected { #src-sidebar div.files > a.selected {
color: #ffb44c; color: #ffb44c;
} }

View file

@ -84,8 +84,8 @@
--crate-search-div-hover-filter: invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg) --crate-search-div-hover-filter: invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg)
brightness(100%) contrast(91%); brightness(100%) contrast(91%);
--crate-search-hover-border: #2196f3; --crate-search-hover-border: #2196f3;
--source-sidebar-background-selected: #333; --src-sidebar-background-selected: #333;
--source-sidebar-background-hover: #444; --src-sidebar-background-hover: #444;
--table-alt-row-background-color: #2A2A2A; --table-alt-row-background-color: #2A2A2A;
--codeblock-link-background: #333; --codeblock-link-background: #333;
--scrape-example-toggle-line-background: #999; --scrape-example-toggle-line-background: #999;

View file

@ -81,8 +81,8 @@
--crate-search-div-hover-filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg) --crate-search-div-hover-filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg)
brightness(96%) contrast(93%); brightness(96%) contrast(93%);
--crate-search-hover-border: #717171; --crate-search-hover-border: #717171;
--source-sidebar-background-selected: #fff; --src-sidebar-background-selected: #fff;
--source-sidebar-background-hover: #e0e0e0; --src-sidebar-background-hover: #e0e0e0;
--table-alt-row-background-color: #F5F5F5; --table-alt-row-background-color: #F5F5F5;
--codeblock-link-background: #eee; --codeblock-link-background: #eee;
--scrape-example-toggle-line-background: #ccc; --scrape-example-toggle-line-background: #ccc;

View file

@ -74,11 +74,11 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
function toggleSidebar() { function toggleSidebar() {
const child = this.parentNode.children[0]; const child = this.parentNode.children[0];
if (child.innerText === ">") { if (child.innerText === ">") {
addClass(document.documentElement, "source-sidebar-expanded"); addClass(document.documentElement, "src-sidebar-expanded");
child.innerText = "<"; child.innerText = "<";
updateLocalStorage("source-sidebar-show", "true"); updateLocalStorage("source-sidebar-show", "true");
} else { } else {
removeClass(document.documentElement, "source-sidebar-expanded"); removeClass(document.documentElement, "src-sidebar-expanded");
child.innerText = ">"; child.innerText = ">";
updateLocalStorage("source-sidebar-show", "false"); updateLocalStorage("source-sidebar-show", "false");
} }
@ -110,7 +110,7 @@ function createSourceSidebar() {
container.insertBefore(sidebarToggle, container.firstChild); container.insertBefore(sidebarToggle, container.firstChild);
const sidebar = document.createElement("div"); const sidebar = document.createElement("div");
sidebar.id = "source-sidebar"; sidebar.id = "src-sidebar";
let hasFoundFile = false; let hasFoundFile = false;

View file

@ -185,7 +185,7 @@ updateTheme();
if (getSettingValue("source-sidebar-show") === "true") { if (getSettingValue("source-sidebar-show") === "true") {
// At this point in page load, `document.body` is not available yet. // At this point in page load, `document.body` is not available yet.
// Set a class on the `<html>` element instead. // Set a class on the `<html>` element instead.
addClass(document.documentElement, "source-sidebar-expanded"); addClass(document.documentElement, "src-sidebar-expanded");
} }
// If we navigate away (for example to a settings page), and then use the back or // If we navigate away (for example to a settings page), and then use the back or

View file

@ -42,7 +42,7 @@
<script src="{{static_root_path|safe}}{{files.storage_js}}"></script> {# #} <script src="{{static_root_path|safe}}{{files.storage_js}}"></script> {# #}
{% if page.css_class.contains("crate") %} {% if page.css_class.contains("crate") %}
<script defer src="{{page.root_path|safe}}crates{{page.resource_suffix}}.js"></script> {# #} <script defer src="{{page.root_path|safe}}crates{{page.resource_suffix}}.js"></script> {# #}
{% else if page.css_class == "source" %} {% else if page.css_class == "src" %}
<script defer src="{{static_root_path|safe}}{{files.source_script_js}}"></script> {# #} <script defer src="{{static_root_path|safe}}{{files.source_script_js}}"></script> {# #}
<script defer src="{{page.root_path|safe}}source-files{{page.resource_suffix}}.js"></script> {# #} <script defer src="{{page.root_path|safe}}source-files{{page.resource_suffix}}.js"></script> {# #}
{% else if !page.css_class.contains("mod") %} {% else if !page.css_class.contains("mod") %}
@ -85,7 +85,7 @@
</div> {# #} </div> {# #}
<![endif]--> {# #} <![endif]--> {# #}
{{ layout.external_html.before_content|safe }} {{ layout.external_html.before_content|safe }}
{% if page.css_class != "source" %} {% if page.css_class != "src" %}
<nav class="mobile-topbar"> {# #} <nav class="mobile-topbar"> {# #}
<button class="sidebar-menu-toggle">&#9776;</button> {# #} <button class="sidebar-menu-toggle">&#9776;</button> {# #}
<a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #} <a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #}
@ -99,7 +99,7 @@
</nav> {# #} </nav> {# #}
{% endif %} {% endif %}
<nav class="sidebar"> {# #} <nav class="sidebar"> {# #}
{% if page.css_class != "source" %} {% if page.css_class != "src" %}
<a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #} <a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #}
{% if !layout.logo.is_empty() %} {% if !layout.logo.is_empty() %}
<img src="{{layout.logo}}" alt="logo"> {# #} <img src="{{layout.logo}}" alt="logo"> {# #}
@ -111,9 +111,9 @@
{{ sidebar|safe }} {{ sidebar|safe }}
</nav> {# #} </nav> {# #}
<main> {# #} <main> {# #}
{% if page.css_class != "source" %}<div class="width-limiter">{% endif %} {% if page.css_class != "src" %}<div class="width-limiter">{% endif %}
<nav class="sub"> {# #} <nav class="sub"> {# #}
{% if page.css_class == "source" %} {% if page.css_class == "src" %}
<a class="sub-logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #} <a class="sub-logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #}
{% if !layout.logo.is_empty() %} {% if !layout.logo.is_empty() %}
<img src="{{layout.logo}}" alt="logo"> {# #} <img src="{{layout.logo}}" alt="logo"> {# #}
@ -144,7 +144,7 @@
</form> {# #} </form> {# #}
</nav> {# #} </nav> {# #}
<section id="main-content" class="content">{{ content|safe }}</section> {# #} <section id="main-content" class="content">{{ content|safe }}</section> {# #}
{% if page.css_class != "source" %}</div>{% endif %} {% if page.css_class != "src" %}</div>{% endif %}
</main> {# #} </main> {# #}
{{ layout.external_html.after_content|safe }} {{ layout.external_html.after_content|safe }}
</body> {# #} </body> {# #}

View file

@ -18,7 +18,7 @@
{% endif %} {% endif %}
{% match src_href %} {% match src_href %}
{% when Some with (href) %} {% when Some with (href) %}
<a class="srclink" href="{{href|safe}}">source</a> · {#+ #} <a class="src" href="{{href|safe}}">source</a> · {#+ #}
{% else %} {% else %}
{% endmatch %} {% endmatch %}
<button id="toggle-all-docs" title="collapse all docs"> {# #} <button id="toggle-all-docs" title="collapse all docs"> {# #}

View file

@ -17,34 +17,34 @@ define-function: (
assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|}) assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|})
assert-css: (".main-heading a:nth-of-type(2)", {"color": |main_heading_type_color|}) assert-css: (".main-heading a:nth-of-type(2)", {"color": |main_heading_type_color|})
assert-css: ( assert-css: (
".rightside .srclink", ".rightside a.src",
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
ALL, ALL,
) )
compare-elements-css: ( compare-elements-css: (
".rightside .srclink", ".rightside a.src",
".rightside.srclink", "a.rightside.src",
["color", "text-decoration"], ["color", "text-decoration"],
) )
compare-elements-css: ( compare-elements-css: (
".main-heading .srclink", ".main-heading a.src",
".rightside.srclink", "a.rightside.src",
["color", "text-decoration"], ["color", "text-decoration"],
) )
move-cursor-to: ".main-heading .srclink" move-cursor-to: ".main-heading a.src"
assert-css: ( assert-css: (
".main-heading .srclink", ".main-heading a.src",
{"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|}, {"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|},
) )
move-cursor-to: ".impl-items .rightside .srclink" move-cursor-to: ".impl-items .rightside a.src"
assert-css: ( assert-css: (
".impl-items .rightside .srclink", ".impl-items .rightside a.src",
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
) )
move-cursor-to: ".impl-items .rightside.srclink" move-cursor-to: ".impl-items a.rightside.src"
assert-css: ( assert-css: (
".impl-items .rightside.srclink", ".impl-items a.rightside.src",
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
) )

View file

@ -1,6 +1,6 @@
// Small test to ensure the "src-line-numbers" element is only present once on // Small test to ensure the "src-line-numbers" element is only present once on
// the page. // the page.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
click: ".srclink" click: "a.src"
wait-for: ".src-line-numbers" wait-for: ".src-line-numbers"
assert-count: (".src-line-numbers", 1) assert-count: (".src-line-numbers", 1)

View file

@ -1,7 +1,7 @@
// This test checks that the source code pages sidebar toggle is working as expected. // This test checks that the source code pages sidebar toggle is working as expected.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
click: ".srclink" click: "a.src"
wait-for: "#src-sidebar-toggle" wait-for: "#src-sidebar-toggle"
click: "#src-sidebar-toggle" click: "#src-sidebar-toggle"
expect-failure: true expect-failure: true
assert-css: ("#source-sidebar", { "left": "-300px" }) assert-css: ("#src-sidebar", { "left": "-300px" })

View file

@ -1,4 +1,4 @@
// We check the background color on the jump to definition links in the source code page. // We check the background color on the jump to definition links in the src code page.
go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html"
define-function: ( define-function: (
@ -10,7 +10,7 @@ define-function: (
// We reload the page so the local storage settings are being used. // We reload the page so the local storage settings are being used.
reload: reload:
assert-css: ( assert-css: (
"body.source .example-wrap pre.rust a", "body.src .example-wrap pre.rust a",
{"background-color": |background_color|}, {"background-color": |background_color|},
ALL, ALL,
) )

View file

@ -40,7 +40,7 @@ define-function: (
reload: reload:
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
assert-css: ( assert-css: (
"#source-sidebar details[open] > .files a.selected", "#src-sidebar details[open] > .files a.selected",
{"color": |color_hover|, "background-color": |background|}, {"color": |color_hover|, "background-color": |background|},
) )
@ -62,58 +62,58 @@ define-function: (
// Without hover or focus. // Without hover or focus.
assert-css: ( assert-css: (
"#source-sidebar details[open] > .files a:not(.selected)", "#src-sidebar details[open] > .files a:not(.selected)",
{"color": |color|, "background-color": |background_toggle|}, {"color": |color|, "background-color": |background_toggle|},
) )
// With focus. // With focus.
focus: "#source-sidebar details[open] > .files a:not(.selected)" focus: "#src-sidebar details[open] > .files a:not(.selected)"
wait-for-css: ( wait-for-css: (
"#source-sidebar details[open] > .files a:not(.selected):focus", "#src-sidebar details[open] > .files a:not(.selected):focus",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
focus: ".search-input" focus: ".search-input"
// With hover. // With hover.
move-cursor-to: "#source-sidebar details[open] > .files a:not(.selected)" move-cursor-to: "#src-sidebar details[open] > .files a:not(.selected)"
assert-css: ( assert-css: (
"#source-sidebar details[open] > .files a:not(.selected):hover", "#src-sidebar details[open] > .files a:not(.selected):hover",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
// Without hover or focus. // Without hover or focus.
assert-css: ( assert-css: (
"#source-sidebar .dir-entry summary", "#src-sidebar .dir-entry summary",
{"color": |color|, "background-color": |background_toggle|}, {"color": |color|, "background-color": |background_toggle|},
) )
// With focus. // With focus.
focus: "#source-sidebar .dir-entry summary" focus: "#src-sidebar .dir-entry summary"
wait-for-css: ( wait-for-css: (
"#source-sidebar .dir-entry summary:focus", "#src-sidebar .dir-entry summary:focus",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
focus: ".search-input" focus: ".search-input"
// With hover. // With hover.
move-cursor-to: "#source-sidebar .dir-entry summary" move-cursor-to: "#src-sidebar .dir-entry summary"
assert-css: ( assert-css: (
"#source-sidebar .dir-entry summary:hover", "#src-sidebar .dir-entry summary:hover",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
// Without hover or focus. // Without hover or focus.
assert-css: ( assert-css: (
"#source-sidebar details[open] > .folders > details > summary", "#src-sidebar details[open] > .folders > details > summary",
{"color": |color|, "background-color": |background_toggle|}, {"color": |color|, "background-color": |background_toggle|},
) )
// With focus. // With focus.
focus: "#source-sidebar details[open] > .folders > details > summary" focus: "#src-sidebar details[open] > .folders > details > summary"
wait-for-css: ( wait-for-css: (
"#source-sidebar details[open] > .folders > details > summary:focus", "#src-sidebar details[open] > .folders > details > summary:focus",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
focus: ".search-input" focus: ".search-input"
// With hover. // With hover.
move-cursor-to: "#source-sidebar details[open] > .folders > details > summary" move-cursor-to: "#src-sidebar details[open] > .folders > details > summary"
assert-css: ( assert-css: (
"#source-sidebar details[open] > .folders > details > summary:hover", "#src-sidebar details[open] > .folders > details > summary:hover",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
}, },
@ -190,16 +190,16 @@ assert-window-property: {"pageYOffset": "2542"}
// make it the current selection. // make it the current selection.
set-window-size: (500, 700) set-window-size: (500, 700)
click: "#src-sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: ("#source-sidebar", {"visibility": "visible"}) wait-for-css: ("#src-sidebar", {"visibility": "visible"})
assert-local-storage: {"rustdoc-source-sidebar-show": "true"} assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
click: ".sidebar a.selected" click: ".sidebar a.selected"
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) wait-for-css: ("#src-sidebar", {"visibility": "hidden"})
assert-local-storage: {"rustdoc-source-sidebar-show": "false"} assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
// Resize back to desktop size, to check that the sidebar doesn't spontaneously open. // Resize back to desktop size, to check that the sidebar doesn't spontaneously open.
set-window-size: (1000, 1000) set-window-size: (1000, 1000)
wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) wait-for-css: ("#src-sidebar", {"visibility": "hidden"})
assert-local-storage: {"rustdoc-source-sidebar-show": "false"} assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
click: "#src-sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: ("#source-sidebar", {"visibility": "visible"}) wait-for-css: ("#src-sidebar", {"visibility": "visible"})
assert-local-storage: {"rustdoc-source-sidebar-show": "true"} assert-local-storage: {"rustdoc-source-sidebar-show": "true"}

View file

@ -14,7 +14,7 @@ define-function: (
} }
reload: reload:
// Checking results colors. // Checking results colors.
assert-css: (".source .sidebar", { assert-css: (".src .sidebar", {
"color": |color|, "color": |color|,
"background-color": |background_color| "background-color": |background_color|
}, ALL) }, ALL)
@ -53,8 +53,8 @@ assert-css: ("nav.sidebar", {"width": "50px"})
// We now click on the button to expand the sidebar. // We now click on the button to expand the sidebar.
click: (10, 10) click: (10, 10)
// We wait for the sidebar to be expanded. // We wait for the sidebar to be expanded.
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"}) wait-for-css: (".src-sidebar-expanded nav.sidebar", {"width": "300px"})
assert-css: (".source-sidebar-expanded nav.sidebar a", {"font-size": "14px"}) assert-css: (".src-sidebar-expanded nav.sidebar a", {"font-size": "14px"})
// We collapse the sidebar. // We collapse the sidebar.
click: (10, 10) click: (10, 10)
// We ensure that the class has been removed. // We ensure that the class has been removed.
@ -66,24 +66,24 @@ go-to: "file://" + |DOC_PATH| + "/src/lib2/another_folder/sub_mod/mod.rs.html"
// First we expand the sidebar again. // First we expand the sidebar again.
click: (10, 10) click: (10, 10)
// We wait for the sidebar to be expanded. // We wait for the sidebar to be expanded.
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"}) wait-for-css: (".src-sidebar-expanded nav.sidebar", {"width": "300px"})
assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']" assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']"
assert: "//*[@class='dir-entry' and @open]/*[text()='another_folder']" assert: "//*[@class='dir-entry' and @open]/*[text()='another_folder']"
assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']" assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
// Only "another_folder" should be "open" in "lib2". // Only "another_folder" should be "open" in "lib2".
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']" assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
// All other trees should be collapsed. // All other trees should be collapsed.
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 9) assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 9)
// We now switch to mobile mode. // We now switch to mobile mode.
set-window-size: (600, 600) set-window-size: (600, 600)
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"left": "0px"}) wait-for-css: (".src-sidebar-expanded nav.sidebar", {"left": "0px"})
// We collapse the sidebar. // We collapse the sidebar.
click: (10, 10) click: (10, 10)
// We check that the sidebar has been moved off-screen. // We check that the sidebar has been moved off-screen.
assert-css: ("nav.sidebar", {"left": "-1000px"}) assert-css: ("nav.sidebar", {"left": "-1000px"})
// We ensure that the class has been removed. // We ensure that the class has been removed.
assert-false: ".source-sidebar-expanded" assert-false: ".src-sidebar-expanded"
assert: "nav.sidebar" assert: "nav.sidebar"
// Check that the topbar is not visible // Check that the topbar is not visible

View file

@ -98,26 +98,26 @@ assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
// First we "open" it. // First we "open" it.
click: "#src-sidebar-toggle" click: "#src-sidebar-toggle"
assert: ".source-sidebar-expanded" assert: ".src-sidebar-expanded"
// We check that the first entry of the sidebar is collapsed // We check that the first entry of the sidebar is collapsed
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) assert-property: ("#src-sidebar details:first-of-type", {"open": "false"})
assert-text: ("#source-sidebar details:first-of-type > summary", "extend_css") assert-text: ("#src-sidebar details:first-of-type > summary", "extend_css")
// We now click on it. // We now click on it.
click: "#source-sidebar details:first-of-type > summary" click: "#src-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) assert-property: ("#src-sidebar details:first-of-type", {"open": "true"})
// And now we collapse it again. // And now we collapse it again.
click: "#source-sidebar details:first-of-type > summary" click: "#src-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) assert-property: ("#src-sidebar details:first-of-type", {"open": "false"})
// And open it again, since it'll be the reference we use to check positions. // And open it again, since it'll be the reference we use to check positions.
click: "#source-sidebar details:first-of-type > summary" click: "#src-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) assert-property: ("#src-sidebar details:first-of-type", {"open": "true"})
// Check the sidebar directory entries have a marker and spacing (desktop). // Check the sidebar directory entries have a marker and spacing (desktop).
store-property: ( store-property: (
"#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", "#src-sidebar > details:first-of-type.dir-entry[open] > .files > a",
{"offsetHeight": link_height}, {"offsetHeight": link_height},
) )
define-function: ( define-function: (
@ -125,28 +125,28 @@ define-function: (
(x, y), (x, y),
block { block {
assert: "details:first-of-type.dir-entry[open] > summary::marker" assert: "details:first-of-type.dir-entry[open] > summary::marker"
assert-css: ("#source-sidebar > details:first-of-type.dir-entry", {"padding-left": "4px"}) assert-css: ("#src-sidebar > details:first-of-type.dir-entry", {"padding-left": "4px"})
// This check ensures that the summary is only one line. // This check ensures that the summary is only one line.
assert-property: ( assert-property: (
"#source-sidebar > details:first-of-type.dir-entry[open] > summary", "#src-sidebar > details:first-of-type.dir-entry[open] > summary",
{"offsetHeight": |link_height|} {"offsetHeight": |link_height|}
) )
assert-position: ( assert-position: (
"#source-sidebar > details:first-of-type.dir-entry[open] > summary", "#src-sidebar > details:first-of-type.dir-entry[open] > summary",
{"x": |x|, "y": |y|} {"x": |x|, "y": |y|}
) )
assert-property: ( assert-property: (
"#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", "#src-sidebar > details:first-of-type.dir-entry[open] > .files > a",
{"offsetHeight": |link_height|} {"offsetHeight": |link_height|}
) )
assert-position: ( assert-position: (
"#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", "#src-sidebar > details:first-of-type.dir-entry[open] > .files > a",
// left margin // left margin
{"x": |x| + 27, "y": |y| + |link_height|} {"x": |x| + 27, "y": |y| + |link_height|}
) )
} }
) )
store-property: ("#source-sidebar > .title", { store-property: ("#src-sidebar > .title", {
"offsetHeight": source_sidebar_title_height, "offsetHeight": source_sidebar_title_height,
"offsetTop": source_sidebar_title_y, "offsetTop": source_sidebar_title_y,
}) })
@ -175,7 +175,7 @@ assert-property: ("#main-content", {"offsetTop": 76})
// 21 = 76 - 34 - 21 // 21 = 76 - 34 - 21
// Check the sidebar directory entries have a marker and spacing (tablet). // Check the sidebar directory entries have a marker and spacing (tablet).
store-property: ("#source-sidebar > .title", { store-property: ("#src-sidebar > .title", {
"offsetHeight": source_sidebar_title_height, "offsetHeight": source_sidebar_title_height,
"offsetTop": source_sidebar_title_y, "offsetTop": source_sidebar_title_y,
}) })
@ -189,7 +189,7 @@ set-window-size: (450, 700)
assert-css: ("nav.sub", {"flex-direction": "column"}) assert-css: ("nav.sub", {"flex-direction": "column"})
// Check the sidebar directory entries have a marker and spacing (phone). // Check the sidebar directory entries have a marker and spacing (phone).
store-property: ("#source-sidebar > .title", { store-property: ("#src-sidebar > .title", {
"offsetHeight": source_sidebar_title_height, "offsetHeight": source_sidebar_title_height,
"offsetTop": source_sidebar_title_y, "offsetTop": source_sidebar_title_y,
}) })

View file

@ -4,13 +4,13 @@
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
show-text: true show-text: true
// Check the impl headers. // Check the impl headers.
assert-css: (".impl .srclink", {"font-size": "16px", "font-weight": 400}, ALL) assert-css: (".impl a.src", {"font-size": "16px", "font-weight": 400}, ALL)
assert-css: (".impl .code-header", {"font-size": "18px", "font-weight": 600}, ALL) assert-css: (".impl .code-header", {"font-size": "18px", "font-weight": 600}, ALL)
// Check the impl items. // Check the impl items.
assert-css: (".impl-items .srclink", {"font-size": "16px", "font-weight": 400}, ALL) assert-css: (".impl-items a.src", {"font-size": "16px", "font-weight": 400}, ALL)
assert-css: (".impl-items .code-header", {"font-size": "16px", "font-weight": 600}, ALL) assert-css: (".impl-items .code-header", {"font-size": "16px", "font-weight": 600}, ALL)
// Check that we can click on source link // Check that we can click on source link
store-document-property: {"URL": url} store-document-property: {"URL": url}
click: ".impl-items .srclink" click: ".impl-items a.src"
assert-document-property-false: {"URL": |url|} assert-document-property-false: {"URL": |url|}

View file

@ -1 +1 @@
<section id="associatedconstant.YOLO" class="method"><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> <section id="associatedconstant.YOLO" class="method"><a class="src 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>

View file

@ -1 +1 @@
<section id="associatedconstant.X" class="associatedconstant"><a class="srclink rightside" href="../src/foo/anchors.rs.html#42">source</a><h4 class="code-header">pub const <a href="#associatedconstant.X" class="constant">X</a>: <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a> = 0i32</h4></section> <section id="associatedconstant.X" class="associatedconstant"><a class="src rightside" href="../src/foo/anchors.rs.html#42">source</a><h4 class="code-header">pub const <a href="#associatedconstant.X" class="constant">X</a>: <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a> = 0i32</h4></section>

View file

@ -1 +1 @@
<section id="method.new" class="method"><a class="srclink rightside" href="../src/foo/anchors.rs.html#48">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>() -&gt; Self</h4></section> <section id="method.new" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#48">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>() -&gt; Self</h4></section>

View file

@ -1 +1 @@
<section id="method.bar" class="method"><a class="srclink rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fn">bar</a>()</h4></section> <section id="method.bar" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fn">bar</a>()</h4></section>

View file

@ -1 +1 @@
<section id="tymethod.foo" class="method"><a class="srclink rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fn">foo</a>()</h4></section> <section id="tymethod.foo" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fn">foo</a>()</h4></section>

View file

@ -1 +1 @@
<section id="associatedtype.T" class="method"><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> <section id="associatedtype.T" class="method"><a class="src 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>

View file

@ -2,5 +2,5 @@
// This test ensures that the [src] link is present on traits items. // This test ensures that the [src] link is present on traits items.
// @has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="srclink rightside"]' "source" // @has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="src rightside"]' "source"
pub use std::iter::Iterator; pub use std::iter::Iterator;

View file

@ -2,11 +2,11 @@
// @has foo/struct.Unsized.html // @has foo/struct.Unsized.html
// @has - '//*[@id="impl-Sized-for-Unsized"]/h3[@class="code-header"]' 'impl !Sized for Unsized' // @has - '//*[@id="impl-Sized-for-Unsized"]/h3[@class="code-header"]' 'impl !Sized for Unsized'
// @!has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="srclink"]' 'source' // @!has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="src"]' 'source'
// @has - '//*[@id="impl-Sync-for-Unsized"]/h3[@class="code-header"]' 'impl Sync for Unsized' // @has - '//*[@id="impl-Sync-for-Unsized"]/h3[@class="code-header"]' 'impl Sync for Unsized'
// @!has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="srclink"]' 'source' // @!has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="src"]' 'source'
// @has - '//*[@id="impl-Any-for-Unsized"]/h3[@class="code-header"]' 'impl<T> Any for T' // @has - '//*[@id="impl-Any-for-Unsized"]/h3[@class="code-header"]' 'impl<T> Any for T'
// @has - '//*[@id="impl-Any-for-Unsized"]//a[@class="srclink rightside"]' 'source' // @has - '//*[@id="impl-Any-for-Unsized"]//a[@class="src rightside"]' 'source'
pub struct Unsized { pub struct Unsized {
data: [u8], data: [u8],
} }