Skip to content

Commit a56559d

Browse files
committed
Set color for <a> in a more straightforward way
Previously, we set the default color for <a> 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 <a> 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.
1 parent f377ac5 commit a56559d

File tree

5 files changed

+56
-28
lines changed

5 files changed

+56
-28
lines changed

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

-4
Original file line numberDiff line numberDiff line change
@@ -1079,10 +1079,6 @@ a.test-arrow:hover{
10791079
text-decoration: none;
10801080
}
10811081

1082-
.section-header a {
1083-
color: inherit;
1084-
}
1085-
10861082
.code-attribute {
10871083
font-weight: 300;
10881084
}

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

+11-6
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,23 @@ nav.main .separator {
214214
border: 1px solid #5c6773;
215215
}
216216
a {
217+
color: #39AFD7;
218+
}
219+
a.srclink,
220+
a#toggle-all-docs,
221+
#source-sidebar a,
222+
pre.rust a,
223+
.sidebar a,
224+
.in-band a {
217225
color: #c5c5c5;
218226
}
227+
.search-results a {
228+
color: #0096cf;
229+
}
219230
body.source .example-wrap pre.rust a {
220231
background: #333;
221232
}
222233

223-
.docblock:not(.item-decl) a:not(.srclink):not(.test-arrow),
224-
.docblock-short a:not(.srclink):not(.test-arrow), .item-info a,
225-
#help a {
226-
color: #39AFD7;
227-
}
228-
229234
details.rustdoc-toggle > summary.hideme > span,
230235
details.rustdoc-toggle > summary::before,
231236
details.undocumented > summary::before {

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

+14-9
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,27 @@ nav.main .current {
174174
nav.main .separator {
175175
border-color: #eee;
176176
}
177+
177178
a {
178-
color: #ddd;
179+
color: #D2991D;
179180
}
180-
body.source .example-wrap pre.rust a {
181-
background: #333;
181+
a.srclink,
182+
a#toggle-all-docs,
183+
#source-sidebar a,
184+
pre.rust a,
185+
.sidebar a,
186+
.in-band a {
187+
color: #ddd;
182188
}
183-
184-
.docblock:not(.item-decl) a:not(.srclink):not(.test-arrow),
185-
.docblock-short a:not(.srclink):not(.test-arrow), .item-info a,
186-
#help a {
187-
color: #D2991D;
189+
.search-results a {
190+
color: #ddd;
188191
}
189-
190192
a.test-arrow {
191193
color: #dedede;
192194
}
195+
body.source .example-wrap pre.rust a {
196+
background: #333;
197+
}
193198

194199
details.rustdoc-toggle > summary.hideme > span,
195200
details.rustdoc-toggle > summary::before,

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

+14-9
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,27 @@ nav.main .current {
169169
nav.main .separator {
170170
border: 1px solid #000;
171171
}
172+
172173
a {
173-
color: #000;
174+
color: #3873AD;
174175
}
175-
body.source .example-wrap pre.rust a {
176-
background: #eee;
176+
a.srclink,
177+
a#toggle-all-docs,
178+
#source-sidebar a,
179+
pre.rust a,
180+
.sidebar a,
181+
.in-band a {
182+
color: #000;
177183
}
178-
179-
.docblock:not(.item-decl) a:not(.srclink):not(.test-arrow),
180-
.docblock-short a:not(.srclink):not(.test-arrow), .item-info a,
181-
#help a {
182-
color: #3873AD;
184+
.search-results a {
185+
color: initial;
183186
}
184-
185187
a.test-arrow {
186188
color: #f5f5f5;
187189
}
190+
body.source .example-wrap pre.rust a {
191+
background: #eee;
192+
}
188193

189194
details.rustdoc-toggle > summary.hideme > span,
190195
details.rustdoc-toggle > summary::before,

src/test/rustdoc-gui/anchors.goml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
2+
3+
// Set the theme to light.
4+
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
5+
// We reload the page so the local storage settings are being used.
6+
reload:
7+
8+
assert-css: ("#toggle-all-docs", {"color": "rgba(0, 0, 0, 0)"})
9+
assert-css: (".fqn .in-band a:nth-of-type(1)", {"color": "rgba(0, 0, 0, 0)"})
10+
assert-css: (".fqn .in-band a:nth-of-type(2)", {"color": "rgba(0, 0, 0, 0)"})
11+
assert-css: (".srclink", {"color": "rgba(0, 0, 0, 0)"})
12+
assert-css: (".srclink", {"color": "rgba(0, 0, 0, 0)"})
13+
14+
assert-css: ("#top-doc-prose-title", {"color": "rgba(0, 0, 0, 0)"})
15+
16+
assert-css: (".sidebar a", {"color": "rgba(0, 0, 0, 0)"})
17+
assert-css: (".in-band a", {"color": "rgba(0, 0, 0, 0)"})

0 commit comments

Comments
 (0)