#!/bin/bash # # Build a flat aggregate of every language's PDF under docs/build/html/pdf/ # (hardlinks, cheap and idempotent) plus an index listing. The PDFs # themselves live in the per-language trees docs/build/html//pdf/; this # flat folder keeps the legacy /pdf/ URL working with all languages side by # side. # set -e # Assume we're running in src/, we can't call `git rev-parse # --show-toplevel` because when building from dsc we don't have a # git repo. TOPLEVEL=${PWD}/.. HTML="${TOPLEVEL}/docs/build/html" DEST="${HTML}/pdf" mkdir -p "${DEST}" # Hardlink every per-language PDF into the flat folder. Names already carry a # _ suffix so there are no collisions. mindepth 3 skips DEST itself # (docs/build/html/pdf/*.pdf is only two levels below html/). find "${HTML}" -mindepth 3 -path '*/pdf/*.pdf' -print0 \ | while IFS= read -r -d '' F; do ln -f "${F}" "${DEST}/$(basename "${F}")" done TITLE="LinuxCNC PDF docs ($(cat "${TOPLEVEL}"/VERSION))" PDF_INDEX="${DEST}/index.html" rm -f "${PDF_INDEX}" { echo "" echo "${TITLE}" echo "

${TITLE}

" for F in $(cd "${DEST}" && find . -maxdepth 1 -name '*.pdf' | sort); do echo " ${F#./}
" done echo "" echo "" } >> "${PDF_INDEX}"