From b4db13e4eb154b839e011a0ffabcd2c8da1cf425 Mon Sep 17 00:00:00 2001 From: Matthew Ryall Date: Wed, 1 Nov 2023 16:08:16 +0000 Subject: [PATCH] PI-1515: Script to generate D2 diagrams (#2425) * PI-1515: Script to generate D2 diagrams --- script/generate-diagrams | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 script/generate-diagrams diff --git a/script/generate-diagrams b/script/generate-diagrams new file mode 100755 index 0000000000..c1b7c6bc03 --- /dev/null +++ b/script/generate-diagrams @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +PROJECT=$1 + +# Run from the base directory +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") + +# Create SVGs for all d2 diagrams in the project +while IFS= read -r -d '' d2_file; do + diagram=$(basename "$d2_file") + svg=${diagram%.d2}.svg + d2 -t 8 --layout elk --pad 25 \ + "$SCRIPTPATH/../projects/${PROJECT}/tech-docs/diag/$diagram" \ + "$SCRIPTPATH/../projects/${PROJECT}/tech-docs/source/img/$svg" +done < <( + find "$SCRIPTPATH/../projects/${PROJECT}/tech-docs/diag/" -iname "*.d2" -print0 +)