Skip to content

Commit f029325

Browse files
committed
Fix windows test
Signed-off-by: Moritz Hoffmann <[email protected]>
1 parent d8198df commit f029325

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

mdbook/build.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ fn find_mds(dir: impl AsRef<Path>, mds: &mut Vec<PathBuf>) -> io::Result<()> {
2323

2424
fn main() -> io::Result<()> {
2525
let mut mds = Vec::new();
26-
find_mds("src/", &mut mds)?;
26+
find_mds("src", &mut mds)?;
2727

2828
let mut lib = String::new();
2929

3030
for md in mds {
3131
let md_path = md.to_str().unwrap();
3232
println!("cargo::rerun-if-changed={md_path}");
33-
let mod_name = md_path
34-
.strip_prefix("src/")
35-
.and_then(|s| s.strip_suffix(".md"))
36-
.map(|s| s.replace(['/', '-'], "_"))
37-
.unwrap();
33+
let mod_name = md_path.replace(['/', '\\', '-', '.'], "_");
3834
use std::fmt::Write;
39-
writeln!(&mut lib, "#[allow(non_snake_case)] #[doc = include_str!(concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/{md_path}\"))] mod {mod_name} {{}}").unwrap();
35+
writeln!(
36+
&mut lib,
37+
"#[allow(non_snake_case)] #[doc = include_str!(concat!(env!(\"CARGO_MANIFEST_DIR\"), r\"{}{md_path}\"))] mod {mod_name} {{}}",
38+
std::path::MAIN_SEPARATOR,
39+
).unwrap();
4040
}
4141

4242
let dest_path = Path::new(&env::var("OUT_DIR").unwrap()).join("mdbook.rs");

0 commit comments

Comments
 (0)