mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
start GitHub pages
This commit is contained in:
parent
fdb2874e3e
commit
798dc2ca80
9 changed files with 120 additions and 4 deletions
|
@ -5,6 +5,8 @@ gen-syntax = "run --package ra_tools --bin ra_tools -- gen-syntax"
|
||||||
# Extracts the tests from
|
# Extracts the tests from
|
||||||
gen-tests = "run --package ra_tools --bin ra_tools -- gen-tests"
|
gen-tests = "run --package ra_tools --bin ra_tools -- gen-tests"
|
||||||
|
|
||||||
|
build-website = "run --package website-gen"
|
||||||
|
|
||||||
# Installs the visual studio code extension
|
# Installs the visual studio code extension
|
||||||
install-ra = "run --package ra_tools --bin ra_tools -- install-ra"
|
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
|
install-code = "run --package ra_tools --bin ra_tools -- install-ra" # just an alias
|
||||||
|
|
|
@ -28,7 +28,7 @@ matrix:
|
||||||
language: rust
|
language: rust
|
||||||
rust: stable
|
rust: stable
|
||||||
script:
|
script:
|
||||||
- cargo doc --all --no-deps
|
- cargo build-website
|
||||||
env:
|
env:
|
||||||
- RUSTFLAGS="-D warnings", CARGO_INCREMENTAL=0
|
- RUSTFLAGS="-D warnings", CARGO_INCREMENTAL=0
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ deploy:
|
||||||
skip-cleanup: true
|
skip-cleanup: true
|
||||||
github-token: $DOCS_TOKEN # Set in the settings page of your repository, as a secure variable
|
github-token: $DOCS_TOKEN # Set in the settings page of your repository, as a secure variable
|
||||||
keep-history: true
|
keep-history: true
|
||||||
local-dir: target/doc
|
local-dir: target/website/
|
||||||
on:
|
on:
|
||||||
branch: master
|
branch: master
|
||||||
condition: $DEPLOY_DOCS = 1
|
condition: $DEPLOY_DOCS = 1
|
||||||
|
|
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -1776,6 +1776,13 @@ name = "wasi"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
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]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.2.8"
|
version = "0.2.8"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [ "crates/*" ]
|
members = [ "crates/*", "website/website-gen" ]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
incremental = true
|
incremental = true
|
||||||
|
|
|
@ -55,7 +55,7 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0
|
||||||
## Quick Links
|
## Quick Links
|
||||||
|
|
||||||
* Work List: https://paper.dropbox.com/doc/RLS-2.0-work-list--AZ3BgHKKCtqszbsi3gi6sjchAQ-42vbnxzuKq2lKwW0mkn8Y
|
* 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
|
* CI: https://travis-ci.org/rust-analyzer/rust-analyzer
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
21
website/src/index.html
Normal file
21
website/src/index.html
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Hello World! Site Title</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>rust-analyzer</h1>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="./api-docs/ra_ide_api/index.html">API Docs</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="./wasm-demo/index.html">WASM Demo</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
13
website/src/wasm-demo/index.html
Normal file
13
website/src/wasm-demo/index.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Hello World! Site Title</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
TBD
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
9
website/website-gen/Cargo.toml
Normal file
9
website/website-gen/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "website-gen"
|
||||||
|
version = "0.0.0"
|
||||||
|
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
walkdir = "2.2.0"
|
64
website/website-gen/src/main.rs
Normal file
64
website/website-gen/src/main.rs
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
use std::{fs, path::Path, process::Command};
|
||||||
|
|
||||||
|
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||||
|
|
||||||
|
/// 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<Path>, dst: impl AsRef<Path>) -> 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(())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue