Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit da86509

Browse files
committedJun 2, 2021
Auto merge of #84703 - GuillaumeGomez:cleanup-dom, r=jsha
Clean up dom The commits come from #84480. They were errors reported by the `tidy` script that we will use to ensure that the HTML generated by rustdoc is valid. I checked carefully that there were no difference so in principle it should be exactly the same rendering but a double-check would be very appreciated in case I missed something. Extra note: `<h4>` and some `<h3>` tags were replaced by `<div>` because they're not supposed to contain tags as they currently do. r? `@jsha`
2 parents dbe459d + 0daf8ac commit da86509

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+256
-241
lines changed
 

‎src/librustdoc/html/layout.rs

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ crate fn redirect(url: &str) -> String {
235235
<html lang="en">
236236
<head>
237237
<meta http-equiv="refresh" content="0;URL={url}">
238+
<title>Redirection</title>
238239
</head>
239240
<body>
240241
<p>Redirecting to <a href="{url}">{url}</a>...</p>

‎src/librustdoc/html/render/mod.rs

+32-16
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,11 @@ fn render_impl(
13691369
})
13701370
})
13711371
.map(|item| format!("{}.{}", item.type_(), name));
1372-
write!(w, "<h4 id=\"{}\" class=\"{}{}\">", id, item_type, in_trait_class,);
1372+
write!(
1373+
w,
1374+
"<div id=\"{}\" class=\"{}{} has-srclink\">",
1375+
id, item_type, in_trait_class,
1376+
);
13731377
w.write_str("<code>");
13741378
render_assoc_item(
13751379
w,
@@ -1388,13 +1392,17 @@ fn render_impl(
13881392
);
13891393
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
13901394
write_srclink(cx, item, w);
1391-
w.write_str("</h4>");
1395+
w.write_str("</div>");
13921396
}
13931397
}
13941398
clean::TypedefItem(ref tydef, _) => {
13951399
let source_id = format!("{}.{}", ItemType::AssocType, name);
13961400
let id = cx.derive_id(source_id.clone());
1397-
write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class);
1401+
write!(
1402+
w,
1403+
"<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
1404+
id, item_type, in_trait_class
1405+
);
13981406
assoc_type(
13991407
w,
14001408
item,
@@ -1406,12 +1414,16 @@ fn render_impl(
14061414
);
14071415
w.write_str("</code>");
14081416
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
1409-
w.write_str("</h4>");
1417+
w.write_str("</div>");
14101418
}
14111419
clean::AssocConstItem(ref ty, ref default) => {
14121420
let source_id = format!("{}.{}", item_type, name);
14131421
let id = cx.derive_id(source_id.clone());
1414-
write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class);
1422+
write!(
1423+
w,
1424+
"<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
1425+
id, item_type, in_trait_class
1426+
);
14151427
assoc_const(
14161428
w,
14171429
item,
@@ -1431,12 +1443,12 @@ fn render_impl(
14311443
);
14321444
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
14331445
write_srclink(cx, item, w);
1434-
w.write_str("</h4>");
1446+
w.write_str("</div>");
14351447
}
14361448
clean::AssocTypeItem(ref bounds, ref default) => {
14371449
let source_id = format!("{}.{}", item_type, name);
14381450
let id = cx.derive_id(source_id.clone());
1439-
write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class);
1451+
write!(w, "<div id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class,);
14401452
assoc_type(
14411453
w,
14421454
item,
@@ -1448,7 +1460,7 @@ fn render_impl(
14481460
);
14491461
w.write_str("</code>");
14501462
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
1451-
w.write_str("</h4>");
1463+
w.write_str("</div>");
14521464
}
14531465
clean::StrippedItem(..) => return,
14541466
_ => panic!("can't make docs for trait item with name {:?}", item.name),
@@ -1577,7 +1589,8 @@ fn render_impl(
15771589
if let Some(use_absolute) = use_absolute {
15781590
write!(
15791591
w,
1580-
"{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">",
1592+
"{}<div id=\"{}\" class=\"impl has-srclink\"{}>\
1593+
<code class=\"in-band\">",
15811594
open_details(&mut close_tags, is_implementing_trait),
15821595
id,
15831596
aliases
@@ -1604,7 +1617,8 @@ fn render_impl(
16041617
} else {
16051618
write!(
16061619
w,
1607-
"{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">{}</code>",
1620+
"{}<div id=\"{}\" class=\"impl has-srclink\"{}>\
1621+
<code class=\"in-band\">{}</code>",
16081622
open_details(&mut close_tags, is_implementing_trait),
16091623
id,
16101624
aliases,
@@ -1621,9 +1635,9 @@ fn render_impl(
16211635
);
16221636
write_srclink(cx, &i.impl_item, w);
16231637
if !toggled {
1624-
w.write_str("</h3>");
1638+
w.write_str("</div>");
16251639
} else {
1626-
w.write_str("</h3></summary>");
1640+
w.write_str("</div></summary>");
16271641
}
16281642

16291643
if trait_.is_some() {
@@ -1649,10 +1663,12 @@ fn render_impl(
16491663
);
16501664
}
16511665
}
1652-
w.write_str("<div class=\"impl-items\">");
1653-
w.push_buffer(default_impl_items);
1654-
w.push_buffer(impl_items);
1655-
close_tags.insert_str(0, "</div>");
1666+
if !default_impl_items.is_empty() || !impl_items.is_empty() {
1667+
w.write_str("<div class=\"impl-items\">");
1668+
w.push_buffer(default_impl_items);
1669+
w.push_buffer(impl_items);
1670+
close_tags.insert_str(0, "</div>");
1671+
}
16561672
w.write_str(&close_tags);
16571673
}
16581674

0 commit comments

Comments
 (0)