diff options
author | Aleksey Kladov <[email protected]> | 2019-10-17 20:37:01 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-10-17 20:37:01 +0100 |
commit | 9a7c8d4b0ff3b9a7d736bbda68e12a9f3867ec1b (patch) | |
tree | 030cdccce151f42e6b560142cd52f059e20bebd8 /website/website-gen | |
parent | 6df2bcd7ca97261b59ca04a85b7355432a63c0d9 (diff) |
scale website back
We have dedicated https://rust-analyzer.github.io/ now
Diffstat (limited to 'website/website-gen')
-rw-r--r-- | website/website-gen/Cargo.toml | 9 | ||||
-rw-r--r-- | website/website-gen/src/main.rs | 64 |
2 files changed, 0 insertions, 73 deletions
diff --git a/website/website-gen/Cargo.toml b/website/website-gen/Cargo.toml deleted file mode 100644 index b471a81fd..000000000 --- a/website/website-gen/Cargo.toml +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | [package] | ||
2 | name = "website-gen" | ||
3 | version = "0.0.0" | ||
4 | authors = ["Aleksey Kladov <[email protected]>"] | ||
5 | edition = "2018" | ||
6 | publish = false | ||
7 | |||
8 | [dependencies] | ||
9 | walkdir = "2.2.0" | ||
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 @@ | |||
1 | use std::{fs, path::Path, process::Command}; | ||
2 | |||
3 | type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; | ||
4 | |||
5 | /// This tool builds the github-pages website to the `./target/website` folder | ||
6 | fn main() { | ||
7 | if let Err(err) = try_main() { | ||
8 | eprintln!("{}", err); | ||
9 | std::process::exit(-1); | ||
10 | } | ||
11 | } | ||
12 | |||
13 | fn try_main() -> Result<()> { | ||
14 | check_cwd()?; | ||
15 | build_scaffold()?; | ||
16 | build_docs()?; | ||
17 | println!("Finished\n./target/website/index.html"); | ||
18 | Ok(()) | ||
19 | } | ||
20 | |||
21 | fn cargo() -> Command { | ||
22 | Command::new("cargo") | ||
23 | } | ||
24 | |||
25 | fn check_cwd() -> Result<()> { | ||
26 | let toml = std::fs::read_to_string("./Cargo.toml")?; | ||
27 | if !toml.contains("[workspace]") { | ||
28 | Err("website-gen should be run from the root of workspace")?; | ||
29 | } | ||
30 | Ok(()) | ||
31 | } | ||
32 | |||
33 | fn build_docs() -> Result<()> { | ||
34 | let status = cargo().args(&["doc", "--all", "--no-deps"]).status()?; | ||
35 | if !status.success() { | ||
36 | Err("cargo doc failed")?; | ||
37 | } | ||
38 | sync_dir("./target/doc", "./target/website/api-docs")?; | ||
39 | Ok(()) | ||
40 | } | ||
41 | |||
42 | fn build_scaffold() -> Result<()> { | ||
43 | sync_dir("./website/src", "./target/website") | ||
44 | } | ||
45 | |||
46 | fn sync_dir(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()> { | ||
47 | return sync_dir(src.as_ref(), dst.as_ref()); | ||
48 | |||
49 | fn sync_dir(src: &Path, dst: &Path) -> Result<()> { | ||
50 | let _ = fs::remove_dir_all(dst); | ||
51 | fs::create_dir_all(dst)?; | ||
52 | for entry in walkdir::WalkDir::new(src) { | ||
53 | let entry = entry?; | ||
54 | let src_path = entry.path(); | ||
55 | let dst_path = dst.join(src_path.strip_prefix(src)?); | ||
56 | if src_path.is_dir() { | ||
57 | fs::create_dir_all(dst_path)?; | ||
58 | } else { | ||
59 | fs::copy(src_path, dst_path)?; | ||
60 | } | ||
61 | } | ||
62 | Ok(()) | ||
63 | } | ||
64 | } | ||