23 |
|
|
24 |
umltool.settings['css'] = 'doc/gzz.css' |
umltool.settings['css'] = 'doc/gzz.css' |
25 |
|
|
26 |
def run(path): |
def run_convert(path): |
27 |
umltool.set_to_root(path) |
umltool.set_to_root(path) |
28 |
|
|
29 |
if os.path.isdir(path): |
if os.path.isdir(path): |
30 |
if not path.endswith("/"): umltool.settings['to_root'] += "../" |
umltool.set_to_root((path+"/").replace("//", "/")) |
31 |
|
files = [f for f in os.listdir(path+'/') \ |
32 |
|
if os.path.isfile(path+'/'+f) and not f.startswith('.') |
33 |
|
and '#' not in f and '~' not in f] |
34 |
|
rstfiles = [f for f in files if f.endswith('.rst')] |
35 |
|
|
36 |
|
for rstfile in rstfiles: |
37 |
|
rst2html(path+"/"+rstfile) |
38 |
|
|
39 |
elif os.path.isfile(path) or os.path.isfile(path+'.rst'): |
elif os.path.isfile(path) or os.path.isfile(path+'.rst'): |
40 |
rst2html(path) |
rst2html(path) |
|
umlrst.embed_diagram(path) |
|
41 |
|
|
42 |
else: |
else: |
43 |
umltool.run(path) |
umltool.run(path) |
44 |
|
|
45 |
|
def run_embed(path): |
46 |
|
umltool.set_to_root(path) |
47 |
|
|
48 |
|
if os.path.isdir(path): |
49 |
|
umltool.set_to_root((path+"/").replace("//", "/")) |
50 |
|
files = [f for f in os.listdir(path+'/') \ |
51 |
|
if os.path.isfile(path+'/'+f) and not f.startswith('.') |
52 |
|
and '#' not in f and '~' not in f] |
53 |
|
rstfiles = [f for f in files if f.endswith('.rst')] |
54 |
|
|
55 |
|
for rstfile in rstfiles: |
56 |
|
umlrst.embed_diagram(path+"/"+rstfile) |
57 |
|
|
58 |
|
elif os.path.isfile(path) or os.path.isfile(path+'.rst'): |
59 |
|
umlrst.embed_diagram(path) |
60 |
|
|
61 |
def rst2html(path): |
def rst2html(path): |
62 |
#the first pass - converts rst into html |
#the first pass - converts rst into html |
63 |
if path.endswith(".rst"): path = path[0:len(path)-4] |
if path.endswith(".rst"): path = path[0:len(path)-4] |
64 |
args = '-stg --stylesheet '+umltool.settings['to_root']\ |
args = '-stg --stylesheet '+umltool.settings['to_css']\ |
65 |
+umltool.settings['css']+' '+path+'.rst '+path+'.gen.html' |
+' '+path+'.rst '+path+'.gen.html' |
66 |
docutils.core.publish_cmdline(writer_name='html', argv=args.split()) |
docutils.core.publish_cmdline(writer_name='html', argv=args.split()) |
67 |
|
|
68 |
|
|
69 |
|
#the first pass, create all diagrams data |
70 |
|
for path in sys.argv[1:]: |
71 |
|
run_convert(path) |
72 |
|
|
73 |
|
#the second pass, generate and embed diagrams |
74 |
for path in sys.argv[1:]: |
for path in sys.argv[1:]: |
75 |
run(path) |
run_embed(path) |