Skip to content

Commit cb77767

Browse files
authored
Rollup merge of rust-lang#91102 - jsha:theme-anchor, r=GuillaumeGomez
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. Demo at https://rustdoc.crud.net/jsha/theme-anchor/std/string/struct.String.html. This should result in no visible changes. r? `@GuillaumeGomez`
2 parents 936f260 + a56559d commit cb77767

File tree

6 files changed

+60
-32
lines changed

6 files changed

+60
-32
lines changed

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

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

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

Diff for: 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 {

Diff for: 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,

Diff for: 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,

Diff for: 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)"})

Diff for: src/tools/rustdoc-gui/tester.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ async function main(argv) {
194194
.then(out => {
195195
const [output, nb_failures] = out;
196196
results[nb_failures === 0 ? "successful" : "failed"].push({
197-
file_name: file_name,
197+
file_name: testPath,
198198
output: output,
199199
});
200200
if (nb_failures > 0) {
@@ -206,7 +206,7 @@ async function main(argv) {
206206
})
207207
.catch(err => {
208208
results.errored.push({
209-
file_name: file_name,
209+
file_name: testPath + file_name,
210210
output: err,
211211
});
212212
status_bar.erroneous();
@@ -239,15 +239,15 @@ async function main(argv) {
239239
console.log("");
240240
results.failed.sort(by_filename);
241241
results.failed.forEach(r => {
242-
console.log(r.output);
242+
console.log(r.file_name, r.output);
243243
});
244244
}
245245
if (results.errored.length > 0) {
246246
console.log(os.EOL);
247247
// print run errors on the bottom so developers see them better
248248
results.errored.sort(by_filename);
249249
results.errored.forEach(r => {
250-
console.error(r.output);
250+
console.error(r.file_name, r.output);
251251
});
252252
}
253253

0 commit comments

Comments
 (0)