@@ -40,7 +40,7 @@ def __init__(self,
4040 rst_extension = '.txt' ,
4141 package_skip_patterns = None ,
4242 module_skip_patterns = None ,
43- other_defines = True
43+ other_defines = True
4444 ):
4545 ''' Initialize package for parsing
4646
@@ -162,7 +162,7 @@ def _uri2path(self, uri):
162162 path = path .replace ('.' , os .path .sep )
163163 path = os .path .join (self .root_path , path )
164164 # XXX maybe check for extensions as well?
165- if os .path .exists (path + '.py' ): # file
165+ if os .path .exists (path + '.py' ): # file
166166 path += '.py'
167167 elif os .path .exists (os .path .join (path , '__init__.py' )):
168168 path = os .path .join (path , '__init__.py' )
@@ -184,7 +184,7 @@ def _parse_module(self, uri):
184184 if filename is None :
185185 print (filename , 'erk' )
186186 # nothing that we could handle here.
187- return ([],[])
187+ return ([], [])
188188
189189 f = open (filename , 'rt' )
190190 functions , classes = self ._parse_lines (f )
@@ -207,7 +207,7 @@ def _parse_module_with_import(self, uri):
207207 classes : list of str
208208 A list of (public) class names in the module.
209209 """
210- mod = __import__ (uri , fromlist = [uri ])
210+ mod = __import__ (uri , fromlist = [uri . split ( '.' )[ - 1 ] ])
211211 # find all public objects in the module.
212212 obj_strs = [obj for obj in dir (mod ) if not obj .startswith ('_' )]
213213 functions = []
@@ -276,7 +276,7 @@ def generate_api_doc(self, uri):
276276
277277 # Make a shorter version of the uri that omits the package name for
278278 # titles
279- uri_short = re .sub (r'^%s\.' % self .package_name ,'' ,uri )
279+ uri_short = re .sub (r'^%s\.' % self .package_name , '' , uri )
280280
281281 head = '.. AUTO-GENERATED FILE -- DO NOT EDIT!\n \n '
282282 body = ''
@@ -300,10 +300,10 @@ def generate_api_doc(self, uri):
300300 body += '\n .. autoclass:: ' + c + '\n '
301301 # must NOT exclude from index to keep cross-refs working
302302 body += ' :members:\n ' \
303- ' :undoc-members:\n ' \
304- ' :show-inheritance:\n ' \
305- '\n ' \
306- ' .. automethod:: __init__\n \n '
303+ ' :undoc-members:\n ' \
304+ ' :show-inheritance:\n ' \
305+ '\n ' \
306+ ' .. automethod:: __init__\n \n '
307307 head += '.. autosummary::\n \n '
308308 for f in classes + functions :
309309 head += ' ' + f + '\n '
@@ -402,7 +402,7 @@ def discover_modules(self):
402402 package_uri = '.' .join ((root_uri , subpkg_name ))
403403 package_path = self ._uri2path (package_uri )
404404 if (package_path and
405- self ._survives_exclude (package_uri , 'package' )):
405+ self ._survives_exclude (package_uri , 'package' )):
406406 modules .append (package_uri )
407407
408408 return sorted (modules )
@@ -425,12 +425,12 @@ def write_modules_api(self, modules, outdir):
425425 written_modules = []
426426
427427 for ulm , mods in module_by_ulm .items ():
428- print "Generating docs for %s:" % ulm
428+ print ( "Generating docs for %s:" % ulm )
429429 document_head = []
430430 document_body = []
431431
432432 for m in mods :
433- print " -> " + m
433+ print ( " -> " + m )
434434 head , body = self .generate_api_doc (m )
435435
436436 document_head .append (head )
@@ -467,7 +467,7 @@ def write_api_docs(self, outdir):
467467 os .mkdir (outdir )
468468 # compose list of modules
469469 modules = self .discover_modules ()
470- self .write_modules_api (modules ,outdir )
470+ self .write_modules_api (modules , outdir )
471471
472472 def write_index (self , outdir , froot = 'gen' , relative_to = None ):
473473 """Make a reST API index file from written files
@@ -493,10 +493,11 @@ def write_index(self, outdir, froot='gen', relative_to=None):
493493 path = os .path .join (outdir , froot + self .rst_extension )
494494 # Path written into index is relative to rootpath
495495 if relative_to is not None :
496- relpath = (outdir + os .path .sep ).replace (relative_to + os .path .sep , '' )
496+ relpath = (
497+ outdir + os .path .sep ).replace (relative_to + os .path .sep , '' )
497498 else :
498499 relpath = outdir
499- idx = open (path ,'wt' )
500+ idx = open (path , 'wt' )
500501 w = idx .write
501502 w ('.. AUTO-GENERATED FILE -- DO NOT EDIT!\n \n ' )
502503
@@ -505,5 +506,5 @@ def write_index(self, outdir, froot='gen', relative_to=None):
505506 w ("=" * len (title ) + "\n \n " )
506507 w ('.. toctree::\n \n ' )
507508 for f in self .written_modules :
508- w (' %s\n ' % os .path .join (relpath ,f ))
509+ w (' %s\n ' % os .path .join (relpath , f ))
509510 idx .close ()
0 commit comments