Skip to content

Commit a8e9fd4

Browse files
author
Richard Jones
committed
Tools used to build the documentation
1 parent d265f91 commit a8e9fd4

File tree

2 files changed

+724
-0
lines changed

2 files changed

+724
-0
lines changed

tools/build_html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+

0 commit comments

Comments
 (0)