Skip to content

Commit

Permalink
release 0.2.12 - 0.2.18 testing the docs.rs builder
Browse files Browse the repository at this point in the history
  • Loading branch information
jdonszelmann committed Jun 4, 2024
1 parent f08c53d commit 076215d
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 14 deletions.
4 changes: 2 additions & 2 deletions scopegraphs-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scopegraphs-macros"
version = "0.2.9"
version = "0.2.13"
edition = "2021"
license = "MIT OR Apache-2.0"
authors = [
Expand All @@ -20,7 +20,7 @@ proc-macro = true
[dependencies]
syn = { version = "2.0.29", features = [] }
quote = "1.0.33"
scopegraphs-regular-expressions = { path = "../scopegraphs-regular-expressions", features = ["dot"], version = "0.2.0" }
scopegraphs-regular-expressions = { path = "../scopegraphs-regular-expressions", features = ["dot"], version = "0.2" }
proc-macro2 = "1.0.69"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion scopegraphs-regular-expressions/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scopegraphs-regular-expressions"
version = "0.2.10"
version = "0.2.13"
edition = "2021"
license = "MIT OR Apache-2.0"
authors = [
Expand Down
4 changes: 2 additions & 2 deletions scopegraphs-render-docs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "scopegraphs-render-docs"
version = "0.2.0"
version = "0.2.18"
authors = ["Mike Lubinets <[email protected]>", "Frank Rehberger <[email protected]>", "Jonathan Dönszelmann <[email protected]>"]
description = "Derived from Aquamarine, a mermaid.js integration for rustdoc, renders scopegraphs by executing doctests to generate mermaid"
keywords = ["proc_macro", "docs", "rustdoc", "mermaid", "diagram"]
categories = ["visualization", "development-tools::build-utils"]
repository = "https://github.com/mersinvald/aquamarine"
repository = "https://github.com/metaborg/rust-scopegraphs/"
edition = "2018"
license = "MIT"
include = ["src/**/*", "Cargo.toml", "doc/js/**"]
Expand Down
59 changes: 55 additions & 4 deletions scopegraphs-render-docs/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::hash::{DefaultHasher, Hash, Hasher};
use std::io::{stderr, stdout, Write};
use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
use std::process::{Command, Stdio};
use std::{fs, io};
use syn::{Attribute, Ident, MetaNameValue};

Expand Down Expand Up @@ -297,6 +297,54 @@ fn run_code(code: &str) -> Result<Vec<String>, EvalError> {
);
let target_dir = std::env::var("CARGO_TARGET_DIR").unwrap_or("./target".to_string());

// this if is so it works on docs.rs,
// which sets a custom target and compiles in a folder called "workdir"
let (sg_dir, target_dir) = if manifest_dir.join("..").join("workdir").exists() {
(
manifest_dir
.join("..")
.join("workdir")
.to_string_lossy()
.to_string(),
"/opt/rustwide/target".to_string(),
)
} else {
(
manifest_dir
.join("..")
.join("scopegraphs")
.to_string_lossy()
.to_string(),
target_dir,
)
};

fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
fs::create_dir_all(&dst)?;
for entry in fs::read_dir(src)? {
let entry = entry?;
let ty = entry.file_type()?;
if ty.is_dir() {
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
} else {
fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
}
}
Ok(())
}

let sg_target_dir = temp_dir().join("SG_TARGET");
if sg_target_dir.exists() {
fs::remove_dir_all(&sg_target_dir).map_err(EvalError::RemoveOldOutputDir)?;
}
copy_dir_all(target_dir, &sg_target_dir).expect("copy dir");
if sg_target_dir.join("debug").join(".cargo-lock").exists() {
fs::remove_file(sg_target_dir.join("debug").join(".cargo-lock")).unwrap();
}
if sg_target_dir.join("release").join(".cargo-lock").exists() {
fs::remove_file(sg_target_dir.join("release").join(".cargo-lock")).unwrap();
}

let cargo = PathBuf::from(std::env::var("CARGO").expect("$CARGO is set during compilation"));

let code_hash = hash_str(code).to_string();
Expand All @@ -319,9 +367,9 @@ name = \"render_docs_{code_hash}\"
edition=\"2021\"
[dev-dependencies]
scopegraphs = {{path = \"{}/../scopegraphs\"}}
scopegraphs = {{path = \"{}\"}}
",
manifest_dir.to_string_lossy()
sg_dir
),
)
.map_err(EvalError::WriteProject)?;
Expand All @@ -341,10 +389,13 @@ fn documented() {{}}

let output = Command::new(cargo)
.current_dir(out_dir)
.env("CARGO_TARGET_DIR", target_dir)
.env("CARGO_TARGET_DIR", sg_target_dir)
.arg("test")
.arg("--offline")
.arg("--doc")
.arg("documented")
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.output()
.map_err(EvalError::RunCargo)?;

Expand Down
10 changes: 5 additions & 5 deletions scopegraphs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "scopegraphs"
version = "0.2.7"
version = "0.2.18"
edition = "2021"
license = "MIT OR Apache-2.0"
authors = [
"Aron Zwaan <[email protected]>",
"Jonathan Dönszelmann <J.B.Doenszelmann@tudelft.nl>",
"Jonathan Dönszelmann <jonathan@donsz.nl>",
]
description = "A port of scopegraphs https://pl.ewi.tudelft.nl/research/projects/scope-graphs/ to Rust"
repository = "https://github.com/metaborg/rust-scopegraphs/"
Expand All @@ -20,9 +20,9 @@ bumpalo = "3.14.0"
scopegraphs-prust-lib = { version = "0.1.0" }
log = "0.4.20"

scopegraphs-macros = { path = "../scopegraphs-macros", version = "0.2.0" }
scopegraphs-regular-expressions = { path = "../scopegraphs-regular-expressions", version = "0.2.0" }
scopegraphs-render-docs = { path = "../scopegraphs-render-docs", version = "0.2.0", optional = true }
scopegraphs-macros = { path = "../scopegraphs-macros", version = "0.2" }
scopegraphs-regular-expressions = { path = "../scopegraphs-regular-expressions", version = "0.2" }
scopegraphs-render-docs = { path = "../scopegraphs-render-docs", version = "0.2", optional = true }

[dev-dependencies]
env_logger = "0.10.1"
Expand Down

0 comments on commit 076215d

Please sign in to comment.