#!/usr/bin/env bash # # Extract every mermaid diagram of documentation/architecture.md into a # standalone .mmd file, and render it to PNG and SVG next to it. # # The document is the source: a diagram is picked up when its fenced block is # preceded by a `` comment, which gives it its file name. # # Usage: ./documentation/assets/diagrams/render.sh [name ...] # (no argument renders them all) set -euo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" doc="${here}/../../architecture.md" width="${MERMAID_WIDTH:-2000}" [ -f "$doc" ] || { echo "not found: $doc" >&2; exit 1; } # 1. extract names=$(awk -v dir="$here" ' /^