Skip to content

Commit 0d6e130

Browse files
committed
Auto merge of rust-lang#131002 - steffahn:rustdoc-long-names-fix, r=notriddle
In redesigned rustdoc toolbar: Adjust spacings and sizing to improve behavior with over-long names Fixes rust-lang#130993. Some additional adjustments also fix more issues I’ve noticed such as: * on small screens, opening search made the 3 bottons move down very slightly (because the row with the crate picker got larger, enlarging the whole grid), this is fixed with a `min-height: 60px` on the toolbar * with long names in the “breadcrumps” area, wrapping was very broken * ![Screenshot_20240929_031831](https://github.com/user-attachments/assets/6f46bbb7-004b-4606-bf17-8a6f3289a8f7) * fixed: * ![Screenshot_20240929_035312](https://github.com/user-attachments/assets/4e2f8dd2-043e-4279-b588-0a72c7533f8e) * the left grid area has a minimal width (105px); like before, that leaves about enough space for crate names becoming as short as “all cra…”; to save even more space, there’s support for a little bit of extra squeezing of the buttons * ![Screenshot_20240929_034511](https://github.com/user-attachments/assets/7c6788ee-8ec1-4a38-b341-8d67704f5575) * ![Screenshot_20240929_034525](https://github.com/user-attachments/assets/e141756d-37a9-4205-bc4d-235ddd1c0609) * ![Screenshot_20240929_034535](https://github.com/user-attachments/assets/526447f3-48b6-47aa-8a60-e5b0d4d055f0) I’m really not super good with HTML or CSS stuff at all; there seem to be many magical numbers already, I’ve just used `px` values until things look right, I hope that’s okay 🤷‍♂️ r? `@GuillaumeGomez` cc `@notriddle`
2 parents 7608018 + c27b54a commit 0d6e130

File tree

6 files changed

+26
-20
lines changed

6 files changed

+26
-20
lines changed

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

+12-6
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,18 @@ h1, h2, h3, h4 {
182182
"main-heading-breadcrumbs main-heading-breadcrumbs"
183183
"main-heading-h1 main-heading-toolbar"
184184
"main-heading-sub-heading main-heading-toolbar";
185-
grid-template-columns: 1fr max-content;
186-
grid-template-rows: 25px min-content min-content;
185+
grid-template-columns: minmax(105px, 1fr) minmax(0, max-content);
186+
grid-template-rows: minmax(25px, min-content) min-content min-content;
187187
padding-bottom: 6px;
188188
margin-bottom: 11px;
189189
}
190190
.rustdoc-breadcrumbs {
191191
grid-area: main-heading-breadcrumbs;
192-
height: 25px;
193192
line-height: 1.25;
194193
display: flex;
194+
flex-wrap: wrap;
195195
align-items: end;
196+
padding-top: 5px;
196197
}
197198
.rustdoc-breadcrumbs a {
198199
padding: 4px 0;
@@ -928,6 +929,7 @@ rustdoc-toolbar {
928929
display: flex;
929930
flex-direction: row;
930931
flex-wrap: nowrap;
932+
min-height: 60px;
931933
}
932934

933935
.docblock code, .docblock-short code,
@@ -1104,17 +1106,17 @@ table,
11041106
.search-results-title + .sub-heading {
11051107
color: var(--main-color);
11061108
display: flex;
1107-
align-items: center;
1109+
align-items: baseline;
1110+
white-space: nowrap;
11081111
}
11091112
#crate-search-div {
11101113
/* ensures that 100% in properties of #crate-search-div:after
11111114
are relative to the size of this div */
11121115
position: relative;
11131116
/* allows this div (and with it the <select>-element "#crate-search") to be shrunk */
1114-
min-width: 5em;
1117+
min-width: 0;
11151118
}
11161119
#crate-search {
1117-
min-width: 115px;
11181120
padding: 0 23px 0 4px;
11191121
/* prevents the <select> from overflowing the containing div in case it's shrunk */
11201122
max-width: 100%;
@@ -1825,6 +1827,7 @@ a.tooltip:hover::after {
18251827
margin-left: var(--button-left-margin);
18261828
display: flex;
18271829
line-height: 1.25;
1830+
min-width: 14px;
18281831
}
18291832
#sidebar-button {
18301833
display: none;
@@ -1861,6 +1864,9 @@ a.tooltip:hover::after {
18611864
width: 80px;
18621865
border-radius: var(--toolbar-button-border-radius);
18631866
}
1867+
#settings-menu > a, #help-button > a {
1868+
min-width: 0;
1869+
}
18641870
#sidebar-button > a {
18651871
background-color: var(--button-background-color);
18661872
border-color: var(--border-color);

