Skip to content

Commit 7ff5c85

Browse files
authored
Rollup merge of #147047 - notriddle:toolbar-index, r=GuillaumeGomez
rustdoc: put the toolbar on the all item index
2 parents d06bc1d + 51ae86d commit 7ff5c85

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,12 @@ impl AllTypes {
603603
}
604604

605605
fmt::from_fn(|f| {
606-
f.write_str("<h1>List of all items</h1>")?;
606+
f.write_str(
607+
"<div class=\"main-heading\">\
608+
<h1>List of all items</h1>\
609+
<rustdoc-toolbar></rustdoc-toolbar>\
610+
</div>",
611+
)?;
607612
// Note: print_entries does not escape the title, because we know the current set of titles
608613
// doesn't require escaping.
609614
print_entries(&self.structs, ItemSection::Structs).fmt(f)?;

src/librustdoc/html/render/write_shared.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,13 @@ impl CratesIndexPart {
386386
let layout = &cx.shared.layout;
387387
let style_files = &cx.shared.style_files;
388388
const DELIMITER: &str = "\u{FFFC}"; // users are being naughty if they have this
389-
let content =
390-
format!("<h1>List of all crates</h1><ul class=\"all-items\">{DELIMITER}</ul>");
389+
let content = format!(
390+
"<div class=\"main-heading\">\
391+
<h1>List of all crates</h1>\
392+
<rustdoc-toolbar></rustdoc-toolbar>\
393+
</div>\
394+
<ul class=\"all-items\">{DELIMITER}</ul>"
395+
);
391396
let template = layout::render(layout, &page, "", content, style_files);
392397
SortedTemplate::from_template(&template, DELIMITER)
393398
.expect("Object Replacement Character (U+FFFC) should not appear in the --index-page")

tests/rustdoc-gui/search-title.goml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,15 @@ assert-document-property: {"title": '"another one" Search - Rust'}
2020
press-key: "Escape"
2121

2222
assert-document-property: {"title": |title|}
23+
24+
// check that all.html does it correctly, too.
25+
go-to: "file://" + |DOC_PATH| + "/test_docs/all.html"
26+
assert-document-property: {"title": "List of all items in this crate"}
27+
call-function: ("perform-search", {"query": "verify"})
28+
assert-document-property: {"title": '"verify" Search - Rust'}
29+
30+
// check that index.html does it correctly, too.
31+
go-to: "file://" + |DOC_PATH| + "/index.html"
32+
assert-document-property: {"title": "Index of crates"}
33+
call-function: ("perform-search", {"query": "verify"})
34+
assert-document-property: {"title": '"verify" Search - Rust'}

tests/rustdoc-gui/src/test_docs/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ compile-flags: --enable-index-page -Z unstable-options
12
//! The point of this crate is to be able to have enough different "kinds" of
23
//! documentation generated so we can test each different features.
34
#![doc(html_playground_url="https://play.rust-lang.org/")]

0 commit comments

Comments
 (0)