Skip to content

Commit e79871f

Browse files
committed
book
1 parent 5937fe5 commit e79871f

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build-jacs build-jacsbook test test-jacs audit-jacs test-jacs-cli test-jacs-observability test-jacspy \
1+
.PHONY: build-jacs build-jacsbook build-jacsbook-pdf test test-jacs audit-jacs test-jacs-cli test-jacs-observability test-jacspy \
22
publish-jacs publish-jacspy publish-jacsnpm \
33
release-jacs release-jacspy release-jacsnpm release-all \
44
retry-jacspy retry-jacsnpm \
@@ -38,6 +38,9 @@ build-jacsnpm:
3838
build-jacsbook:
3939
cd jacs/docs/jacsbook && mdbook build
4040

41+
build-jacsbook-pdf:
42+
./jacs/docs/jacsbook/scripts/build-pdf.sh
43+
4144
# ============================================================================
4245
# TEST
4346
# ============================================================================
@@ -236,6 +239,7 @@ help:
236239
@echo " make build-jacspy Build Python bindings (dev mode)"
237240
@echo " make build-jacsnpm Build Node.js bindings"
238241
@echo " make build-jacsbook Generate jacsbook (mdbook build)"
242+
@echo " make build-jacsbook-pdf Generate single PDF book at docs/jacsbook.pdf"
239243
@echo ""
240244
@echo "TEST:"
241245
@echo " make test Run all tests (alias for test-jacs)"

docs/jacsbook.pdf

3.19 MB
Binary file not shown.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
BOOK_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
6+
REPO_ROOT="$(cd "${BOOK_DIR}/../../.." && pwd)"
7+
8+
OUTPUT_PDF="${1:-${REPO_ROOT}/docs/jacsbook.pdf}"
9+
OUTPUT_DIR="$(dirname "${OUTPUT_PDF}")"
10+
PRINT_HTML="${BOOK_DIR}/book/print.html"
11+
12+
if ! command -v mdbook >/dev/null 2>&1; then
13+
echo "error: mdbook is required but not installed" >&2
14+
exit 1
15+
fi
16+
17+
if ! command -v playwright >/dev/null 2>&1; then
18+
echo "error: playwright CLI is required but not installed" >&2
19+
exit 1
20+
fi
21+
22+
mkdir -p "${OUTPUT_DIR}"
23+
24+
(
25+
cd "${BOOK_DIR}"
26+
mdbook build
27+
)
28+
29+
if [[ ! -f "${PRINT_HTML}" ]]; then
30+
echo "error: expected print HTML was not generated at ${PRINT_HTML}" >&2
31+
exit 1
32+
fi
33+
34+
PAPER_FORMAT="${JACSBOOK_PDF_PAPER_FORMAT:-Letter}"
35+
BROWSER="${JACSBOOK_PDF_BROWSER:-chromium}"
36+
37+
playwright pdf \
38+
--browser "${BROWSER}" \
39+
--paper-format "${PAPER_FORMAT}" \
40+
"file://${PRINT_HTML}" \
41+
"${OUTPUT_PDF}"
42+
43+
echo "Generated PDF: ${OUTPUT_PDF}"

0 commit comments

Comments
 (0)