From 3c7d646b7b380bae48d617c796891427ba8d1add Mon Sep 17 00:00:00 2001 From: Moritz Hoffmann Date: Fri, 20 Feb 2026 20:17:14 +0100 Subject: [PATCH] Test mdbook like a crate Changes the tests for the mdbook from the mdbook tool to cargo test, which is simpler for local development. Mirrors the pattern used by Timely. Signed-off-by: Moritz Hoffmann --- .github/workflows/test.yml | 16 --------- Cargo.toml | 6 +++- differential-dataflow/Cargo.toml | 2 +- dogsdogsdogs/Cargo.toml | 2 +- doop/Cargo.toml | 2 +- experiments/Cargo.toml | 2 +- interactive/Cargo.toml | 2 +- mdbook/Cargo.toml | 9 +++++ mdbook/build.rs | 46 ++++++++++++++++++++++++ mdbook/src/lib.rs | 2 ++ server/Cargo.toml | 2 +- server/dataflows/degr_dist/Cargo.toml | 2 +- server/dataflows/neighborhood/Cargo.toml | 2 +- server/dataflows/random_graph/Cargo.toml | 2 +- server/dataflows/reachability/Cargo.toml | 2 +- 15 files changed, 72 insertions(+), 27 deletions(-) create mode 100644 mdbook/Cargo.toml create mode 100644 mdbook/build.rs create mode 100644 mdbook/src/lib.rs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 28e69bd60..936f5a1cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,19 +27,3 @@ jobs: run: cargo test --workspace --all-targets - name: Cargo doc test run: cargo test --doc - - # Check formatting with rustfmt - mdbook: - name: test mdBook - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - # rustdoc doesn't build dependencies, so it needs to run after `cargo build`, - # but its dependency search gets confused if there are multiple copies of any - # dependency in target/debug/deps, so it needs to run before `cargo test` et al. - # clutter target/debug/deps with multiple copies of things. - - run: cargo clean - - run: cargo build - - name: test mdBook - run: for file in $(find mdbook -name '*.md' | sort); do rustdoc --test $file -L ./target/debug/deps; done diff --git a/Cargo.toml b/Cargo.toml index f7ec724d8..60fe1ebe7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,14 @@ members = [ "server/dataflows/random_graph", "server/dataflows/reachability", #"tpchlike", - "doop" + "doop", + "mdbook", ] resolver = "2" +[workspace.package] +edition = "2021" + [workspace.dependencies] differential-dataflow = { path = "differential-dataflow", default-features = false, version = "0.19.1" } timely = { version = "0.26", default-features = false } diff --git a/differential-dataflow/Cargo.toml b/differential-dataflow/Cargo.toml index 31622ee0c..a421d96ee 100644 --- a/differential-dataflow/Cargo.toml +++ b/differential-dataflow/Cargo.toml @@ -13,7 +13,7 @@ repository = "https://github.com/TimelyDataflow/differential-dataflow.git" keywords = ["differential", "dataflow"] license = "MIT" readme = "../README.md" -edition="2021" +edition.workspace = true [dev-dependencies] rand="0.4" diff --git a/dogsdogsdogs/Cargo.toml b/dogsdogsdogs/Cargo.toml index ed1930358..fa40e9adf 100644 --- a/dogsdogsdogs/Cargo.toml +++ b/dogsdogsdogs/Cargo.toml @@ -3,7 +3,7 @@ name = "differential-dogs3" version = "0.19.1" authors = ["Frank McSherry "] license = "MIT" -edition = "2021" +edition.workspace = true description = "Advanced join patterns in differential dataflow" documentation = "https://docs.rs/differential-dogs3" diff --git a/doop/Cargo.toml b/doop/Cargo.toml index b8146a75b..e195b7014 100644 --- a/doop/Cargo.toml +++ b/doop/Cargo.toml @@ -2,7 +2,7 @@ name = "doop" version = "0.1.0" authors = ["Frank McSherry "] -edition = "2021" +edition.workspace = true publish = false [dependencies] diff --git a/experiments/Cargo.toml b/experiments/Cargo.toml index 15176d51a..1f1811dc8 100644 --- a/experiments/Cargo.toml +++ b/experiments/Cargo.toml @@ -2,7 +2,7 @@ name = "experiments" version = "0.1.0" authors = ["Frank McSherry "] -edition = "2021" +edition.workspace = true publish = false [dependencies] diff --git a/interactive/Cargo.toml b/interactive/Cargo.toml index 16e6f2efa..8b6a3bd5a 100644 --- a/interactive/Cargo.toml +++ b/interactive/Cargo.toml @@ -2,7 +2,7 @@ name = "interactive" version = "0.1.0" authors = ["Frank McSherry "] -edition = "2021" +edition.workspace = true publish = false [dependencies] diff --git a/mdbook/Cargo.toml b/mdbook/Cargo.toml new file mode 100644 index 000000000..d04f41fc6 --- /dev/null +++ b/mdbook/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "mdbook" +version = "0.0.0" +edition.workspace = true +publish = false + +[dependencies] +differential-dataflow = { path = "../differential-dataflow" } +timely.workspace = true diff --git a/mdbook/build.rs b/mdbook/build.rs new file mode 100644 index 000000000..260c1d2b3 --- /dev/null +++ b/mdbook/build.rs @@ -0,0 +1,46 @@ +//! Infrastructure to test the mdbook documentation. +//! +//! Generates a module for each Markdown file in the `src/` directory, and includes +//! the contents of each file as a doc comment for that module. + +use std::env; +use std::fs; +use std::io; +use std::path::{Path, PathBuf}; + +/// Recursively finds all Markdown files in the given path and collects their paths into `mds`. +fn find_mds(dir: impl AsRef, mds: &mut Vec) -> io::Result<()> { + for entry in fs::read_dir(dir)? { + let path = entry?.path(); + if path.is_dir() { + find_mds(path, mds)?; + } else if path.extension().and_then(|s| s.to_str()) == Some("md") { + mds.push(path); + } + } + Ok(()) +} + +fn main() -> io::Result<()> { + let mut mds = Vec::new(); + find_mds("src", &mut mds)?; + + let mut lib = String::new(); + + for md in mds { + let md_path = md.to_str().unwrap(); + println!("cargo::rerun-if-changed={md_path}"); + let mod_name = md_path.replace(['/', '\\', '-', '.'], "_"); + use std::fmt::Write; + writeln!( + &mut lib, + "#[allow(non_snake_case)] #[doc = include_str!(concat!(env!(\"CARGO_MANIFEST_DIR\"), r\"{}{md_path}\"))] mod {mod_name} {{}}", + std::path::MAIN_SEPARATOR, + ).unwrap(); + } + + let dest_path = Path::new(&env::var("OUT_DIR").unwrap()).join("mdbook.rs"); + fs::write(&dest_path, lib)?; + println!("cargo::rerun-if-changed=build.rs"); + Ok(()) +} diff --git a/mdbook/src/lib.rs b/mdbook/src/lib.rs new file mode 100644 index 000000000..c8ed5d8a8 --- /dev/null +++ b/mdbook/src/lib.rs @@ -0,0 +1,2 @@ +//! Dummy library file to allow testing the mdbook documentation. +include!(concat!(env!("OUT_DIR"), "/mdbook.rs")); diff --git a/server/Cargo.toml b/server/Cargo.toml index 21015d42c..c9e9ade3e 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -2,7 +2,7 @@ name = "dd_server" version = "0.1.0" authors = ["Frank McSherry "] -edition = "2021" +edition.workspace = true publish = false [dependencies] diff --git a/server/dataflows/degr_dist/Cargo.toml b/server/dataflows/degr_dist/Cargo.toml index eab5ac9c8..e9dd8d9e1 100644 --- a/server/dataflows/degr_dist/Cargo.toml +++ b/server/dataflows/degr_dist/Cargo.toml @@ -2,7 +2,7 @@ name = "degr_dist" version = "0.1.0" authors = ["Frank McSherry "] -edition = "2021" +edition.workspace = true publish = false [dependencies] diff --git a/server/dataflows/neighborhood/Cargo.toml b/server/dataflows/neighborhood/Cargo.toml index 6e4c431b1..3d850278c 100644 --- a/server/dataflows/neighborhood/Cargo.toml +++ b/server/dataflows/neighborhood/Cargo.toml @@ -2,7 +2,7 @@ name = "neighborhood" version = "0.1.0" authors = ["Frank McSherry "] -edition = "2021" +edition.workspace = true publish = false [dependencies] diff --git a/server/dataflows/random_graph/Cargo.toml b/server/dataflows/random_graph/Cargo.toml index 0e419fd87..c6053c3d1 100644 --- a/server/dataflows/random_graph/Cargo.toml +++ b/server/dataflows/random_graph/Cargo.toml @@ -2,7 +2,7 @@ name = "random_graph" version = "0.1.0" authors = ["Frank McSherry "] -edition = "2021" +edition.workspace = true publish = false [dependencies] diff --git a/server/dataflows/reachability/Cargo.toml b/server/dataflows/reachability/Cargo.toml index 8c5026c90..d97567389 100644 --- a/server/dataflows/reachability/Cargo.toml +++ b/server/dataflows/reachability/Cargo.toml @@ -2,7 +2,7 @@ name = "reachability" version = "0.1.0" authors = ["Frank McSherry "] -edition = "2021" +edition.workspace = true publish = false [dependencies]