Skip to content

Commit 26c585e

Browse files
committed
rustdoc: redesign toolbar and disclosure widgets
This adds labels to the icons and moves them away from the search box. These changes are made together, because they work together, but are based on several complaints: * The [+/-] thing are a Reddit-ism. They don't look like buttons, but look like syntax <https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/More.20visual.20difference.20for.20the.20.2B.2F-.20.20Icons>, <#59851> (some of these are laundry lists with more suggestions, but they all mention [+/-] looking wrong) * The settings, help, and summary buttons are also too hard to recognize <https://lwn.net/Articles/987070/>, <#90310>, <#14475 (comment)>, <https://internals.rust-lang.org/t/improve-rustdoc-design/12758> ("Not all functionality is self-explanatory, for example the [+] button in the top right corner, the theme picker or the settings button.") The toggle-all and toggle-individual buttons both need done at once, since we want them to look like they go together. This changes them from both being [+/-] to both being arrows. Settings and Help are also migrated, so that the whole group can benefit from being described using actual words.
1 parent f167efa commit 26c585e

File tree

14 files changed

+245
-137
lines changed

14 files changed

+245
-137
lines changed

src/librustdoc/html/sources.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,22 @@ impl SourceCollector<'_, '_> {
209209
},
210210
);
211211

212+
let src_fname = p.file_name().expect("source has no filename").to_os_string();
213+
let mut fname = src_fname.clone();
214+
212215
let root_path = PathBuf::from("../../").join(root_path.into_inner());
213216
let mut root_path = root_path.to_string_lossy();
214217
if let Some(c) = root_path.as_bytes().last()
215218
&& *c != b'/'
216219
{
217220
root_path += "/";
218221
}
222+
let mut file_path = cur.clone().into_inner();
223+
file_path.push(&fname);
224+
fname.push(".html");
219225
let mut cur = self.dst.join(cur.into_inner());
220226
shared.ensure_dir(&cur)?;
221227

222-
let src_fname = p.file_name().expect("source has no filename").to_os_string();
223-
let mut fname = src_fname.clone();
224-
fname.push(".html");
225228
cur.push(&fname);
226229

227230
let title = format!("{} - source", src_fname.to_string_lossy());
@@ -249,7 +252,7 @@ impl SourceCollector<'_, '_> {
249252
cx,
250253
&root_path,
251254
highlight::DecorationInfo::default(),
252-
SourceContext::Standalone,
255+
SourceContext::Standalone { file_path },
253256
)
254257
},
255258
&shared.style_files,
@@ -290,7 +293,7 @@ where
290293
}
291294

292295
pub(crate) enum SourceContext {
293-
Standalone,
296+
Standalone { file_path: PathBuf },
294297
Embedded { offset: usize, needs_expansion: bool },
295298
}
296299

@@ -312,10 +315,11 @@ pub(crate) fn print_src(
312315
needs_expansion: bool,
313316
lines: RangeInclusive<usize>,
314317
code_html: Code,
318+
file_path: Option<String>,
315319
}
316320
let lines = s.lines().count();
317321
let (embedded, needs_expansion, lines) = match source_context {
318-
SourceContext::Standalone => (false, false, 1..=lines),
322+
SourceContext::Standalone { file_path: _ } => (false, false, 1..=lines),
319323
SourceContext::Embedded { offset, needs_expansion } => {
320324
(true, needs_expansion, (1 + offset)..=(lines + offset))
321325
}
@@ -332,5 +336,15 @@ pub(crate) fn print_src(
332336
);
333337
Ok(())
334338
});
335-
Source { embedded, needs_expansion, lines, code_html: code }.render_into(&mut writer).unwrap();
339+
Source {
340+
embedded,
341+
needs_expansion,
342+
lines,
343+
code_html: code,
344+
file_path: if let SourceContext::Standalone { file_path } = source_context {
345+
Some(file_path.display().to_string())
346+
} else {
347+
None
348+
},
349+
}.render_into(&mut writer).unwrap();
336350
}

src/librustdoc/html/static/css/noscript.css

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ nav.sub {
5959
--copy-path-button-color: #999;
6060
--copy-path-img-filter: invert(50%);
6161
--copy-path-img-hover-filter: invert(35%);
62+
--settings-menu-filter: invert(50%);
63+
--settings-menu-hover-filter: invert(35%);
6264
--codeblock-error-hover-color: rgb(255, 0, 0);
6365
--codeblock-error-color: rgba(255, 0, 0, .5);
6466
--codeblock-ignore-hover-color: rgb(255, 142, 0);
@@ -85,7 +87,6 @@ nav.sub {
8587
--search-tab-button-not-selected-background: #e6e6e6;
8688
--search-tab-button-selected-border-top-color: #0089ff;
8789
--search-tab-button-selected-background: #fff;
88-
--settings-menu-filter: none;
8990
--stab-background-color: #fff5d6;
9091
--stab-code-color: #000;
9192
--code-highlight-kw-color: #8959a8;
@@ -188,6 +189,8 @@ nav.sub {
188189
--search-tab-button-not-selected-background: #252525;
189190
--search-tab-button-selected-border-top-color: #0089ff;
190191
--search-tab-button-selected-background: #353535;
192+
--settings-menu-filter: invert(50%);
193+
--settings-menu-hover-filter: invert(65%);
191194
--stab-background-color: #314559;
192195
--stab-code-color: #e6e1cf;
193196
--code-highlight-kw-color: #ab8ac1;

0 commit comments

Comments
 (0)