From 10408da57eaed6d404a2a717f05ed34b4ffa0e40 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Sun, 31 May 2026 13:09:33 -0700 Subject: [PATCH 1/2] Port bindings-doctests.sh into CI --- crates/bindings/bindings-doctests.sh | 15 --------------- crates/bindings/src/lib.rs | 10 +++++----- crates/bindings/src/rng.rs | 5 ++--- crates/bindings/src/table.rs | 6 +++--- tools/ci/src/main.rs | 6 ++++++ 5 files changed, 16 insertions(+), 26 deletions(-) delete mode 100644 crates/bindings/bindings-doctests.sh diff --git a/crates/bindings/bindings-doctests.sh b/crates/bindings/bindings-doctests.sh deleted file mode 100644 index 73f539ed1c9..00000000000 --- a/crates/bindings/bindings-doctests.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/env bash - -# Script to run doctests. -# Note: if you get `cannot find type thing__TableHandle in this scope`, that -# means you forgot to properly wrap your doctest. -# See the top comment of README.md. - -set -exo pipefail - -# Test doctests -rustup run nightly cargo test --doc --target wasm32-unknown-unknown -Zdoctest-xcompile -# Make sure they also work outside wasm (use the proper boilerplate) -cargo test --doc -# And look for broken links -RUSTDOCFLAGS="-D warnings" cargo doc \ No newline at end of file diff --git a/crates/bindings/src/lib.rs b/crates/bindings/src/lib.rs index abc972748dd..e2695498d13 100644 --- a/crates/bindings/src/lib.rs +++ b/crates/bindings/src/lib.rs @@ -365,9 +365,9 @@ pub use spacetimedb_bindings_macro::settings; /// // The following line would panic, since we use `insert` rather than `try_insert`. /// // let result = ctx.db.country().insert(Country { code: "CN".into(), national_bird: "Blue Magpie".into() }); /// -/// // If we wanted to *update* the row for Australia, we can use the `update` method of `UniqueIndex`. -/// // The following line will succeed: -/// ctx.db.country().code().update(Country { +/// // If we wanted to replace the row for Australia, we can delete it and insert the new row. +/// assert!(ctx.db.country().code().delete("AU".to_string())); +/// ctx.db.country().insert(Country { /// code: "AU".into(), national_bird: "Australian Emu".into() /// }); /// } @@ -1118,7 +1118,7 @@ impl ReducerContext { /// #[reducer] /// fn generate_uuid_v4(ctx: &ReducerContext) -> Result<(), Box> { /// let uuid = ctx.new_uuid_v4()?; - /// log::info!(uuid); + /// log::info!("{uuid}"); /// Ok(()) /// } /// # } @@ -1140,7 +1140,7 @@ impl ReducerContext { /// #[reducer] /// fn generate_uuid_v7(ctx: &ReducerContext) -> Result<(), Box> { /// let uuid = ctx.new_uuid_v7()?; - /// log::info!(uuid); + /// log::info!("{uuid}"); /// Ok(()) /// } /// # } diff --git a/crates/bindings/src/rng.rs b/crates/bindings/src/rng.rs index d9ed0bf65d7..61596cd317a 100644 --- a/crates/bindings/src/rng.rs +++ b/crates/bindings/src/rng.rs @@ -30,8 +30,7 @@ impl ReducerContext { /// /// ```no_run /// # #[cfg(target_arch = "wasm32")] mod demo { - /// use spacetimedb::{reducer, ReducerContext}; - /// use rand::Rng; + /// use spacetimedb::{rand::Rng, reducer, ReducerContext}; /// /// #[spacetimedb::reducer] /// fn rng_demo(ctx: &spacetimedb::ReducerContext) { @@ -40,7 +39,7 @@ impl ReducerContext { /// /// // Or, cache locally for reuse: /// let mut rng = ctx.rng(); - /// let floats: Vec = rng.sample_iter(rand::distributions::Standard).collect(); + /// let floats: Vec = rng.sample_iter(spacetimedb::rand::distributions::Standard).collect(); /// } /// # } /// ``` diff --git a/crates/bindings/src/table.rs b/crates/bindings/src/table.rs index 5ec636cc731..ec18f601509 100644 --- a/crates/bindings/src/table.rs +++ b/crates/bindings/src/table.rs @@ -516,7 +516,7 @@ pub trait IndexIsPointed: Index {} /// /// ```no_run /// # #[cfg(target_arch = "wasm32")] mod demo { -/// use spacetimedb::{table, PointIndex, ReducerContext, DbContext}; +/// use spacetimedb::{table, DbContext, PointIndex, ReducerContext}; /// /// #[table(accessor = user, /// index(accessor = dogs_and_name, hash(columns = [dogs, name])))] @@ -537,7 +537,7 @@ pub trait IndexIsPointed: Index {} /// /// ```no_run /// # #[cfg(target_arch = "wasm32")] mod demo { -/// use spacetimedb::{table, PointIndex, ReducerContext, DbContext}; +/// use spacetimedb::{table, DbContext, RangedIndex, ReducerContext}; /// /// #[table(accessor = user)] /// struct User { @@ -548,7 +548,7 @@ pub trait IndexIsPointed: Index {} /// } /// /// fn demo(ctx: &ReducerContext) { -/// let by_dogs: PointIndex<_, (u64,), _> = ctx.db().user().dogs(); +/// let by_dogs: RangedIndex<_, (u64,), _> = ctx.db().user().dogs(); /// } /// # } /// ``` diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index 3ba1b433ba3..e5b240edca0 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -616,6 +616,12 @@ fn main() -> Result<()> { .dir("crates/bindings-csharp") .run()?; cmd!("pnpm", "lint").run()?; + cmd!("cargo", "test", "--doc", "--target", "wasm32-unknown-unknown") + .dir("crates/bindings") + .run()?; + cmd!("cargo", "test", "--doc") + .dir("crates/bindings") + .run()?; // `bindings` is the only crate we care strongly about documenting, // since we link to its docs.rs from our website. // We won't pass `--no-deps`, though, From fccc26028d98bb97b521c8a8f8bf7c84eb82074c Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Sun, 31 May 2026 13:14:54 -0700 Subject: [PATCH 2/2] lint --- tools/ci/src/main.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index e5b240edca0..eb27190cbb0 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -619,9 +619,7 @@ fn main() -> Result<()> { cmd!("cargo", "test", "--doc", "--target", "wasm32-unknown-unknown") .dir("crates/bindings") .run()?; - cmd!("cargo", "test", "--doc") - .dir("crates/bindings") - .run()?; + cmd!("cargo", "test", "--doc").dir("crates/bindings").run()?; // `bindings` is the only crate we care strongly about documenting, // since we link to its docs.rs from our website. // We won't pass `--no-deps`, though,