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>
This commit is contained in:
Ian Jackson 2020-10-28 17:53:12 +00:00
parent d8a4497561
commit 709efd9df6
2 changed files with 21 additions and 0 deletions

View File

@ -378,6 +378,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()

View File

@ -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(
"",