-
Notifications
You must be signed in to change notification settings - Fork 7
/
sphinx_rebuild_all.sh
executable file
·69 lines (51 loc) · 2.79 KB
/
sphinx_rebuild_all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Compiles the HTML and ePUB documentation and converts
# ePUB to PDF and MOBI. Takes a list of language codes as a parameter. The results are stored in the folder ``deploy``.
# Needs Calibre command line tools.
set -e
BUILD=../build-littlenavmap-manual
DEPLOY="../deploy/Little Navmap Manual"
# Create HTML documentation
rm -rfv ${BUILD}/html
./sphinx_rebuild.sh html $@
# Create ePUB file
rm -rfv ${BUILD}/epub
./sphinx_rebuild.sh epub $@
# Run for all given language codes ==============
for LANGNAME in "$@" ; do
# Clean target folder for each given language
rm -rfv "${DEPLOY}/${LANGNAME}" "${DEPLOY}/littlenavmap_book_${LANGNAME}.mobi" "${DEPLOY}/littlenavmap_book_${LANGNAME}.epub" "${DEPLOY}/littlenavmap_book_${LANGNAME}.pdf" "Little Navmap Manual ${LANGNAME}.zip"
# Copy generated HTML documentation
mkdir -pv "${DEPLOY}"
cp -av "${BUILD}/html/${LANGNAME}" "${DEPLOY}/${LANGNAME}"
# Strip unneeded files off
rm -rfv "${DEPLOY}/${LANGNAME}/.doctrees" "${DEPLOY}/${LANGNAME}/.buildinfo"
cat << EOL > "${DEPLOY}/README.txt"
This is the Little Navmap Manual in HTML format.
Open the file ${LANGNAME}/index.html in your web browser to see the Little Navmap Manual.
EOL
(
cd "${DEPLOY}"
zip -r -9 "Little Navmap Manual HTML ${LANGNAME}.zip" ${LANGNAME} README.txt
)
# Add cover to ePUB file and copy to deploy
echo
echo =====================================================================================
echo Running ebook-convert for ePub ======================================================
ebook-convert "${BUILD}/epub/${LANGNAME}/LittleNavmap.epub" "${DEPLOY}/littlenavmap_book_${LANGNAME}.epub" --cover src/images/cover.png --preserve-cover-aspect-ratio
# Create MOBI file
echo
echo =====================================================================================
echo Running ebook-convert for MOBI ======================================================
ebook-convert "${DEPLOY}/littlenavmap_book_${LANGNAME}.epub" "${DEPLOY}/littlenavmap_book_${LANGNAME}.mobi"
# Create A4 PDF
echo
echo =====================================================================================
echo Running ebook-convert for A4 PDF ====================================================
ebook-convert "${DEPLOY}/littlenavmap_book_${LANGNAME}.epub" "${DEPLOY}/littlenavmap_book_${LANGNAME}_a4.pdf" --preserve-cover-aspect-ratio --paper-size a4 --base-font-size 6
# Create US Letter PDF
echo
echo =====================================================================================
echo Running ebook-convert for US Letter PDF =============================================
ebook-convert "${DEPLOY}/littlenavmap_book_${LANGNAME}.epub" "${DEPLOY}/littlenavmap_book_${LANGNAME}_letter.pdf" --preserve-cover-aspect-ratio --paper-size letter --base-font-size 6
done