Files
nym/documentation/scripts/verify-doc-versions.sh
mfahampshire a70e68c7bd Max/smolmix docs (#6716)
* Smolmix documentation

* Add smolmix docs: landing page, tutorials, and developer page links

* Add Exit Gateway services page (NR vs IPR) and link from existing docs

* Update auto-generated command and API outputs

* Reorg of tutorials and architecture pages

* License information + remove TODO from docs.rs visibile comment + reorg
readme

* Add versions file for doc-wide versioning

* Relative -> absolute links

* Relative -> absolute links

* Update license + add old tutorial code as examples

* Streamline smolmix docs

* Clippy

* Clean up doc comments

* Last pass

* Add larger file download to list

* set new versions

* Clippy

* Remove blake pin from docs + add version range to root Cargo.toml

* Format example logging

* Remove crate blocked component

* Loose whitespace

* Add doc verification script for inline mdx

* Formatting

* Components regen

* Reorg + tighten text

* Voicing cohesion pass + remove bloated examples

* Voicing cont.

* Reduce max download size

* Small suggested clarifications

* Max/docs voicing consistency (#6769)

* Reduce max download size

* voicing consistency across docs

* New landing order w smolmix

* Tweaks

* Final tweaks
2026-05-13 11:19:44 +00:00

63 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Verify that hardcoded crate versions in MDX fenced code blocks
# match the canonical constants in components/versions.ts.
#
# Usage: ./scripts/verify-doc-versions.sh
# Returns: 0 if all versions match, 1 if any mismatch is found.
set -euo pipefail
DOCS_DIR="$(cd "$(dirname "$0")/../docs" && pwd)"
VERSIONS_FILE="$DOCS_DIR/components/versions.ts"
# Extract canonical versions from versions.ts
sdk_version=$(sed -n 's/.*NYM_SDK_VERSION *= *"\([^"]*\)".*/\1/p' "$VERSIONS_FILE")
smolmix_version=$(sed -n 's/.*SMOLMIX_VERSION *= *"\([^"]*\)".*/\1/p' "$VERSIONS_FILE")
echo "Canonical versions:"
echo " NYM_SDK_VERSION = $sdk_version"
echo " SMOLMIX_VERSION = $smolmix_version"
echo ""
errors=0
# Check a grep match against an expected version.
# Args: file:linenum:content expected_version
check_line() {
local match="$1"
local expected="$2"
local file="${match%%:*}"
local rest="${match#*:}"
local linenum="${rest%%:*}"
local content="${rest#*:}"
local found
found=$(echo "$content" | sed -n 's/.*"\([0-9]\+\.[0-9]\+\.[0-9]\+\)".*/\1/p')
if [ -n "$found" ] && [ "$found" != "$expected" ]; then
echo "MISMATCH: $file:$linenum"
echo " found: $found"
echo " expected: $expected"
echo " line: $content"
echo ""
errors=$((errors + 1))
fi
}
# Crates that should track NYM_SDK_VERSION
while IFS= read -r match; do
check_line "$match" "$sdk_version"
done < <(grep -rn --include='*.mdx' -E '(nym-sdk|nym-bin-common|nym-network-defaults)\s*=' "$DOCS_DIR/pages")
# smolmix version
while IFS= read -r match; do
check_line "$match" "$smolmix_version"
done < <(grep -rn --include='*.mdx' -E 'smolmix\s*=' "$DOCS_DIR/pages")
if [ "$errors" -gt 0 ]; then
echo "FAILED: $errors version mismatch(es) found."
echo "Update the hardcoded versions or bump components/versions.ts."
exit 1
else
echo "OK: all hardcoded versions match."
fi