lots
[arrocco.git] / gather.py
blobf4a775a114c400e5df82d23689a911f92d7ac5ea
1 #!/usr/bin/python
2 # gather.py
3 # 29 Nov 2006
4 # Gather together all the .py files into a Latex document.
5 # If you are reading this in the source printout, I hope you're enjoying
6 # the self-referential madness. I know I am.
8 # invoke in source directory as: ./gather.py > output.tex
10 import sys
12 print r"""
13 \documentclass{article}
14 \usepackage{fullpage}
15 \usepackage[left=1.0in,right=1.0in,top=1.0in,bottom=1.0in,nohead]{geometry}
16 \begin{document}
17 """
19 import glob
20 filenames = glob.glob("*.py") + glob.glob("*.c") + glob.glob("*.h") + ["Makefile"]
21 filenames.sort()
22 filenames = [x for x in filenames if not x.startswith("_")]
24 for i, filename in enumerate(filenames):
25 # if i > 1:
26 # print r"\pagebreak"
28 # print "\n%scenter{%s}\n" % ('\\', filename.replace('_', r'\_'))
29 print "\n%ssection{%s}\n" % ('\\', filename.replace('_', r'\_'))
30 print r"""
31 \begin{%s}
33 \end{%s}
34 """ % ('verbatim', file(filename, 'rU').read().replace('\t', ' '), 'verbatim')
36 print r"\end{document}"