use std::{fs, path::Path};
fn main() {
let readme_path = Path::new("README.md");
let out_dir = std::env::var("OUT_DIR").unwrap();
let out_readme = Path::new(&out_dir).join("README.docs.md");
let contents = fs::read_to_string(readme_path).expect("Failed to read README.md");
let patched = contents
.replace("```rust", "```ignore")
.replace(
"src=\"images/composition.svg\"",
"src=\"https://raw.githubusercontent.com/bosun-ai/swiftide/master/images/composition.svg\"",
)
.replace(
"[CONTRIBUTING.md](CONTRIBUTING.md)",
"[CONTRIBUTING.md](https://github.com/bosun-ai/swiftide/blob/master/CONTRIBUTING.md)",
)
.replace(
"[AGENTS.md](AGENTS.md)",
"[AGENTS.md](https://github.com/bosun-ai/swiftide/blob/master/AGENTS.md)",
)
.replace(
"[LICENSE](LICENSE)",
"[LICENSE](https://github.com/bosun-ai/swiftide/blob/master/LICENSE)",
);
fs::write(&out_readme, patched).expect("Failed to write patched README");
println!("cargo:rerun-if-changed=README.md");
println!("cargo:rustc-env=DOC_README={}", out_readme.display());
}