39 |
The main frontend for running Navidoc. |
The main frontend for running Navidoc. |
40 |
""" |
""" |
41 |
|
|
42 |
dbg = config.dbg.shorthand("main") |
dbg = config.dbg.shorthand('navidoc') |
43 |
|
|
44 |
# XXX: figure out, why docutils want locals to be cleaned |
# XXX: figure out, why docutils want locals to be cleaned |
45 |
import locale |
import locale |
55 |
""" |
""" |
56 |
if os.path.isdir(path): |
if os.path.isdir(path): |
57 |
rstfiles = _rstFiles(path) |
rstfiles = _rstFiles(path) |
58 |
if os.path.isfile(_slashify(path) + "docutils.conf"): |
if os.path.isfile(_slashify(path) + 'docutils.conf'): |
59 |
config.docutils = _slashify(path) + "docutils.conf" |
config.docutils = _slashify(path) + 'docutils.conf' |
60 |
for rstfile in rstfiles: |
for rstfile in rstfiles: |
61 |
rst2any(_slashify(path)+rstfile) |
rst2any(_slashify(path)+rstfile) |
62 |
elif os.path.isfile(path) or os.path.isfile(path+'.rst'): |
elif os.path.isfile(path): |
63 |
rst2any(path) |
rst2any(path) |
64 |
|
elif os.path.isfile(path+'.rst'): |
65 |
|
rst2any(path+'.rst') |
66 |
|
|
67 |
def rst2any(filepath): |
def rst2any(input): |
68 |
""" |
""" |
69 |
Runs docutils for a single file. |
Runs docutils for a single file. |
70 |
""" |
""" |
71 |
if filepath.endswith(".rst"): filepath = filepath[0:len(filepath)-4] |
if input.endswith('.rst'): output = input[0:len(input)-4]+'.gen.html' |
72 |
|
else: output = input+'.gen.html' |
73 |
|
args = "--config "+config.docutils+" "+input+' '+output |
74 |
if html: |
if html: |
75 |
args = "--config "+config.docutils+" "+filepath+'.rst '+filepath+'.gen.html' |
dbg("Compiling: "+input) |
|
dbg("Compiling: "+filepath) |
|
76 |
docutils.core.publish_cmdline(writer_name='html', argv=args.split()) |
docutils.core.publish_cmdline(writer_name='html', argv=args.split()) |
77 |
if latex: |
if latex: |
78 |
args = "--config "+config.docutils+" "+filepath+'.rst '+filepath+'.gen.latex' |
dbg("Compiling: "+input) |
|
dbg("Compiling: "+filepath) |
|
79 |
docutils.core.publish_cmdline(writer_name='latex', argv=args.split()) |
docutils.core.publish_cmdline(writer_name='latex', argv=args.split()) |
80 |
|
|
81 |
# catching loop parameters from the command line |
# catching loop parameters from the command line |
95 |
while 1: |
while 1: |
96 |
dbg_name = sys.argv[sys.argv.index("-d") + 1] |
dbg_name = sys.argv[sys.argv.index("-d") + 1] |
97 |
config.dbg.enable(dbg_name) |
config.dbg.enable(dbg_name) |
98 |
print "Enabling debug for:", dbg_name |
print "Enabling debug output for:", dbg_name |
99 |
sys.argv.remove("-d") |
sys.argv.remove("-d") |
100 |
sys.argv.remove(dbg_name) |
sys.argv.remove(dbg_name) |
101 |
|
|