Skip to content

Commit d9de05f

Browse files
committed
rustdoc: redesign toolbar with a separate "Search" button
1 parent 246733a commit d9de05f

File tree

66 files changed

+923
-641
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

+923
-641
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
@@ -204,6 +204,18 @@ impl<'tcx> Context<'tcx> {
204204
if !is_module {
205205
title.push_str(it.name.unwrap().as_str());
206206
}
207+
let short_title;
208+
let short_title = if is_module {
209+
let module_name = self.current.last().unwrap();
210+
short_title = if it.is_crate() {
211+
format!("Crate {module_name}")
212+
} else {
213+
format!("Module {module_name}")
214+
};
215+
&short_title[..]
216+
} else {
217+
it.name.as_ref().unwrap().as_str()
218+
};
207219
if !it.is_primitive() && !it.is_keyword() {
208220
if !is_module {
209221
title.push_str(" in ");
@@ -240,6 +252,7 @@ impl<'tcx> Context<'tcx> {
240252
root_path: &self.root_path(),
241253
static_root_path: self.shared.static_root_path.as_deref(),
242254
title: &title,
255+
short_title,
243256
description: &desc,
244257
resource_suffix: &self.shared.resource_suffix,
245258
rust_logo: has_doc_flag(self.tcx(), LOCAL_CRATE.as_def_id(), sym::rust_logo),
@@ -617,6 +630,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
617630
let shared = &self.shared;
618631
let mut page = layout::Page {
619632
title: "List of all items in this crate",
633+
short_title: "All",
620634
css_class: "mod sys",
621635
root_path: "../",
622636
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
@@ -35,6 +35,7 @@ use crate::html::format::{
3535
visibility_print_with_space,
3636
};
3737
use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine};
38+
use crate::html::render::sidebar::filters;
3839
use crate::html::render::{document_full, document_item_info};
3940
use crate::html::url_parts_builder::UrlPartsBuilder;
4041

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)