diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-25 23:06:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-25 23:06:01 +0100 |
| commit | c8999d9d91ebc10857b7e46dbda3b4f5b3d84f94 (patch) | |
| tree | bf2a947e7ae837f13f076f49c43978d4f1046a49 | |
| parent | 83cc776d7cdcb2bcd4ede77aed59b99582ec7b70 (diff) | |
| parent | abffd4af08ac3bc4ab91cfc83ad3055529e63d57 (diff) | |
| download | rust-c8999d9d91ebc10857b7e46dbda3b4f5b3d84f94.tar.gz rust-c8999d9d91ebc10857b7e46dbda3b4f5b3d84f94.zip | |
Rollup merge of #93286 - jsha:sidebar-nowrap, r=GuillaumeGomez
Add white-space: nowrap to links in the sidebar We already have overflow: hidden on these links, but if there is a possibility to wrap, they will wrap. This happens in particular for trait implementations because the punctuation (`<>, `) introduces opportunities for breaks. That produces inconsistent UI. Fix it by forcing them not to wrap. Demo: https://rustdoc.crud.net/jsha/sidebar-nowrap/std/string/struct.String.html To see the effect, scroll down to the "Trait Implementations" portion of the sidebar and look at IndexMut. Compare vs: https://doc.rust-lang.org/std/string/struct.String.html https://doc.rust-lang.org/nightly/std/string/struct.String.html r? `@camelid`
| -rw-r--r-- | src/librustdoc/html/static/css/rustdoc.css | 4 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/sidebar.goml | 4 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src/lib2/lib.rs | 6 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 645c0aba6ac..4c79218f62a 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -484,6 +484,10 @@ nav.sub { overflow: hidden; } +.sidebar-links a { + white-space: nowrap; +} + .sidebar h2 { border-bottom: none; font-weight: 500; diff --git a/src/test/rustdoc-gui/sidebar.goml b/src/test/rustdoc-gui/sidebar.goml index ae198e41742..ef3a92ad7a6 100644 --- a/src/test/rustdoc-gui/sidebar.goml +++ b/src/test/rustdoc-gui/sidebar.goml @@ -74,3 +74,7 @@ assert-text: (".sidebar > .location", "Module sub_sub_module") assert-false: ".sidebar-elems .crate" assert-text: (".sidebar-elems .items > ul > li:nth-child(1)", "Functions") assert-text: ("#functions + .item-table .item-left > a", "foo") + +// Links to trait implementations in the sidebar should not wrap even if they are long. +goto: file://|DOC_PATH|/lib2/struct.HasALongTraitWithParams.html +assert-property: (".sidebar-links a", {"offsetHeight": 29}) diff --git a/src/test/rustdoc-gui/src/lib2/lib.rs b/src/test/rustdoc-gui/src/lib2/lib.rs index 73013c9778f..5b6d236e8e0 100644 --- a/src/test/rustdoc-gui/src/lib2/lib.rs +++ b/src/test/rustdoc-gui/src/lib2/lib.rs @@ -114,3 +114,9 @@ pub mod too_long { pub fn foo(&self) {} } } + +pub struct HasALongTraitWithParams {} + +pub trait LongTraitWithParamsBananaBananaBanana<T> {} + +impl LongTraitWithParamsBananaBananaBanana<usize> for HasALongTraitWithParams {} |
