Skip to content

Commit 331b5ba

Browse files
authored
Rollup merge of #113709 - notriddle:notriddle/src, r=GuillaumeGomez
rustdoc: use src consistently over source in CSS/JS The two terms have been used, inconsistently, in closely related spots like the `src/` directory vs `source-files.js`, and with things like `src-sidebar-toggle` vs the `source-sidebar`. This PR changes most use of `source` to `src` instead (except the localStorage configuration variables, which would be very complicated to migrate). It also renames `.srclink` to `.src`. This is mostly aiming to cut out one of those many little peanut-butter bits of bloat, and is consistent with how other link classes are done (like how you have `a.mod` stylesheet rules, but there's also a `mod` class put on the body tag).
2 parents d0ef799 + d7d0a45 commit 331b5ba

31 files changed

+155
-155
lines changed

src/librustdoc/html/render/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1821,9 +1821,9 @@ fn render_rightside(
18211821
);
18221822
if let Some(l) = src_href {
18231823
if has_stability {
1824-
write!(rightside, " · <a class=\"srclink\" href=\"{}\">source</a>", l)
1824+
write!(rightside, " · <a class=\"src\" href=\"{}\">source</a>", l)
18251825
} else {
1826-
write!(rightside, "<a class=\"srclink rightside\" href=\"{}\">source</a>", l)
1826+
write!(rightside, "<a class=\"src rightside\" href=\"{}\">source</a>", l)
18271827
}
18281828
}
18291829
if has_stability && has_src_ref {

src/librustdoc/html/render/write_shared.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ pub(super) fn write_shared(
270270
hierarchy.add_path(source);
271271
}
272272
let hierarchy = Rc::try_unwrap(hierarchy).unwrap();
273-
let dst = cx.dst.join(&format!("source-files{}.js", cx.shared.resource_suffix));
273+
let dst = cx.dst.join(&format!("src-files{}.js", cx.shared.resource_suffix));
274274
let make_sources = || {
275275
let (mut all_sources, _krates) =
276276
try_err!(collect_json(&dst, krate.name(cx.tcx()).as_str()), &dst);
@@ -286,12 +286,12 @@ pub(super) fn write_shared(
286286
.replace("\\\"", "\\\\\"")
287287
));
288288
all_sources.sort();
289-
let mut v = String::from("var sourcesIndex = JSON.parse('{\\\n");
289+
let mut v = String::from("var srcIndex = JSON.parse('{\\\n");
290290
v.push_str(&all_sources.join(",\\\n"));
291-
v.push_str("\\\n}');\ncreateSourceSidebar();\n");
291+
v.push_str("\\\n}');\ncreateSrcSidebar();\n");
292292
Ok(v.into_bytes())
293293
};
294-
write_invocation_specific("source-files.js", &make_sources)?;
294+
write_invocation_specific("src-files.js", &make_sources)?;
295295
}
296296

297297
// Update the search index and crate list.

