Skip to content

Commit bc50b18

Browse files
committed
rustdoc: redesign toolbar with a separate "Search" button
1 parent 15825b7 commit bc50b18

File tree

66 files changed

+878
-645
lines changed

Some content is hidden

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

66 files changed

+878
-645
lines changed

src/librustdoc/html/layout.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub(crate) struct Layout {
2424

2525
pub(crate) struct Page<'a> {
2626
pub(crate) title: &'a str,
27+
pub(crate) short_title: &'a str,
2728
pub(crate) css_class: &'a str,
2829
pub(crate) root_path: &'a str,
2930
pub(crate) static_root_path: Option<&'a str>,

src/librustdoc/html/render/context.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,18 @@ impl<'tcx> Context<'tcx> {
206206
if !is_module {
207207
title.push_str(it.name.unwrap().as_str());
208208
}
209+
let short_title;
210+
let short_title = if is_module {
211+
let module_name = self.current.last().unwrap();
212+
short_title = if it.is_crate() {
213+
format!("Crate {module_name}")
214+
} else {
215+
format!("Module {module_name}")
216+
};
217+
&short_title[..]
218+
} else {
219+
it.name.as_ref().unwrap().as_str()
220+
};
209221
if !it.is_primitive() && !it.is_keyword() {
210222
if !is_module {
211223
title.push_str(" in ");
@@ -242,6 +254,7 @@ impl<'tcx> Context<'tcx> {
242254
root_path: &self.root_path(),
243255
static_root_path: self.shared.static_root_path.as_deref(),
244256
title: &title,
257+
short_title,
245258
description: &desc,
246259
resource_suffix: &self.shared.resource_suffix,
247260
rust_logo: has_doc_flag(self.tcx(), LOCAL_CRATE.as_def_id(), sym::rust_logo),
@@ -623,6 +636,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
623636
let shared = &self.shared;
624637
let mut page = layout::Page {
625638
title: "List of all items in this crate",
639+
short_title: "All",
626640
css_class: "mod sys",
627641
root_path: "../",
628642
static_root_path: shared.static_root_path.as_deref(),

src/librustdoc/html/render/print_item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use crate::html::format::{
3434
print_constness_with_space, print_where_clause, visibility_print_with_space,
3535
};
3636
use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine};
37+
use crate::html::render::sidebar::filters;
3738
use crate::html::render::{document_full, document_item_info};
3839
use crate::html::url_parts_builder::UrlPartsBuilder;
3940

src/librustdoc/html/render/write_shared.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ impl CratesIndexPart {
426426
fn blank(cx: &Context<'_>) -> SortedTemplate<<Self as CciPart>::FileFormat> {
427427
let page = layout::Page {
428428
title: "Index of crates",
429+
short_title: "Crates",
429430
css_class: "mod sys",
430431
root_path: "./",
431432
static_root_path: cx.shared.static_root_path.as_deref(),

src/librustdoc/html/sources.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ impl SourceCollector<'_, '_> {
230230
);
231231
let page = layout::Page {
232232
title: &title,
233+
short_title: &src_fname.to_string_lossy(),
233234
css_class: "src",
234235
root_path: &root_path,
235236
static_root_path: shared.static_root_path.as_deref(),

0 commit comments

Comments
 (0)