Skip to content

Commit 709efd9

Browse files
committed
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 <[email protected]>
1 parent d8a4497 commit 709efd9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/librustdoc/config.rs

+11
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,17 @@ impl Options {
378378
};
379379

380380
let mut default_settings: Vec<Vec<(String, String)>> = vec![
381+
matches
382+
.opt_str("default-theme")
383+
.iter()
384+
.map(|theme| {
385+
vec![
386+
("use-system-theme".to_string(), "false".to_string()),
387+
("theme".to_string(), theme.to_string()),
388+
]
389+
})
390+
.flatten()
391+
.collect(),
381392
matches
382393
.opt_strs("default-setting")
383394
.iter()

src/librustdoc/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@ fn opts() -> Vec<RustcOptGroup> {
269269
"sort modules by where they appear in the program, rather than alphabetically",
270270
)
271271
}),
272+
unstable("default-theme", |o| {
273+
o.optopt(
274+
"",
275+
"default-theme",
276+
"Set the default theme. THEME should be the theme name, generally lowercase. \
277+
If an unknown default theme is specified, the builtin default is used. \
278+
The set of themes, and the rustdoc built-in default is not stable.",
279+
"THEME",
280+
)
281+
}),
272282
unstable("default-setting", |o| {
273283
o.optmulti(
274284
"",

0 commit comments

Comments
 (0)