Skip to content

Commit 2b4fa3d

Browse files
authored
Rollup merge of #81459 - probablykasper:text-selection-fix, r=Nemo157
Fix rustdoc text selection for page titles Fixes text selection of page titles by placing the `h1.fqn span.in-band` element before `h1.fqn span.out-of-band`. Before vs after: https://user-images.githubusercontent.com/11315492/105768203-55708700-5f5c-11eb-924b-4e7527ffe147.mp4 Retry of PR #81397 due to merge conflicts confusing me. Recreated the same changes as in that PR, but now when I run `./x.py doc library/std`, no changes I make to `src/librustdoc/html/render/mod.rs` to the file are reflected in the built doc files, even if I delete the `build` folder. I'm guessing there's some cache I'm missing? r? `@Nemo157`
2 parents 046a414 + 74f26a1 commit 2b4fa3d

File tree

1 file changed

+32
-32
lines changed
  • src/librustdoc/html/render

1 file changed

+32
-32
lines changed

src/librustdoc/html/render/mod.rs

+32-32
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,7 @@ impl AllTypes {
13451345
write!(
13461346
f,
13471347
"<h1 class=\"fqn\">\
1348+
<span class=\"in-band\">List of all items</span>\
13481349
<span class=\"out-of-band\">\
13491350
<span id=\"render-detail\">\
13501351
<a id=\"toggle-all-docs\" href=\"javascript:void(0)\" \
@@ -1353,7 +1354,6 @@ impl AllTypes {
13531354
</a>\
13541355
</span>
13551356
</span>
1356-
<span class=\"in-band\">List of all items</span>\
13571357
</h1>"
13581358
);
13591359
print_entries(f, &self.structs, "Structs", "structs");
@@ -1711,36 +1711,7 @@ where
17111711
fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer) {
17121712
debug_assert!(!item.is_stripped());
17131713
// Write the breadcrumb trail header for the top
1714-
write!(buf, "<h1 class=\"fqn\"><span class=\"out-of-band\">");
1715-
render_stability_since_raw(
1716-
buf,
1717-
item.stable_since(cx.tcx()).as_deref(),
1718-
item.const_stable_since(cx.tcx()).as_deref(),
1719-
None,
1720-
None,
1721-
);
1722-
write!(
1723-
buf,
1724-
"<span id=\"render-detail\">\
1725-
<a id=\"toggle-all-docs\" href=\"javascript:void(0)\" \
1726-
title=\"collapse all docs\">\
1727-
[<span class=\"inner\">&#x2212;</span>]\
1728-
</a>\
1729-
</span>"
1730-
);
1731-
1732-
// Write `src` tag
1733-
//
1734-
// When this item is part of a `crate use` in a downstream crate, the
1735-
// [src] link in the downstream documentation will actually come back to
1736-
// this page, and this link will be auto-clicked. The `id` attribute is
1737-
// used to find the link to auto-click.
1738-
if cx.shared.include_sources && !item.is_primitive() {
1739-
write_srclink(cx, item, buf);
1740-
}
1741-
1742-
write!(buf, "</span>"); // out-of-band
1743-
write!(buf, "<span class=\"in-band\">");
1714+
write!(buf, "<h1 class=\"fqn\"><span class=\"in-band\">");
17441715
let name = match *item.kind {
17451716
clean::ModuleItem(ref m) => {
17461717
if m.is_crate {
@@ -1788,7 +1759,36 @@ fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer) {
17881759
}
17891760
write!(buf, "<a class=\"{}\" href=\"\">{}</a>", item.type_(), item.name.as_ref().unwrap());
17901761

1791-
write!(buf, "</span></h1>"); // in-band
1762+
write!(buf, "</span>"); // in-band
1763+
write!(buf, "<span class=\"out-of-band\">");
1764+
render_stability_since_raw(
1765+
buf,
1766+
item.stable_since(cx.tcx()).as_deref(),
1767+
item.const_stable_since(cx.tcx()).as_deref(),
1768+
None,
1769+
None,
1770+
);
1771+
write!(
1772+
buf,
1773+
"<span id=\"render-detail\">\
1774+
<a id=\"toggle-all-docs\" href=\"javascript:void(0)\" \
1775+
title=\"collapse all docs\">\
1776+
[<span class=\"inner\">&#x2212;</span>]\
1777+
</a>\
1778+
</span>"
1779+
);
1780+
1781+
// Write `src` tag
1782+
//
1783+
// When this item is part of a `crate use` in a downstream crate, the
1784+
// [src] link in the downstream documentation will actually come back to
1785+
// this page, and this link will be auto-clicked. The `id` attribute is
1786+
// used to find the link to auto-click.
1787+
if cx.shared.include_sources && !item.is_primitive() {
1788+
write_srclink(cx, item, buf);
1789+
}
1790+
1791+
write!(buf, "</span></h1>"); // out-of-band
17921792

17931793
match *item.kind {
17941794
clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items),

0 commit comments

Comments
 (0)