Skip to content

Commit 0b97831

Browse files
committed
rustdoc: give .line-number / .line-numbers meaningful names
1 parent e1d7dec commit 0b97831

File tree

12 files changed

+47
-47
lines changed

12 files changed

+47
-47
lines changed

src/librustdoc/html/sources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ pub(crate) fn print_src(
274274
) {
275275
let lines = s.lines().count();
276276
let mut line_numbers = Buffer::empty_from(buf);
277-
line_numbers.write_str("<pre class=\"line-numbers\">");
277+
line_numbers.write_str("<pre class=\"src-line-numbers\">");
278278
match source_context {
279279
SourceContext::Standalone => {
280280
for line in 1..=lines {

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ h2.location a {
578578
position: relative;
579579
}
580580

581-
.example-wrap > pre.line-number {
581+
.example-wrap > pre.example-line-numbers {
582582
overflow: initial;
583583
border: 1px solid;
584584
padding: 13px 8px;
@@ -591,15 +591,15 @@ h2.location a {
591591
text-decoration: underline;
592592
}
593593

594-
.line-numbers {
594+
.src-line-numbers {
595595
text-align: right;
596596
}
597-
.rustdoc:not(.source) .example-wrap > pre:not(.line-number) {
597+
.rustdoc:not(.source) .example-wrap > pre:not(.example-line-numbers) {
598598
width: 100%;
599599
overflow-x: auto;
600600
}
601601

602-
.rustdoc:not(.source) .example-wrap > pre.line-numbers {
602+
.rustdoc:not(.source) .example-wrap > pre.src-line-numbers {
603603
width: auto;
604604
overflow-x: visible;
605605
}
@@ -612,14 +612,14 @@ h2.location a {
612612
text-align: center;
613613
}
614614

615-
.content > .example-wrap pre.line-numbers {
615+
.content > .example-wrap pre.src-line-numbers {
616616
position: relative;
617617
-webkit-user-select: none;
618618
-moz-user-select: none;
619619
-ms-user-select: none;
620620
user-select: none;
621621
}
622-
.line-numbers span {
622+
.src-line-numbers span {
623623
cursor: pointer;
624624
}
625625

@@ -2067,7 +2067,7 @@ in storage.js plus the media query with (min-width: 701px)
20672067
padding-bottom: 0;
20682068
}
20692069

2070-
.scraped-example:not(.expanded) .code-wrapper pre.line-numbers {
2070+
.scraped-example:not(.expanded) .code-wrapper pre.src-line-numbers {
20712071
overflow-x: hidden;
20722072
}
20732073

@@ -2113,12 +2113,12 @@ in storage.js plus the media query with (min-width: 701px)
21132113
bottom: 0;
21142114
}
21152115

2116-
.scraped-example .code-wrapper .line-numbers {
2116+
.scraped-example .code-wrapper .src-line-numbers {
21172117
margin: 0;
21182118
padding: 14px 0;
21192119
}
21202120

2121-
.scraped-example .code-wrapper .line-numbers span {
2121+
.scraped-example .code-wrapper .src-line-numbers span {
21222122
padding: 0 14px;
21232123
}
21242124

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ pre, .rustdoc.source .example-wrap {
9393
color: #ff7733;
9494
}
9595

96-
.line-numbers span { color: #5c6773; }
97-
.line-numbers .line-highlighted {
96+
.src-line-numbers span { color: #5c6773; }
97+
.src-line-numbers .line-highlighted {
9898
color: #708090;
9999
background-color: rgba(255, 236, 164, 0.06);
100100
padding-right: 4px;
@@ -171,7 +171,7 @@ details.rustdoc-toggle > summary::before {
171171
color: #788797;
172172
}
173173

174-
.line-numbers :target { background-color: transparent; }
174+
.src-line-numbers :target { background-color: transparent; }
175175

176176
/* Code highlighting */
177177
pre.rust .number, pre.rust .string { color: #b8cc52; }
@@ -190,7 +190,7 @@ pre.rust .attribute {
190190
color: #e6e1cf;
191191
}
192192

193-
.example-wrap > pre.line-number {
193+
.example-wrap > pre.example-line-numbers {
194194
color: #5c67736e;
195195
border: none;
196196
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ input:focus + .slider {
5454
background: #444;
5555
}
5656

57-
.line-numbers span { color: #3B91E2; }
58-
.line-numbers .line-highlighted {
57+
.src-line-numbers span { color: #3B91E2; }
58+
.src-line-numbers .line-highlighted {
5959
background-color: #0a042f !important;
6060
}
6161

@@ -141,7 +141,7 @@ details.rustdoc-toggle > summary::before {
141141
background: none;
142142
}
143143

144-
.line-numbers :target { background-color: transparent; }
144+
.src-line-numbers :target { background-color: transparent; }
145145

146146
/* Code highlighting */
147147
pre.rust .kw { color: #ab8ac1; }
@@ -155,7 +155,7 @@ pre.rust .question-mark {
155155
color: #ff9011;
156156
}
157157

158-
.example-wrap > pre.line-number {
158+
.example-wrap > pre.example-line-numbers {
159159
border-color: #4a4949;
160160
}
161161

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ input:focus + .slider {
5353
background-color: #fff;
5454
}
5555

56-
.line-numbers span { color: #c67e2d; }
57-
.line-numbers .line-highlighted {
56+
.src-line-numbers span { color: #c67e2d; }
57+
.src-line-numbers .line-highlighted {
5858
background-color: #FDFFD3 !important;
5959
}
6060

@@ -125,7 +125,7 @@ body.source .example-wrap pre.rust a {
125125
.stab { background: #FFF5D6; border-color: #FFC600; }
126126
.stab.portability > code { background: none; }
127127

128-
.line-numbers :target { background-color: transparent; }
128+
.src-line-numbers :target { background-color: transparent; }
129129

130130
/* Code highlighting */
131131
pre.rust .kw { color: #8959A8; }
@@ -141,7 +141,7 @@ pre.rust .question-mark {
141141
color: #ff9011;
142142
}
143143

144-
.example-wrap > pre.line-number {
144+
.example-wrap > pre.example-line-numbers {
145145
border-color: #c7c7c7;
146146
}
147147

src/librustdoc/html/static/js/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ function loadCss(cssFileName) {
699699
window.rustdoc_add_line_numbers_to_examples = () => {
700700
onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => {
701701
const parent = x.parentNode;
702-
const line_numbers = parent.querySelectorAll(".line-number");
702+
const line_numbers = parent.querySelectorAll(".example-line-numbers");
703703
if (line_numbers.length > 0) {
704704
return;
705705
}
@@ -709,7 +709,7 @@ function loadCss(cssFileName) {
709709
elems.push(i + 1);
710710
}
711711
const node = document.createElement("pre");
712-
addClass(node, "line-number");
712+
addClass(node, "example-line-numbers");
713713
node.innerHTML = elems.join("\n");
714714
parent.insertBefore(node, x);
715715
});
@@ -718,7 +718,7 @@ function loadCss(cssFileName) {
718718
window.rustdoc_remove_line_numbers_from_examples = () => {
719719
onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => {
720720
const parent = x.parentNode;
721-
const line_numbers = parent.querySelectorAll(".line-number");
721+
const line_numbers = parent.querySelectorAll(".example-line-numbers");
722722
for (const node of line_numbers) {
723723
parent.removeChild(node);
724724
}

src/librustdoc/html/static/js/scrape-examples.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Scroll code block to the given code location
1010
function scrollToLoc(elt, loc) {
11-
const lines = elt.querySelector(".line-numbers");
11+
const lines = elt.querySelector(".src-line-numbers");
1212
let scrollOffset;
1313

1414
// If the block is greater than the size of the viewer,

src/librustdoc/html/static/js/source-script.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function highlightSourceLines(match) {
183183
if (x) {
184184
x.scrollIntoView();
185185
}
186-
onEachLazy(document.getElementsByClassName("line-numbers"), e => {
186+
onEachLazy(document.getElementsByClassName("src-line-numbers"), e => {
187187
onEachLazy(e.getElementsByTagName("span"), i_e => {
188188
removeClass(i_e, "line-highlighted");
189189
});
@@ -245,7 +245,7 @@ window.addEventListener("hashchange", () => {
245245
}
246246
});
247247

248-
onEachLazy(document.getElementsByClassName("line-numbers"), el => {
248+
onEachLazy(document.getElementsByClassName("src-line-numbers"), el => {
249249
el.addEventListener("click", handleSourceHighlight);
250250
});
251251

src/test/run-make-fulldeps/rustdoc-scrape-examples-macros/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Scraped example should only include line numbers for items b and c in ex.rs
2-
// @!has foobar/fn.f.html '//*[@class="line-numbers"]' '14'
3-
// @has foobar/fn.f.html '//*[@class="line-numbers"]' '15'
4-
// @has foobar/fn.f.html '//*[@class="line-numbers"]' '21'
5-
// @!has foobar/fn.f.html '//*[@class="line-numbers"]' '22'
2+
// @!has foobar/fn.f.html '//*[@class="src-line-numbers"]' '14'
3+
// @has foobar/fn.f.html '//*[@class="src-line-numbers"]' '15'
4+
// @has foobar/fn.f.html '//*[@class="src-line-numbers"]' '21'
5+
// @!has foobar/fn.f.html '//*[@class="src-line-numbers"]' '22'
66

77
pub fn f() {}
88

src/test/rustdoc-gui/basic-code.goml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
goto: file://|DOC_PATH|/test_docs/index.html
22
click: ".srclink"
3-
assert-count: (".line-numbers", 1)
3+
assert-count: (".src-line-numbers", 1)

0 commit comments

Comments
 (0)