Skip to content
This repository
Newer
Older
100755 61 lines (48 sloc) 1.447 kb
ff4e22fc » pv
2008-10-26 Import initial version of Scipy documentation
1 #!/usr/bin/env python
2 """
3 %prog MODE FILES...
4
5 Post-processes HTML and Latex files output by Sphinx.
6 MODE is either 'html' or 'tex'.
7
8 """
9 import re, optparse
10
11 def main():
12 p = optparse.OptionParser(__doc__)
13 options, args = p.parse_args()
14
15 if len(args) < 1:
16 p.error('no mode given')
17
18 mode = args.pop(0)
19
20 if mode not in ('html', 'tex'):
21 p.error('unknown mode %s' % mode)
22
23 for fn in args:
24 f = open(fn, 'r')
25 try:
26 if mode == 'html':
27 lines = process_html(fn, f.readlines())
28 elif mode == 'tex':
29 lines = process_tex(f.readlines())
30 finally:
31 f.close()
32
33 f = open(fn, 'w')
34 f.write("".join(lines))
35 f.close()
36
37 def process_html(fn, lines):
38 return lines
39
40 def process_tex(lines):
41 """
39294b7a » pv
2012-03-31 DOC: improve appearance of PDF output
42 Remove unnecessary section titles from the LaTeX file.
43
ff4e22fc » pv
2008-10-26 Import initial version of Scipy documentation
44 """
45 new_lines = []
46 for line in lines:
39294b7a » pv
2012-03-31 DOC: improve appearance of PDF output
47 line = re.sub(r'^\s*\\strong{See Also:}\s*$', r'\paragraph{See Also}', line)
48
49 if (line.startswith(r'\section{scipy.')
50 or line.startswith(r'\subsection{scipy.')
51 or line.startswith(r'\subsubsection{scipy.')
52 or line.startswith(r'\paragraph{scipy.')
53 or line.startswith(r'\subparagraph{scipy.')
54 ):
ff4e22fc » pv
2008-10-26 Import initial version of Scipy documentation
55 pass # skip!
56 else:
57 new_lines.append(line)
58 return new_lines
59
60 if __name__ == "__main__":
61 main()
Something went wrong with that request. Please try again.