Code

"upgrade you doofus" text inserted to appease anthony ;)
[roundup.git] / tools / build_html
1 #! /usr/bin/python
3 import sys
4 import os.path
5 import glob
6 import html
7 import dps.utils
8 try:
9     from restructuredtext import Parser
10 except ImportError:
11     from dps.parsers.restructuredtext import Parser
13 if sys.argv[1:] == '--help':
14     print """
15 Usage: build_html
17 Converts all structured text (.stx) files to html files.
18 """
19     sys.exit(1)
21 def to_html(filename):
22     parser = Parser()
23     input = open(filename).read()
24     document = dps.utils.newdocument()
25     parser.parse(input, document)
27     formatter = html.DumbHTMLFormatter()
28     return formatter.format_document(document)
31 for filename in glob.glob('*.stx'):
32     htmlfile = "%s.html" % os.path.splitext(filename)[0]
33     print "%s -> %s" % (filename, htmlfile)
34     f=open(htmlfile, 'wb')
35     f.write(to_html(filename))
36     f.close()
38