diff --git a/.cargo/config b/.cargo/config index 92a3acfd0b..9f9b24a492 100644 --- a/.cargo/config +++ b/.cargo/config @@ -5,6 +5,8 @@ gen-syntax = "run --package ra_tools --bin ra_tools -- gen-syntax" # Extracts the tests from gen-tests = "run --package ra_tools --bin ra_tools -- gen-tests" +build-website = "run --package website-gen" + # Installs the visual studio code extension install-ra = "run --package ra_tools --bin ra_tools -- install-ra" install-code = "run --package ra_tools --bin ra_tools -- install-ra" # just an alias diff --git a/.travis.yml b/.travis.yml index 52af053753..c198cc5f75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ matrix: language: rust rust: stable script: - - cargo doc --all --no-deps + - cargo build-website env: - RUSTFLAGS="-D warnings", CARGO_INCREMENTAL=0 @@ -59,7 +59,7 @@ deploy: skip-cleanup: true github-token: $DOCS_TOKEN # Set in the settings page of your repository, as a secure variable keep-history: true - local-dir: target/doc + local-dir: target/website/ on: branch: master condition: $DEPLOY_DOCS = 1 diff --git a/Cargo.lock b/Cargo.lock index ffcce476e3..d1fa5ebee6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1776,6 +1776,13 @@ name = "wasi" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "website-gen" +version = "0.0.0" +dependencies = [ + "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "winapi" version = "0.2.8" diff --git a/Cargo.toml b/Cargo.toml index e44c9570fd..317c637958 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = [ "crates/*" ] +members = [ "crates/*", "website/website-gen" ] [profile.release] incremental = true diff --git a/README.md b/README.md index e8f0e953eb..c875dbb543 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0 ## Quick Links * Work List: https://paper.dropbox.com/doc/RLS-2.0-work-list--AZ3BgHKKCtqszbsi3gi6sjchAQ-42vbnxzuKq2lKwW0mkn8Y -* API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide_api/index.html +* API docs: https://rust-analyzer.github.io/rust-analyzer/api-docs/ra_ide_api/index.html * CI: https://travis-ci.org/rust-analyzer/rust-analyzer ## License diff --git a/website/src/index.html b/website/src/index.html new file mode 100644 index 0000000000..0b678b4990 --- /dev/null +++ b/website/src/index.html @@ -0,0 +1,21 @@ + + + + + + Hello World! Site Title + + + +

rust-analyzer

+ + + + diff --git a/website/src/wasm-demo/index.html b/website/src/wasm-demo/index.html new file mode 100644 index 0000000000..e81ccb0f72 --- /dev/null +++ b/website/src/wasm-demo/index.html @@ -0,0 +1,13 @@ + + + + + + Hello World! Site Title + + + + TBD + + + diff --git a/website/website-gen/Cargo.toml b/website/website-gen/Cargo.toml new file mode 100644 index 0000000000..b471a81fd0 --- /dev/null +++ b/website/website-gen/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "website-gen" +version = "0.0.0" +authors = ["Aleksey Kladov "] +edition = "2018" +publish = false + +[dependencies] +walkdir = "2.2.0" diff --git a/website/website-gen/src/main.rs b/website/website-gen/src/main.rs new file mode 100644 index 0000000000..7d35a37cf3 --- /dev/null +++ b/website/website-gen/src/main.rs @@ -0,0 +1,64 @@ +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(()) + } +}