Skip to content

Commit a65c98f

Browse files
committed
Remove underlines from non-top docblocks.
We still had a number of places where underlined section headings would show up, like under Implementations.
1 parent 6d42707 commit a65c98f

File tree

2 files changed

+65
-4
lines changed

2 files changed

+65
-4
lines changed

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ h1, h2, h3, h4 {
134134
margin: 20px 0 15px 0;
135135
padding-bottom: 6px;
136136
}
137-
h5, h6 {
137+
.docblock h3, .docblock h4, h5, h6 {
138138
margin: 15px 0 5px 0;
139139
}
140140
h1.fqn {
@@ -149,7 +149,14 @@ h1.fqn {
149149
h1.fqn > .in-band > a:hover {
150150
text-decoration: underline;
151151
}
152-
h2, h3, h4 {
152+
/* The only headings that get underlines are:
153+
Markdown-generated headings within the top-doc
154+
Rustdoc-generated h2 section headings (e.g. "Implementations", "Required Methods", etc)
155+
Underlines elsewhere in the documentation break up visual flow and tend to invert
156+
section hierarchies. */
157+
h2,
158+
.top-doc h3,
159+
.top-doc h4 {
153160
border-bottom: 1px solid;
154161
}
155162
h3.code-header {

src/test/rustdoc-gui/header-size.goml src/test/rustdoc-gui/headings.goml

+56-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
// This test check that headers (a) have the correct heading level, and (b) are the right size.
1+
// This test check that headers (a) have the correct heading level, (b) are the right size,
2+
// and (c) have the correct underlining (or absence of underlining).
23
// The sizes may change as design changes, but try to make sure a lower header is never bigger than
3-
// its parent headers.
4+
// its parent headers. Also make sure lower headers don't have underlines when their parents lack
5+
// an underline.
46
// Most of these sizes are set in CSS in `em` units, so here's a conversion chart based on our
57
// default 16px font size:
68
// 24px 1.5em
@@ -13,87 +15,139 @@
1315
goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
1416

1517
assert-css: ("h1.fqn", {"font-size": "24px"})
18+
assert-css: ("h1.fqn", {"border-bottom-width": "1px"})
1619

1720
assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
21+
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
1822
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
23+
assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"})
1924
assert-css: ("h4#top-doc-prose-sub-sub-heading", {"font-size": "17.6px"})
25+
assert-css: ("h4#top-doc-prose-sub-sub-heading", {"border-bottom-width": "1px"})
2026

2127
assert-css: ("h2#fields", {"font-size": "22.4px"})
28+
assert-css: ("h2#fields", {"border-bottom-width": "1px"})
2229
assert-css: ("h3#title-for-field", {"font-size": "20.8px"})
30+
assert-css: ("h3#title-for-field", {"border-bottom-width": "0px"})
2331
assert-css: ("h4#sub-heading-for-field", {"font-size": "16px"})
32+
assert-css: ("h4#sub-heading-for-field", {"border-bottom-width": "0px"})
2433

2534
assert-css: ("h2#implementations", {"font-size": "22.4px"})
35+
assert-css: ("h2#implementations", {"border-bottom-width": "1px"})
2636

2737
assert-css: ("#impl > h3.code-header", {"font-size": "17.6px"})
38+
assert-css: ("#impl > h3.code-header", {"border-bottom-width": "0px"})
2839
assert-css: ("#method\.do_nothing > h4.code-header", {"font-size": "16px"})
40+
assert-css: ("#method\.do_nothing > h4.code-header", {"border-bottom-width": "0px"})
2941

3042
assert-css: ("h4#title-for-struct-impl-doc", {"font-size": "16px"})
43+
assert-css: ("h4#title-for-struct-impl-doc", {"border-bottom-width": "0px"})
3144
assert-css: ("h5#sub-heading-for-struct-impl-doc", {"font-size": "16px"})
45+
assert-css: ("h5#sub-heading-for-struct-impl-doc", {"border-bottom-width": "0px"})
3246
assert-css: ("h6#sub-sub-heading-for-struct-impl-doc", {"font-size": "15.2px"})
47+
assert-css: ("h6#sub-sub-heading-for-struct-impl-doc", {"border-bottom-width": "0px"})
3348

3449
assert-css: ("h5#title-for-struct-impl-item-doc", {"font-size": "16px"})
50+
assert-css: ("h5#title-for-struct-impl-item-doc", {"border-bottom-width": "0px"})
3551
assert-css: ("h6#sub-heading-for-struct-impl-item-doc", {"font-size": "15.2px"})
52+
assert-css: ("h6#sub-heading-for-struct-impl-item-doc", {"border-bottom-width": "0px"})
3653
assert-css: ("h6#sub-sub-heading-for-struct-impl-item-doc", {"font-size": "15.2px"})
3754

3855
goto: file://|DOC_PATH|/test_docs/enum.HeavilyDocumentedEnum.html
3956

4057
assert-css: ("h1.fqn", {"font-size": "24px"})
58+
assert-css: ("h1.fqn", {"border-bottom-width": "1px"})
4159

4260
assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
61+
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
4362
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
63+
assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"})
4464
assert-css: ("h4#top-doc-prose-sub-sub-heading", {"font-size": "17.6px"})
65+
assert-css: ("h4#top-doc-prose-sub-sub-heading", {"border-bottom-width": "1px"})
4566

4667
assert-css: ("h2#variants", {"font-size": "22.4px"})
68+
assert-css: ("h2#variants", {"border-bottom-width": "1px"})
4769

4870
assert-css: ("h3#none-prose-title", {"font-size": "20.8px"})
71+
assert-css: ("h3#none-prose-title", {"border-bottom-width": "0px"})
4972
assert-css: ("h4#none-prose-sub-heading", {"font-size": "16px"})
73+
assert-css: ("h4#none-prose-sub-heading", {"border-bottom-width": "0px"})
5074

5175
assert-css: ("h3#wrapped-prose-title", {"font-size": "20.8px"})
76+
assert-css: ("h3#wrapped-prose-title", {"border-bottom-width": "0px"})
5277
assert-css: ("h4#wrapped-prose-sub-heading", {"font-size": "16px"})
78+
assert-css: ("h4#wrapped-prose-sub-heading", {"border-bottom-width": "0px"})
5379

5480
assert-css: ("h4#wrapped0-prose-title", {"font-size": "16px"})
81+
assert-css: ("h4#wrapped0-prose-title", {"border-bottom-width": "0px"})
5582
assert-css: ("h5#wrapped0-prose-sub-heading", {"font-size": "16px"})
83+
assert-css: ("h5#wrapped0-prose-sub-heading", {"border-bottom-width": "0px"})
5684

5785
assert-css: ("h4#structy-prose-title", {"font-size": "16px"})
86+
assert-css: ("h4#structy-prose-title", {"border-bottom-width": "0px"})
5887
assert-css: ("h5#structy-prose-sub-heading", {"font-size": "16px"})
88+
assert-css: ("h5#structy-prose-sub-heading", {"border-bottom-width": "0px"})
5989

6090
assert-css: ("h2#implementations", {"font-size": "22.4px"})
91+
assert-css: ("h2#implementations", {"border-bottom-width": "1px"})
6192

6293
assert-css: ("#impl > h3.code-header", {"font-size": "17.6px"})
94+
assert-css: ("#impl > h3.code-header", {"border-bottom-width": "0px"})
6395
assert-css: ("#method\.do_nothing > h4.code-header", {"font-size": "16px"})
96+
assert-css: ("#method\.do_nothing > h4.code-header", {"border-bottom-width": "0px"})
6497

6598
assert-css: ("h4#title-for-enum-impl-doc", {"font-size": "16px"})
99+
assert-css: ("h4#title-for-enum-impl-doc", {"border-bottom-width": "0px"})
66100
assert-css: ("h5#sub-heading-for-enum-impl-doc", {"font-size": "16px"})
101+
assert-css: ("h5#sub-heading-for-enum-impl-doc", {"border-bottom-width": "0px"})
67102
assert-css: ("h6#sub-sub-heading-for-enum-impl-doc", {"font-size": "15.2px"})
103+
assert-css: ("h6#sub-sub-heading-for-enum-impl-doc", {"border-bottom-width": "0px"})
68104

69105
assert-css: ("h5#title-for-enum-impl-item-doc", {"font-size": "16px"})
106+
assert-css: ("h5#title-for-enum-impl-item-doc", {"border-bottom-width": "0px"})
70107
assert-css: ("h6#sub-heading-for-enum-impl-item-doc", {"font-size": "15.2px"})
108+
assert-css: ("h6#sub-heading-for-enum-impl-item-doc", {"border-bottom-width": "0px"})
71109
assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"font-size": "15.2px"})
110+
assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"border-bottom-width": "0px"})
72111

73112
goto: file://|DOC_PATH|/test_docs/union.HeavilyDocumentedUnion.html
74113

75114
assert-css: ("h1.fqn", {"font-size": "24px"})
115+
assert-css: ("h1.fqn", {"border-bottom-width": "1px"})
76116

77117
assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
118+
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
78119
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
120+
assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"})
79121

80122
assert-css: ("h2#fields", {"font-size": "22.4px"})
123+
assert-css: ("h2#fields", {"border-bottom-width": "1px"})
81124

82125
assert-css: ("h3#title-for-union-variant", {"font-size": "20.8px"})
126+
assert-css: ("h3#title-for-union-variant", {"border-bottom-width": "0px"})
83127
assert-css: ("h4#sub-heading-for-union-variant", {"font-size": "16px"})
128+
assert-css: ("h4#sub-heading-for-union-variant", {"border-bottom-width": "0px"})
84129

85130
assert-css: ("h2#implementations", {"font-size": "22.4px"})
131+
assert-css: ("h2#implementations", {"border-bottom-width": "1px"})
86132

87133
assert-css: ("#impl > h3.code-header", {"font-size": "17.6px"})
134+
assert-css: ("#impl > h3.code-header", {"border-bottom-width": "0px"})
88135
assert-css: ("h4#title-for-union-impl-doc", {"font-size": "16px"})
136+
assert-css: ("h4#title-for-union-impl-doc", {"border-bottom-width": "0px"})
89137
assert-css: ("h5#sub-heading-for-union-impl-doc", {"font-size": "16px"})
138+
assert-css: ("h5#sub-heading-for-union-impl-doc", {"border-bottom-width": "0px"})
90139

91140
assert-css: ("h5#title-for-union-impl-item-doc", {"font-size": "16px"})
141+
assert-css: ("h5#title-for-union-impl-item-doc", {"border-bottom-width": "0px"})
92142
assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"font-size": "15.2px"})
143+
assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"border-bottom-width": "0px"})
93144

94145
goto: file://|DOC_PATH|/test_docs/macro.heavily_documented_macro.html
95146

96147
assert-css: ("h1.fqn", {"font-size": "24px"})
148+
assert-css: ("h1.fqn", {"border-bottom-width": "1px"})
97149

98150
assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
151+
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
99152
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
153+
assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"})

0 commit comments

Comments
 (0)