Skip to content

Commit 9ee6981

Browse files
Add test when trying to add new theme
1 parent 583b29f commit 9ee6981

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/librustdoc/lib.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,23 @@ pub fn main_args(args: &[String]) -> isize {
398398
}
399399

400400
let mut themes = Vec::new();
401-
for theme in matches.opt_strs("themes").iter().map(|s| PathBuf::from(&s)) {
402-
if !theme.is_file() {
403-
eprintln!("rustdoc: option --themes arguments must all be files");
404-
return 1;
401+
if matches.opt_present("themes") {
402+
let pathes = theme::load_css_pathes(include_bytes!("html/static/themes/main.css"));
403+
404+
for (theme_file, theme_s) in matches.opt_strs("themes")
405+
.iter()
406+
.map(|s| (PathBuf::from(&s), s.to_owned())) {
407+
if !theme_file.is_file() {
408+
eprintln!("rustdoc: option --themes arguments must all be files");
409+
return 1;
410+
}
411+
if !theme::test_theme_against(&theme_file, &pathes).is_empty() {
412+
eprintln!("rustdoc: invalid theme: \"{}\"", theme_s);
413+
eprintln!(" Check what's wrong with the \"theme-checker\" option");
414+
return 1;
415+
}
416+
themes.push(theme_file);
405417
}
406-
themes.push(theme);
407418
}
408419

409420
let external_html = match ExternalHtml::load(

0 commit comments

Comments
 (0)