aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/build_html22
-rwxr-xr-xbin/mermaid_cvt_svg15
-rw-r--r--mdbook/spec/book.toml2
3 files changed, 25 insertions, 14 deletions
diff --git a/bin/build_html b/bin/build_html
index 533e17c..04b1f5e 100755
--- a/bin/build_html
+++ b/bin/build_html
@@ -10,12 +10,22 @@ cd "${TOPLEVEL}"
./bin/make_redirects
-./bin/mermaid_cvt_svg
-
-trap 'rm -rf ${TOPLEVEL}/tmp_mermaid' 0
-
-cd "${TOPLEVEL}/mdbook/spec"
+if test -n "${MMDC:-}" || command -v "mmdc" >&/dev/null; then
+ TMPDIR=$(mktemp -d "${TOPLEVEL}/tmp_mmdc.XXXXXXXX")
+ trap 'rm -rf "$TMPDIR"' 0
+ ./bin/mermaid_cvt_svg "$TMPDIR"
+ BUILD_ROOT="$TMPDIR"
+else
+ BUILD_ROOT="$TOPLEVEL"
+fi
+
+cd "${BUILD_ROOT}/mdbook/spec"
$MDBOOK build
-cd "${TOPLEVEL}/mdbook/proposals"
+cd "${BUILD_ROOT}/mdbook/proposals"
$MDBOOK build
+
+if test "${BUILD_ROOT}" != "${TOPLEVEL}"; then
+ rm -rf "${TOPLEVEL}/html"
+ mv "${BUILD_ROOT}/html" "${TOPLEVEL}/html"
+fi
diff --git a/bin/mermaid_cvt_svg b/bin/mermaid_cvt_svg
index 11aa596..3198a00 100755
--- a/bin/mermaid_cvt_svg
+++ b/bin/mermaid_cvt_svg
@@ -3,22 +3,23 @@
set -e -u -o pipefail -x
TOPLEVEL=$(realpath $(dirname "$0"))/..
+TMPDIR="$1"
: ${MMDC:=mmdc}
-# We can't use mktemp here, since we need the actual
-# path in build.html
-TMPDIR="${TOPLEVEL}/tmp_mermaid/"
-rm -rf "$TMPDIR"
-mkdir -p "${TOPLEVEL}/tmp_mermaid/"
+cd "$TOPLEVEL"
# We make a mirror of the specs, since we will need to make changes to them.
-cp -rl spec ./tmp_mermaid/spec
+cp -rl spec proposals mdbook "$TMPDIR"
+
# We use mermaid-cli to extract the mermaid from any file containing it,
# and generate a new version that uses svg instead.
-for fname in $(find ./tmp_mermaid -name "*.md") ; do
+for fname in $(find "$TMPDIR" -name "*.md") ; do
if grep '^```mermaid' $fname; then
ORIG="${fname%.md}.__orig.md"
mv $fname $ORIG
$MMDC -i $ORIG -o $fname
fi
done
+
+
+
diff --git a/mdbook/spec/book.toml b/mdbook/spec/book.toml
index 5aee5dc..b85e320 100644
--- a/mdbook/spec/book.toml
+++ b/mdbook/spec/book.toml
@@ -2,7 +2,7 @@
authors = ["The Tor Project"]
language = "en"
multilingual = false
-src = "../../tmp_mermaid/spec"
+src = "../../spec"
title = "Tor Specifications"
[build]