Skip to content

Commit 1e09d95

Browse files
committed
rustdoc: consistentify #TOC and #ModNav to lowercase
1 parent 31af096 commit 1e09d95

File tree

10 files changed

+39
-38
lines changed

10 files changed

+39
-38
lines changed

src/doc/not_found.md

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

33
<!-- Completely hide the TOC and the section numbers -->
44
<style type="text/css">
5-
#TOC { display: none; }
5+
#rustdoc-toc { display: none; }
66
.header-section-number { display: none; }
77
li {list-style-type: none; }
88
#search-input {

src/librustdoc/html/markdown.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ impl MarkdownWithToc<'_> {
14321432
}
14331433
pub(crate) fn into_string(self) -> String {
14341434
let (toc, s) = self.into_parts();
1435-
format!("<nav id=\"TOC\">{toc}</nav>{s}", toc = toc.print())
1435+
format!("<nav id=\"rustdoc\">{toc}</nav>{s}", toc = toc.print())
14361436
}
14371437
}
14381438

@@ -2008,7 +2008,8 @@ fn init_id_map() -> FxHashMap<Cow<'static, str>, usize> {
20082008
map.insert("default-settings".into(), 1);
20092009
map.insert("sidebar-vars".into(), 1);
20102010
map.insert("copy-path".into(), 1);
2011-
map.insert("TOC".into(), 1);
2011+
map.insert("rustdoc-toc".into(), 1);
2012+
map.insert("rustdoc-modnav".into(), 1);
20122013
// This is the list of IDs used by rustdoc sections (but still generated by
20132014
// rustdoc).
20142015
map.insert("fields".into(), 1);

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -589,11 +589,11 @@ ul.block, .block li, .block ul {
589589
background-clip: border-box;
590590
}
591591

592-
.hide-toc #TOC, .hide-toc .in-crate {
592+
.hide-toc #rustdoc-toc, .hide-toc .in-crate {
593593
display: none;
594594
}
595595

