Skip to content

Commit 94b21eb

Browse files
Rename rustdoc options --themes and --check-themes to --theme and --check-theme
1 parent 747dcaf commit 94b21eb

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

src/doc/rustdoc/src/command-line-arguments.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -359,19 +359,19 @@ This flag allows `rustdoc` to treat your rust code as the given edition. It will
359359
the given edition as well. As with `rustc`, the default edition that `rustdoc` will use is `2015`
360360
(the first edition).
361361

362-
## `themes`: add more themes to generated documentation
362+
## `theme`: add more themes to generated documentation
363363

364364
By default, `rustdoc` only provides the "dark" and "light" themes. If you want to add new ones,
365365
you'll need to use this flag as follows:
366366

367367
```bash
368-
$ rustdoc src/lib.rs --themes /path/to/your/theme/file.css
368+
$ rustdoc src/lib.rs --theme /path/to/your/theme/file.css
369369
```
370370

371371
Note that the theme's name will be the file name without its extension. So if you pass
372372
`/path/to/your/theme/file.css` as theme, then the theme's name will be `file`.
373373

374-
### `check-themes`: check if your themes implement all the required rules
374+
### `check-theme`: check if your themes implement all the required rules
375375

376376
This flag allows you to check if your themes implement the necessary CSS rules. To put it more
377377
simply, when adding a new theme, it needs to implements all the CSS rules present in the "light"
@@ -380,5 +380,5 @@ CSS theme.
380380
You can use this flag like this:
381381

382382
```bash
383-
$ rustdoc --check-themes /path/to/your/theme/file.css
383+
$ rustdoc --check-theme /path/to/your/theme/file.css
384384
```

src/librustdoc/config.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,12 @@ impl Options {
280280
// check for deprecated options
281281
check_deprecated_options(&matches, &diag);
282282

283-
let to_check = matches.opt_strs("check-themes");
283+
let to_check = matches.opt_strs("check-theme");
284284
if !to_check.is_empty() {
285285
let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes());
286286
let mut errors = 0;
287287

288-
println!("rustdoc: [check-themes] Starting tests! (Ignoring all other arguments)");
288+
println!("rustdoc: [check-theme] Starting tests! (Ignoring all other arguments)");
289289
for theme_file in to_check.iter() {
290290
print!(" - Checking \"{}\"...", theme_file);
291291
let (success, differences) = theme::test_theme_against(theme_file, &paths, &diag);
@@ -360,15 +360,15 @@ impl Options {
360360
}
361361

362362
let mut themes = Vec::new();
363-
if matches.opt_present("themes") {
363+
if matches.opt_present("theme") {
364364
let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes());
365365

366-
for (theme_file, theme_s) in matches.opt_strs("themes")
366+
for (theme_file, theme_s) in matches.opt_strs("theme")
367367
.iter()
368368
.map(|s| (PathBuf::from(&s), s.to_owned())) {
369369
if !theme_file.is_file() {
370370
diag.struct_err(&format!("invalid file: \"{}\"", theme_s))
371-
.help("option --themes arguments must all be files")
371+
.help("option --theme arguments must all be files")
372372
.emit();
373373
return Err(1);
374374
}
@@ -386,7 +386,7 @@ impl Options {
386386
default theme", theme_s))
387387
.warn("the theme may appear incorrect when loaded")
388388
.help(&format!("to see what rules are missing, call `rustdoc \
389-
--check-themes \"{}\"`", theme_s))
389+
--check-theme \"{}\"`", theme_s))
390390
.emit();
391391
}
392392
themes.push(theme_file);

src/librustdoc/html/static_files.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub static RUST_FAVICON: &'static [u8] = include_bytes!("static/favicon.ico");
5959
/// The built-in themes given to every documentation site.
6060
pub mod themes {
6161
/// The "light" theme, selected by default when no setting is available. Used as the basis for
62-
/// the `--check-themes` functionality.
62+
/// the `--check-theme` functionality.
6363
pub static LIGHT: &'static str = include_str!("static/themes/light.css");
6464

6565
/// The "dark" theme.

src/librustdoc/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ fn opts() -> Vec<RustcOptGroup> {
247247
o.optflag("", "sort-modules-by-appearance", "sort modules by where they appear in the \
248248
program, rather than alphabetically")
249249
}),
250-
stable("themes", |o| {
251-
o.optmulti("", "themes",
250+
stable("theme", |o| {
251+
o.optmulti("", "theme",
252252
"additional themes which will be added to the generated docs",
253253
"FILES")
254254
}),
255-
stable("check-themes", |o| {
256-
o.optmulti("", "check-themes",
255+
stable("check-theme", |o| {
256+
o.optmulti("", "check-theme",
257257
"check if given theme is valid",
258258
"FILES")
259259
}),

src/test/run-make-fulldeps/rustdoc-themes/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ OUTPUT_DIR := "$(TMPDIR)/rustdoc-themes"
66

77
all:
88
cp $(S)/src/librustdoc/html/static/themes/light.css $(TMPDIR)/test.css
9-
$(RUSTDOC) -o $(OUTPUT_DIR) foo.rs --themes $(TMPDIR)/test.css
9+
$(RUSTDOC) -o $(OUTPUT_DIR) foo.rs --theme $(TMPDIR)/test.css
1010
$(HTMLDOCCK) $(OUTPUT_DIR) foo.rs

src/tools/rustdoc-themes/main.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ fn main() {
3838
eprintln!("No theme found in \"{}\"...", themes_folder);
3939
exit(1);
4040
}
41+
let arg_name = "--check-theme".to_owned();
4142
let status = Command::new(rustdoc_bin)
42-
.args(&["-Z", "unstable-options", "--check-themes"])
43-
.args(&themes)
43+
.args(&["-Z", "unstable-options"])
44+
.args(&themes.iter()
45+
.flat_map(|t| vec![&arg_name, t].into_iter())
46+
.collect::<Vec<_>>())
4447
.status()
4548
.expect("failed to execute child");
4649
if !status.success() {

0 commit comments

Comments
 (0)