about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2020-10-28 17:53:12 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2020-10-28 18:01:06 +0000
commit709efd9df6e21ca07c7c0cceea468663f8a52c23 (patch)
tree409a68e00a606e7ee78cb099402749ae0d6305ef
parentd8a449756172f7be072b87a545bacf91e10d1bb9 (diff)
downloadrust-709efd9df6e21ca07c7c0cceea468663f8a52c23.tar.gz
rust-709efd9df6e21ca07c7c0cceea468663f8a52c23.zip
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 <ijackson@chiark.greenend.org.uk>
-rw-r--r--src/librustdoc/config.rs11
-rw-r--r--src/librustdoc/lib.rs10
2 files changed, 21 insertions, 0 deletions
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index 45106c5dbf6..2558f9e0d78 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -379,6 +379,17 @@ impl Options {
 
         let mut default_settings: Vec<Vec<(String, String)>> = 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()
                 .map(|s| {
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 90c77488ee9..54463d5c375 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -269,6 +269,16 @@ fn opts() -> Vec<RustcOptGroup> {
                 "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(
                 "",