diff options
| author | bors <bors@rust-lang.org> | 2023-09-20 16:16:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-09-20 16:16:01 +0000 |
| commit | 4f226925cefa01f41a425b277be466380ddf0b9e (patch) | |
| tree | 1a0e49db4d7e71cb32a08086039ba80916d0c442 /src | |
| parent | e3811a785e089294b58f6a22e447cc5c314d1070 (diff) | |
| parent | 70076c5fe8c9c46d5befcfa1d6f0c864332aa00f (diff) | |
| download | rust-4f226925cefa01f41a425b277be466380ddf0b9e.tar.gz rust-4f226925cefa01f41a425b277be466380ddf0b9e.zip | |
Auto merge of #116006 - GuillaumeGomez:rollup-elrbjd4, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - #115566 (clean up unneeded `ToPredicate` impls) - #115962 (coverage: Remove debug code from the instrumentor) - #115988 (rustdoc: add test cases, and fix, search tabs layout jank) - #115991 (Ensure `build/tmp` exists in `rustdoc_themes::get_themes`) - #115997 (RELEASES.md: Add missing patch releases) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/static/css/rustdoc.css | 12 | ||||
| -rw-r--r-- | src/librustdoc/html/static/js/search.js | 13 | ||||
| -rw-r--r-- | src/tools/rustdoc-themes/main.rs | 3 |
3 files changed, 21 insertions, 7 deletions
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 3b236641337..47f9e650281 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1355,6 +1355,7 @@ a.tooltip:hover::after { #search-tabs .count { font-size: 1rem; + font-variant-numeric: tabular-nums; color: var(--search-tab-title-count-color); } @@ -1637,6 +1638,13 @@ However, it's not needed with smaller screen width because the doc/code block is /* Media Queries */ +/* Make sure all the buttons line wrap at the same time */ +@media (max-width: 850px) { + #search-tabs .count { + display: block; + } +} + /* WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY If you update this line, then you also need to update the line with the same warning @@ -1764,10 +1772,6 @@ in src-script.js display: none !important; } - #search-tabs .count { - display: block; - } - #main-content > details.toggle > summary::before, #main-content > div > details.toggle > summary::before { left: -11px; diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 407bf5f2c5f..2f0cae0a48e 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -2334,11 +2334,20 @@ ${item.displayPath}<span class="${type}">${name}</span>\ } function makeTabHeader(tabNb, text, nbElems) { + // https://blog.horizon-eda.org/misc/2020/02/19/ui.html + // + // CSS runs with `font-variant-numeric: tabular-nums` to ensure all + // digits are the same width. \u{2007} is a Unicode space character + // that is defined to be the same width as a digit. + const fmtNbElems = + nbElems < 10 ? `\u{2007}(${nbElems})\u{2007}\u{2007}` : + nbElems < 100 ? `\u{2007}(${nbElems})\u{2007}` : + `\u{2007}(${nbElems})`; if (searchState.currentTab === tabNb) { return "<button class=\"selected\">" + text + - " <span class=\"count\">(" + nbElems + ")</span></button>"; + "<span class=\"count\">" + fmtNbElems + "</span></button>"; } - return "<button>" + text + " <span class=\"count\">(" + nbElems + ")</span></button>"; + return "<button>" + text + "<span class=\"count\">" + fmtNbElems + "</span></button>"; } /** diff --git a/src/tools/rustdoc-themes/main.rs b/src/tools/rustdoc-themes/main.rs index cc13df1f5ba..1eba83a8057 100644 --- a/src/tools/rustdoc-themes/main.rs +++ b/src/tools/rustdoc-themes/main.rs @@ -1,5 +1,5 @@ use std::env::args; -use std::fs::File; +use std::fs::{create_dir_all, File}; use std::io::{BufRead, BufReader, BufWriter, Write}; use std::path::Path; use std::process::{exit, Command}; @@ -14,6 +14,7 @@ fn get_themes<P: AsRef<Path>>(style_path: P) -> Vec<String> { std::time::SystemTime::UNIX_EPOCH.elapsed().expect("time is after UNIX epoch").as_millis(); let mut in_theme = None; + create_dir_all("build/tmp").expect("failed to create temporary test directory"); for line in BufReader::new(File::open(style_path).expect("read rustdoc.css failed")).lines() { let line = line.expect("read line from rustdoc.css failed"); let line = line.trim(); |
