From a56559df1346c44aa058f3a82785f20230a0468f Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Sun, 21 Nov 2021 21:10:12 -0800 Subject: [PATCH] Set color for in a more straightforward way Previously, we set the default color for tags to black, and then had an override with a bunch of not() clauses to set anchors in docblocks to blue. Instead, we should set the default color for to blue (or equivalent in other themes), and override it for places like the sidebar or search results, where we don't want them to be styled as links. --- src/librustdoc/html/static/css/rustdoc.css | 4 --- src/librustdoc/html/static/css/themes/ayu.css | 17 ++++++++----- .../html/static/css/themes/dark.css | 25 +++++++++++-------- .../html/static/css/themes/light.css | 25 +++++++++++-------- src/test/rustdoc-gui/anchors.goml | 17 +++++++++++++ 5 files changed, 58 insertions(+), 30 deletions(-) create mode 100644 src/test/rustdoc-gui/anchors.goml diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 89a763ef6d7..f4d6b39eedf 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1079,10 +1079,6 @@ a.test-arrow:hover{ text-decoration: none; } -.section-header a { - color: inherit; -} - .code-attribute { font-weight: 300; } diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css index ba7fb3b5456..a808dbd9ef1 100644 --- a/src/librustdoc/html/static/css/themes/ayu.css +++ b/src/librustdoc/html/static/css/themes/ayu.css @@ -214,18 +214,23 @@ nav.main .separator { border: 1px solid #5c6773; } a { + color: #39AFD7; +} +a.srclink, +a#toggle-all-docs, +#source-sidebar a, +pre.rust a, +.sidebar a, +.in-band a { color: #c5c5c5; } +.search-results a { + color: #0096cf; +} body.source .example-wrap pre.rust a { background: #333; } -.docblock:not(.item-decl) a:not(.srclink):not(.test-arrow), -.docblock-short a:not(.srclink):not(.test-arrow), .item-info a, -#help a { - color: #39AFD7; -} - details.rustdoc-toggle > summary.hideme > span, details.rustdoc-toggle > summary::before, details.undocumented > summary::before { diff --git a/src/librustdoc/html/static/css/themes/dark.css b/src/librustdoc/html/static/css/themes/dark.css index 77ac217e6f4..f0ac129b997 100644 --- a/src/librustdoc/html/static/css/themes/dark.css +++ b/src/librustdoc/html/static/css/themes/dark.css @@ -174,23 +174,28 @@ nav.main .current { nav.main .separator { border-color: #eee; } + a { + color: #D2991D; +} +a.srclink, +a#toggle-all-docs, +#source-sidebar a, +pre.rust a, +.sidebar a, +.in-band a { color: #ddd; } +.search-results a { + color: #ddd; +} +a.test-arrow { + color: #dedede; +} body.source .example-wrap pre.rust a { background: #333; } -.docblock:not(.item-decl) a:not(.srclink):not(.test-arrow), -.docblock-short a:not(.srclink):not(.test-arrow), .item-info a, -#help a { - color: #D2991D; -} - -a.test-arrow { - color: #dedede; -} - details.rustdoc-toggle > summary.hideme > span, details.rustdoc-toggle > summary::before, details.undocumented > summary::before { diff --git a/src/librustdoc/html/static/css/themes/light.css b/src/librustdoc/html/static/css/themes/light.css index 6df137e3914..05f12fc365d 100644 --- a/src/librustdoc/html/static/css/themes/light.css +++ b/src/librustdoc/html/static/css/themes/light.css @@ -169,23 +169,28 @@ nav.main .current { nav.main .separator { border: 1px solid #000; } + a { + color: #3873AD; +} +a.srclink, +a#toggle-all-docs, +#source-sidebar a, +pre.rust a, +.sidebar a, +.in-band a { color: #000; } +.search-results a { + color: initial; +} +a.test-arrow { + color: #f5f5f5; +} body.source .example-wrap pre.rust a { background: #eee; } -.docblock:not(.item-decl) a:not(.srclink):not(.test-arrow), -.docblock-short a:not(.srclink):not(.test-arrow), .item-info a, -#help a { - color: #3873AD; -} - -a.test-arrow { - color: #f5f5f5; -} - details.rustdoc-toggle > summary.hideme > span, details.rustdoc-toggle > summary::before, details.undocumented > summary::before { diff --git a/src/test/rustdoc-gui/anchors.goml b/src/test/rustdoc-gui/anchors.goml new file mode 100644 index 00000000000..6953009604c --- /dev/null +++ b/src/test/rustdoc-gui/anchors.goml @@ -0,0 +1,17 @@ +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html + +// Set the theme to light. +local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} +// We reload the page so the local storage settings are being used. +reload: + +assert-css: ("#toggle-all-docs", {"color": "rgba(0, 0, 0, 0)"}) +assert-css: (".fqn .in-band a:nth-of-type(1)", {"color": "rgba(0, 0, 0, 0)"}) +assert-css: (".fqn .in-band a:nth-of-type(2)", {"color": "rgba(0, 0, 0, 0)"}) +assert-css: (".srclink", {"color": "rgba(0, 0, 0, 0)"}) +assert-css: (".srclink", {"color": "rgba(0, 0, 0, 0)"}) + +assert-css: ("#top-doc-prose-title", {"color": "rgba(0, 0, 0, 0)"}) + +assert-css: (".sidebar a", {"color": "rgba(0, 0, 0, 0)"}) +assert-css: (".in-band a", {"color": "rgba(0, 0, 0, 0)"})