diff options
Diffstat (limited to 'bin/build_html')
-rwxr-xr-x | bin/build_html | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/bin/build_html b/bin/build_html index 26fd7d8..67fc067 100755 --- a/bin/build_html +++ b/bin/build_html @@ -18,7 +18,7 @@ cd "${TOPLEVEL}" # and then make changes to that copy. # # When we are done with these changes, we will set some variables: -# - HTML_OUTPUT_DIR is "", or the location where we have put our output. +# - MDBOOK_OUTPUT_DIR is "", or the location where we have put our raw mdbook output. # - MDBOOK_DIR is the parent directory of the possibly modified copies # of mdbook/{spec,proposals}. @@ -32,11 +32,12 @@ if test -n "${MMDC:-}" || command -v "mmdc" >&/dev/null; then # (The conversion involves npm and a headless chrome browser, # to it is understandable that not everybody would want to do it # this way.) + echo "Using mermaid-cli to pre-render mermaid diagrams" TMPDIR=$(mktemp -d "${TOPLEVEL}/tmp_mmdc.XXXXXXXX") trap 'rm -rf "$TMPDIR"' 0 ./bin/mermaid_cvt_svg "$TMPDIR" - HTML_OUTPUT_DIR="$TMPDIR/html" + MDBOOK_OUTPUT_DIR="$TMPDIR/build" MDBOOK_DIR="$TMPDIR/mdbook" elif test -n "${MDBOOK_MERMAID:-}" || command -v "mdbook-mermaid" >&/dev/null; then # CASE 2: mdbook_mermaid is installed. @@ -47,30 +48,43 @@ elif test -n "${MDBOOK_MERMAID:-}" || command -v "mdbook-mermaid" >&/dev/null; t # This is much easier to run locally, but it requires that your # browser has enough client-side javascript in order to run # mermaid. It doesn't touch npm. + echo "Using mdbook-mermaid to set up dynamic rendering of mermaid diagrams" + MDBOOK_MERMAID=${MDBOOK_MERMAID:=mdbook-mermaid} TMPDIR=$(mktemp -d "${TOPLEVEL}/tmp_mdbook_mermaid.XXXXXXXX") trap 'rm -rf "$TMPDIR"' 0 cp -r ./mdbook/proposals ./mdbook/spec ./mdbook/theme "$TMPDIR" mdbook-mermaid install "$TMPDIR/spec" mdbook-mermaid install "$TMPDIR/proposals" - HTML_OUTPUT_DIR="" + MDBOOK_OUTPUT_DIR="" MDBOOK_DIR="$TMPDIR" else # CASE 3: No mermaid support. # # In this case we run mdbook on our inputs unchanged. # The mermaid blocks will render as code. - HTML_OUTPUT_DIR="" + echo "No mermaid support found; mermaid diagrams will be unrendered" + + MDBOOK_OUTPUT_DIR="" MDBOOK_DIR="$TOPLEVEL/mdbook" fi -cd "${MDBOOK_DIR}/spec" -$MDBOOK build +# mdbook-linkcheck is a non-obvious dependency, and the mdbook output when it's +# not found doesn't spell out how to install it. +if ! command -v mdbook-linkcheck; then + echo 'ERROR: mdbook-linkcheck not found. You should probably install it with `cargo install mdbook-linkcheck`' + exit 1 +fi -cd "${MDBOOK_DIR}/proposals" -$MDBOOK build +$MDBOOK build "${MDBOOK_DIR}/spec" +$MDBOOK build "${MDBOOK_DIR}/proposals" -if test -n "${HTML_OUTPUT_DIR}"; then - rm -rf "${TOPLEVEL}/html" - mv "${HTML_OUTPUT_DIR}" "${TOPLEVEL}/html" +if test -n "${MDBOOK_OUTPUT_DIR}"; then + rm -rf "${TOPLEVEL}/build" + mv "${MDBOOK_OUTPUT_DIR}" "${TOPLEVEL}/build" fi + +rm -rf "${TOPLEVEL}/html/" +cp -r "${TOPLEVEL}/build/spec/html/" "${TOPLEVEL}" +cp -r "${TOPLEVEL}/build/proposals/html/" "${TOPLEVEL}/html/proposals/" + |