Separate out and simplify build logic for print/web PDFs

This commit is contained in:
RunasSudo 2021-02-22 00:48:55 +11:00
parent 84c546ba33
commit d074eb5a39
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
5 changed files with 38 additions and 19 deletions

View File

@ -8,6 +8,8 @@ SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
LATEX_PRE = \\\\newif\\\\ifpolulu\\\\newif\\\\ifpoweb
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@ -19,6 +21,16 @@ help:
%: Makefile
@PYTHONPATH=. TEX_MAX_REPEAT=3 $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
latexpdf: latexpdf-lulu latexpdf-web
latexpdf-lulu:
@PYTHONPATH=. TEX_JOBNAME=PointsOfOrder_Lulu $(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@cd _build/latex; TEX_MAX_REPEAT=3 LATEXMKOPTS="-usepretex=$(LATEX_PRE)\\\\polulutrue -r latexmkrc -lualatex" make PointsOfOrder_Lulu.pdf
latexpdf-web:
@PYTHONPATH=. TEX_JOBNAME=PointsOfOrder_Web $(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@cd _build/latex; TEX_MAX_REPEAT=3 LATEXMKOPTS="-usepretex=$(LATEX_PRE)\\\\powebtrue -r latexmkrc -lualatex" make PointsOfOrder_Web.pdf
livehtml:
@PYTHONPATH=. sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)/html" $(SPHINXOPTS) -d _build/doctrees $(O)
@ -27,6 +39,6 @@ mobi:
upload:
cp -r _build/html/* '/home/runassudo/Documents/Work/School Cloud Data/unenc/public/www/pointsoforder'
sha256sum _build/latex/PointsOfOrder_Print.pdf | awk '{print substr($$1,0,6);}' > _build/latex/PointsOfOrder_Print.pdf.sha256
rm '/home/runassudo/Documents/Work/School Cloud Data/unenc_transient/Lulu/PointsOfOrder_Print'*.pdf
cp _build/latex/PointsOfOrder_Print.pdf '/home/runassudo/Documents/Work/School Cloud Data/unenc_transient/Lulu/PointsOfOrder_Print_'$$(sha256sum _build/latex/PointsOfOrder_Print.pdf | awk '{print substr($$1,0,6);}')'.pdf'
sha256sum _build/latex/PointsOfOrder_Lulu.pdf | awk '{print substr($$1,0,6);}' > _build/latex/PointsOfOrder_Lulu.pdf.sha256
rm '/home/runassudo/Documents/Work/School Cloud Data/unenc_transient/Lulu/PointsOfOrder_Lulu'*.pdf
cp _build/latex/PointsOfOrder_Lulu.pdf '/home/runassudo/Documents/Work/School Cloud Data/unenc_transient/Lulu/PointsOfOrder_Lulu_'$$(sha256sum _build/latex/PointsOfOrder_Lulu.pdf | awk '{print substr($$1,0,6);}')'.pdf'

12
conf.py
View File

@ -10,7 +10,7 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
@ -79,20 +79,16 @@ latex_engine = 'lualatex'
latex_elements = {
'passoptionstopackages': r'\input{pass-options.tex.txt}',
'preamble': r'\input{preamble.tex.txt}',
#'geometry': r'\usepackage[paperwidth=6in,paperheight=9in,margin=0.5in,bottom=0.75in,inner=0.75in]{geometry}',
#'geometry': r'\usepackage[paperwidth=5.5in,paperheight=9in,margin=0.5in,bottom=0.75in,inner=0.5in]{geometry}',
'sphinxsetup': r'AtStartFootnote={},OuterLinkColor={rgb}{0.208,0.374,0.486}',
'papersize': 'a4paper',
'pointsize': '11pt',
'releasename': 'Edition',
}
latex_additional_files = ['pass-options.tex.txt', 'preamble.tex.txt', 'NLA_PDS.eps']
latex_additional_files = ['pass-options.tex.txt', 'preamble.tex.txt', 'NLA_PDS.eps', 'latexmkrc']
#latex_show_pagerefs = True
latex_documents = [
('index', 'PointsOfOrder_Web.tex', 'Points of Order', '', 'manual'),
('index', 'PointsOfOrder_Print.tex', 'Points of Order', '', 'manual'),
]
if 'TEX_JOBNAME' in os.environ:
latex_documents = [('index', os.environ['TEX_JOBNAME'] + '.tex', 'Points of Order', '', 'manual')]
# -- Options for EPUB output -------------------------------------------------

16
latexmkrc Normal file
View File

@ -0,0 +1,16 @@
$makeindex = 'internal xindy ' . $ENV{'XINDYOPTS'} . ' %O -o %D %S';
sub xindy {
my @args = @_;
if (-z $args[-1]) {
# create an empty .ind file if .idx is empty
open(FH, ">" . $args[-2]);
close(FH);
return 0;
} else {
return system("xindy", @args);
}
}
add_cus_dep( "glo", "gls", 0, "makeglo" );
sub makeglo {
return system( "makeindex -s gglo.ist -o '$_[0].gls' '$_[0].glo'" );
}

View File

@ -1,11 +1,6 @@
% Colours/formatting by output mode
\newif\ifpoprint\poprintfalse
\makeatletter
\edef\@tempa{\jobname}
\def\@tempb{PointsOfOrder_Print}
\@onelevel@sanitize\@tempb % https://tex.stackexchange.com/questions/243591/comparing-strings-extracted-from-jobname
\ifx\@tempa\@tempb % Compare \jobname with "PointsOfOrder_Print"
\poprinttrue
\ifpolulu
\PassOptionsToPackage{cmyk}{xcolor}
\fi
\makeatother

View File

@ -34,7 +34,7 @@
\newlength{\stdmargin}\setlength{\stdmargin}{15mm}
\newlength{\bottomadd}\setlength{\bottomadd}{5mm}
\newlength{\gutteradd}\setlength{\gutteradd}{4mm}
\ifpoprint
\ifpolulu
\definecolor{TitleColor}{cmyk}{0,0,0,1}
\definecolor{InnerLinkColor}{cmyk}{0,0,0,1}
\definecolor{OuterLinkColor}{cmyk}{0,0,0,1}
@ -80,7 +80,7 @@
Authored in \sphinxhref{https://www.sphinx-doc.org/}{Sphinx} and typeset using \LaTeX{} in EB Garamond 11pt and Source Sans Pro
\ifpoprint
\ifpolulu
Cover image courtesy of Breather Products Inc., licensed under the \sphinxhref{https://creativecommons.org/publicdomain/zero/1.0/}{Creative Commons CC0 1.0 Universal Public Domain Dedication}
Printed by Lulu Press