obus/docs/build.py

29 lines
1 KiB
Python
Raw Normal View History

2021-07-31 01:29:37 +00:00
import glob
import os
2022-02-01 07:00:20 +00:00
from pathlib import PurePath
import sys
2021-07-31 01:29:37 +00:00
# https://tex.stackexchange.com/questions/101717/converting-markdown-to-latex-in-latex/246871#246871
2022-02-01 07:00:20 +00:00
remove_testmodules = True
if len(sys.argv) >= 2:
remove_testmodules = False
2021-07-31 01:29:37 +00:00
outfilename = '/tmp/out.md'
with open(outfilename, 'w') as outfile:
2022-02-01 07:00:20 +00: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")
outfile.write("\n\\part{Appendix}\\newpage\n")
for filepath in only_info:
2021-07-31 01:29:37 +00:00
with open(filepath) as infile:
outfile.write(infile.read())
outfile.write("\n\\newpage{}\n")
2022-02-01 07:00:20 +00:00
os.system(f"pandoc --from=markdown --template=template.tex --output=docs.pdf prefix.yaml {outfilename} --highlight-style=espresso")