|
| 1 | +#!/bin/sh |
| 2 | +# Assemble the combined documentation site into _book |
| 3 | +# - Copies API docs (pdoc), coverage, test report, and marimushka exports |
| 4 | +# - Generates a links.json consumed by minibook |
| 5 | +# |
| 6 | +# This script mirrors the logic previously embedded in the Makefile `book` target |
| 7 | +# for maintainability and testability. It is POSIX-sh compatible. |
| 8 | + |
| 9 | +set -e |
| 10 | + |
| 11 | +BLUE="\033[36m" |
| 12 | +YELLOW="\033[33m" |
| 13 | +RESET="\033[0m" |
| 14 | + |
| 15 | +printf "%b[INFO] Building combined documentation...%b\n" "$BLUE" "$RESET" |
| 16 | +printf "%b[INFO] Assembling book...%b\n" "$BLUE" "$RESET" |
| 17 | + |
| 18 | +printf "%b[INFO] Delete the _book folder...%b\n" "$BLUE" "$RESET" |
| 19 | +rm -rf _book |
| 20 | +printf "%b[INFO] Create empty _book folder...%b\n" "$BLUE" "$RESET" |
| 21 | +mkdir -p _book |
| 22 | + |
| 23 | +# Start building links.json content without jq |
| 24 | +LINKS_ENTRIES="" |
| 25 | + |
| 26 | +#printf "%b[INFO] Copy API docs...%b\n" "$BLUE" "$RESET" |
| 27 | +#if [ -f _pdoc/index.html ]; then |
| 28 | +# mkdir -p _book/pdoc |
| 29 | +# cp -r _pdoc/* _book/pdoc |
| 30 | +# LINKS_ENTRIES='"API": "./pdoc/index.html"' |
| 31 | +#fi |
| 32 | + |
| 33 | +printf "%b[INFO] Copy coverage report...%b\n" "$BLUE" "$RESET" |
| 34 | +if [ -f _tests/html-coverage/index.html ]; then |
| 35 | + mkdir -p _book/tests/html-coverage |
| 36 | + cp -r _tests/html-coverage/* _book/tests/html-coverage |
| 37 | + #if [ -n "$LINKS_ENTRIES" ]; then |
| 38 | + # LINKS_ENTRIES="$LINKS_ENTRIES, \"Coverage\": \"./tests/html-coverage/index.html\"" |
| 39 | + #else |
| 40 | + LINKS_ENTRIES='"Coverage": "./tests/html-coverage/index.html"' |
| 41 | + #fi |
| 42 | +else |
| 43 | + printf "%b[WARN] No coverage report found or directory is empty%b\n" "$YELLOW" "$RESET" |
| 44 | +fi |
| 45 | + |
| 46 | +printf "%b[INFO] Copy test report...%b\n" "$BLUE" "$RESET" |
| 47 | +if [ -f _tests/html-report/report.html ]; then |
| 48 | + mkdir -p _book/tests/html-report |
| 49 | + cp -r _tests/html-report/* _book/tests/html-report |
| 50 | + if [ -n "$LINKS_ENTRIES" ]; then |
| 51 | + LINKS_ENTRIES="$LINKS_ENTRIES, \"Test Report\": \"./tests/html-report/report.html\"" |
| 52 | + else |
| 53 | + LINKS_ENTRIES='"Test Report": "./tests/html-report/report.html"' |
| 54 | + fi |
| 55 | +else |
| 56 | + printf "%b[WARN] No test report found or directory is empty%b\n" "$YELLOW" "$RESET" |
| 57 | +fi |
| 58 | + |
| 59 | +#printf "%b[INFO] Copy notebooks...%b\n" "$BLUE" "$RESET" |
| 60 | +#if [ -f _marimushka/index.html ]; then |
| 61 | +# mkdir -p _book/marimushka |
| 62 | +# cp -r _marimushka/* _book/marimushka |
| 63 | +# if [ -n "$LINKS_ENTRIES" ]; then |
| 64 | +# LINKS_ENTRIES="$LINKS_ENTRIES, \"Notebooks\": \"./marimushka/index.html\"" |
| 65 | +# else |
| 66 | +# LINKS_ENTRIES='"Notebooks": "./marimushka/index.html"' |
| 67 | +# fi |
| 68 | +# printf "%b[INFO] Copied notebooks into _book/marimushka%b\n" "$BLUE" "$RESET" |
| 69 | +#else |
| 70 | +# printf "%b[WARN] No notebooks found or directory is empty%b\n" "$YELLOW" "$RESET" |
| 71 | +#fi |
| 72 | + |
| 73 | +# Write final links.json |
| 74 | +if [ -n "$LINKS_ENTRIES" ]; then |
| 75 | + printf '{%s}\n' "$LINKS_ENTRIES" > _book/links.json |
| 76 | +else |
| 77 | + printf '{}\n' > _book/links.json |
| 78 | +fi |
| 79 | + |
| 80 | +printf "%b[INFO] Generated links.json:%b\n" "$BLUE" "$RESET" |
| 81 | +cat _book/links.json |
0 commit comments