Mercurial > p > roundup > code
comparison tools/build_html @ 632:71bf8f97fe30
Tools used to build the documentation
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 21 Feb 2002 06:21:18 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 631:993e0162b7c2 | 632:71bf8f97fe30 |
|---|---|
| 1 #! /usr/bin/python | |
| 2 | |
| 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 | |
| 12 | |
| 13 if sys.argv[1:] == '--help': | |
| 14 print """ | |
| 15 Usage: build_html | |
| 16 | |
| 17 Converts all structured text (.stx) files to html files. | |
| 18 """ | |
| 19 sys.exit(1) | |
| 20 | |
| 21 def to_html(filename): | |
| 22 parser = Parser() | |
| 23 input = open(filename).read() | |
| 24 document = dps.utils.newdocument() | |
| 25 parser.parse(input, document) | |
| 26 | |
| 27 formatter = html.DumbHTMLFormatter() | |
| 28 return formatter.format_document(document) | |
| 29 | |
| 30 | |
| 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() | |
| 37 | |
| 38 | |
| 39 |
