summaryrefslogtreecommitdiff
path: root/doc/postprocess.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2008-11-23 10:39:05 +0000
committerPauli Virtanen <pav@iki.fi>2008-11-23 10:39:05 +0000
commit03582a3dbd1b4643b7b70cf277eada66dcb0800e (patch)
tree1cc0fa73843d5e602a561696817f41c4abfb811b /doc/postprocess.py
parent638bacdd9212dd2258a886e0124cca56bf2b905d (diff)
parent84054e34dd58ceebc981d349d997e4dd7cd7c80c (diff)
downloadnumpy-03582a3dbd1b4643b7b70cf277eada66dcb0800e.tar.gz
Moved numpy-docs under doc/ in the main Numpy trunk.
Diffstat (limited to 'doc/postprocess.py')
-rwxr-xr-xdoc/postprocess.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/doc/postprocess.py b/doc/postprocess.py
new file mode 100755
index 000000000..1c6ef1b2e
--- /dev/null
+++ b/doc/postprocess.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+"""
+%prog MODE FILES...
+
+Post-processes HTML and Latex files output by Sphinx.
+MODE is either 'html' or 'tex'.
+
+"""
+import re, optparse
+
+def main():
+ p = optparse.OptionParser(__doc__)
+ options, args = p.parse_args()
+
+ if len(args) < 1:
+ p.error('no mode given')
+
+ mode = args.pop(0)
+
+ if mode not in ('html', 'tex'):
+ p.error('unknown mode %s' % mode)
+
+ for fn in args:
+ f = open(fn, 'r')
+ try:
+ if mode == 'html':
+ lines = process_html(fn, f.readlines())
+ elif mode == 'tex':
+ lines = process_tex(f.readlines())
+ finally:
+ f.close()
+
+ f = open(fn, 'w')
+ f.write("".join(lines))
+ f.close()
+
+def process_html(fn, lines):
+ return lines
+
+def process_tex(lines):
+ """
+ Remove unnecessary section titles from the LaTeX file.
+
+ """
+ new_lines = []
+ for line in lines:
+ if (line.startswith(r'\section{numpy.')
+ or line.startswith(r'\subsection{numpy.')
+ or line.startswith(r'\subsubsection{numpy.')
+ or line.startswith(r'\paragraph{numpy.')
+ or line.startswith(r'\subparagraph{numpy.')
+ ):
+ pass # skip!
+ else:
+ new_lines.append(line)
+ return new_lines
+
+if __name__ == "__main__":
+ main()