Diff for: tests/rustdoc-gui/scrape-examples-layout.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ assert-css: (".scraped-example .example-wrap::after", {"bottom": "0px"})
9090
// Then with mobile
9191
set-window-size: (600, 600)
9292
store-size: (".scraped-example .scraped-example-title", {"height": title_height})
93-
assert-position: (".scraped-example", {"y": 281})
94-
assert-position: (".scraped-example .prev", {"y": 281 + |offset_y| + |title_height|})
93+
assert-position: (".scraped-example", {"y": 287})
94+
assert-position: (".scraped-example .prev", {"y": 287 + |offset_y| + |title_height|})
9595

9696
define-function: (
9797
"check_title_and_code_position",

Diff for: tests/rustdoc-gui/search-result-display.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ set-text: (
6464
)
6565

6666
// Then we compare again to confirm the height didn't change.
67-
assert-size: ("#crate-search", {"width": 509})
67+
assert-size: ("#crate-search", {"width": 370})
6868
assert-size: (".search-results-title", {
6969
"height": |search_results_title_height|,
7070
})

Diff for: tests/rustdoc-gui/sidebar-source-code-display.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ click: "#sidebar-button"
141141
wait-for-css: (".src .sidebar > *", {"visibility": "hidden"})
142142
// We scroll to line 117 to change the scroll position.
143143
scroll-to: '//*[@id="117"]'
144-
store-value: (y_offset, "2564")
144+
store-value: (y_offset, "2570")
145145
assert-window-property: {"pageYOffset": |y_offset|}
146146
// Expanding the sidebar...
147147
click: "#sidebar-button"

Diff for: tests/rustdoc-gui/source-anchor-scroll.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ set-window-size: (600, 800)
88
assert-property: ("html", {"scrollTop": "0"})
99

1010
click: '//a[text() = "barbar" and @href="#5-7"]'
11-
assert-property: ("html", {"scrollTop": "194"})
11+
assert-property: ("html", {"scrollTop": "200"})
1212
click: '//a[text() = "bar" and @href="#28-36"]'
13-
assert-property: ("html", {"scrollTop": "225"})
13+
assert-property: ("html", {"scrollTop": "231"})
1414
click: '//a[normalize-space() = "sub_fn" and @href="#2-4"]'
15-
assert-property: ("html", {"scrollTop": "122"})
15+
assert-property: ("html", {"scrollTop": "128"})
1616

1717
// We now check that clicking on lines doesn't change the scroll
1818
// Extra information: the "sub_fn" function header is on line 1.
1919
click: '//*[@id="6"]'
20-
assert-property: ("html", {"scrollTop": "122"})
20+
assert-property: ("html", {"scrollTop": "128"})

Diff for: tests/rustdoc-gui/toggle-docs-mobile.goml

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
44
set-window-size: (433, 600)
55
assert-attribute: (".top-doc", {"open": ""})
6-
click: (4, 260) // This is the position of the top doc comment toggle
6+
click: (4, 270) // This is the position of the top doc comment toggle
77
assert-attribute-false: (".top-doc", {"open": ""})
8-
click: (4, 260)
8+
click: (4, 270)
99
assert-attribute: (".top-doc", {"open": ""})
1010
// To ensure that the toggle isn't over the text, we check that the toggle isn't clicked.
11-
click: (3, 260)
11+
click: (3, 270)
1212
assert-attribute: (".top-doc", {"open": ""})
1313

1414
// Assert the position of the toggle on the top doc block.
@@ -24,10 +24,10 @@ assert-position: (
2424
// Now we do the same but with a little bigger width
2525
set-window-size: (600, 600)
2626
assert-attribute: (".top-doc", {"open": ""})
27-
click: (4, 260) // New Y position since all search elements are back on one line.
27+
click: (4, 270) // New Y position since all search elements are back on one line.
2828
assert-attribute-false: (".top-doc", {"open": ""})
29-
click: (4, 260)
29+
click: (4, 270)
3030
assert-attribute: (".top-doc", {"open": ""})
3131
// To ensure that the toggle isn't over the text, we check that the toggle isn't clicked.
32-
click: (3, 260)
32+
click: (3, 270)
3333
assert-attribute: (".top-doc", {"open": ""})

0 commit comments

Comments
 (0)