Skip to content

Commit

Permalink
Pass themes folder as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Feb 8, 2018
1 parent 51580d4 commit b1b11d4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ impl Step for RustdocTheme {
fn run(self, builder: &Builder) {
let rustdoc = builder.rustdoc(self.compiler.host);
let mut cmd = Command::new(builder.config.python.clone().expect("python not defined"));
cmd.args(&["src/tools/rustdoc-themes/test-themes.py", rustdoc.to_str().unwrap()]);
cmd.args(&[builder.src.join("src/tools/rustdoc-themes/test-themes.py").to_str().unwrap(),
rustdoc.to_str().unwrap(),
builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap()]);
cmd.env("RUSTC_STAGE", self.compiler.stage.to_string())
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
.env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
Expand Down
10 changes: 5 additions & 5 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ pub fn main_args(args: &[String]) -> isize {
print!(" - Checking \"{}\"...", theme_file);
let (success, differences) = theme::test_theme_against(theme_file, &paths);
if !differences.is_empty() || !success {
eprintln!(" FAILED");
println!(" FAILED");
errors += 1;
if !differences.is_empty() {
eprintln!("{}", differences.join("\n"));
println!("{}", differences.join("\n"));
}
} else {
println!(" OK");
Expand Down Expand Up @@ -407,13 +407,13 @@ pub fn main_args(args: &[String]) -> isize {
.iter()
.map(|s| (PathBuf::from(&s), s.to_owned())) {
if !theme_file.is_file() {
eprintln!("rustdoc: option --themes arguments must all be files");
println!("rustdoc: option --themes arguments must all be files");
return 1;
}
let (success, ret) = theme::test_theme_against(&theme_file, &paths);
if !success || !ret.is_empty() {
eprintln!("rustdoc: invalid theme: \"{}\"", theme_s);
eprintln!(" Check what's wrong with the \"theme-checker\" option");
println!("rustdoc: invalid theme: \"{}\"", theme_s);
println!(" Check what's wrong with the \"theme-checker\" option");
return 1;
}
themes.push(theme_file);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ c // sdf
d {}
"#;
let paths = load_css_paths(text.as_bytes());
assert!(paths.children.get(&CssPath::new("a b c d".to_owned())).is_some());
assert!(paths.children.contains(&CssPath::new("a b c d".to_owned())));
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions src/tools/rustdoc-themes/test-themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import sys

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


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


def main(argv):
if len(argv) < 1:
if len(argv) < 2:
print_err("Needs rustdoc binary path")
return 1
rustdoc_bin = argv[0]
themes = [join(THEME_DIR_PATH, f) for f in listdir(THEME_DIR_PATH)
if isfile(join(THEME_DIR_PATH, f)) and f not in FILES_TO_IGNORE]
themes_folder = argv[1]
themes = [join(themes_folder, f) for f in listdir(themes_folder)
if isfile(join(themes_folder, f)) and f not in FILES_TO_IGNORE]
if len(themes) < 1:
print_err('No theme found in "{}"...'.format(THEME_DIR_PATH))
print_err('No theme found in "{}"...'.format(themes_folder))
return 1
args = [rustdoc_bin, '-Z', 'unstable-options', '--theme-checker']
args.extend(themes)
Expand Down

0 comments on commit b1b11d4

Please sign in to comment.