/[navidoc]/navidoc/rst2any.py
ViewVC logotype

Diff of /navidoc/rst2any.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by humppake, Tue Mar 18 16:02:27 2003 UTC revision 1.6 by humppake, Tue Mar 18 16:28:36 2003 UTC
# Line 40  The main frontend for running Navidoc. Line 40  The main frontend for running Navidoc.
40  """  """
41    
42  dbg = config.dbg.shorthand('navidoc')  dbg = config.dbg.shorthand('navidoc')
43    dbg_path = config.dbg.shorthand('path')
44    
45  # XXX: figure out, why docutils want locals to be cleaned  # XXX: figure out, why docutils want locals to be cleaned
46  import locale  import locale
# Line 54  def run_docutils(path): Line 55  def run_docutils(path):
55      specified by ``path``) and forwards them to conversion method.      specified by ``path``) and forwards them to conversion method.
56      """      """
57      if os.path.isdir(path):      if os.path.isdir(path):
58            config.working_directory = os.path.normpath(path)
59          rstfiles = _rstFiles(path)          rstfiles = _rstFiles(path)
60          if os.path.isfile(_slashify(path) + 'docutils.conf'):          if os.path.isfile(_slashify(path) + 'docutils.conf'):
61              config.docutils = _slashify(path) + 'docutils.conf'              config.docutils = _slashify(path) + 'docutils.conf'
62          for rstfile in rstfiles:          for rstfile in rstfiles:
63              rst2any(_slashify(path)+rstfile)              rst2any(_slashify(path)+rstfile)
64      elif os.path.isfile(path):      elif os.path.isfile(path):
65            config.working_directory = os.path.normpath(os.path.dirname(path))
66            config.input_filename = os.path.basename(path)
67          rst2any(path)          rst2any(path)
68      elif os.path.isfile(path+'.rst'):      elif os.path.isfile(path+'.rst'):
69            config.working_directory = os.path.normpath(os.path.dirname(path))
70            config.input_filename = os.path.basename(path+'.rst')
71          rst2any(path+'.rst')          rst2any(path+'.rst')
72    
73  def rst2any(input):  def rst2any(input):
74      """      """
75      Runs docutils for a single file.      Runs docutils for a single file.
76      """      """
77      if input.endswith('.rst'): output = input[0:len(input)-4]+'.gen.html'      if input.endswith('.rst'): output = input[0:len(input)-4]
78      else: output = input+'.gen.html'      else: output = input
79      args = "--config "+config.docutils+" "+input+' '+output  
80        dbg_path("working directory: "+config.working_directory)
81        dbg_path("input file: "+config.input_filename)
82    
83      if html:      if html:
84          dbg("Compiling: "+input)          dbg('Compiling: '+input)
85            output = output+".gen.html"
86            config.output_filename = os.path.basename(output)
87            dbg_path("output file: "+config.output_filename)
88            args = "--config "+config.docutils+" "+input+' '+output
89          docutils.core.publish_cmdline(writer_name='html', argv=args.split())          docutils.core.publish_cmdline(writer_name='html', argv=args.split())
90    
91      if latex:      if latex:
92          dbg("Compiling: "+input)          dbg('Compiling: '+input)
93            output = output+".gen.latex"
94            config.output_filename = os.path.basename(output)
95            dbg_path("output file: "+config.output_filename)
96            args = "--config "+config.docutils+" "+input+' '+output
97          docutils.core.publish_cmdline(writer_name='latex', argv=args.split())          docutils.core.publish_cmdline(writer_name='latex', argv=args.split())
98    
99    
100  # catching loop parameters from the command line  # catching loop parameters from the command line
101  try: sys.argv.remove("--loop"); loop = 1  try: sys.argv.remove('--loop'); loop = 1
102  except ValueError: loop = 0  except ValueError: loop = 0
103    
104  # catching writer parameters from the command line  # catching writer parameters from the command line
105  try: sys.argv.remove("--latex"); latex = 1  try: sys.argv.remove('--latex'); latex = 1
106  except ValueError: latex = 0  except ValueError: latex = 0
107    
108  # catching writer parameters from the command line  # catching writer parameters from the command line
109  try: sys.argv.remove("--html"); html = 1  try: sys.argv.remove('--html'); html = 1
110  except ValueError: html = 0  except ValueError: html = 0
111    
112  # catching debug parameters  # catching debug parameters
113  dbg_names, sys.argv = getopt.getopt(sys.argv[1:], config.dbg.short, config.dbg.long)  dbg_names, sys.argv = getopt.getopt(sys.argv[1:], config.dbg.short, config.dbg.long)
114  for dbg_name in dbg_names:  for dbg_name in dbg_names:
115      config.dbg.enable(dbg_name[1])      config.dbg.enable(dbg_name[1])
116      print "Enabling debug output for:", dbg_name[1]      print 'Enabling debug output for:', dbg_name[1]
117    
118  # conversion loop  # conversion loop
119  while 1:  while 1:
# Line 120  while 1: Line 139  while 1:
139      #        break      #        break
140    
141      if not loop: break      if not loop: break
142      print "\n\nNavidoc finished. Press Enter to recompile.\n"+ \      print "\n\n"+'Navidoc finished. Press Enter to recompile.'+"\n"+ \
143            "Enter any other key to exit loop and quit."            'Enter any other key to exit loop and quit.'
144      if  raw_input().lower() != '':      if  raw_input().lower() != '':
145          break          break
146      print "Rerunning Navidoc..."      print 'Rerunning Navidoc...'

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26