48 |
""" |
""" |
49 |
|
|
50 |
import sys, os.path |
import sys, os.path |
51 |
import umltool, umlrst |
import umltool, umlrst, mputils |
52 |
import docutils.core |
import docutils.core |
53 |
|
|
54 |
# must be run in the main directory of gzz module |
# must be run in the main directory of gzz module |
55 |
|
|
56 |
umltool.settings['css'] = 'doc/gzz.css' |
umltool.settings['css'] = 'doc/gzz.css' |
57 |
|
|
58 |
def _slashify(path): |
mputils.__rst_init__() |
59 |
"""Add a trailing slash if not already there. |
umlrst.__rst_init__() |
|
""" |
|
|
return (path+"/").replace("//","/") |
|
60 |
|
|
61 |
def _rstFiles(path): |
def _rstFiles(path): |
62 |
files = [f for f in os.listdir(path+'/') \ |
files = [f for f in os.listdir(mputils._slashify(path)) \ |
63 |
if os.path.isfile(path+'/'+f) and not f.startswith('.') |
if os.path.isfile(mputils._slashify(path)+f) and not f.startswith('.') |
64 |
and '#' not in f and '~' not in f] |
and '#' not in f and '~' not in f] |
65 |
rstfiles = [f for f in files if f.endswith('.rst')] |
rstfiles = [f for f in files if f.endswith('.rst')] |
66 |
return rstfiles |
return rstfiles |
67 |
|
|
68 |
def run_convert(path): |
def run_convert(path): |
|
umltool.set_to_root(path) |
|
|
|
|
69 |
if os.path.isdir(path): |
if os.path.isdir(path): |
|
umltool.set_to_root(_slashify(path)) |
|
70 |
rstfiles = _rstFiles(path) |
rstfiles = _rstFiles(path) |
71 |
for rstfile in rstfiles: |
for rstfile in rstfiles: |
72 |
rst2html(path+"/"+rstfile) |
rst2html(mputils._slashify(path)+rstfile) |
73 |
|
|
74 |
elif os.path.isfile(path) or os.path.isfile(path+'.rst'): |
elif os.path.isfile(path) or os.path.isfile(path+'.rst'): |
75 |
rst2html(path) |
rst2html(path) |
76 |
|
|
77 |
else: |
else: |
78 |
|
umltool.set_transition_paths(path) |
79 |
umltool.run(path) |
umltool.run(path) |
80 |
|
|
81 |
def run_embed(path): |
def run_embed(path): |
|
umltool.set_to_root(path) |
|
|
|
|
82 |
if os.path.isdir(path): |
if os.path.isdir(path): |
|
umltool.set_to_root(_slashify(path)) |
|
83 |
rstfiles = _rstFiles(path) |
rstfiles = _rstFiles(path) |
84 |
|
|
85 |
for rstfile in rstfiles: |
for rstfile in rstfiles: |
86 |
print "Embed",path+"/"+rstfile |
print "Embed",mputils._slashify(path)+rstfile |
87 |
umlrst.embed_diagram(path+"/"+rstfile) |
umlrst.embed_diagrams(mputils._slashify(path)+rstfile) |
88 |
|
|
89 |
elif os.path.isfile(path) or os.path.isfile(path+'.rst'): |
elif os.path.isfile(path) or os.path.isfile(path+'.rst'): |
90 |
print "Embed",path |
print "Embed",path |
91 |
umlrst.embed_diagram(path) |
umlrst.embed_diagrams(path) |
92 |
|
|
93 |
def rst2html(path): |
def rst2html(path): |
94 |
|
umltool.set_transition_paths(path) |
95 |
|
umltool.settings['context'] = path |
96 |
#the first pass - converts rst into html |
#the first pass - converts rst into html |
97 |
if path.endswith(".rst"): path = path[0:len(path)-4] |
if path.endswith(".rst"): path = path[0:len(path)-4] |
98 |
args = '-stg --stylesheet '+umltool.settings['to_css']\ |
args = '-stg --stylesheet '+umltool.settings['to_css']\ |