Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search result colors #102369

Merged
merged 2 commits into from
Sep 28, 2022
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
4 changes: 3 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ pre.rust a,
}

.content span.fn, .content a.fn,
.content .fnname {
.content .fnname,
.content span.method, .content a.method,
.content span.tymethod, .content a.tymethod {
color: var(--function-link-color);
}

Expand Down
153 changes: 149 additions & 4 deletions src/test/rustdoc-gui/search-result-color.goml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ show-text: true
// Ayu theme
local-storage: {
"rustdoc-theme": "ayu",
"rustdoc-preferred-dark-theme": "ayu",
"rustdoc-use-system-theme": "false",
}
reload:
Expand All @@ -23,16 +22,66 @@ assert-css: (
{"color": "rgb(0, 150, 207)"},
)

// Checking the color for "keyword".
// Checking the color of "keyword" text.
assert-css: (
"//*[@class='result-name']//*[text()='(keyword)']",
{"color": "rgb(120, 135, 151)"},
)

// Checking the color of "keyword".
assert-css: (
".result-name .keyword",
{"color": "rgb(57, 175, 215)"},
ALL,
)
// Check the color of "struct".
assert-css: (
".result-name .struct",
{"color": "rgb(255, 160, 165)"},
ALL,
)
// Check the color of "associated type".
assert-css: (
".result-name .associatedtype",
{"color": "rgb(57, 175, 215)"},
ALL,
)
// Check the color of "type method".
assert-css: (
".result-name .tymethod",
{"color": "rgb(253, 214, 135)"},
ALL,
)
// Check the color of "method".
assert-css: (
".result-name .method",
{"color": "rgb(253, 214, 135)"},
ALL,
)
// Check the color of "struct field".
assert-css: (
".result-name .structfield",
{"color": "rgb(0, 150, 207)"},
ALL,
)
// Check the color of "macro".
assert-css: (
".result-name .macro",
{"color": "rgb(163, 122, 204)"},
ALL,
)
// Check the color of "fn".
assert-css: (
".result-name .fn",
{"color": "rgb(253, 214, 135)"},
ALL,
)

// Checking the `<a>` container.
assert-css: (
"//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
{"color": "rgb(0, 150, 207)", "background-color": "rgba(0, 0, 0, 0)"},
ALL,
)

// Checking color and background on hover.
Expand All @@ -49,7 +98,6 @@ assert-css: (
// Dark theme
local-storage: {
"rustdoc-theme": "dark",
"rustdoc-preferred-dark-theme": "dark",
"rustdoc-use-system-theme": "false",
}
reload:
Expand All @@ -71,6 +119,55 @@ assert-css: (
{"color": "rgb(221, 221, 221)"},
)

// Checking the color of "keyword".
assert-css: (
".result-name .keyword",
{"color": "rgb(210, 153, 29)"},
ALL,
)
// Check the color of "struct".
assert-css: (
".result-name .struct",
{"color": "rgb(45, 191, 184)"},
ALL,
)
// Check the color of "associated type".
assert-css: (
".result-name .associatedtype",
{"color": "rgb(210, 153, 29)"},
ALL,
)
// Check the color of "type method".
assert-css: (
".result-name .tymethod",
{"color": "rgb(43, 171, 99)"},
ALL,
)
// Check the color of "method".
assert-css: (
".result-name .method",
{"color": "rgb(43, 171, 99)"},
ALL,
)
// Check the color of "struct field".
assert-css: (
".result-name .structfield",
{"color": "rgb(221, 221, 221)"},
ALL,
)
// Check the color of "macro".
assert-css: (
".result-name .macro",
{"color": "rgb(9, 189, 0)"},
ALL,
)
// Check the color of "fn".
assert-css: (
".result-name .fn",
{"color": "rgb(43, 171, 99)"},
ALL,
)

// Checking the `<a>` container.
assert-css: (
"//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
Expand Down Expand Up @@ -109,6 +206,55 @@ assert-css: (
{"color": "rgb(0, 0, 0)"},
)

// Checking the color of "keyword".
assert-css: (
".result-name .keyword",
{"color": "rgb(56, 115, 173)"},
ALL,
)
// Check the color of "struct".
assert-css: (
".result-name .struct",
{"color": "rgb(173, 55, 138)"},
ALL,
)
// Check the color of "associated type".
assert-css: (
".result-name .associatedtype",
{"color": "rgb(56, 115, 173)"},
ALL,
)
// Check the color of "type method".
assert-css: (
".result-name .tymethod",
{"color": "rgb(173, 124, 55)"},
ALL,
)
// Check the color of "method".
assert-css: (
".result-name .method",
{"color": "rgb(173, 124, 55)"},
ALL,
)
// Check the color of "struct field".
assert-css: (
".result-name .structfield",
{"color": "rgb(0, 0, 0)"},
ALL,
)
// Check the color of "macro".
assert-css: (
".result-name .macro",
{"color": "rgb(6, 128, 0)"},
ALL,
)
// Check the color of "fn".
assert-css: (
".result-name .fn",
{"color": "rgb(173, 124, 55)"},
ALL,
)

// Checking the `<a>` container.
assert-css: (
"//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
Expand All @@ -132,7 +278,6 @@ goto: file://|DOC_PATH|/test_docs/index.html
// this test is running on.
local-storage: {
"rustdoc-theme": "dark",
"rustdoc-preferred-dark-theme": "dark",
"rustdoc-use-system-theme": "false",
}
// If the text isn't displayed, the browser doesn't compute color style correctly...
Expand Down
3 changes: 3 additions & 0 deletions src/test/rustdoc-gui/src/lib2/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ pub trait Trait {

#[deprecated = "Whatever [`Foo`](#tadam)"]
fn foo() {}
fn fooo();
}

impl Trait for Foo {
type X = u32;
const Y: u32 = 0;

fn fooo() {}
}

impl implementors::Whatever for Foo {
Expand Down