Skip to content

Commit 39b90a5

Browse files
committed
rustdoc: remove unnecessary DOM class h1.fqn
It's misleading. The main heading sometimes isn't an fully qualified name at all. It's also redundant. It's always a child of `div.main-heading`, so just use that.
1 parent 5ca6f7d commit 39b90a5

17 files changed

+33
-33
lines changed

src/librustdoc/html/render/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
639639
write!(
640640
buf,
641641
"<div class=\"main-heading\">\
642-
<h1 class=\"fqn\">Rustdoc settings</h1>\
642+
<h1>Rustdoc settings</h1>\
643643
<span class=\"out-of-band\">\
644644
<a id=\"back\" href=\"javascript:void(0)\" onclick=\"history.back();\">\
645645
Back\
@@ -677,7 +677,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
677677
write!(
678678
buf,
679679
"<div class=\"main-heading\">\
680-
<h1 class=\"fqn\">Rustdoc help</h1>\
680+
<h1>Rustdoc help</h1>\
681681
<span class=\"out-of-band\">\
682682
<a id=\"back\" href=\"javascript:void(0)\" onclick=\"history.back();\">\
683683
Back\

src/librustdoc/html/render/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl AllTypes {
364364
}
365365
}
366366

367-
f.write_str("<h1 class=\"fqn\">List of all items</h1>");
367+
f.write_str("<h1>List of all items</h1>");
368368
// Note: print_entries does not escape the title, because we know the current set of titles
369369
// doesn't require escaping.
370370
print_entries(f, &self.structs, ItemSection::Structs);
@@ -394,7 +394,7 @@ fn scrape_examples_help(shared: &SharedContext<'_>) -> String {
394394
let mut ids = IdMap::default();
395395
format!(
396396
"<div class=\"main-heading\">\
397-
<h1 class=\"fqn\">About scraped examples</h1>\
397+
<h1>About scraped examples</h1>\
398398
</div>\
399399
<div>{}</div>",
400400
Markdown {

src/librustdoc/html/render/write_shared.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};
345345
};
346346

347347
let content = format!(
348-
"<h1 class=\"fqn\">List of all crates</h1><ul class=\"all-items\">{}</ul>",
348+
"<h1>List of all crates</h1><ul class=\"all-items\">{}</ul>",
349349
krates
350350
.iter()
351351
.map(|s| {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ h1, h2, h3, h4 {
139139
.docblock > h6:first-child {
140140
margin-top: 0;
141141
}
142-
h1.fqn {
142+
.main-heading h1 {
143143
margin: 0;
144144
padding: 0;
145145
flex-grow: 1;

src/librustdoc/html/static/js/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ function loadCss(cssUrl) {
526526
}
527527

528528
let currentNbImpls = implementors.getElementsByClassName("impl").length;
529-
const traitName = document.querySelector("h1.fqn > .trait").textContent;
529+
const traitName = document.querySelector(".main-heading h1 > .trait").textContent;
530530
const baseIdName = "impl-" + traitName + "-";
531531
const libs = Object.getOwnPropertyNames(imp);
532532
// We don't want to include impls from this JS file, when the HTML already has them.

src/librustdoc/html/templates/print_item.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="main-heading"> {#- -#}
2-
<h1 class="fqn"> {#- -#}
2+
<h1> {#- -#}
33
{{-typ-}}
44
{#- The breadcrumbs of the item path, like std::string -#}
55
{%- for component in path_components -%}

tests/rustdoc-gui/anchors.goml

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
define-function: (
44
"check-colors",
5-
(theme, main_color, title_color, fqn_color, fqn_type_color, src_link_color, sidebar_link_color),
5+
(theme, main_color, title_color, main_heading_color, main_heading_type_color, src_link_color, sidebar_link_color),
66
block {
77
goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"
88
// This is needed to ensure that the text color is computed.
@@ -14,8 +14,8 @@ define-function: (
1414
reload:
1515

1616
assert-css: ("#toggle-all-docs", {"color": |main_color|})
17-
assert-css: (".fqn a:nth-of-type(1)", {"color": |fqn_color|})
18-
assert-css: (".fqn a:nth-of-type(2)", {"color": |fqn_type_color|})
17+
assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|})
18+
assert-css: (".main-heading a:nth-of-type(2)", {"color": |main_heading_type_color|})
1919
assert-css: (
2020
".rightside .srclink",
2121
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
@@ -57,7 +57,7 @@ define-function: (
5757
assert-css: ("#top-doc-prose-title", {"color": |title_color|})
5858

5959
assert-css: (".sidebar a", {"color": |sidebar_link_color|})
60-
assert-css: ("h1.fqn a", {"color": |title_color|})
60+
assert-css: (".main-heading h1 a", {"color": |title_color|})
6161

6262
// We move the cursor over the "Implementations" title so the anchor is displayed.
6363
move-cursor-to: "h2#implementations"
@@ -77,8 +77,8 @@ call-function: (
7777
"theme": "ayu",
7878
"main_color": "rgb(197, 197, 197)",
7979
"title_color": "rgb(255, 255, 255)",
80-
"fqn_color": "rgb(255, 255, 255)",
81-
"fqn_type_color": "rgb(255, 160, 165)",
80+
"main_heading_color": "rgb(255, 255, 255)",
81+
"main_heading_type_color": "rgb(255, 160, 165)",
8282
"src_link_color": "rgb(57, 175, 215)",
8383
"sidebar_link_color": "rgb(83, 177, 219)",
8484
},
@@ -89,8 +89,8 @@ call-function: (
8989
"theme": "dark",
9090
"main_color": "rgb(221, 221, 221)",
9191
"title_color": "rgb(221, 221, 221)",
92-
"fqn_color": "rgb(221, 221, 221)",
93-
"fqn_type_color": "rgb(45, 191, 184)",
92+
"main_heading_color": "rgb(221, 221, 221)",
93+
"main_heading_type_color": "rgb(45, 191, 184)",
9494
"src_link_color": "rgb(210, 153, 29)",
9595
"sidebar_link_color": "rgb(253, 191, 53)",
9696
},
@@ -101,8 +101,8 @@ call-function: (
101101
"theme": "light",
102102
"main_color": "rgb(0, 0, 0)",
103103
"title_color": "rgb(0, 0, 0)",
104-
"fqn_color": "rgb(0, 0, 0)",
105-
"fqn_type_color": "rgb(173, 55, 138)",
104+
"main_heading_color": "rgb(0, 0, 0)",
105+
"main_heading_type_color": "rgb(173, 55, 138)",
106106
"src_link_color": "rgb(56, 115, 173)",
107107
"sidebar_link_color": "rgb(53, 109, 164)",
108108
},

tests/rustdoc-gui/headings.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// 14px 0.875rem
1414
goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
1515

16-
assert-css: ("h1.fqn", {"font-size": "24px"})
16+
assert-css: (".main-heading h1", {"font-size": "24px"})
1717

1818
assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"})
1919
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
@@ -52,7 +52,7 @@ assert-css: ("h6#sub-sub-heading-for-struct-impl-item-doc", {"font-size": "14px"
5252

5353
goto: "file://" + |DOC_PATH| + "/test_docs/enum.HeavilyDocumentedEnum.html"
5454

55-
assert-css: ("h1.fqn", {"font-size": "24px"})
55+
assert-css: (".main-heading h1", {"font-size": "24px"})
5656

5757
assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"})
5858
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
@@ -111,7 +111,7 @@ assert-css: ("//ul[@class='block mod']/preceding-sibling::h3", {"border-bottom-w
111111

112112
goto: "file://" + |DOC_PATH| + "/test_docs/union.HeavilyDocumentedUnion.html"
113113

114-
assert-css: ("h1.fqn", {"font-size": "24px"})
114+
assert-css: (".main-heading h1", {"font-size": "24px"})
115115

116116
assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"})
117117
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
@@ -143,7 +143,7 @@ assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"border-bottom-width": "
143143

144144
goto: "file://" + |DOC_PATH| + "/test_docs/macro.heavily_documented_macro.html"
145145

146-
assert-css: ("h1.fqn", {"font-size": "24px"})
146+
assert-css: (".main-heading h1", {"font-size": "24px"})
147147

148148
assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"})
149149
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})

tests/rustdoc-gui/search-result-go-to-first.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
// First, we check that the first page doesn't have the string we're looking for to ensure
44
// that the feature is changing page as expected.
55
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
6-
assert-text-false: (".fqn", "Struct test_docs::Foo")
6+
assert-text-false: (".main-heading h1", "Struct test_docs::Foo")
77

88
// We now check that we land on the search result page if "go_to_first" isn't set.
99
goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=struct%3AFoo"
1010
// Waiting for the search results to appear...
1111
wait-for: "#search-tabs"
12-
assert-text-false: (".fqn", "Struct test_docs::Foo")
12+
assert-text-false: (".main-heading h1", "Struct test_docs::Foo")
1313
// Ensure that the search results are displayed, not the "normal" content.
1414
assert-css: ("#main-content", {"display": "none"})
1515

1616
// Now we can check that the feature is working as expected!
1717
goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=struct%3AFoo&go_to_first=true"
1818
// Waiting for the page to load...
19-
wait-for-text: (".fqn", "Struct test_docs::Foo")
19+
wait-for-text: (".main-heading h1", "Struct test_docs::Foo")

tests/rustdoc-gui/toggle-click-deadspace.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ assert-attribute-false: (".impl-items .rustdoc-toggle", {"open": ""})
1212

1313
// Click the "Trait" part of "impl Trait" and verify it navigates.
1414
click: "#impl-Trait-for-Foo h3 a:first-of-type"
15-
assert-text: (".fqn", "Trait lib2::Trait")
15+
assert-text: (".main-heading h1", "Trait lib2::Trait")

tests/rustdoc/index-page.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![crate_name = "foo"]
66

77
// @has foo/../index.html
8-
// @has - '//h1[@class="fqn"]' 'List of all crates'
8+
// @has - '//h1' 'List of all crates'
99
// @has - '//ul[@class="all-items"]//a[@href="foo/index.html"]' 'foo'
1010
// @has - '//ul[@class="all-items"]//a[@href="all_item_types/index.html"]' 'all_item_types'
1111
pub struct Foo;

tests/rustdoc/keyword.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// @has foo/index.html '//div[@class="sidebar-elems"]//li/a' 'Keywords'
88
// @has foo/index.html '//div[@class="sidebar-elems"]//li/a/@href' '#keywords'
99
// @has foo/keyword.match.html '//a[@class="keyword"]' 'match'
10-
// @has foo/keyword.match.html '//h1[@class="fqn"]' 'Keyword match'
10+
// @has foo/keyword.match.html '//h1' 'Keyword match'
1111
// @has foo/keyword.match.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!'
1212
// @has foo/index.html '//a/@href' '../foo/index.html'
1313
// @!has foo/foo/index.html

tests/rustdoc/primitive-reference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// @has - '//div[@class="sidebar-elems"]//li/a/@href' '#primitives'
1010
// @has foo/primitive.reference.html
1111
// @has - '//a[@class="primitive"]' 'reference'
12-
// @has - '//h1[@class="fqn"]' 'Primitive Type reference'
12+
// @has - '//h1' 'Primitive Type reference'
1313
// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!'
1414

1515
// There should be only one implementation listed.

tests/rustdoc/primitive-slice-auto-trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![feature(rustdoc_internals)]
55

66
// @has foo/primitive.slice.html '//a[@class="primitive"]' 'slice'
7-
// @has - '//h1[@class="fqn"]' 'Primitive Type slice'
7+
// @has - '//h1' 'Primitive Type slice'
88
// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!'
99
// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations'
1010
// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Send for [T]where T: Send'

tests/rustdoc/primitive-tuple-auto-trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![feature(rustdoc_internals)]
55

66
// @has foo/primitive.tuple.html '//a[@class="primitive"]' 'tuple'
7-
// @has - '//h1[@class="fqn"]' 'Primitive Type tuple'
7+
// @has - '//h1' 'Primitive Type tuple'
88
// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!'
99
// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations'
1010
// @has - '//div[@id="synthetic-implementations-list"]//h3' 'Send'

tests/rustdoc/primitive-unit-auto-trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![feature(rustdoc_internals)]
55

66
// @has foo/primitive.unit.html '//a[@class="primitive"]' 'unit'
7-
// @has - '//h1[@class="fqn"]' 'Primitive Type unit'
7+
// @has - '//h1' 'Primitive Type unit'
88
// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!'
99
// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations'
1010
// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Send for ()'

tests/rustdoc/primitive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// @has foo/index.html '//div[@class="sidebar-elems"]//li/a' 'Primitive Types'
88
// @has foo/index.html '//div[@class="sidebar-elems"]//li/a/@href' '#primitives'
99
// @has foo/primitive.i32.html '//a[@class="primitive"]' 'i32'
10-
// @has foo/primitive.i32.html '//h1[@class="fqn"]' 'Primitive Type i32'
10+
// @has foo/primitive.i32.html '//h1' 'Primitive Type i32'
1111
// @has foo/primitive.i32.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!'
1212
// @has foo/index.html '//a/@href' '../foo/index.html'
1313
// @!has foo/index.html '//span' '🔒'

0 commit comments

Comments
 (0)