src/librustdoc/html/sources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl SourceCollector<'_, '_> {
227227
let desc = format!("Source of the Rust file `{}`.", filename.prefer_remapped());
228228
let page = layout::Page {
229229
title: &title,
230-
css_class: "source",
230+
css_class: "src",
231231
root_path: &root_path,
232232
static_root_path: shared.static_root_path.as_deref(),
233233
description: &desc,

src/librustdoc/html/static/css/noscript.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ nav.sub {
1919
display: none;
2020
}
2121

22-
.source .sidebar {
22+
.src .sidebar {
2323
display: none;
2424
}
2525

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

+30-30
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ h1, h2, h3, h4, h5, h6,
194194
.item-name > a,
195195
.out-of-band,
196196
span.since,
197-
a.srclink,
197+
a.src,
198198
#help-button > a,
199199
summary.hideme,
200200
.scraped-example-list,
@@ -206,7 +206,7 @@ ul.all-items {
206206
#toggle-all-docs,
207207
a.anchor,
208208
.small-section-header a,
209-
#source-sidebar a,
209+
#src-sidebar a,
210210
.rust a,
211211
.sidebar h2 a,
212212
.sidebar h3 a,
@@ -315,7 +315,7 @@ main {
315315
min-width: 0; /* avoid growing beyond the size limit */
316316
}
317317

318-
.source main {
318+
.src main {
319319
padding: 15px;
320320
}
321321

@@ -350,10 +350,10 @@ pre.item-decl {
350350
contain: initial;
351351
}
352352

353-
.source .content pre {
353+
.src .content pre {
354354
padding: 20px;
355355
}
356-
.rustdoc.source .example-wrap pre.src-line-numbers {
356+
.rustdoc.src .example-wrap pre.src-line-numbers {
357357
padding: 20px 0 20px 4px;
358358
}
359359

@@ -392,7 +392,7 @@ img {
392392
left: 0;
393393
}
394394

395-
.rustdoc.source .sidebar {
395+
.rustdoc.src .sidebar {
396396
flex-basis: 50px;
397397
border-right: 1px solid;
398398
overflow-x: hidden;
@@ -402,24 +402,24 @@ img {
402402
}
403403

404404
.sidebar, .mobile-topbar, .sidebar-menu-toggle,
405-
#src-sidebar-toggle, #source-sidebar {
405+
#src-sidebar-toggle, #src-sidebar {
406406
background-color: var(--sidebar-background-color);
407407
}
408408

409409
#src-sidebar-toggle > button:hover, #src-sidebar-toggle > button:focus {
410410
background-color: var(--sidebar-background-color-hover);
411411
}
412412

413-
.source .sidebar > *:not(#src-sidebar-toggle) {
413+
.src .sidebar > *:not(#src-sidebar-toggle) {
414414
visibility: hidden;
415415
}
416416

417-
.source-sidebar-expanded .source .sidebar {
417+
.src-sidebar-expanded .src .sidebar {
418418
overflow-y: auto;
419419
flex-basis: 300px;
420420
}
421421

422-
.source-sidebar-expanded .source .sidebar > *:not(#src-sidebar-toggle) {
422+
.src-sidebar-expanded .src .sidebar > *:not(#src-sidebar-toggle) {
423423
visibility: visible;
424424
}
425425

@@ -544,7 +544,7 @@ ul.block, .block li {
544544
flex-grow: 1;
545545
}
546546

547-
.rustdoc:not(.source) .example-wrap pre {
547+
.rustdoc:not(.src) .example-wrap pre {
548548
overflow: auto hidden;
549549
}
550550

@@ -619,7 +619,7 @@ ul.block, .block li {
619619
}
620620

621621
.docblock code, .docblock-short code,
622-
pre, .rustdoc.source .example-wrap {
622+
pre, .rustdoc.src .example-wrap {
623623
background-color: var(--code-block-background-color);
624624
}
625625

@@ -676,7 +676,7 @@ nav.sub {
676676
height: 34px;
677677
flex-grow: 1;
678678
}
679-
.source nav.sub {
679+
.src nav.sub {
680680
margin: 0 0 15px 0;
681681
}
682682

@@ -1074,7 +1074,7 @@ pre.rust .doccomment {
10741074
color: var(--code-highlight-doc-comment-color);
10751075
}
10761076

1077-
.rustdoc.source .example-wrap pre.rust a {
1077+
.rustdoc.src .example-wrap pre.rust a {
10781078
background: var(--codeblock-link-background);
10791079
}
10801080

@@ -1301,22 +1301,22 @@ a.tooltip:hover::after {
13011301
align-items: stretch;
13021302
z-index: 10;
13031303
}
1304-
#source-sidebar {
1304+
#src-sidebar {
13051305
width: 100%;
13061306
overflow: auto;
13071307
}
1308-
#source-sidebar > .title {
1308+
#src-sidebar > .title {
13091309
font-size: 1.5rem;
13101310
text-align: center;
13111311
border-bottom: 1px solid var(--border-color);
13121312
margin-bottom: 6px;
13131313
}
1314-
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
1315-
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
1316-
background-color: var(--source-sidebar-background-hover);
1314+
#src-sidebar div.files > a:hover, details.dir-entry summary:hover,
1315+
#src-sidebar div.files > a:focus, details.dir-entry summary:focus {
1316+
background-color: var(--src-sidebar-background-hover);
13171317
}
1318-
#source-sidebar div.files > a.selected {
1319-
background-color: var(--source-sidebar-background-selected);
1318+
#src-sidebar div.files > a.selected {
1319+
background-color: var(--src-sidebar-background-selected);
13201320
}
13211321
#src-sidebar-toggle > button {
13221322
font-size: inherit;
@@ -1562,7 +1562,7 @@ However, it's not needed with smaller screen width because the doc/code block is
15621562
/*
15631563
WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY
15641564
If you update this line, then you also need to update the line with the same warning
1565-
in source-script.js
1565+
in src-script.js
15661566
*/
15671567
@media (max-width: 700px) {
15681568
/* When linking to an item with an `id` (for instance, by clicking a link in the sidebar,
@@ -1619,17 +1619,17 @@ in source-script.js
16191619

16201620
/* The source view uses a different design for the sidebar toggle, and doesn't have a topbar,
16211621
so don't bump down the main content or the sidebar. */
1622-
.source main,
1623-
.rustdoc.source .sidebar {
1622+
.src main,
1623+
.rustdoc.src .sidebar {
16241624
top: 0;
16251625
padding: 0;
16261626
height: 100vh;
16271627
border: 0;
16281628
}
16291629

16301630
.sidebar.shown,
1631-
.source-sidebar-expanded .source .sidebar,
1632-
.rustdoc:not(.source) .sidebar:focus-within {
1631+
.src-sidebar-expanded .src .sidebar,
1632+
.rustdoc:not(.src) .sidebar:focus-within {
16331633
left: 0;
16341634
}
16351635

@@ -1709,7 +1709,7 @@ in source-script.js
17091709
border-left: 0;
17101710
}
17111711

1712-
.source-sidebar-expanded #src-sidebar-toggle {
1712+
.src-sidebar-expanded #src-sidebar-toggle {
17131713
left: unset;
17141714
top: unset;
17151715
width: unset;
@@ -1749,7 +1749,7 @@ in source-script.js
17491749
display: inline;
17501750
}
17511751

1752-
.source-sidebar-expanded .source .sidebar {
1752+
.src-sidebar-expanded .src .sidebar {
17531753
max-width: 100vw;
17541754
width: 100vw;
17551755
}
@@ -1769,7 +1769,7 @@ in source-script.js
17691769
margin-left: 34px;
17701770
}
17711771

1772-
.source nav.sub {
1772+
.src nav.sub {
17731773
margin: 0;
17741774
padding: var(--nav-sub-mobile-padding);
17751775
}
@@ -1792,7 +1792,7 @@ in source-script.js
17921792
}
17931793

17941794
@media print {
1795-
nav.sidebar, nav.sub, .out-of-band, a.srclink, #copy-path,
1795+
nav.sidebar, nav.sub, .out-of-band, a.src, #copy-path,
17961796
details.toggle[open] > summary::before, details.toggle > summary::before,
17971797
details.toggle.top-doc > summary {
17981798
display: none;

src/librustdoc/html/static/css/themes/ayu.css

+7-7
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
8989
--crate-search-div-hover-filter: invert(98%) sepia(12%) saturate(81%) hue-rotate(343deg)
9090
brightness(113%) contrast(76%);
9191
--crate-search-hover-border: #e0e0e0;
92-
--source-sidebar-background-selected: #14191f;
93-
--source-sidebar-background-hover: #14191f;
92+
--src-sidebar-background-selected: #14191f;
93+
--src-sidebar-background-hover: #14191f;
9494
--table-alt-row-background-color: #191f26;
9595
--codeblock-link-background: #333;
9696
--scrape-example-toggle-line-background: #999;
@@ -107,7 +107,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
107107

108108
h1, h2, h3, h4,
109109
h1 a, .sidebar h2 a, .sidebar h3 a,
110-
#source-sidebar > .title {
110+
#src-sidebar > .title {
111111
color: #fff;
112112
}
113113
h4 {
@@ -124,15 +124,15 @@ h4 {
124124
.docblock pre > code,
125125
pre, pre > code,
126126
.item-info code,
127-
.rustdoc.source .example-wrap {
127+
.rustdoc.src .example-wrap {
128128
color: #e6e1cf;
129129
}
130130

131131
.sidebar .current,
132132
.sidebar a:hover,
133-
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
134-
#source-sidebar div.files > a:focus, details.dir-entry summary:focus,
135-
#source-sidebar div.files > a.selected {
133+
#src-sidebar div.files > a:hover, details.dir-entry summary:hover,
134+
#src-sidebar div.files > a:focus, details.dir-entry summary:focus,
135+
#src-sidebar div.files > a.selected {
136136
color: #ffb44c;
137137
}
138138

src/librustdoc/html/static/css/themes/dark.css

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

src/librustdoc/html/static/css/themes/light.css

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

0 commit comments

Comments
 (0)