From 652e408cfc028e4a5aa64572ba4daf156022b5df Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 16 Jul 2026 12:33:52 +0200 Subject: [PATCH 1/2] fix(docs): restore version and discovery correctness --- .github/workflows/book.yml | 11 +- CONTRIBUTING.md | 20 +- README.md | 8 +- scripts/check-versions.ts | 30 + scripts/update.sh | 42 +- vocs/docs/pages/examples/advanced/README.mdx | 2 +- .../pages/examples/big-numbers/README.mdx | 2 +- .../docs/pages/examples/comparison/README.mdx | 2 +- vocs/docs/pages/examples/contracts/README.mdx | 2 +- vocs/docs/pages/examples/ens/README.mdx | 2 +- vocs/docs/pages/examples/fillers/README.mdx | 2 +- vocs/docs/pages/examples/layers/README.mdx | 2 +- .../pages/examples/node-bindings/README.mdx | 2 +- .../docs/pages/examples/primitives/README.mdx | 2 +- vocs/docs/pages/examples/providers/README.mdx | 2 +- vocs/docs/pages/examples/queries/README.mdx | 2 +- vocs/docs/pages/examples/sol-macro/README.mdx | 2 +- .../pages/examples/subscriptions/README.mdx | 2 +- .../pages/examples/transactions/README.mdx | 2 +- vocs/docs/pages/examples/wallets/README.mdx | 2 +- .../pages/introduction/getting-started.md | 6 +- vocs/docs/pages/introduction/installation.md | 3 +- vocs/docs/pages/introduction/prompting.md | 1697 +---------------- vocs/docs/snippets/installation/alloy.toml | 1 + .../installation/individual-crates.toml | 4 + .../{pages => }/templates/advanced/README.mdx | 0 .../templates/big-numbers/README.mdx | 0 .../templates/comparison/README.mdx | 0 .../templates/contracts/README.mdx | 0 .../docs/{pages => }/templates/ens/README.mdx | 0 .../{pages => }/templates/fillers/README.mdx | 0 .../{pages => }/templates/layers/README.mdx | 0 .../templates/node-bindings/README.mdx | 0 .../templates/primitives/README.mdx | 0 .../templates/providers/README.mdx | 0 .../{pages => }/templates/queries/README.mdx | 0 .../templates/sol-macro/README.mdx | 0 .../templates/subscriptions/README.mdx | 0 .../templates/transactions/README.mdx | 0 .../{pages => }/templates/wallets/README.mdx | 0 vocs/public/robots.txt | 4 + vocs/versions.ts | 5 + vocs/vocs.config.ts | 11 +- 43 files changed, 165 insertions(+), 1707 deletions(-) create mode 100644 scripts/check-versions.ts create mode 100644 vocs/docs/snippets/installation/alloy.toml create mode 100644 vocs/docs/snippets/installation/individual-crates.toml rename vocs/docs/{pages => }/templates/advanced/README.mdx (100%) rename vocs/docs/{pages => }/templates/big-numbers/README.mdx (100%) rename vocs/docs/{pages => }/templates/comparison/README.mdx (100%) rename vocs/docs/{pages => }/templates/contracts/README.mdx (100%) rename vocs/docs/{pages => }/templates/ens/README.mdx (100%) rename vocs/docs/{pages => }/templates/fillers/README.mdx (100%) rename vocs/docs/{pages => }/templates/layers/README.mdx (100%) rename vocs/docs/{pages => }/templates/node-bindings/README.mdx (100%) rename vocs/docs/{pages => }/templates/primitives/README.mdx (100%) rename vocs/docs/{pages => }/templates/providers/README.mdx (100%) rename vocs/docs/{pages => }/templates/queries/README.mdx (100%) rename vocs/docs/{pages => }/templates/sol-macro/README.mdx (100%) rename vocs/docs/{pages => }/templates/subscriptions/README.mdx (100%) rename vocs/docs/{pages => }/templates/transactions/README.mdx (100%) rename vocs/docs/{pages => }/templates/wallets/README.mdx (100%) create mode 100644 vocs/public/robots.txt create mode 100644 vocs/versions.ts diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml index 63849f9b..f1e7f838 100644 --- a/.github/workflows/book.yml +++ b/.github/workflows/book.yml @@ -19,8 +19,17 @@ jobs: submodules: recursive - uses: oven-sh/setup-bun@v2 + - name: Check documented dependency versions + run: bun scripts/check-versions.ts + - name: Build Vocs - run: cd vocs && bun install && bun run build + run: cd vocs && bun install --frozen-lockfile && bun run build + + - name: Check generated discovery files + run: | + test -f vocs/dist/public/sitemap.xml + test -f vocs/dist/public/robots.txt + test ! -d vocs/dist/public/templates # Only prepare for deploy if a push to main - name: Setup Pages diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 620c9dcd..36ff9951 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,17 +12,15 @@ expert, we can use your help. This guide will help you get started. **Do not let this guide intimidate you**. It should be considered a map to help you navigate the process. -The [dev channel][dev] is available for any concerns not covered in this guide, -please join us! - -[dev]: https://t.me/ethers_rs +For questions not covered here, open a discussion in the +[Alloy repository](https://github.com/alloy-rs/alloy/discussions). ## Conduct The Alloy project adheres to the [Rust Code of Conduct][coc]. This describes the _minimum_ behavior expected from all contributors. Instances of violations of the Code of Conduct can be reported by contacting the project team at -[james@prestwich](mailto:james@prestwi.ch). +[james@prestwi.ch](mailto:james@prestwi.ch). [coc]: https://www.rust-lang.org/policies/code-of-conduct @@ -98,7 +96,7 @@ specification. This section lists some commonly needed commands. -First create a [fork](https://github.com/alloy-rs/book/fork). +First create a [fork](https://github.com/alloy-rs/docs/fork). Next clone your fork with the `--recurse-submodules` flag: @@ -106,7 +104,12 @@ Next clone your fork with the `--recurse-submodules` flag: git clone --recurse-submodules $FORK_URL ``` -The documentation is built with [`vocs`](https://vocs.dev), you can install `vocs` by using any javascript package manager such as `bun` or `npm`. We prefer `bun`. +The documentation is built with [`vocs`](https://vocs.dev). Install the pinned +dependencies with Bun: + +```sh +cd vocs && bun install --frozen-lockfile +``` To see the book change live run: @@ -116,7 +119,8 @@ cd vocs && bun dev To perform an update of generated output inspect and run `./scripts/update.sh`. -To add a new section (file) to the book, add it to `./src/SUMMARY.md`. +To add a new page, create it under `./vocs/docs/pages` and add it to +`./vocs/sidebar.ts` when it should appear in the primary navigation. ### Discuss and update diff --git a/README.md b/README.md index 038ab63d..833016c7 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,6 @@ Documentation for all things Alloy. -[![Telegram chat][telegram-badge]][telegram-url] - -[`alloy-rs`]: https://github.com/gakonst/ethers-rs -[telegram-badge]: https://img.shields.io/endpoint?color=neon&style=for-the-badge&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fethers_rs -[telegram-url]: https://t.me/ethers_rs - View the docs [here](https://alloy.rs/). ## Contributing @@ -16,7 +10,7 @@ Thanks for your help improving the project! We are so happy to have you! We have [a contributing guide](./CONTRIBUTING.md) to help you get involved in the Alloy project. -#### License +## License Licensed under either of Apache License, Version diff --git a/scripts/check-versions.ts b/scripts/check-versions.ts new file mode 100644 index 00000000..e8764846 --- /dev/null +++ b/scripts/check-versions.ts @@ -0,0 +1,30 @@ +import { versions } from '../vocs/versions' + +const generatedSnippets = new Map([ + [ + new URL('../vocs/docs/snippets/installation/alloy.toml', import.meta.url), + `alloy = "${versions.alloy}"\n`, + ], + [ + new URL('../vocs/docs/snippets/installation/individual-crates.toml', import.meta.url), + [ + '[dependencies]', + `alloy-primitives = { version = "${versions.alloyCore}", default-features = false, features = ["rand", "serde", "map-foldhash"] }`, + `alloy-provider = { version = "${versions.alloy}", default-features = false, features = ["ipc"] }`, + '# ..snip..', + '', + ].join('\n'), + ], +]) + +let valid = true + +for (const [url, expected] of generatedSnippets) { + const actual = await Bun.file(url).text() + if (actual !== expected) { + valid = false + console.error(`${url.pathname} is stale; expected documentation versions from vocs/versions.ts`) + } +} + +if (!valid) process.exit(1) diff --git a/scripts/update.sh b/scripts/update.sh index 16f4a861..5193e3fe 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -20,7 +20,7 @@ SNIPPETS_PATH="./vocs/docs/snippets" # MDX Snippets path MDX_SNIPPETS_PATH="./vocs/docs/pages/examples" # Templates path -MDX_TEMPLATES_PATH="./vocs/docs/pages/templates" +MDX_TEMPLATES_PATH="./vocs/docs/templates" # Sidebar items TS file SIDEBAR_ITEMS_PATH="./vocs/example-items.ts" @@ -32,7 +32,7 @@ SIDEBAR_ITEMS_PATH="./vocs/example-items.ts" # the example code and instructions on how to run the example. # 3. Print any differences between the current and updated example files list. function main () { - log $GREEN "Updating..." + log "$GREEN" "Updating..." # Change directory to project root SCRIPT_PATH="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )" @@ -45,16 +45,16 @@ function main () { git submodule foreach git pull origin main # Create the $SNIPPETS_PATH directory if it doesn't exist - mkdir -p $SNIPPETS_PATH + mkdir -p "$SNIPPETS_PATH" # Create the $MDX_SNIPPETS_PATH directory if it doesn't exist - mkdir -p $MDX_SNIPPETS_PATH + mkdir -p "$MDX_SNIPPETS_PATH" # Copy the directory and files from `lib/examples/examples` to $SNIPPETS_PATH echo "Copying examples to $SNIPPETS_PATH" - cp -r ./lib/examples/examples/* $SNIPPETS_PATH/ + cp -r ./lib/examples/examples/* "$SNIPPETS_PATH/" - log $GREEN "Copied examples to $SNIPPETS_PATH" + log "$GREEN" "Copied examples to $SNIPPETS_PATH" # Get the commit hash of the latest commit in the examples repository EXAMPLES_COMMIT_HASH=$(git -C ./lib/examples rev-parse HEAD) @@ -64,30 +64,30 @@ function main () { # Clean up existing examples echo "Cleaning up existing examples" - rm -rf $MDX_SNIPPETS_PATH/* + rm -rf "${MDX_SNIPPETS_PATH:?}/"* # Create the $MDX_SNIPPETS_PATH directory if it doesn't exist - mkdir -p $MDX_SNIPPETS_PATH + mkdir -p "$MDX_SNIPPETS_PATH" # Create example markdown files for CODE_DIRPATH in ./lib/examples/examples/*/; do # Get the example category directory name - EXAMPLE_DIRNAME=$(basename $CODE_DIRPATH) + EXAMPLE_DIRNAME=$(basename "$CODE_DIRPATH") # Populate the $MDX_SNIPPETS_PATH directory with the example category directory - mkdir -p $MDX_SNIPPETS_PATH/$EXAMPLE_DIRNAME + mkdir -p "$MDX_SNIPPETS_PATH/$EXAMPLE_DIRNAME" # Populate the $MDX_TEMPLATES_PATH directory with the example category directory if it doesn't exist - mkdir -p $MDX_TEMPLATES_PATH/$EXAMPLE_DIRNAME - touch $MDX_TEMPLATES_PATH/$EXAMPLE_DIRNAME/README.mdx - cp $MDX_TEMPLATES_PATH/$EXAMPLE_DIRNAME/README.mdx $MDX_SNIPPETS_PATH/$EXAMPLE_DIRNAME/README.mdx + mkdir -p "$MDX_TEMPLATES_PATH/$EXAMPLE_DIRNAME" + touch "$MDX_TEMPLATES_PATH/$EXAMPLE_DIRNAME/README.mdx" + cp "$MDX_TEMPLATES_PATH/$EXAMPLE_DIRNAME/README.mdx" "$MDX_SNIPPETS_PATH/$EXAMPLE_DIRNAME/README.mdx" # For every example file in the examples directory # - Create a markdown file in the $MDX_SNIPPETS_PATH directory # - Insert the example code by reference in the markdown file # - Include the template content by pointer if it exists - for EXAMPLE_FILEPATH in $CODE_DIRPATH/examples/*.rs; do - EXAMPLE_FILENAME=$(basename $EXAMPLE_FILEPATH .rs) + for EXAMPLE_FILEPATH in "$CODE_DIRPATH"examples/*.rs; do + EXAMPLE_FILENAME=$(basename "$EXAMPLE_FILEPATH" .rs) MDX_TEMPLATE_FILEPATH="$MDX_TEMPLATES_PATH/$EXAMPLE_DIRNAME/README.mdx" EXAMPLE_README_MDX=$MDX_SNIPPETS_PATH/$EXAMPLE_DIRNAME/README.mdx MDX_SNIPPET=$MDX_SNIPPETS_PATH/$EXAMPLE_DIRNAME/$EXAMPLE_FILENAME.mdx @@ -95,9 +95,9 @@ function main () { # Include the template content pointer if the template exists TEMPLATE_CONTENT=$( - [ -f $MDX_TEMPLATE_FILEPATH ] && \ + [ -f "$MDX_TEMPLATE_FILEPATH" ] && \ printf "%s\n\n%s\n" \ - "import Template from '../../templates/$EXAMPLE_DIRNAME/README.mdx'" \ + "import Template from '../../../templates/$EXAMPLE_DIRNAME/README.mdx'" \ "