Improve documentation, add checks for themes option arguments, make sure the themes file names are js compatible
This commit is contained in:
parent
6f2d1f51eb
commit
bbfd63c89a
@ -368,6 +368,9 @@ you'll need to use this flag as follows:
|
||||
$ rustdoc src/lib.rs --themes /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-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
|
||||
@ -377,5 +380,5 @@ CSS theme.
|
||||
You can use this flag like this:
|
||||
|
||||
```bash
|
||||
$ rustdoc src/lib.rs --check-theme /path/to/your/theme/file.css
|
||||
$ rustdoc --check-theme /path/to/your/theme/file.css
|
||||
```
|
||||
|
@ -1,4 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::ffi::OsStr;
|
||||
use std::fmt;
|
||||
use std::path::PathBuf;
|
||||
|
||||
@ -369,9 +370,14 @@ impl Options {
|
||||
.emit();
|
||||
return Err(1);
|
||||
}
|
||||
if theme_file.extension() != Some(OsStr::new("css")) {
|
||||
diag.struct_err(&format!("invalid file: \"{}\": expected CSS file", theme_s))
|
||||
.emit();
|
||||
return Err(1);
|
||||
}
|
||||
let (success, ret) = theme::test_theme_against(&theme_file, &paths, &diag);
|
||||
if !success {
|
||||
diag.struct_warn(&format!("error loading theme file: \"{}\"", theme_s)).emit();
|
||||
diag.struct_err(&format!("error loading theme file: \"{}\"", theme_s)).emit();
|
||||
return Err(1);
|
||||
} else if !ret.is_empty() {
|
||||
diag.struct_warn(&format!("theme file \"{}\" is missing CSS rules from the \
|
||||
|
@ -645,7 +645,7 @@ themePicker.onblur = handleThemeButtonsBlur;
|
||||
themes.appendChild(but);
|
||||
}});"#,
|
||||
themes.iter()
|
||||
.map(|s| format!("\"{}\"", s))
|
||||
.map(|s| format!("\"{}\"", s.replace("\\", "\\\\").replace("\"", "\\\"")))
|
||||
.collect::<Vec<String>>()
|
||||
.join(","));
|
||||
write(cx.dst.join(&format!("theme{}.js", cx.shared.resource_suffix)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user