|
1 | 1 | use std::collections::BTreeMap;
|
| 2 | +use std::ffi::OsStr; |
2 | 3 | use std::fmt;
|
3 | 4 | use std::path::PathBuf;
|
4 | 5 |
|
@@ -281,12 +282,12 @@ impl Options {
|
281 | 282 | // check for deprecated options
|
282 | 283 | check_deprecated_options(&matches, &diag);
|
283 | 284 |
|
284 |
| - let to_check = matches.opt_strs("theme-checker"); |
| 285 | + let to_check = matches.opt_strs("check-theme"); |
285 | 286 | if !to_check.is_empty() {
|
286 | 287 | let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes());
|
287 | 288 | let mut errors = 0;
|
288 | 289 |
|
289 |
| - println!("rustdoc: [theme-checker] Starting tests!"); |
| 290 | + println!("rustdoc: [check-theme] Starting tests! (Ignoring all other arguments)"); |
290 | 291 | for theme_file in to_check.iter() {
|
291 | 292 | print!(" - Checking \"{}\"...", theme_file);
|
292 | 293 | let (success, differences) = theme::test_theme_against(theme_file, &paths, &diag);
|
@@ -357,23 +358,35 @@ impl Options {
|
357 | 358 | }
|
358 | 359 |
|
359 | 360 | let mut themes = Vec::new();
|
360 |
| - if matches.opt_present("themes") { |
| 361 | + if matches.opt_present("theme") { |
361 | 362 | let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes());
|
362 | 363 |
|
363 |
| - for (theme_file, theme_s) in matches.opt_strs("themes") |
| 364 | + for (theme_file, theme_s) in matches.opt_strs("theme") |
364 | 365 | .iter()
|
365 | 366 | .map(|s| (PathBuf::from(&s), s.to_owned())) {
|
366 | 367 | if !theme_file.is_file() {
|
367 |
| - diag.struct_err("option --themes arguments must all be files").emit(); |
| 368 | + diag.struct_err(&format!("invalid argument: \"{}\"", theme_s)) |
| 369 | + .help("arguments to --theme must be files") |
| 370 | + .emit(); |
368 | 371 | return Err(1);
|
369 | 372 | }
|
370 |
| - let (success, ret) = theme::test_theme_against(&theme_file, &paths, &diag); |
371 |
| - if !success || !ret.is_empty() { |
372 |
| - diag.struct_err(&format!("invalid theme: \"{}\"", theme_s)) |
373 |
| - .help("check what's wrong with the --theme-checker option") |
| 373 | + if theme_file.extension() != Some(OsStr::new("css")) { |
| 374 | + diag.struct_err(&format!("invalid argument: \"{}\"", theme_s)) |
374 | 375 | .emit();
|
375 | 376 | return Err(1);
|
376 | 377 | }
|
| 378 | + let (success, ret) = theme::test_theme_against(&theme_file, &paths, &diag); |
| 379 | + if !success { |
| 380 | + diag.struct_err(&format!("error loading theme file: \"{}\"", theme_s)).emit(); |
| 381 | + return Err(1); |
| 382 | + } else if !ret.is_empty() { |
| 383 | + diag.struct_warn(&format!("theme file \"{}\" is missing CSS rules from the \ |
| 384 | + default theme", theme_s)) |
| 385 | + .warn("the theme may appear incorrect when loaded") |
| 386 | + .help(&format!("to see what rules are missing, call `rustdoc \ |
| 387 | + --check-theme \"{}\"`", theme_s)) |
| 388 | + .emit(); |
| 389 | + } |
377 | 390 | themes.push(theme_file);
|
378 | 391 | }
|
379 | 392 | }
|
|
0 commit comments