@@ -158,9 +158,11 @@ def exfile2rstfile(filename, opts):
158158 """
159159 # doc filename
160160 dfilename = os .path .basename (filename [:- 3 ]) + '.rst'
161+ dfilepath = os .path .join (opts .outdir , os .path .basename (dfilename ))
162+ print ("Creating file %s." % os .path .abspath (dfilepath ))
161163
162164 # open dest file
163- dfile = open (os . path . join ( opts . outdir , os . path . basename ( dfilename )) , 'w' )
165+ dfile = open (dfilepath , 'w' )
164166
165167 # place header
166168 dfile .write ('.. AUTO-GENERATED FILE -- DO NOT EDIT!\n \n ' )
@@ -196,8 +198,8 @@ def exfile2rstfile(filename, opts):
196198
197199
198200def main ():
199- parser = OptionParser ( \
200- usage = "%prog [options] <filename|directory> [...]" , \
201+ parser = OptionParser (
202+ usage = "%prog [options] <filename|directory> [...]" ,
201203 version = "%prog 0.1" , description = """\
202204 %prog converts Python scripts into restructered text (ReST) format suitable for
203205integration into the Sphinx documentation framework. Its key feature is that it
@@ -217,7 +219,7 @@ the respective indentation is removed in the ReST output.
217219
218220The parser algorithm automatically excludes file headers and starts with the
219221first (module-level) docstring instead.
220- """ ) #'
222+ """ )
221223
222224 # define options
223225 parser .add_option (
@@ -293,8 +295,7 @@ Name of the project that contains the examples. This name is used in the
293295 if len (toparse ) != len (toparse_list ):
294296 print ('Ignoring duplicate parse targets.' )
295297
296- if not os .path .exists (opts .outdir ):
297- os .mkdir (outdir )
298+ os .makedirs (opts .outdir , exist_ok = True )
298299
299300 # finally process all examples
300301 for t in toparse :
0 commit comments