Skip to content

Commit 750bf73

Browse files
authored
2 parents 09ee704 + f451717 commit 750bf73

File tree

6 files changed

+54
-39
lines changed

6 files changed

+54
-39
lines changed

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

+9-21
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ pre {
347347
.source .content pre {
348348
padding: 20px;
349349
}
350+
.rustdoc.source .example-wrap > pre.src-line-numbers {
351+
padding: 20px 0 20px 4px;
352+
}
350353

351354
img {
352355
max-width: 100%;
@@ -519,10 +522,6 @@ ul.block, .block li {
519522
display: none;
520523
}
521524

522-
.source .content pre.rust {
523-
padding-left: 0;
524-
}
525-
526525
.rustdoc .example-wrap {
527526
display: flex;
528527
position: relative;
@@ -550,23 +549,21 @@ ul.block, .block li {
550549
-moz-user-select: none;
551550
-ms-user-select: none;
552551
user-select: none;
552+
padding: 14px 8px;
553+
color: var(--src-line-numbers-span-color);
553554
}
554555

555-
.example-line-numbers {
556-
border: 1px solid;
557-
padding: 13px 8px;
558-
border-top-left-radius: 5px;
559-
border-bottom-left-radius: 5px;
560-
border-color: var(--example-line-numbers-border-color);
556+
.rustdoc .example-wrap > pre.src-line-numbers {
557+
padding: 14px 0;
561558
}
562-
563559
.src-line-numbers a, .src-line-numbers span {
564560
color: var(--src-line-numbers-span-color);
561+
padding: 0 8px;
565562
}
566563
.src-line-numbers :target {
567564
background-color: transparent;
568565
border-right: none;
569-
padding-right: 0;
566+
padding: 0 8px;
570567
}
571568
.src-line-numbers .line-highlighted {
572569
background-color: var(--src-line-number-highlighted-background-color);
@@ -1958,15 +1955,6 @@ in storage.js
19581955
bottom: 0;
19591956
}
19601957

1961-
.scraped-example .code-wrapper .src-line-numbers {
1962-
padding: 14px 0;
1963-
}
1964-
1965-
.scraped-example .code-wrapper .src-line-numbers a,
1966-
.scraped-example .code-wrapper .src-line-numbers span {
1967-
padding: 0 14px;
1968-
}
1969-
19701958
.scraped-example .code-wrapper .example-wrap {
19711959
width: 100%;
19721960
overflow-y: hidden;

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ Original by Dempfi (https://github.com/dempfi/ayu)
6262
--code-highlight-question-mark-color: #ff9011;
6363
--code-highlight-comment-color: #788797;
6464
--code-highlight-doc-comment-color: #a1ac88;
65-
--example-line-numbers-border-color: none;
6665
--src-line-numbers-span-color: #5c6773;
6766
--src-line-number-highlighted-background-color: rgba(255, 236, 164, 0.06);
6867
--test-arrow-color: #788797;
@@ -132,7 +131,7 @@ pre, .rustdoc.source .example-wrap {
132131

133132
.src-line-numbers .line-highlighted {
134133
color: #708090;
135-
padding-right: 4px;
134+
padding-right: 7px;
136135
border-right: 1px solid #ffb44c;
137136
}
138137

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

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
--code-highlight-question-mark-color: #ff9011;
5858
--code-highlight-comment-color: #8d8d8b;
5959
--code-highlight-doc-comment-color: #8ca375;
60-
--example-line-numbers-border-color: #4a4949;
6160
--src-line-numbers-span-color: #3b91e2;
6261
--src-line-number-highlighted-background-color: #0a042f;
6362
--test-arrow-color: #dedede;

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

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
--code-highlight-question-mark-color: #ff9011;
5858
--code-highlight-comment-color: #8e908c;
5959
--code-highlight-doc-comment-color: #4d4d4c;
60-
--example-line-numbers-border-color: #c7c7c7;
6160
--src-line-numbers-span-color: #c67e2d;
6261
--src-line-number-highlighted-background-color: #fdffd3;
6362
--test-arrow-color: #f5f5f5;

src/test/rustdoc-gui/docblock-code-block-line-number.goml

+42-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,53 @@
11
// Checks that the setting "line numbers" is working as expected.
22
goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
33

4+
// Otherwise, we can't check text color
5+
show-text: true
6+
47
// We check that without this setting, there is no line number displayed.
58
assert-false: "pre.example-line-numbers"
69

7-
// We now set the setting to show the line numbers on code examples.
8-
local-storage: {"rustdoc-line-numbers": "true" }
9-
// We reload to make the line numbers appear.
10-
reload:
11-
12-
// We wait for them to be added into the DOM by the JS...
13-
wait-for: "pre.example-line-numbers"
14-
// If the test didn't fail, it means that it was found!
1510
// Let's now check some CSS properties...
16-
assert-css: ("pre.example-line-numbers", {
17-
"margin": "0px",
18-
"padding": "13px 8px",
19-
"text-align": "right",
11+
define-function: (
12+
"check-colors",
13+
(theme, color),
14+
[
15+
// We now set the setting to show the line numbers on code examples.
16+
("local-storage", {
17+
"rustdoc-theme": |theme|,
18+
"rustdoc-use-system-theme": "false",
19+
"rustdoc-line-numbers": "true"
20+
}),
21+
// We reload to make the line numbers appear and change theme.
22+
("reload"),
23+
// We wait for them to be added into the DOM by the JS...
24+
("wait-for", "pre.example-line-numbers"),
25+
// If the test didn't fail, it means that it was found!
26+
("assert-css", (
27+
"pre.example-line-numbers",
28+
{
29+
"color": |color|,
30+
"margin": "0px",
31+
"padding": "14px 8px",
32+
"text-align": "right",
33+
},
34+
ALL,
35+
)),
36+
],
37+
)
38+
call-function: ("check-colors", {
39+
"theme": "ayu",
40+
"color": "rgb(92, 103, 115)",
2041
})
42+
call-function: ("check-colors", {
43+
"theme": "dark",
44+
"color": "rgb(59, 145, 226)",
45+
})
46+
call-function: ("check-colors", {
47+
"theme": "light",
48+
"color": "rgb(198, 126, 45)",
49+
})
50+
2151
// The first code block has two lines so let's check its `<pre>` elements lists both of them.
2252
assert-text: ("pre.example-line-numbers", "1\n2")
2353

src/test/rustdoc-gui/source-code-page.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
8989
// do anything (and certainly not add a `#NaN` to the URL!).
9090
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
9191
// We use this assert-position to know where we will click.
92-
assert-position: ("//*[@id='1']", {"x": 104, "y": 112})
92+
assert-position: ("//*[@id='1']", {"x": 88, "y": 112})
9393
// We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
94-
click: (103, 103)
94+
click: (87, 103)
9595
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
9696

9797
// Checking the source code sidebar.

0 commit comments

Comments
 (0)