diff --git a/make.py b/make.py index e3e1533..f91175d 100755 --- a/make.py +++ b/make.py @@ -2,22 +2,33 @@ import os import shutil +import subprocess -PURGE = ["doctrees"] FORMATS = { - "html": "html", -# "xelatexpdf": "latex", + "html": "docs", + "latex": "doc", } +INPUT = "in" +OUTPUT = "out" + + +def run(*arguments): + return subprocess.call(arguments) + + +def main(): + script_file = os.path.realpath(__file__) + project_directory = os.path.dirname(script_file) + os.chdir(project_directory) + shutil.rmtree(OUTPUT, ignore_errors=True) + for f, name in reversed(sorted(FORMATS.items())): + run("sphinx-build", + "-b", f, + "-c", os.curdir, + "-j", "2", + "-D", "latex_paper_size=a4", + INPUT, os.path.join(OUTPUT, name)) if __name__ == "__main__": - file = os.path.realpath(__file__) - directory = os.path.dirname(file) - os.chdir(directory) - for build in PURGE + list(FORMATS.values()): - try: - shutil.rmtree(os.path.join("build", build)) - except: - pass - for make in reversed(sorted(FORMATS.keys())): - os.system(" ".join(["make", make])) + main()