Skip to content

Commit a53655a

Browse files
committed
rustdoc: adjust spacing and typography in header
1 parent b0c2d2e commit a53655a

23 files changed

+53
-47
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,9 +2010,9 @@ fn render_rightside(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, render
20102010
);
20112011
if let Some(link) = src_href {
20122012
if has_stability {
2013-
write!(rightside, " · <a class=\"src\" href=\"{link}\">source</a>")
2013+
write!(rightside, " · <a class=\"src\" href=\"{link}\">Source</a>")
20142014
} else {
2015-
write!(rightside, "<a class=\"src rightside\" href=\"{link}\">source</a>")
2015+
write!(rightside, "<a class=\"src rightside\" href=\"{link}\">Source</a>")
20162016
}
20172017
}
20182018
if has_stability && has_src_ref {

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ h1, h2, h3, h4 {
185185
grid-template-columns: minmax(105px, 1fr) minmax(0, max-content);
186186
grid-template-rows: minmax(25px, min-content) min-content min-content;
187187
padding-bottom: 6px;
188-
margin-bottom: 11px;
188+
margin-bottom: 15px;
189189
}
190190
.rustdoc-breadcrumbs {
191191
grid-area: main-heading-breadcrumbs;
@@ -1004,6 +1004,7 @@ nav.sub {
10041004
display: flex;
10051005
height: 34px;
10061006
flex-grow: 1;
1007+
margin-bottom: 4px;
10071008
}
10081009
.src nav.sub {
10091010
margin: 0 0 -10px 0;
@@ -2253,7 +2254,12 @@ in src-script.js and main.js
22532254

22542255
/* We don't display this button on mobile devices. */
22552256
#copy-path {
2256-
display: none;
2257+
/* display: none; avoided as a layout hack.
2258+
When there's one line, we get an effective line-height of 34px,
2259+
because that's how big the image is, but if the header wraps,
2260+
they're packed more tightly than that. */
2261+
width: 0;
2262+
visibility: hidden;
22572263
}
22582264

22592265
/* Text label takes up too much space at this size. */

src/librustdoc/html/templates/print_item.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1>
2626
{% match src_href %}
2727
{% when Some with (href) %}
2828
{% if !stability_since_raw.is_empty() +%} · {%+ endif %}
29-
<a class="src" href="{{href|safe}}">source</a> {#+ #}
29+
<a class="src" href="{{href|safe}}">Source</a> {#+ #}
3030
{% else %}
3131
{% endmatch %}
3232
</span> {# #}

tests/rustdoc-gui/item-info.goml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ store-position: (
2020
{"x": second_line_x, "y": second_line_y},
2121
)
2222
assert: |first_line_x| != |second_line_x| && |first_line_x| == 516 && |second_line_x| == 272
23-
assert: |first_line_y| != |second_line_y| && |first_line_y| == 714 && |second_line_y| == 737
23+
assert: |first_line_y| != |second_line_y| && |first_line_y| == 718 && |second_line_y| == 741
2424

2525
// Now we ensure that they're not rendered on the same line.
2626
set-window-size: (1100, 800)

tests/rustdoc-gui/scrape-examples-layout.goml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ click: ".scraped-example .button-holder .expand"
8080
store-value: (offset_y, 4)
8181

8282
// First with desktop
83-
assert-position: (".scraped-example", {"y": 252})
84-
assert-position: (".scraped-example .prev", {"y": 252 + |offset_y|})
83+
assert-position: (".scraped-example", {"y": 256})
84+
assert-position: (".scraped-example .prev", {"y": 256 + |offset_y|})
8585

8686
// Gradient background should be at the top of the code block.
8787
assert-css: (".scraped-example .example-wrap::before", {"top": "0px"})
@@ -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": 287})
94-
assert-position: (".scraped-example .prev", {"y": 287 + |offset_y| + |title_height|})
93+
assert-position: (".scraped-example", {"y": 291})
94+
assert-position: (".scraped-example .prev", {"y": 291 + |offset_y| + |title_height|})
9595

9696
define-function: (
9797
"check_title_and_code_position",

tests/rustdoc-gui/sidebar-source-code-display.goml

Lines changed: 1 addition & 1 deletion
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, "2570")
144+
store-value: (y_offset, "2578")
145145
assert-window-property: {"pageYOffset": |y_offset|}
146146
// Expanding the sidebar...
147147
click: "#sidebar-button"

tests/rustdoc-gui/source-anchor-scroll.goml

Lines changed: 4 additions & 4 deletions
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": "200"})
11+
assert-property: ("html", {"scrollTop": "208"})
1212
click: '//a[text() = "bar" and @href="#28-36"]'
13-
assert-property: ("html", {"scrollTop": "231"})
13+
assert-property: ("html", {"scrollTop": "239"})
1414
click: '//a[normalize-space() = "sub_fn" and @href="#2-4"]'
15-
assert-property: ("html", {"scrollTop": "128"})
15+
assert-property: ("html", {"scrollTop": "136"})
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": "128"})
20+
assert-property: ("html", {"scrollTop": "136"})

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
8989
// do anything (and certainly not add a `#NaN` to the URL!).
9090
go-to: "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": 88, "y": 163})
92+
assert-position: ("//*[@id='1']", {"x": 88, "y": 171})
9393
// We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
9494
click: (163, 77)
9595
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
@@ -165,15 +165,15 @@ assert-css: ("nav.sub", {"flex-direction": "row"})
165165
// offsetTop[nav.sub form] = offsetTop[#main-content] - offsetHeight[nav.sub form] - offsetTop[nav.sub form]
166166
assert-position: ("nav.sub form", {"y": 15})
167167
assert-property: ("nav.sub form", {"offsetHeight": 34})
168-
assert-position: ("h1", {"y": 64})
168+
assert-position: ("h1", {"y": 68})
169169
// 15 = 64 - 34 - 15
170170

171171
// Now do the same check on moderately-sized, tablet mobile.
172172
set-window-size: (700, 700)
173173
assert-css: ("nav.sub", {"flex-direction": "row"})
174174
assert-position: ("nav.sub form", {"y": 8})
175175
assert-property: ("nav.sub form", {"offsetHeight": 34})
176-
assert-position: ("h1", {"y": 50})
176+
assert-position: ("h1", {"y": 54})
177177
// 8 = 50 - 34 - 8
178178

179179
// Check the sidebar directory entries have a marker and spacing (tablet).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<section id="associatedconstant.YOLO" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#16">source</a><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>
1+
<section id="associatedconstant.YOLO" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#16">Source</a><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<section id="associatedconstant.X" class="associatedconstant"><a class="src rightside" href="../src/foo/anchors.rs.html#42">source</a><h4 class="code-header">pub const <a href="#associatedconstant.X" class="constant">X</a>: <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a> = 0i32</h4></section>
1+
<section id="associatedconstant.X" class="associatedconstant"><a class="src rightside" href="../src/foo/anchors.rs.html#42">Source</a><h4 class="code-header">pub const <a href="#associatedconstant.X" class="constant">X</a>: <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a> = 0i32</h4></section>

0 commit comments

Comments
 (0)