596-
.hide-modnav #ModNav {
596+
.hide-modnav #rustdoc-modnav {
597597
display: none;
598598
}
599599

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ function preLoadCss(cssUrl) {
493493
if (!window.SIDEBAR_ITEMS) {
494494
return;
495495
}
496-
const sidebar = document.getElementById("ModNav");
496+
const sidebar = document.getElementById("rustdoc-modnav");
497497

498498
/**
499499
* Append to the sidebar a "block" of links - a heading along with a list (`<ul>`) of items.
@@ -880,7 +880,7 @@ function preLoadCss(cssUrl) {
880880
if (!window.ALL_CRATES) {
881881
return;
882882
}
883-
const sidebarElems = document.getElementById("ModNav");
883+
const sidebarElems = document.getElementById("rustdoc-modnav");
884884
if (!sidebarElems) {
885885
return;
886886
}

src/librustdoc/html/templates/sidebar.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{% endif %}
77

88
{% if self.should_render_blocks() %}
9-
<section id="TOC">
9+
<section id="rustdoc-toc">
1010
{% if !title.is_empty() %}
1111
<h2 class="location"> {# #}
1212
<a href="#">{{title_prefix}}{{title|wrapped|safe}}</a> {# #}
@@ -53,7 +53,7 @@ <h3> {# #}
5353
{% endfor %}
5454
</section>
5555
{% endif %}
56-
<div id="ModNav">
56+
<div id="rustdoc-modnav">
5757
{% if !path.is_empty() %}
5858
<h2{% if parent_is_crate +%} class="in-crate"{% endif %}> {# #}
5959
<a href="{% if is_mod %}../{% endif %}index.html">In {{+ path|wrapped|safe}}</a> {# #}

tests/rustdoc-gui/sidebar.goml

+12-12
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ assert-text: (".sidebar-elems ul.block > li.current > a", "module")
126126
// - Module name, followed by TOC for module headings
127127
// - "In crate [name]" parent pointer, followed by sibling navigation
128128
assert-count: (".sidebar h2", 3)
129-
assert-text: (".sidebar > .sidebar-elems > #ModNav > h2", "In crate lib2")
130-
assert-property: (".sidebar > .sidebar-elems > #ModNav > h2 > a", {
129+
assert-text: (".sidebar > .sidebar-elems > #rustdoc-modnav > h2", "In crate lib2")
130+
assert-property: (".sidebar > .sidebar-elems > #rustdoc-modnav > h2 > a", {
131131
"href": "/lib2/index.html",
132132
}, ENDS_WITH)
133133
// We check that we don't have the crate list.
@@ -137,8 +137,8 @@ go-to: "./sub_module/sub_sub_module/index.html"
137137
assert-property: (".sidebar", {"clientWidth": "200"})
138138
assert-text: (".sidebar > .sidebar-crate > h2 > a", "lib2")
139139
assert-text: (".sidebar .location", "Module sub_sub_module")
140-
assert-text: (".sidebar > .sidebar-elems > #ModNav > h2", "In lib2::module::sub_module")
141-
assert-property: (".sidebar > .sidebar-elems > #ModNav > h2 > a", {
140+
assert-text: (".sidebar > .sidebar-elems > #rustdoc-modnav > h2", "In lib2::module::sub_module")
141+
assert-property: (".sidebar > .sidebar-elems > #rustdoc-modnav > h2 > a", {
142142
"href": "/module/sub_module/index.html",
143143
}, ENDS_WITH)
144144
assert-text: (".sidebar-elems ul.block > li.current > a", "sub_sub_module")
@@ -202,32 +202,32 @@ assert-position: (".sidebar-crate > h2 > a", {"x": -3})
202202
// Configuration option to show TOC in sidebar.
203203
set-local-storage: {"rustdoc-hide-toc": "true"}
204204
go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html"
205-
assert-css: ("#TOC", {"display": "none"})
205+
assert-css: ("#rustdoc-toc", {"display": "none"})
206206
assert-css: (".sidebar .in-crate", {"display": "none"})
207207
set-local-storage: {"rustdoc-hide-toc": "false"}
208208
go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html"
209-
assert-css: ("#TOC", {"display": "block"})
209+
assert-css: ("#rustdoc-toc", {"display": "block"})
210210
assert-css: (".sidebar .in-crate", {"display": "block"})
211211

212212
set-local-storage: {"rustdoc-hide-modnav": "true"}
213213
go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html"
214-
assert-css: ("#ModNav", {"display": "none"})
214+
assert-css: ("#rustdoc-modnav", {"display": "none"})
215215
set-local-storage: {"rustdoc-hide-modnav": "false"}
216216
go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html"
217-
assert-css: ("#ModNav", {"display": "block"})
217+
assert-css: ("#rustdoc-modnav", {"display": "block"})
218218

219219
set-local-storage: {"rustdoc-hide-toc": "true"}
220220
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
221-
assert-css: ("#TOC", {"display": "none"})
221+
assert-css: ("#rustdoc-toc", {"display": "none"})
222222
assert-false: ".sidebar .in-crate"
223223
set-local-storage: {"rustdoc-hide-toc": "false"}
224224
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
225-
assert-css: ("#TOC", {"display": "block"})
225+
assert-css: ("#rustdoc-toc", {"display": "block"})
226226
assert-false: ".sidebar .in-crate"
227227

228228
set-local-storage: {"rustdoc-hide-modnav": "true"}
229229
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
230-
assert-css: ("#ModNav", {"display": "none"})
230+
assert-css: ("#rustdoc-modnav", {"display": "none"})
231231
set-local-storage: {"rustdoc-hide-modnav": "false"}
232232
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
233-
assert-css: ("#ModNav", {"display": "block"})
233+
assert-css: ("#rustdoc-modnav", {"display": "block"})

tests/rustdoc/sidebar/module.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#![crate_name = "foo"]
22

33
//@ has 'foo/index.html'
4-
//@ has - '//section[@id="TOC"]/h3' 'Crate Items'
4+
//@ has - '//section[@id="rustdoc-toc"]/h3' 'Crate Items'
55

66
//@ has 'foo/bar/index.html'
7-
//@ has - '//section[@id="TOC"]/h3' 'Module Items'
7+
//@ has - '//section[@id="rustdoc-toc"]/h3' 'Module Items'
88
pub mod bar {
99
//@ has 'foo/bar/struct.Baz.html'
10-
//@ !has - '//section[@id="TOC"]/h3' 'Module Items'
10+
//@ !has - '//section[@id="rustdoc-toc"]/h3' 'Module Items'
1111
pub struct Baz;
1212
}
1313

1414
//@ has 'foo/baz/index.html'
15-
//@ !has - '//section[@id="TOC"]/h3' 'Module Items'
15+
//@ !has - '//section[@id="rustdoc-toc"]/h3' 'Module Items'
1616
pub mod baz {}

tests/rustdoc/sidebar/top-toc-html.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
1515
//@ has foo/index.html
1616
// User header
17-
//@ has - '//section[@id="TOC"]/h3' 'Sections'
18-
//@ has - '//section[@id="TOC"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/@title' 'Basic link, emphasis, very emphasis and `code`'
19-
//@ has - '//section[@id="TOC"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]' 'Basic link, emphasis, very emphasis and code'
20-
//@ count - '//section[@id="TOC"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/em' 0
21-
//@ count - '//section[@id="TOC"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/a' 0
22-
//@ count - '//section[@id="TOC"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/code' 1
23-
//@ has - '//section[@id="TOC"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/code' 'code'
17+
//@ has - '//section[@id="rustdoc-toc"]/h3' 'Sections'
18+
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/@title' 'Basic link, emphasis, very emphasis and `code`'
19+
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]' 'Basic link, emphasis, very emphasis and code'
20+
//@ count - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/em' 0
21+
//@ count - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/a' 0
22+
//@ count - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/code' 1
23+
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#basic-link-emphasis-very-emphasis-and-code"]/code' 'code'

tests/rustdoc/sidebar/top-toc-idmap.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
1717
//@ has foo/index.html
1818
// User header
19-
//@ has - '//section[@id="TOC"]/ul[@class="block top-toc"]/li/a[@href="#structs"]' 'Structs'
19+
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#structs"]' 'Structs'
2020
//@ has - '//details[@class="toggle top-doc"]/div[@class="docblock"]/h2[@id="structs"]' 'Structs'
2121
// Built-in header
22-
//@ has - '//section[@id="TOC"]/ul[@class="block"]/li/a[@href="#structs-1"]' 'Structs'
22+
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block"]/li/a[@href="#structs-1"]' 'Structs'
2323
//@ has - '//section[@id="main-content"]/h2[@id="structs-1"]' 'Structs'
2424

2525
/// # Fields
@@ -31,12 +31,12 @@
3131
3232
//@ has foo/struct.MyStruct.html
3333
// User header
34-
//@ has - '//section[@id="TOC"]/ul[@class="block top-toc"]/li/a[@href="#fields-1"]' 'Fields'
34+
//@ has - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]/li/a[@href="#fields-1"]' 'Fields'
3535
//@ has - '//details[@class="toggle top-doc"]/div[@class="docblock"]/h2[@id="fields-1"]' 'Fields'
3636
// Only one level of nesting
37-
//@ count - '//section[@id="TOC"]/ul[@class="block top-toc"]//a' 2
37+
//@ count - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]//a' 2
3838
// Built-in header
39-
//@ has - '//section[@id="TOC"]/h3/a[@href="#fields"]' 'Fields'
39+
//@ has - '//section[@id="rustdoc-toc"]/h3/a[@href="#fields"]' 'Fields'
4040
//@ has - '//section[@id="main-content"]/h2[@id="fields"]' 'Fields'
4141

4242
pub struct MyStruct {

tests/rustdoc/sidebar/top-toc-nil.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
55
//@ has foo/index.html
66
// User header
7-
//@ !has - '//section[@id="TOC"]/ul[@class="block top-toc"]' 'Basic link and emphasis'
7+
//@ !has - '//section[@id="rustdoc-toc"]/ul[@class="block top-toc"]' 'Basic link and emphasis'

0 commit comments

Comments
 (0)