obus/docs/build.py

33 lines
1.1 KiB
Python
Raw Normal View History

2021-07-31 03:29:37 +02:00
import glob
import os
2022-02-01 08:00:20 +01:00
from pathlib import PurePath
import sys
2021-07-31 03:29:37 +02:00
# https://tex.stackexchange.com/questions/101717/converting-markdown-to-latex-in-latex/246871#246871
2022-02-01 08:00:20 +01:00
remove_testmodules = True
if len(sys.argv) >= 2:
remove_testmodules = False
2021-07-31 03:29:37 +02:00
outfilename = '/tmp/out.md'
with open(outfilename, 'w') as outfile:
2022-02-11 21:14:49 +01:00
with open('prefix.md') as infile:
outfile.write(infile.read())
outfile.write("\n\\newpage{}\n")
2022-02-01 08:00:20 +01:00
all_modules = sorted(glob.glob('../src/modules/*/doc/index.md'))
if remove_testmodules:
all_modules = [p for p in all_modules if 'testmodule_' not in p]
without_info = [p for p in all_modules if "info_" not in p]
only_info = [p for p in all_modules if "info_" in p]
for filepath in without_info:
with open(filepath) as infile:
outfile.write(infile.read())
outfile.write("\n\\newpage{}\n")
2022-02-03 06:59:51 +01:00
# outfile.write("\n\\part{Appendix}\\newpage\n")
outfile.write("\n\\newpage{}\n")
2022-02-01 08:00:20 +01:00
for filepath in only_info:
2021-07-31 03:29:37 +02:00
with open(filepath) as infile:
outfile.write(infile.read())
outfile.write("\n\\newpage{}\n")
2022-02-15 16:38:27 +01:00
exit(os.system(f"pandoc --from=markdown --template=template.tex --output=docs.pdf prefix.yaml {outfilename} --highlight-style=espresso"))