Skip to content

Commit a1cb194

Browse files
committed
Add styles for non-white themes
Tweak colors Tabs New link heading style
1 parent 18edcf8 commit a1cb194

File tree

4 files changed

+61
-15
lines changed

4 files changed

+61
-15
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,16 +2482,6 @@ fn render_call_locations(
24822482
id
24832483
);
24842484

2485-
// Link to the source file containing a given example
2486-
let example_url = |call_data: &CallData| -> String {
2487-
format!(
2488-
r#"<a href="{root}{url}" target="_blank">{name}</a>"#,
2489-
root = cx.root_path(),
2490-
url = call_data.url,
2491-
name = call_data.display_name
2492-
)
2493-
};
2494-
24952485
// Generate the HTML for a single example, being the title and code block
24962486
let tcx = cx.tcx();
24972487
let write_example = |w: &mut Buffer, (path, call_data): (&PathBuf, &CallData)| -> bool {
@@ -2534,9 +2524,13 @@ fn render_call_locations(
25342524
write!(
25352525
w,
25362526
r#"<div class="scraped-example" data-locs="{locations}">
2537-
<div class="scraped-example-title">{title}</div>
2538-
<div class="code-wrapper">"#,
2539-
title = example_url(call_data),
2527+
<div class="scraped-example-title">
2528+
{name} <a href="{root}{url}" target="_blank">[src]</a>
2529+
</div>
2530+
<div class="code-wrapper">"#,
2531+
root = cx.root_path(),
2532+
url = call_data.url,
2533+
name = call_data.display_name,
25402534
// The locations are encoded as a data attribute, so they can be read
25412535
// later by the JS for interactions.
25422536
locations = serde_json::to_string(&line_ranges).unwrap(),
@@ -2639,7 +2633,13 @@ fn render_call_locations(
26392633
r#"<div class="example-links">Additional examples can be found in:<br /><ul>"#
26402634
);
26412635
it.for_each(|(_, call_data)| {
2642-
write!(w, "<li>{}</li>", example_url(call_data));
2636+
write!(
2637+
w,
2638+
r#"<li><a href="{}{}" target="_blank">{}</a></li>"#,
2639+
root = cx.root_path(),
2640+
url = call_data.url,
2641+
name = call_data.display_name
2642+
);
26432643
});
26442644
write!(w, "</ul></div>");
26452645
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,10 @@ details.undocumented[open] > summary::before {
19761976

19771977
.scraped-example-title {
19781978
font-family: 'Fira Sans';
1979-
font-weight: 500;
1979+
}
1980+
1981+
.scraped-example-title a {
1982+
margin-left: 5px;
19801983
}
19811984

19821985
.scraped-example:not(.expanded) .code-wrapper pre.line-numbers,
@@ -2115,7 +2118,12 @@ h1 + .scraped-example {
21152118
margin-bottom: 20px;
21162119
}
21172120

2121+
.more-scraped-examples .scraped-example:last-child {
2122+
margin-bottom: 0;
2123+
}
2124+
21182125
.example-links a {
2126+
margin-top: 20px;
21192127
font-family: 'Fira Sans';
21202128
}
21212129

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,3 +613,22 @@ div.files > .selected {
613613
input:checked + .slider {
614614
background-color: #ffb454 !important;
615615
}
616+
617+
.scraped-example .example-wrap .rust span.highlight {
618+
background: rgb(91, 59, 1);
619+
}
620+
.scraped-example .example-wrap .rust span.highlight.focus {
621+
background: rgb(124, 75, 15);
622+
}
623+
.scraped-example:not(.expanded) .code-wrapper:before {
624+
background: linear-gradient(to bottom, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
625+
}
626+
.scraped-example:not(.expanded) .code-wrapper:after {
627+
background: linear-gradient(to top, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
628+
}
629+
.toggle-line-inner {
630+
background: #616161;
631+
}
632+
.toggle-line:hover .toggle-line-inner {
633+
background: ##898989;
634+
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,3 +485,22 @@ div.files > .selected {
485485
.setting-line > .title {
486486
border-bottom-color: #ddd;
487487
}
488+
489+
.scraped-example .example-wrap .rust span.highlight {
490+
background: rgb(91, 59, 1);
491+
}
492+
.scraped-example .example-wrap .rust span.highlight.focus {
493+
background: rgb(124, 75, 15);
494+
}
495+
.scraped-example:not(.expanded) .code-wrapper:before {
496+
background: linear-gradient(to bottom, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
497+
}
498+
.scraped-example:not(.expanded) .code-wrapper:after {
499+
background: linear-gradient(to top, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
500+
}
501+
.toggle-line-inner {
502+
background: #616161;
503+
}
504+
.toggle-line:hover .toggle-line-inner {
505+
background: ##898989;
506+
}

0 commit comments

Comments
 (0)