From 8f9014d98f88c57dbd786a3b9ac86c5bfcdcb401 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 22 Sep 2019 22:35:25 +0200 Subject: [PATCH] Rename rustdoc options --themes and --check-themes to --theme and --check-theme --- src/doc/rustdoc/src/command-line-arguments.md | 8 ++++---- src/librustdoc/config.rs | 12 ++++++------ src/librustdoc/html/static_files.rs | 2 +- src/librustdoc/lib.rs | 8 ++++---- src/test/run-make-fulldeps/rustdoc-themes/Makefile | 2 +- src/tools/rustdoc-themes/main.rs | 7 +++++-- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index 64eaf528241..c935699abb0 100644 --- a/src/doc/rustdoc/src/command-line-arguments.md +++ b/src/doc/rustdoc/src/command-line-arguments.md @@ -359,19 +359,19 @@ This flag allows `rustdoc` to treat your rust code as the given edition. It will the given edition as well. As with `rustc`, the default edition that `rustdoc` will use is `2015` (the first edition). -## `themes`: add more themes to generated documentation +## `theme`: add more themes to generated documentation By default, `rustdoc` only provides the "dark" and "light" themes. If you want to add new ones, you'll need to use this flag as follows: ```bash -$ rustdoc src/lib.rs --themes /path/to/your/theme/file.css +$ rustdoc src/lib.rs --theme /path/to/your/theme/file.css ``` Note that the theme's name will be the file name without its extension. So if you pass `/path/to/your/theme/file.css` as theme, then the theme's name will be `file`. -### `check-themes`: check if your themes implement all the required rules +### `check-theme`: check if your themes implement all the required rules This flag allows you to check if your themes implement the necessary CSS rules. To put it more simply, when adding a new theme, it needs to implements all the CSS rules present in the "light" @@ -380,5 +380,5 @@ CSS theme. You can use this flag like this: ```bash -$ rustdoc --check-themes /path/to/your/theme/file.css +$ rustdoc --check-theme /path/to/your/theme/file.css ``` diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 85feb89d7d5..d48416d4177 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -282,12 +282,12 @@ impl Options { // check for deprecated options check_deprecated_options(&matches, &diag); - let to_check = matches.opt_strs("check-themes"); + let to_check = matches.opt_strs("check-theme"); if !to_check.is_empty() { let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes()); let mut errors = 0; - println!("rustdoc: [check-themes] Starting tests! (Ignoring all other arguments)"); + println!("rustdoc: [check-theme] Starting tests! (Ignoring all other arguments)"); for theme_file in to_check.iter() { print!(" - Checking \"{}\"...", theme_file); let (success, differences) = theme::test_theme_against(theme_file, &paths, &diag); @@ -358,15 +358,15 @@ impl Options { } let mut themes = Vec::new(); - if matches.opt_present("themes") { + if matches.opt_present("theme") { let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes()); - for (theme_file, theme_s) in matches.opt_strs("themes") + for (theme_file, theme_s) in matches.opt_strs("theme") .iter() .map(|s| (PathBuf::from(&s), s.to_owned())) { if !theme_file.is_file() { diag.struct_err(&format!("invalid file: \"{}\"", theme_s)) - .help("option --themes arguments must all be files") + .help("option --theme arguments must all be files") .emit(); return Err(1); } @@ -384,7 +384,7 @@ impl Options { default theme", theme_s)) .warn("the theme may appear incorrect when loaded") .help(&format!("to see what rules are missing, call `rustdoc \ - --check-themes \"{}\"`", theme_s)) + --check-theme \"{}\"`", theme_s)) .emit(); } themes.push(theme_file); diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index 8702ba224db..9fc1d76185f 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -59,7 +59,7 @@ pub static RUST_FAVICON: &'static [u8] = include_bytes!("static/favicon.ico"); /// The built-in themes given to every documentation site. pub mod themes { /// The "light" theme, selected by default when no setting is available. Used as the basis for - /// the `--check-themes` functionality. + /// the `--check-theme` functionality. pub static LIGHT: &'static str = include_str!("static/themes/light.css"); /// The "dark" theme. diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 6241ae7a3bb..bdb45f888d2 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -251,13 +251,13 @@ fn opts() -> Vec { o.optflag("", "sort-modules-by-appearance", "sort modules by where they appear in the \ program, rather than alphabetically") }), - stable("themes", |o| { - o.optmulti("", "themes", + stable("theme", |o| { + o.optmulti("", "theme", "additional themes which will be added to the generated docs", "FILES") }), - stable("check-themes", |o| { - o.optmulti("", "check-themes", + stable("check-theme", |o| { + o.optmulti("", "check-theme", "check if given theme is valid", "FILES") }), diff --git a/src/test/run-make-fulldeps/rustdoc-themes/Makefile b/src/test/run-make-fulldeps/rustdoc-themes/Makefile index a4536e77bd7..f5a471e66e5 100644 --- a/src/test/run-make-fulldeps/rustdoc-themes/Makefile +++ b/src/test/run-make-fulldeps/rustdoc-themes/Makefile @@ -6,5 +6,5 @@ OUTPUT_DIR := "$(TMPDIR)/rustdoc-themes" all: cp $(S)/src/librustdoc/html/static/themes/light.css $(TMPDIR)/test.css - $(RUSTDOC) -o $(OUTPUT_DIR) foo.rs --themes $(TMPDIR)/test.css + $(RUSTDOC) -o $(OUTPUT_DIR) foo.rs --theme $(TMPDIR)/test.css $(HTMLDOCCK) $(OUTPUT_DIR) foo.rs diff --git a/src/tools/rustdoc-themes/main.rs b/src/tools/rustdoc-themes/main.rs index fb0c9d7d4e0..87c1de3e715 100644 --- a/src/tools/rustdoc-themes/main.rs +++ b/src/tools/rustdoc-themes/main.rs @@ -38,9 +38,12 @@ fn main() { eprintln!("No theme found in \"{}\"...", themes_folder); exit(1); } + let arg_name = "--check-theme".to_owned(); let status = Command::new(rustdoc_bin) - .args(&["-Z", "unstable-options", "--check-themes"]) - .args(&themes) + .args(&["-Z", "unstable-options"]) + .args(&themes.iter() + .flat_map(|t| vec![&arg_name, t].into_iter()) + .collect::>()) .status() .expect("failed to execute child"); if !status.success() {