From 709efd9df6e21ca07c7c0cceea468663f8a52c23 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 28 Oct 2020 17:53:12 +0000 Subject: [PATCH] rustdoc: Provide a --default-theme THEME option This is a fairly simple special case of --default-eetting. We must set both "theme" and "use-system-theme". Providing it separately enables us to document a way to set the theme without expoosing the individual settings keywords, which are quite complex. Signed-off-by: Ian Jackson --- src/librustdoc/config.rs | 11 +++++++++++ src/librustdoc/lib.rs | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 45106c5dbf6a..2558f9e0d789 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -378,6 +378,17 @@ impl Options { }; let mut default_settings: Vec> = vec![ + matches + .opt_str("default-theme") + .iter() + .map(|theme| { + vec![ + ("use-system-theme".to_string(), "false".to_string()), + ("theme".to_string(), theme.to_string()), + ] + }) + .flatten() + .collect(), matches .opt_strs("default-setting") .iter() diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 90c77488ee94..54463d5c3758 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -269,6 +269,16 @@ fn opts() -> Vec { "sort modules by where they appear in the program, rather than alphabetically", ) }), + unstable("default-theme", |o| { + o.optopt( + "", + "default-theme", + "Set the default theme. THEME should be the theme name, generally lowercase. \ + If an unknown default theme is specified, the builtin default is used. \ + The set of themes, and the rustdoc built-in default is not stable.", + "THEME", + ) + }), unstable("default-setting", |o| { o.optmulti( "",