Skip to content

Commit 2c4560c

Browse files
authored
Rollup merge of #106218 - GuillaumeGomez:migrate-css-var-scraped-examples, r=notriddle
Migrate css var scraped examples r? ``@notriddle``
2 parents bdf37b7 + aa20f88 commit 2c4560c

File tree

5 files changed

+47
-18
lines changed

5 files changed

+47
-18
lines changed

Diff for: src/librustdoc/html/static/css/rustdoc.css

+7
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,13 @@ in storage.js
19551955
overflow-x: hidden;
19561956
}
19571957

1958+
.scraped-example .example-wrap .rust span.highlight {
1959+
background: var(--scrape-example-code-line-highlight);
1960+
}
1961+
.scraped-example .example-wrap .rust span.highlight.focus {
1962+
background: var(--scrape-example-code-line-highlight-focus);
1963+
}
1964+
19581965
.more-examples-toggle {
19591966
max-width: calc(100% + 25px);
19601967
margin-top: 10px;

Diff for: src/librustdoc/html/static/css/themes/ayu.css

+2-6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
9191
--codeblock-link-background: #333;
9292
--scrape-example-toggle-line-background: #999;
9393
--scrape-example-toggle-line-hover-background: #c5c5c5;
94+
--scrape-example-code-line-highlight: rgb(91, 59, 1);
95+
--scrape-example-code-line-highlight-focus: rgb(124, 75, 15);
9496
}
9597

9698
h1, h2, h3, h4 {
@@ -206,12 +208,6 @@ above the `@media (max-width: 700px)` rules due to a bug in the css checker */
206208
border-color: white;
207209
color: white;
208210
}
209-
.scraped-example .example-wrap .rust span.highlight {
210-
background: rgb(91, 59, 1);
211-
}
212-
.scraped-example .example-wrap .rust span.highlight.focus {
213-
background: rgb(124, 75, 15);
214-
}
215211
.scraped-example:not(.expanded) .code-wrapper::before {
216212
background: linear-gradient(to bottom, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
217213
}

Diff for: src/librustdoc/html/static/css/themes/dark.css

+2-6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
--codeblock-link-background: #333;
8787
--scrape-example-toggle-line-background: #999;
8888
--scrape-example-toggle-line-hover-background: #c5c5c5;
89+
--scrape-example-code-line-highlight: rgb(91, 59, 1);
90+
--scrape-example-code-line-highlight-focus: rgb(124, 75, 15);
8991
}
9092

9193
#search-tabs > button:not(.selected) {
@@ -106,12 +108,6 @@
106108
border-color: white;
107109
color: white;
108110
}
109-
.scraped-example .example-wrap .rust span.highlight {
110-
background: rgb(91, 59, 1);
111-
}
112-
.scraped-example .example-wrap .rust span.highlight.focus {
113-
background: rgb(124, 75, 15);
114-
}
115111
.scraped-example:not(.expanded) .code-wrapper::before {
116112
background: linear-gradient(to bottom, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
117113
}

Diff for: src/librustdoc/html/static/css/themes/light.css

+2-6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
--codeblock-link-background: #eee;
8484
--scrape-example-toggle-line-background: #ccc;
8585
--scrape-example-toggle-line-hover-background: #999;
86+
--scrape-example-code-line-highlight: #fcffd6;
87+
--scrape-example-code-line-highlight-focus: #f6fdb0;
8688
}
8789

8890
#search-tabs > button:not(.selected) {
@@ -103,12 +105,6 @@
103105
border-color: black;
104106
color: black;
105107
}
106-
.scraped-example .example-wrap .rust span.highlight {
107-
background: #fcffd6;
108-
}
109-
.scraped-example .example-wrap .rust span.highlight.focus {
110-
background: #f6fdb0;
111-
}
112108
.scraped-example:not(.expanded) .code-wrapper::before {
113109
background: linear-gradient(to bottom, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
114110
}

Diff for: src/test/rustdoc-gui/scrape-examples-color.goml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Check that scrape example code blocks have the expected colors.
2+
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
3+
4+
define-function: (
5+
"check-colors",
6+
(theme, highlight, highlight_focus),
7+
[
8+
("local-storage", { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }),
9+
("reload"),
10+
("wait-for", ".more-examples-toggle"),
11+
("assert-css", (".scraped-example .example-wrap .rust span.highlight:not(.focus)", {
12+
"background-color": |highlight|,
13+
}, ALL)),
14+
("assert-css", (".scraped-example .example-wrap .rust span.highlight.focus", {
15+
"background-color": |highlight_focus|,
16+
}, ALL)),
17+
]
18+
)
19+
20+
call-function: ("check-colors", {
21+
"theme": "ayu",
22+
"highlight": "rgb(91, 59, 1)",
23+
"highlight_focus": "rgb(124, 75, 15)",
24+
})
25+
call-function: ("check-colors", {
26+
"theme": "dark",
27+
"highlight": "rgb(91, 59, 1)",
28+
"highlight_focus": "rgb(124, 75, 15)",
29+
})
30+
call-function: ("check-colors", {
31+
"theme": "light",
32+
"highlight": "rgb(252, 255, 214)",
33+
"highlight_focus": "rgb(246, 253, 176)",
34+
})

0 commit comments

Comments
 (0)