Skip to content
/ rust Public
forked from rust-lang/rust

Commit a1471f3

Browse files
Rename feature into Word wrap source code
1 parent 38b5bfc commit a1471f3

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

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

+13-13
Original file line numberDiff line numberDiff line change
@@ -938,54 +938,54 @@ ul.block, .block li, .block ul {
938938
.example-wrap .line-highlighted[data-nosnippet] {
939939
background-color: var(--src-line-number-highlighted-background-color);
940940
}
941-
:root.wrap-source-code .example-wrap [data-nosnippet] {
941+
:root.word-wrap-source-code .example-wrap [data-nosnippet] {
942942
position: absolute;
943943
left: 0;
944944
}
945-
.wrap-source-code .example-wrap pre > code {
945+
.word-wrap-source-code .example-wrap pre > code {
946946
position: relative;
947947
word-break: break-all;
948948
}
949-
:root.wrap-source-code .example-wrap pre > code {
949+
:root.word-wrap-source-code .example-wrap pre > code {
950950
display: block;
951951
white-space: pre-wrap;
952952
}
953-
:root.wrap-source-code .example-wrap pre > code * {
953+
:root.word-wrap-source-code .example-wrap pre > code * {
954954
word-break: break-all;
955955
}
956-
:root.wrap-source-code .example-wrap.digits-1 pre > code {
956+
:root.word-wrap-source-code .example-wrap.digits-1 pre > code {
957957
padding-left: calc(
958958
1ch + var(--line-number-padding) * 2 + var(--line-number-right-margin));
959959
}
960-
:root.wrap-source-code .example-wrap.digits-2 pre > code {
960+
:root.word-wrap-source-code .example-wrap.digits-2 pre > code {
961961
padding-left: calc(
962962
2ch + var(--line-number-padding) * 2 + var(--line-number-right-margin));
963963
}
964-
:root.wrap-source-code .example-wrap.digits-3 pre > code {
964+
:root.word-wrap-source-code .example-wrap.digits-3 pre > code {
965965
padding-left: calc(
966966
3ch + var(--line-number-padding) * 2 + var(--line-number-right-margin));
967967
}
968-
:root.wrap-source-code .example-wrap.digits-4 pre > code {
968+
:root.word-wrap-source-code .example-wrap.digits-4 pre > code {
969969
padding-left: calc(
970970
4ch + var(--line-number-padding) * 2 + var(--line-number-right-margin));
971971
}
972-
:root.wrap-source-code .example-wrap.digits-5 pre > code {
972+
:root.word-wrap-source-code .example-wrap.digits-5 pre > code {
973973
padding-left: calc(
974974
5ch + var(--line-number-padding) * 2 + var(--line-number-right-margin));
975975
}
976-
:root.wrap-source-code .example-wrap.digits-6 pre > code {
976+
:root.word-wrap-source-code .example-wrap.digits-6 pre > code {
977977
padding-left: calc(
978978
6ch + var(--line-number-padding) * 2 + var(--line-number-right-margin));
979979
}
980-
:root.wrap-source-code .example-wrap.digits-7 pre > code {
980+
:root.word-wrap-source-code .example-wrap.digits-7 pre > code {
981981
padding-left: calc(
982982
7ch + var(--line-number-padding) * 2 + var(--line-number-right-margin));
983983
}
984-
:root.wrap-source-code .example-wrap.digits-8 pre > code {
984+
:root.word-wrap-source-code .example-wrap.digits-8 pre > code {
985985
padding-left: calc(
986986
8ch + var(--line-number-padding) * 2 + var(--line-number-right-margin));
987987
}
988-
:root.wrap-source-code .example-wrap.digits-9 pre > code {
988+
:root.word-wrap-source-code .example-wrap.digits-9 pre > code {
989989
padding-left: calc(
990990
9ch + var(--line-number-padding) * 2 + var(--line-number-right-margin));
991991
}

src/librustdoc/html/static/js/settings.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@
6060
removeClass(document.documentElement, "sans-serif");
6161
}
6262
break;
63-
case "wrap-source-code":
63+
case "word-wrap-source-code":
6464
if (value === true) {
65-
addClass(document.documentElement, "wrap-source-code");
65+
addClass(document.documentElement, "word-wrap-source-code");
6666
} else {
67-
removeClass(document.documentElement, "wrap-source-code");
67+
removeClass(document.documentElement, "word-wrap-source-code");
6868
}
6969
break;
7070
}
@@ -255,8 +255,8 @@
255255
"default": false,
256256
},
257257
{
258-
"name": "Wrap source codes",
259-
"js_name": "wrap-source-code",
258+
"name": "Word wrap source code",
259+
"js_name": "word-wrap-source-code",
260260
"default": false,
261261
},
262262
];

src/librustdoc/html/static/js/storage.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ if (getSettingValue("hide-modnav") === "true") {
286286
if (getSettingValue("sans-serif-fonts") === "true") {
287287
addClass(document.documentElement, "sans-serif");
288288
}
289-
if (getSettingValue("wrap-source-code") === "true") {
290-
addClass(document.documentElement, "wrap-source-code");
289+
if (getSettingValue("word-wrap-source-code") === "true") {
290+
addClass(document.documentElement, "word-wrap-source-code");
291291
}
292292
function updateSidebarWidth() {
293293
const desktopSidebarWidth = getSettingValue("desktop-sidebar-width");

tests/rustdoc-gui/source-code-wrapping.goml

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
// Checks that the interactions with the source code pages are working as expected.
22
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
33
show-text: true
4+
set-window-size: (1000, 1000)
45

56
define-function: (
67
"click-code-wrapping",
78
[expected],
89
block {
9-
click: "#wrap-source-code"
10-
wait-for-local-storage: {"rustdoc-wrap-source-code": |expected|}
10+
click: "#word-wrap-source-code"
11+
wait-for-local-storage: {"rustdoc-word-wrap-source-code": |expected|}
1112
},
1213
)
1314

1415
store-size: (".rust code", {"width": width, "height": height})
1516
click: "#settings-menu"
1617
wait-for: "#settings"
1718
call-function: ("click-code-wrapping", {"expected": "true"})
19+
wait-for-size-false: (".rust code", {"width": |width|, "height": |height|})
1820
store-size: (".rust code", {"width": new_width, "height": new_height})
1921
// The width should now be smaller than the window's and the height
2022
// should have increased.
@@ -32,6 +34,7 @@ wait-for: "#settings"
3234
store-size: (".example-wrap .rust code", {"width": rust_width, "height": rust_height})
3335
store-size: (".example-wrap .language-text code", {"width": txt_width, "height": txt_height})
3436
call-function: ("click-code-wrapping", {"expected": "true"})
37+
wait-for-size-false: (".example-wrap .rust code", {"width": |rust_width|, "height": |rust_height|})
3538

3639
store-size: (".example-wrap .rust code", {"width": new_rust_width, "height": new_rust_height})
3740
store-size: (".example-wrap .language-text code", {"width": new_txt_width, "height": new_txt_height})
@@ -40,5 +43,5 @@ assert: |rust_width| > |new_rust_width| && |rust_height| < |new_rust_height|
4043
assert: |txt_width| > |new_txt_width| && |txt_height| < |new_txt_height|
4144

4245
call-function: ("click-code-wrapping", {"expected": "false"})
43-
assert-size: (".example-wrap .rust code", {"width": |rust_width|, "height": |rust_height|})
46+
wait-for-size: (".example-wrap .rust code", {"width": |rust_width|, "height": |rust_height|})
4447
assert-size: (".example-wrap .language-text code", {"width": |txt_width|, "height": |txt_height|})

0 commit comments

Comments
 (0)