From 5b1a78782aa561ca2268ffc2b59eb0b0f031733e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Thu, 23 Jul 2026 05:48:43 +0400 Subject: [PATCH] docs: add one-command README HTML/PDF export --- .gitignore | 4 +++ README.adoc | 42 ++++++++++++++++++++-- docs/docinfo.html | 58 +++++++++++++++++++++++++++++++ docs/generate-readme-pdf.sh | 69 +++++++++++++++++++++++++++++++++++++ 4 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 docs/docinfo.html create mode 100755 docs/generate-readme-pdf.sh diff --git a/.gitignore b/.gitignore index 5552979..0d9b960 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,10 @@ temp/ # Fichiers de cache cache/ +# Artefacts de documentation générés (docs/generate-readme-pdf.sh) +README.html +README.pdf + # Dossier pour les images d'annonces (tout ignorer sauf .gitkeep) uploads/* !uploads/.gitkeep diff --git a/README.adoc b/README.adoc index e3ec9de..ff2dbc9 100644 --- a/README.adoc +++ b/README.adoc @@ -161,7 +161,9 @@ Toutes ces sources sont modifiables dans `includes/config.local.php` (voir < + diff --git a/docs/generate-readme-pdf.sh b/docs/generate-readme-pdf.sh new file mode 100755 index 0000000..0149476 --- /dev/null +++ b/docs/generate-readme-pdf.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# Generate the documentation export(s) from README.adoc. +# +# docs/generate-readme-pdf.sh # README.html + README.pdf +# docs/generate-readme-pdf.sh --html # README.html only +# docs/generate-readme-pdf.sh --pdf # README.pdf only +# +# Both outputs land in the project root and are Git-ignored. +# +# Requirements: +# - asciidoctor (e.g. gem install asciidoctor) +# - chromium (headless PDF rendering) +# - fonts-noto-color-emoji (color emoji in the PDF) +# +# Why Chromium instead of asciidoctor-pdf (used by the VSCodium extension)? +# Its Prawn engine cannot embed color-emoji fonts (CBDT/COLR), so emoji +# disappear. Chromium handles them fine as long as "Noto Color Emoji" +# is installed. The docs/docinfo.html stylesheet (emoji fallback + print +# rules) is injected only for this build, via Asciidoctor's docinfo +# mechanism, and adapts the layout for print (TOC in flow, table/page +# breaks, wrapped code listings). + +set -euo pipefail + +cd "$(dirname "$0")/.." + +MODE="${1:---all}" +HTML_OUT="README.html" +PDF_OUT="README.pdf" + +build_html() { + asciidoctor -b html5 -a docinfodir=docs -a docinfo=shared README.adoc -o "$1" + echo "HTML generated: $1" +} + +build_pdf() { + # Resolve to an absolute path for the file:// URL + local html_path="$1" + [[ "$html_path" != /* ]] && html_path="$PWD/$html_path" + chromium --headless --disable-gpu --no-sandbox \ + --no-pdf-header-footer \ + --print-to-pdf="$PDF_OUT" \ + "file://$html_path" + echo "PDF generated: $PDF_OUT" +} + +case "$MODE" in + --html) + build_html "$HTML_OUT" + ;; + --pdf) + TMP_HTML="$(mktemp --suffix=.html)" + trap 'rm -f "$TMP_HTML"' EXIT + build_html "$TMP_HTML" >/dev/null + build_pdf "$TMP_HTML" + ;; + --all) + build_html "$HTML_OUT" + build_pdf "$HTML_OUT" + ;; + -h|--help) + sed -n '2,10p' "$0" + exit 0 + ;; + *) + echo "Usage: $0 [--html|--pdf|--all]" >&2 + exit 1 + ;; +esac