diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 25ca67db6491e..d6e2330f91bbc 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -18,6 +18,7 @@ pub(crate) struct Layout { pub(crate) default_settings: FxHashMap, pub(crate) krate: String, pub(crate) krate_version: String, + pub(crate) krate_version_extra: String, /// The given user css file which allow to customize the generated /// documentation theme. pub(crate) css_file_extension: Option, diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 62c7dbe78eca6..160233d99ac93 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(), }; diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 6ceb42b937950..6f37e49b32f0f 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -492,6 +492,7 @@ ul.block, .block li { } .sidebar-elems, +.sidebar > .version, .sidebar > h2 { padding-left: 24px; } diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index a47caeaf51746..4f8e57efa529e 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -102,8 +102,11 @@

{# #} {% if !layout.krate_version.is_empty() %} {{+ layout.krate_version}} {% endif %} -

- + {# #} + {# #} + {% if !layout.krate_version_extra.is_empty() %} +
{{+ layout.krate_version_extra}}
{# #} + {% endif %} {% endif %} {{ sidebar|safe }} {# #} diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 269d9384376f9..6268f9598bc23 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -322,7 +322,15 @@ impl TestProps { ); if let Some(flags) = config.parse_name_value_directive(ln, COMPILE_FLAGS) { - self.compile_flags.extend(flags.split_whitespace().map(|s| s.to_owned())); + self.compile_flags.extend( + flags + .split("\"") + .enumerate() + .flat_map(|(i, f)| { + if i % 2 == 1 { vec![f] } else { f.split_whitespace().collect() } + }) + .map(|s| s.to_owned()), + ); } if config.parse_name_value_directive(ln, INCORRECT_COMPILER_FLAGS).is_some() { panic!("`compiler-flags` directive should be spelled `compile-flags`"); diff --git a/tests/rustdoc/crate-version-extra.rs b/tests/rustdoc/crate-version-extra.rs new file mode 100644 index 0000000000000..31cc4e7e7fe48 --- /dev/null +++ b/tests/rustdoc/crate-version-extra.rs @@ -0,0 +1,7 @@ +// compile-flags: "--crate-version=1.3.37-nightly (203c57dbe 2023-09-17)" + +#![crate_name="foo"] + +// main version next to logo, extra version data below it +// @has 'foo/index.html' '//h2/span[@class="version"]' '1.3.37-nightly' +// @has 'foo/index.html' '//nav[@class="sidebar"]/div[@class="version"]' '(203c57dbe 2023-09-17)'