feat: accept any .adoc file in PDF generation script
This commit is contained in:
+2
-2
@@ -26,8 +26,8 @@ temp/
|
||||
cache/
|
||||
|
||||
# Artefacts de documentation générés (docs/generate-readme-pdf.sh)
|
||||
README.html
|
||||
README.pdf
|
||||
/*.html
|
||||
/*.pdf
|
||||
|
||||
# Dossier pour les images d'annonces (tout ignorer sauf .gitkeep)
|
||||
uploads/*
|
||||
|
||||
+8
-4
@@ -892,16 +892,18 @@ Bonnes pratiques du dépôt :
|
||||
|
||||
==== 📄 Exporter la documentation (HTML / PDF)
|
||||
|
||||
Ce README peut être exporté en HTML et en PDF en une seule commande :
|
||||
Ce README peut être exporté en HTML et en PDF en une seule commande (tout fichier `.adoc` peut être passé en argument) :
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
docs/generate-readme-pdf.sh # README.html + README.pdf
|
||||
docs/generate-readme-pdf.sh --html # HTML seulement
|
||||
docs/generate-readme-pdf.sh --pdf # PDF seulement
|
||||
docs/generate-readme-pdf.sh DEPLOY.adoc # DEPLOY.html + DEPLOY.pdf
|
||||
docs/generate-readme-pdf.sh DEPLOY.adoc --pdf # DEPLOY.pdf seulement
|
||||
----
|
||||
|
||||
Les fichiers sont produits à la racine du projet et ignorés par Git (`.gitignore`).
|
||||
Les fichiers sont produits à la racine du projet (nommés d'après la source) et ignorés par Git (`.gitignore`).
|
||||
|
||||
Prérequis : `asciidoctor`, `chromium` (rendu headless) et le paquet `fonts-noto-color-emoji` (émojis couleur dans le PDF). La feuille de style `docs/docinfo.html` (fallback emoji + règles d'impression) est injectée automatiquement via le mécanisme `docinfo` d'Asciidoctor.
|
||||
|
||||
@@ -1820,16 +1822,18 @@ Repository best practices:
|
||||
|
||||
==== 📄 Exporting the documentation (HTML / PDF)
|
||||
|
||||
This README can be exported to HTML and PDF with a single command:
|
||||
This README can be exported to HTML and PDF with a single command (any `.adoc` file can be passed as argument):
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
docs/generate-readme-pdf.sh # README.html + README.pdf
|
||||
docs/generate-readme-pdf.sh --html # HTML only
|
||||
docs/generate-readme-pdf.sh --pdf # PDF only
|
||||
docs/generate-readme-pdf.sh DEPLOY.adoc # DEPLOY.html + DEPLOY.pdf
|
||||
docs/generate-readme-pdf.sh DEPLOY.adoc --pdf # DEPLOY.pdf only
|
||||
----
|
||||
|
||||
Files are produced in the project root and are Git-ignored (`.gitignore`).
|
||||
Files are produced in the project root (named after the source) and are Git-ignored (`.gitignore`).
|
||||
|
||||
Requirements: `asciidoctor`, `chromium` (headless rendering) and the `fonts-noto-color-emoji` package (color emoji in the PDF). The `docs/docinfo.html` stylesheet (emoji fallback + print rules) is automatically injected through Asciidoctor's `docinfo` mechanism.
|
||||
|
||||
|
||||
+36
-15
@@ -1,11 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# Generate the documentation export(s) from README.adoc.
|
||||
# Generate the HTML/PDF export(s) from any .adoc document (README.adoc by default).
|
||||
#
|
||||
# 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
|
||||
# docs/generate-readme-pdf.sh DEPLOY.adoc # DEPLOY.html + DEPLOY.pdf
|
||||
# docs/generate-readme-pdf.sh DEPLOY.adoc --pdf # DEPLOY.pdf only
|
||||
#
|
||||
# Both outputs land in the project root and are Git-ignored.
|
||||
# Outputs land in the project root (named after the source) and are Git-ignored.
|
||||
#
|
||||
# Requirements:
|
||||
# - asciidoctor (e.g. gem install asciidoctor)
|
||||
@@ -22,14 +24,41 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
cd "$(dirname "$0")/.." || exit 1
|
||||
|
||||
MODE="${1:---all}"
|
||||
HTML_OUT="README.html"
|
||||
PDF_OUT="README.pdf"
|
||||
SRC="README.adoc"
|
||||
MODE="--all"
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--html|--pdf|--all)
|
||||
MODE="$arg"
|
||||
;;
|
||||
-h|--help)
|
||||
sed -n '2,12p' "$0"
|
||||
exit 0
|
||||
;;
|
||||
*.adoc)
|
||||
SRC="$arg"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [fichier.adoc] [--html|--pdf|--all]" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ! -f "$SRC" ]]; then
|
||||
echo "Erreur : fichier introuvable : $SRC" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASE="$(basename "$SRC" .adoc)"
|
||||
HTML_OUT="$BASE.html"
|
||||
PDF_OUT="$BASE.pdf"
|
||||
|
||||
build_html() {
|
||||
asciidoctor -b html5 -a docinfodir=docs -a docinfo=shared README.adoc -o "$1"
|
||||
asciidoctor -b html5 -a docinfodir=docs -a docinfo=shared "$SRC" -o "$1"
|
||||
echo "HTML generated: $1"
|
||||
}
|
||||
|
||||
@@ -58,12 +87,4 @@ case "$MODE" in
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user