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 has_stability {
write!(rightside, " · <a class=\"srclink\" href=\"{}\">source</a>", l)
write!(rightside, " · <a class=\"src\" href=\"{}\">source</a>", l)
} 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 {

View File

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

View File

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

View File

@ -194,7 +194,7 @@ h1, h2, h3, h4, h5, h6,
.item-name > a,
.out-of-band,
span.since,
a.srclink,
a.src,
#help-button > a,
summary.hideme,
.scraped-example-list,
@ -206,7 +206,7 @@ ul.all-items {
#toggle-all-docs,
a.anchor,
.small-section-header a,
#source-sidebar a,
#src-sidebar a,
.rust a,
.sidebar h2 a,
.sidebar h3 a,
@ -315,7 +315,7 @@ main {
min-width: 0; /* avoid growing beyond the size limit */
}
.source main {
.src main {
padding: 15px;
}
@ -350,10 +350,10 @@ pre.item-decl {
contain: initial;
}
.source .content pre {
.src .content pre {
padding: 20px;
}
.rustdoc.source .example-wrap pre.src-line-numbers {
.rustdoc.src .example-wrap pre.src-line-numbers {
padding: 20px 0 20px 4px;
}
@ -392,7 +392,7 @@ img {
left: 0;
}
.rustdoc.source .sidebar {
.rustdoc.src .sidebar {
flex-basis: 50px;
border-right: 1px solid;
overflow-x: hidden;
@ -402,7 +402,7 @@ img {
}
.sidebar, .mobile-topbar, .sidebar-menu-toggle,
#src-sidebar-toggle, #source-sidebar {
#src-sidebar-toggle, #src-sidebar {
background-color: var(--sidebar-background-color);
}
@ -410,16 +410,16 @@ img {
background-color: var(--sidebar-background-color-hover);
}
.source .sidebar > *:not(#src-sidebar-toggle) {
.src .sidebar > *:not(#src-sidebar-toggle) {
visibility: hidden;
}
.source-sidebar-expanded .source .sidebar {
.src-sidebar-expanded .src .sidebar {
overflow-y: auto;
flex-basis: 300px;
}
.source-sidebar-expanded .source .sidebar > *:not(#src-sidebar-toggle) {
.src-sidebar-expanded .src .sidebar > *:not(#src-sidebar-toggle) {
visibility: visible;
}
@ -544,7 +544,7 @@ ul.block, .block li {
flex-grow: 1;
}
.rustdoc:not(.source) .example-wrap pre {
.rustdoc:not(.src) .example-wrap pre {
overflow: auto hidden;
}
@ -619,7 +619,7 @@ ul.block, .block li {
}
.docblock code, .docblock-short code,
pre, .rustdoc.source .example-wrap {
pre, .rustdoc.src .example-wrap {
background-color: var(--code-block-background-color);
}
@ -676,7 +676,7 @@ nav.sub {
height: 34px;
flex-grow: 1;
}
.source nav.sub {
.src nav.sub {
margin: 0 0 15px 0;
}
@ -1074,7 +1074,7 @@ pre.rust .doccomment {
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);
}
@ -1301,22 +1301,22 @@ a.tooltip:hover::after {
align-items: stretch;
z-index: 10;
}
#source-sidebar {
#src-sidebar {
width: 100%;
overflow: auto;
}
#source-sidebar > .title {
#src-sidebar > .title {
font-size: 1.5rem;
text-align: center;
border-bottom: 1px solid var(--border-color);
margin-bottom: 6px;
}
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: var(--source-sidebar-background-hover);
#src-sidebar div.files > a:hover, details.dir-entry summary:hover,
#src-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: var(--src-sidebar-background-hover);
}
#source-sidebar div.files > a.selected {
background-color: var(--source-sidebar-background-selected);
#src-sidebar div.files > a.selected {
background-color: var(--src-sidebar-background-selected);
}
#src-sidebar-toggle > button {
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,
so don't bump down the main content or the sidebar. */
.source main,
.rustdoc.source .sidebar {
.src main,
.rustdoc.src .sidebar {
top: 0;
padding: 0;
height: 100vh;
@ -1628,8 +1628,8 @@ in source-script.js
}
.sidebar.shown,
.source-sidebar-expanded .source .sidebar,
.rustdoc:not(.source) .sidebar:focus-within {
.src-sidebar-expanded .src .sidebar,
.rustdoc:not(.src) .sidebar:focus-within {
left: 0;
}
@ -1709,7 +1709,7 @@ in source-script.js
border-left: 0;
}
.source-sidebar-expanded #src-sidebar-toggle {
.src-sidebar-expanded #src-sidebar-toggle {
left: unset;
top: unset;
width: unset;
@ -1749,7 +1749,7 @@ in source-script.js
display: inline;
}
.source-sidebar-expanded .source .sidebar {
.src-sidebar-expanded .src .sidebar {
max-width: 100vw;
width: 100vw;
}
@ -1769,7 +1769,7 @@ in source-script.js
margin-left: 34px;
}
.source nav.sub {
.src nav.sub {
margin: 0;
padding: var(--nav-sub-mobile-padding);
}
@ -1792,7 +1792,7 @@ in source-script.js
}
@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.top-doc > summary {
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)
brightness(113%) contrast(76%);
--crate-search-hover-border: #e0e0e0;
--source-sidebar-background-selected: #14191f;
--source-sidebar-background-hover: #14191f;
--src-sidebar-background-selected: #14191f;
--src-sidebar-background-hover: #14191f;
--table-alt-row-background-color: #191f26;
--codeblock-link-background: #333;
--scrape-example-toggle-line-background: #999;
@ -107,7 +107,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
h1, h2, h3, h4,
h1 a, .sidebar h2 a, .sidebar h3 a,
#source-sidebar > .title {
#src-sidebar > .title {
color: #fff;
}
h4 {
@ -124,15 +124,15 @@ h4 {
.docblock pre > code,
pre, pre > code,
.item-info code,
.rustdoc.source .example-wrap {
.rustdoc.src .example-wrap {
color: #e6e1cf;
}
.sidebar .current,
.sidebar a:hover,
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus,
#source-sidebar div.files > a.selected {
#src-sidebar div.files > a:hover, details.dir-entry summary:hover,
#src-sidebar div.files > a:focus, details.dir-entry summary:focus,
#src-sidebar div.files > a.selected {
color: #ffb44c;
}

View File

@ -84,8 +84,8 @@
--crate-search-div-hover-filter: invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg)
brightness(100%) contrast(91%);
--crate-search-hover-border: #2196f3;
--source-sidebar-background-selected: #333;
--source-sidebar-background-hover: #444;
--src-sidebar-background-selected: #333;
--src-sidebar-background-hover: #444;
--table-alt-row-background-color: #2A2A2A;
--codeblock-link-background: #333;
--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)
brightness(96%) contrast(93%);
--crate-search-hover-border: #717171;
--source-sidebar-background-selected: #fff;
--source-sidebar-background-hover: #e0e0e0;
--src-sidebar-background-selected: #fff;
--src-sidebar-background-hover: #e0e0e0;
--table-alt-row-background-color: #F5F5F5;
--codeblock-link-background: #eee;
--scrape-example-toggle-line-background: #ccc;

View File

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

View File

@ -185,7 +185,7 @@ updateTheme();
if (getSettingValue("source-sidebar-show") === "true") {
// At this point in page load, `document.body` is not available yet.
// 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

View File

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

View File

@ -18,7 +18,7 @@
{% endif %}
{% match src_href %}
{% when Some with (href) %}
<a class="srclink" href="{{href|safe}}">source</a> · {#+ #}
<a class="src" href="{{href|safe}}">source</a> · {#+ #}
{% else %}
{% endmatch %}
<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 a:nth-of-type(2)", {"color": |main_heading_type_color|})
assert-css: (
".rightside .srclink",
".rightside a.src",
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
ALL,
)
compare-elements-css: (
".rightside .srclink",
".rightside.srclink",
".rightside a.src",
"a.rightside.src",
["color", "text-decoration"],
)
compare-elements-css: (
".main-heading .srclink",
".rightside.srclink",
".main-heading a.src",
"a.rightside.src",
["color", "text-decoration"],
)
move-cursor-to: ".main-heading .srclink"
move-cursor-to: ".main-heading a.src"
assert-css: (
".main-heading .srclink",
".main-heading a.src",
{"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: (
".impl-items .rightside .srclink",
".impl-items .rightside a.src",
{"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: (
".impl-items .rightside.srclink",
".impl-items a.rightside.src",
{"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
// the page.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
click: ".srclink"
click: "a.src"
wait-for: ".src-line-numbers"
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.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
click: ".srclink"
click: "a.src"
wait-for: "#src-sidebar-toggle"
click: "#src-sidebar-toggle"
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"
define-function: (
@ -10,7 +10,7 @@ define-function: (
// We reload the page so the local storage settings are being used.
reload:
assert-css: (
"body.source .example-wrap pre.rust a",
"body.src .example-wrap pre.rust a",
{"background-color": |background_color|},
ALL,
)

View File

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

View File

@ -14,7 +14,7 @@ define-function: (
}
reload:
// Checking results colors.
assert-css: (".source .sidebar", {
assert-css: (".src .sidebar", {
"color": |color|,
"background-color": |background_color|
}, ALL)
@ -53,8 +53,8 @@ assert-css: ("nav.sidebar", {"width": "50px"})
// We now click on the button to expand the sidebar.
click: (10, 10)
// We wait for the sidebar to be expanded.
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"})
assert-css: (".source-sidebar-expanded nav.sidebar a", {"font-size": "14px"})
wait-for-css: (".src-sidebar-expanded nav.sidebar", {"width": "300px"})
assert-css: (".src-sidebar-expanded nav.sidebar a", {"font-size": "14px"})
// We collapse the sidebar.
click: (10, 10)
// 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.
click: (10, 10)
// 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()='another_folder']"
assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
// Only "another_folder" should be "open" in "lib2".
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
// 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.
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.
click: (10, 10)
// We check that the sidebar has been moved off-screen.
assert-css: ("nav.sidebar", {"left": "-1000px"})
// We ensure that the class has been removed.
assert-false: ".source-sidebar-expanded"
assert-false: ".src-sidebar-expanded"
assert: "nav.sidebar"
// 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.
click: "#src-sidebar-toggle"
assert: ".source-sidebar-expanded"
assert: ".src-sidebar-expanded"
// We check that the first entry of the sidebar is collapsed
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
assert-text: ("#source-sidebar details:first-of-type > summary", "extend_css")
assert-property: ("#src-sidebar details:first-of-type", {"open": "false"})
assert-text: ("#src-sidebar details:first-of-type > summary", "extend_css")
// We now click on it.
click: "#source-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})
click: "#src-sidebar details:first-of-type > summary"
assert-property: ("#src-sidebar details:first-of-type", {"open": "true"})
// And now we collapse it again.
click: "#source-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
click: "#src-sidebar details:first-of-type > summary"
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.
click: "#source-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})
click: "#src-sidebar details:first-of-type > summary"
assert-property: ("#src-sidebar details:first-of-type", {"open": "true"})
// Check the sidebar directory entries have a marker and spacing (desktop).
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},
)
define-function: (
@ -125,28 +125,28 @@ define-function: (
(x, y),
block {
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.
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|}
)
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|}
)
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|}
)
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
{"x": |x| + 27, "y": |y| + |link_height|}
)
}
)
store-property: ("#source-sidebar > .title", {
store-property: ("#src-sidebar > .title", {
"offsetHeight": source_sidebar_title_height,
"offsetTop": source_sidebar_title_y,
})
@ -175,7 +175,7 @@ assert-property: ("#main-content", {"offsetTop": 76})
// 21 = 76 - 34 - 21
// 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,
"offsetTop": source_sidebar_title_y,
})
@ -189,7 +189,7 @@ set-window-size: (450, 700)
assert-css: ("nav.sub", {"flex-direction": "column"})
// 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,
"offsetTop": source_sidebar_title_y,
})

View File

@ -4,13 +4,13 @@
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
show-text: true
// 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)
// 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)
// Check that we can click on source link
store-document-property: {"URL": url}
click: ".impl-items .srclink"
click: ".impl-items a.src"
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.
// @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;

View File

@ -2,11 +2,11 @@
// @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"]//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"]//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"]//a[@class="srclink rightside"]' 'source'
// @has - '//*[@id="impl-Any-for-Unsized"]//a[@class="src rightside"]' 'source'
pub struct Unsized {
data: [u8],
}