71 lines
1.7 KiB
Python
71 lines
1.7 KiB
Python
import subprocess
|
|
import textwrap
|
|
import os
|
|
import shutil
|
|
import docker
|
|
|
|
|
|
def generate_latex() -> str:
|
|
result = textwrap.dedent("""\
|
|
\\documentclass{article}
|
|
|
|
% Packages necessary for common.tex
|
|
\\usepackage{amsmath}
|
|
\\usepackage{pgfplots}
|
|
\\pgfplotsset{compat=newest}
|
|
|
|
% Other packages
|
|
\\usepackage{float}
|
|
\\usepackage{subcaption}
|
|
\\usepackage[a4paper, total={6.5in, 9in}]{geometry}
|
|
\\usetikzlibrary{positioning}
|
|
\\usepackage{ifthen}
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%%%%%% Set common options %%%%%%%
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
\\input{../lib/latex-common/common.tex}
|
|
\\pgfplotsset{colorscheme/rocket}
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%%%%%%% Actual Document %%%%%%%%%
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
\\title{Banking Report}
|
|
\\author{}
|
|
|
|
|
|
\\begin{document}
|
|
|
|
\\maketitle
|
|
|
|
Test
|
|
|
|
|
|
\\end{document}
|
|
""")
|
|
|
|
return result
|
|
|
|
|
|
def build_document(src: str):
|
|
os.makedirs(os.path.dirname("build/doc.tex"), exist_ok=True)
|
|
with open("build/doc.tex", "w") as out_file:
|
|
out_file.write(src)
|
|
|
|
shutil.copyfile("res/.latexmkrc", "build/.latexmkrc")
|
|
|
|
subprocess.call("docker build . -f res/Dockerfile.alpine"
|
|
" -t banking-breakdown",
|
|
shell=True)
|
|
subprocess.call("docker run --rm -u `id -u`:`id -g`"
|
|
" -v $(realpath .):/project"
|
|
" -w /project/build banking-breakdown"
|
|
" latexmk -pdf doc.tex",
|
|
shell=True)
|