File tree Expand file tree Collapse file tree 2 files changed +724
-0
lines changed
Expand file tree Collapse file tree 2 files changed +724
-0
lines changed Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments