Skip to content

Commit 6aad08f

Browse files
Unify headings indent and remove useless anchor
1 parent 1f0a968 commit 6aad08f

File tree

4 files changed

+12
-33
lines changed

4 files changed

+12
-33
lines changed

src/librustdoc/html/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ impl<'a, 'b, 'ids, I: Iterator<Item = SpannedEvent<'a>>> Iterator
565565
self.buf.push_back((Event::Html(format!("</a></h{}>", level).into()), 0..0));
566566

567567
let start_tags = format!(
568-
"<h{level} id=\"{id}\" class=\"section-header\">\
568+
"<h{level} id=\"{id}\">\
569569
<a href=\"#{id}\">",
570570
id = id,
571571
level = level

src/librustdoc/html/markdown/tests.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -161,23 +161,23 @@ fn test_header() {
161161

162162
t(
163163
"# Foo bar",
164-
"<h2 id=\"foo-bar\" class=\"section-header\"><a href=\"#foo-bar\">Foo bar</a></h2>",
164+
"<h2 id=\"foo-bar\"><a href=\"#foo-bar\">Foo bar</a></h2>",
165165
);
166166
t(
167167
"## Foo-bar_baz qux",
168-
"<h3 id=\"foo-bar_baz-qux\" class=\"section-header\">\
168+
"<h3 id=\"foo-bar_baz-qux\">\
169169
<a href=\"#foo-bar_baz-qux\">Foo-bar_baz qux</a></h3>",
170170
);
171171
t(
172172
"### **Foo** *bar* baz!?!& -_qux_-%",
173-
"<h4 id=\"foo-bar-baz--qux-\" class=\"section-header\">\
173+
"<h4 id=\"foo-bar-baz--qux-\">\
174174
<a href=\"#foo-bar-baz--qux-\"><strong>Foo</strong> \
175175
<em>bar</em> baz!?!&amp; -<em>qux</em>-%</a>\
176176
</h4>",
177177
);
178178
t(
179179
"#### **Foo?** & \\*bar?!* _`baz`_ ❤ #qux",
180-
"<h5 id=\"foo--bar--baz--qux\" class=\"section-header\">\
180+
"<h5 id=\"foo--bar--baz--qux\">\
181181
<a href=\"#foo--bar--baz--qux\"><strong>Foo?</strong> &amp; *bar?!* \
182182
<em><code>baz</code></em> ❤ #qux</a>\
183183
</h5>",
@@ -204,32 +204,32 @@ fn test_header_ids_multiple_blocks() {
204204
t(
205205
&mut map,
206206
"# Example",
207-
"<h2 id=\"example\" class=\"section-header\"><a href=\"#example\">Example</a></h2>",
207+
"<h2 id=\"example\"><a href=\"#example\">Example</a></h2>",
208208
);
209209
t(
210210
&mut map,
211211
"# Panics",
212-
"<h2 id=\"panics\" class=\"section-header\"><a href=\"#panics\">Panics</a></h2>",
212+
"<h2 id=\"panics\"><a href=\"#panics\">Panics</a></h2>",
213213
);
214214
t(
215215
&mut map,
216216
"# Example",
217-
"<h2 id=\"example-1\" class=\"section-header\"><a href=\"#example-1\">Example</a></h2>",
217+
"<h2 id=\"example-1\"><a href=\"#example-1\">Example</a></h2>",
218218
);
219219
t(
220220
&mut map,
221221
"# Search",
222-
"<h2 id=\"search-1\" class=\"section-header\"><a href=\"#search-1\">Search</a></h2>",
222+
"<h2 id=\"search-1\"><a href=\"#search-1\">Search</a></h2>",
223223
);
224224
t(
225225
&mut map,
226226
"# Example",
227-
"<h2 id=\"example-2\" class=\"section-header\"><a href=\"#example-2\">Example</a></h2>",
227+
"<h2 id=\"example-2\"><a href=\"#example-2\">Example</a></h2>",
228228
);
229229
t(
230230
&mut map,
231231
"# Panics",
232-
"<h2 id=\"panics-1\" class=\"section-header\"><a href=\"#panics-1\">Panics</a></h2>",
232+
"<h2 id=\"panics-1\"><a href=\"#panics-1\">Panics</a></h2>",
233233
);
234234
}
235235

src/librustdoc/html/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,7 @@ fn render_call_locations(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item) {
25672567
w,
25682568
"<div class=\"docblock scraped-example-list\">\
25692569
<span></span>\
2570-
<h5 id=\"{id}\" class=\"section-header\">\
2570+
<h5 id=\"{id}\">\
25712571
<a href=\"#{id}\">Examples found in repository</a>\
25722572
</h5>",
25732573
id = id

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

-21
Original file line numberDiff line numberDiff line change
@@ -1141,16 +1141,6 @@ a.test-arrow {
11411141
a.test-arrow:hover{
11421142
text-decoration: none;
11431143
}
1144-
.section-header:hover a:before {
1145-
position: absolute;
1146-
left: -25px;
1147-
padding-right: 10px; /* avoid gap that causes hover to disappear */
1148-
content: '\2002\00a7\2002';
1149-
}
1150-
1151-
.section-header:hover a {
1152-
text-decoration: none;
1153-
}
11541144

11551145
.code-attribute {
11561146
font-weight: 300;
@@ -1196,17 +1186,6 @@ h3.variant {
11961186
margin-top: 3px;
11971187
}
11981188

1199-
.top-doc .docblock > .section-header:first-child {
1200-
margin-left: 15px;
1201-
}
1202-
.top-doc .docblock > .section-header:first-child:hover > a:before {
1203-
left: -10px;
1204-
}
1205-
1206-
.docblock > .section-header:first-child {
1207-
margin-top: 0;
1208-
}
1209-
12101189
:target > code, :target > .code-header {
12111190
opacity: 1;
12121191
}

0 commit comments

Comments
 (0)