about summary refs log tree commit diff
path: root/src/librustdoc/html/render
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-09-18 17:48:18 -0700
committerMichael Howell <michael@notriddle.com>2023-10-08 20:17:53 -0700
commit6d6fa792fffa6e22eec1b30cedee6e8306d0df64 (patch)
tree293ffd439cbf85994b1c8f8d912c008e66c8a59b /src/librustdoc/html/render
parent957c5db6be09f8def3f7a8297577a6d42e02f7c0 (diff)
downloadrust-6d6fa792fffa6e22eec1b30cedee6e8306d0df64.tar.gz
rust-6d6fa792fffa6e22eec1b30cedee6e8306d0df64.zip
rustdoc: clean up the layout for annotated version numbers
This should result in a layout for the actual standard library,
when built on CI, that looks like this:

    _____
   /     \ std
   |  R  | 1.74.0-nightly
   \_____/

   (203c57dbe 2023-09-17)

Having the whole version as one string caused it to flex wrap,
because the sidebar isn't wide enough to fit the whole thing.
Diffstat (limited to 'src/librustdoc/html/render')
-rw-r--r--src/librustdoc/html/render/context.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 62c7dbe78ec..160233d99ac 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -528,13 +528,17 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
         if let Some(url) = playground_url {
             playground = Some(markdown::Playground { crate_name: Some(krate.name(tcx)), url });
         }
+        let krate_version = cache.crate_version.as_deref().unwrap_or_default();
+        let (krate_version, krate_version_extra) =
+            krate_version.split_once(" ").unwrap_or((krate_version, ""));
         let mut layout = layout::Layout {
             logo: String::new(),
             favicon: String::new(),
             external_html,
             default_settings,
             krate: krate.name(tcx).to_string(),
-            krate_version: cache.crate_version.as_deref().unwrap_or_default().to_string(),
+            krate_version: krate_version.to_string(),
+            krate_version_extra: krate_version_extra.to_string(),
             css_file_extension: extension_css,
             scrape_examples_extension: !call_locations.is_empty(),
         };