Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,13 @@ in storage.js
overflow-x: hidden;
}

.scraped-example .example-wrap .rust span.highlight {
background: var(--scrape-example-code-line-highlight);
}
.scraped-example .example-wrap .rust span.highlight.focus {
background: var(--scrape-example-code-line-highlight-focus);
}

.more-examples-toggle {
max-width: calc(100% + 25px);
margin-top: 10px;
Expand Down
8 changes: 2 additions & 6 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--codeblock-link-background: #333;
--scrape-example-toggle-line-background: #999;
--scrape-example-toggle-line-hover-background: #c5c5c5;
--scrape-example-code-line-highlight: rgb(91, 59, 1);
--scrape-example-code-line-highlight-focus: rgb(124, 75, 15);
}

h1, h2, h3, h4 {
Expand Down Expand Up @@ -206,12 +208,6 @@ above the `@media (max-width: 700px)` rules due to a bug in the css checker */
border-color: white;
color: white;
}
.scraped-example .example-wrap .rust span.highlight {
background: rgb(91, 59, 1);
}
.scraped-example .example-wrap .rust span.highlight.focus {
background: rgb(124, 75, 15);
}
.scraped-example:not(.expanded) .code-wrapper::before {
background: linear-gradient(to bottom, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
}
Expand Down
8 changes: 2 additions & 6 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
--codeblock-link-background: #333;
--scrape-example-toggle-line-background: #999;
--scrape-example-toggle-line-hover-background: #c5c5c5;
--scrape-example-code-line-highlight: rgb(91, 59, 1);
--scrape-example-code-line-highlight-focus: rgb(124, 75, 15);
}

#search-tabs > button:not(.selected) {
Expand All @@ -106,12 +108,6 @@
border-color: white;
color: white;
}
.scraped-example .example-wrap .rust span.highlight {
background: rgb(91, 59, 1);
}
.scraped-example .example-wrap .rust span.highlight.focus {
background: rgb(124, 75, 15);
}
.scraped-example:not(.expanded) .code-wrapper::before {
background: linear-gradient(to bottom, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
}
Expand Down
8 changes: 2 additions & 6 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
--codeblock-link-background: #eee;
--scrape-example-toggle-line-background: #ccc;
--scrape-example-toggle-line-hover-background: #999;
--scrape-example-code-line-highlight: #fcffd6;
--scrape-example-code-line-highlight-focus: #f6fdb0;
}

#search-tabs > button:not(.selected) {
Expand All @@ -103,12 +105,6 @@
border-color: black;
color: black;
}
.scraped-example .example-wrap .rust span.highlight {
background: #fcffd6;
}
.scraped-example .example-wrap .rust span.highlight.focus {
background: #f6fdb0;
}
.scraped-example:not(.expanded) .code-wrapper::before {
background: linear-gradient(to bottom, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
}
Expand Down
34 changes: 34 additions & 0 deletions src/test/rustdoc-gui/scrape-examples-color.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Check that scrape example code blocks have the expected colors.
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"

define-function: (
"check-colors",
(theme, highlight, highlight_focus),
[
("local-storage", { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }),
("reload"),
("wait-for", ".more-examples-toggle"),
("assert-css", (".scraped-example .example-wrap .rust span.highlight:not(.focus)", {
"background-color": |highlight|,
}, ALL)),
("assert-css", (".scraped-example .example-wrap .rust span.highlight.focus", {
"background-color": |highlight_focus|,
}, ALL)),
]
)

call-function: ("check-colors", {
"theme": "ayu",
"highlight": "rgb(91, 59, 1)",
"highlight_focus": "rgb(124, 75, 15)",
})
call-function: ("check-colors", {
"theme": "dark",
"highlight": "rgb(91, 59, 1)",
"highlight_focus": "rgb(124, 75, 15)",
})
call-function: ("check-colors", {
"theme": "light",
"highlight": "rgb(252, 255, 214)",
"highlight_focus": "rgb(246, 253, 176)",
})