diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2018-01-25 23:31:48 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2018-02-08 10:53:09 +0100 |
| commit | 9ee69818f728df8c37981137e4a5427bb341f845 (patch) | |
| tree | d2a5874860c63a2559ac7cd0376e4bfed55f1fae | |
| parent | 583b29f85c3f478e633eba38c59505e1a31694e6 (diff) | |
| download | rust-9ee69818f728df8c37981137e4a5427bb341f845.tar.gz rust-9ee69818f728df8c37981137e4a5427bb341f845.zip | |
Add test when trying to add new theme
| -rw-r--r-- | src/librustdoc/lib.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 613ac67f03b..1bdcebcee98 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -398,12 +398,23 @@ pub fn main_args(args: &[String]) -> isize { } let mut themes = Vec::new(); - for theme in matches.opt_strs("themes").iter().map(|s| PathBuf::from(&s)) { - if !theme.is_file() { - eprintln!("rustdoc: option --themes arguments must all be files"); - return 1; + if matches.opt_present("themes") { + let pathes = theme::load_css_pathes(include_bytes!("html/static/themes/main.css")); + + for (theme_file, theme_s) in matches.opt_strs("themes") + .iter() + .map(|s| (PathBuf::from(&s), s.to_owned())) { + if !theme_file.is_file() { + eprintln!("rustdoc: option --themes arguments must all be files"); + return 1; + } + if !theme::test_theme_against(&theme_file, &pathes).is_empty() { + eprintln!("rustdoc: invalid theme: \"{}\"", theme_s); + eprintln!(" Check what's wrong with the \"theme-checker\" option"); + return 1; + } + themes.push(theme_file); } - themes.push(theme); } let external_html = match ExternalHtml::load( |
