From 9a7c8d4b0ff3b9a7d736bbda68e12a9f3867ec1b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 17 Oct 2019 22:37:01 +0300 Subject: scale website back We have dedicated https://rust-analyzer.github.io/ now --- website/website-gen/src/main.rs | 64 ----------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 website/website-gen/src/main.rs (limited to 'website/website-gen/src/main.rs') diff --git a/website/website-gen/src/main.rs b/website/website-gen/src/main.rs deleted file mode 100644 index 7d35a37cf..000000000 --- a/website/website-gen/src/main.rs +++ /dev/null @@ -1,64 +0,0 @@ -use std::{fs, path::Path, process::Command}; - -type Result = std::result::Result>; - -/// This tool builds the github-pages website to the `./target/website` folder -fn main() { - if let Err(err) = try_main() { - eprintln!("{}", err); - std::process::exit(-1); - } -} - -fn try_main() -> Result<()> { - check_cwd()?; - build_scaffold()?; - build_docs()?; - println!("Finished\n./target/website/index.html"); - Ok(()) -} - -fn cargo() -> Command { - Command::new("cargo") -} - -fn check_cwd() -> Result<()> { - let toml = std::fs::read_to_string("./Cargo.toml")?; - if !toml.contains("[workspace]") { - Err("website-gen should be run from the root of workspace")?; - } - Ok(()) -} - -fn build_docs() -> Result<()> { - let status = cargo().args(&["doc", "--all", "--no-deps"]).status()?; - if !status.success() { - Err("cargo doc failed")?; - } - sync_dir("./target/doc", "./target/website/api-docs")?; - Ok(()) -} - -fn build_scaffold() -> Result<()> { - sync_dir("./website/src", "./target/website") -} - -fn sync_dir(src: impl AsRef, dst: impl AsRef) -> Result<()> { - return sync_dir(src.as_ref(), dst.as_ref()); - - fn sync_dir(src: &Path, dst: &Path) -> Result<()> { - let _ = fs::remove_dir_all(dst); - fs::create_dir_all(dst)?; - for entry in walkdir::WalkDir::new(src) { - let entry = entry?; - let src_path = entry.path(); - let dst_path = dst.join(src_path.strip_prefix(src)?); - if src_path.is_dir() { - fs::create_dir_all(dst_path)?; - } else { - fs::copy(src_path, dst_path)?; - } - } - Ok(()) - } -} -- cgit v1.2.3