From 72722037eed69e1a05d204c62ed9629f5b571b85 Mon Sep 17 00:00:00 2001 From: Jim Newsome Date: Thu, 9 Nov 2023 18:23:30 -0600 Subject: Reorganize output Adding an additional output plugin to mdbook causes it to create an extra level of subdirectories in its build directory; one for each output plugin. We add an intermediate build directory `build`, and after building the individual mdbooks, construct the `html` directory with the desired layout. --- .gitignore | 5 ++++- bin/build_html | 26 ++++++++++++++------------ mdbook/proposals/book.toml | 2 +- mdbook/spec/book.toml | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 2f9bd0f..905198f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,10 @@ # OS X folder cruft .DS_Store -# mdbook outputs +# mdbook build dir +/build + +# generated html (reorganized from the build dir) /html # bin/check_links output diff --git a/bin/build_html b/bin/build_html index 26fd7d8..0a3d7f6 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}. @@ -36,7 +36,7 @@ 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" - 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. @@ -53,24 +53,26 @@ elif test -n "${MDBOOK_MERMAID:-}" || command -v "mdbook-mermaid" >&/dev/null; t 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="" + MDBOOK_OUTPUT_DIR="" MDBOOK_DIR="$TOPLEVEL/mdbook" fi -cd "${MDBOOK_DIR}/spec" -$MDBOOK build +$MDBOOK build "${MDBOOK_DIR}/spec" +$MDBOOK build "${MDBOOK_DIR}/proposals" -cd "${MDBOOK_DIR}/proposals" -$MDBOOK build - -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/" + diff --git a/mdbook/proposals/book.toml b/mdbook/proposals/book.toml index 8a6045b..e466b1b 100644 --- a/mdbook/proposals/book.toml +++ b/mdbook/proposals/book.toml @@ -7,7 +7,7 @@ title = "Tor design proposals" use-default-preprocessors = false [build] -build-dir = "../../html/proposals" +build-dir = "../../build/proposals" [preprocessor.links] diff --git a/mdbook/spec/book.toml b/mdbook/spec/book.toml index 58dc503..16668c9 100644 --- a/mdbook/spec/book.toml +++ b/mdbook/spec/book.toml @@ -6,7 +6,7 @@ src = "../../spec" title = "Tor Specifications" [build] -build-dir = "../../html" +build-dir = "../../build/spec" [preprocessor] -- cgit v1.2.3-54-g00ecf