diff options
author | Valentin Gagarin <valentin.gagarin@tweag.io> | 2023-03-30 13:54:30 +0200 |
---|---|---|
committer | Valentin Gagarin <valentin.gagarin@tweag.io> | 2023-03-30 13:55:44 +0200 |
commit | cde78f94174333cbd940ace7adb73de2fd88e548 (patch) | |
tree | 7a6dc22d892864fd3d3ca81548aa3a7a2a8645d6 /doc | |
parent | 36b059748d06e39fb3e588463bbc4ddcd2255f27 (diff) |
process includes first
otherwise the order of found `.md` files will influence if `@docroot@`
is replaced before them being included, which may mess up relative
links.
the weirdest thing about it is that the mess-up happens
deterministically on macOS, but deterministically doesn't happen on
Linux!
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual/local.mk | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/doc/manual/local.mk b/doc/manual/local.mk index a38046701..df941d460 100644 --- a/doc/manual/local.mk +++ b/doc/manual/local.mk @@ -37,9 +37,9 @@ nix-eval = $(dummy-env) $(bindir)/nix eval --experimental-features nix-command - define process-includes while read -r line; do \ set -euo pipefail; \ - filename="$$(dirname $(2))/$$(sed 's/{{#include \(.*\)}}/\1/'<<< $$line)"; \ - matchline="$$(sed 's|/|\\/|g' <<< $$line)"; \ + filename="$$(dirname $(1))/$$(sed 's/{{#include \(.*\)}}/\1/'<<< $$line)"; \ test -f "$$filename" || ( echo "#include-d file '$$filename' does not exist." >&2; exit 1; ); \ + matchline="$$(sed 's|/|\\/|g' <<< $$line)"; \ sed -i "/$$matchline/r $$filename" $(2); \ sed -i "s/$$matchline//" $(2); \ done < <(grep '{{#include' $(1)) @@ -151,6 +151,8 @@ $(docdir)/manual/index.html: $(MANUAL_SRCS) $(d)/book.toml $(d)/anchors.jq $(d)/ cp -r doc/manual "$$tmp"; \ find "$$tmp" -name '*.md' | while read -r file; do \ $(call process-includes,$$file,$$file); \ + done; \ + find "$$tmp" -name '*.md' | while read -r file; do \ docroot="$$(realpath --relative-to="$$(dirname "$$file")" $$tmp/manual/src)"; \ sed -i "s,@docroot@,$$docroot,g" "$$file"; \ done; \ |