-
Notifications
You must be signed in to change notification settings - Fork 14
/
make-doc.py
executable file
·62 lines (45 loc) · 1.48 KB
/
make-doc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /usr/bin/env python3
"""Generate a Latex file containing all domain READMEs."""
from pathlib import Path
import sys
DIR = Path(__file__).resolve().parent
HEADER = """\
\\documentclass{article}
\\usepackage[margin=1in]{geometry}
\\usepackage[hidelinks]{hyperref}
\\usepackage[utf8]{inputenc}
\\title{PDDL Generators}
\\author{Jendrik Seipp, \\'Alvaro Torralba, J\\"org Hoffmann}
\\date{}
\\hypersetup{pdfinfo={
Title={PDDL Generators},
Author={Jendrik Seipp, Alvaro Torralba, Joerg Hoffmann}
}}
\\begin{document}
\\maketitle
A collection of PDDL generators, some of which have been used
to generate benchmarks for the International Planning Competition (IPC).
\\tableofcontents
"""
FOOTER = """\
\\end{document}
"""
def get_text(domain_dir: Path):
files = set(x.name for x in domain_dir.iterdir())
content = None
for readme_name in ["README", "README.txt"]:
if readme_name in files:
with (domain_dir / readme_name).open() as f:
content = f.read().strip()
break
if content is None:
sys.exit(f"Error: {domain_dir.name} has no README.txt file.")
return f"\\section{{{domain_dir.name.capitalize()}}}\n\n\\begin{{verbatim}}\n{content}\\end{{verbatim}}"
def main():
parts = []
for domain_dir in sorted(DIR.iterdir()):
if domain_dir.is_dir() and not domain_dir.name.startswith("."):
parts.append(get_text(domain_dir))
print(HEADER + "\n\n".join(parts) + FOOTER)
if __name__ == "__main__":
main()