Rename rustdoc options --themes and --check-themes to --theme and --check-theme
This commit is contained in:
parent
685b63a163
commit
8f9014d98f
6 changed files with 21 additions and 18 deletions
|
@ -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
|
||||
```
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -251,13 +251,13 @@ fn opts() -> Vec<RustcOptGroup> {
|
|||
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")
|
||||
}),
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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::<Vec<_>>())
|
||||
.status()
|
||||
.expect("failed to execute child");
|
||||
if !status.success() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue