Skip to content

Commit b1b11d4

Browse files
Pass themes folder as parameter
1 parent 51580d4 commit b1b11d4

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/bootstrap/test.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@ impl Step for RustdocTheme {
451451
fn run(self, builder: &Builder) {
452452
let rustdoc = builder.rustdoc(self.compiler.host);
453453
let mut cmd = Command::new(builder.config.python.clone().expect("python not defined"));
454-
cmd.args(&["src/tools/rustdoc-themes/test-themes.py", rustdoc.to_str().unwrap()]);
454+
cmd.args(&[builder.src.join("src/tools/rustdoc-themes/test-themes.py").to_str().unwrap(),
455+
rustdoc.to_str().unwrap(),
456+
builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap()]);
455457
cmd.env("RUSTC_STAGE", self.compiler.stage.to_string())
456458
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
457459
.env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))

src/librustdoc/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ pub fn main_args(args: &[String]) -> isize {
332332
print!(" - Checking \"{}\"...", theme_file);
333333
let (success, differences) = theme::test_theme_against(theme_file, &paths);
334334
if !differences.is_empty() || !success {
335-
eprintln!(" FAILED");
335+
println!(" FAILED");
336336
errors += 1;
337337
if !differences.is_empty() {
338-
eprintln!("{}", differences.join("\n"));
338+
println!("{}", differences.join("\n"));
339339
}
340340
} else {
341341
println!(" OK");
@@ -407,13 +407,13 @@ pub fn main_args(args: &[String]) -> isize {
407407
.iter()
408408
.map(|s| (PathBuf::from(&s), s.to_owned())) {
409409
if !theme_file.is_file() {
410-
eprintln!("rustdoc: option --themes arguments must all be files");
410+
println!("rustdoc: option --themes arguments must all be files");
411411
return 1;
412412
}
413413
let (success, ret) = theme::test_theme_against(&theme_file, &paths);
414414
if !success || !ret.is_empty() {
415-
eprintln!("rustdoc: invalid theme: \"{}\"", theme_s);
416-
eprintln!(" Check what's wrong with the \"theme-checker\" option");
415+
println!("rustdoc: invalid theme: \"{}\"", theme_s);
416+
println!(" Check what's wrong with the \"theme-checker\" option");
417417
return 1;
418418
}
419419
themes.push(theme_file);

src/librustdoc/theme.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ c // sdf
348348
d {}
349349
"#;
350350
let paths = load_css_paths(text.as_bytes());
351-
assert!(paths.children.get(&CssPath::new("a b c d".to_owned())).is_some());
351+
assert!(paths.children.contains(&CssPath::new("a b c d".to_owned())));
352352
}
353353

354354
#[test]

src/tools/rustdoc-themes/test-themes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import sys
1818

1919
FILES_TO_IGNORE = ['main.css']
20-
THEME_DIR_PATH = "src/librustdoc/html/static/themes"
2120

2221

2322
def print_err(msg):
@@ -31,14 +30,15 @@ def exec_command(command):
3130

3231

3332
def main(argv):
34-
if len(argv) < 1:
33+
if len(argv) < 2:
3534
print_err("Needs rustdoc binary path")
3635
return 1
3736
rustdoc_bin = argv[0]
38-
themes = [join(THEME_DIR_PATH, f) for f in listdir(THEME_DIR_PATH)
39-
if isfile(join(THEME_DIR_PATH, f)) and f not in FILES_TO_IGNORE]
37+
themes_folder = argv[1]
38+
themes = [join(themes_folder, f) for f in listdir(themes_folder)
39+
if isfile(join(themes_folder, f)) and f not in FILES_TO_IGNORE]
4040
if len(themes) < 1:
41-
print_err('No theme found in "{}"...'.format(THEME_DIR_PATH))
41+
print_err('No theme found in "{}"...'.format(themes_folder))
4242
return 1
4343
args = [rustdoc_bin, '-Z', 'unstable-options', '--theme-checker']
4444
args.extend(themes)

0 commit comments

Comments
 (0)