@@ -40,7 +40,7 @@ def __init__(self,
40
40
rst_extension = '.txt' ,
41
41
package_skip_patterns = None ,
42
42
module_skip_patterns = None ,
43
- other_defines = True
43
+ other_defines = True
44
44
):
45
45
''' Initialize package for parsing
46
46
@@ -162,7 +162,7 @@ def _uri2path(self, uri):
162
162
path = path .replace ('.' , os .path .sep )
163
163
path = os .path .join (self .root_path , path )
164
164
# XXX maybe check for extensions as well?
165
- if os .path .exists (path + '.py' ): # file
165
+ if os .path .exists (path + '.py' ): # file
166
166
path += '.py'
167
167
elif os .path .exists (os .path .join (path , '__init__.py' )):
168
168
path = os .path .join (path , '__init__.py' )
@@ -184,7 +184,7 @@ def _parse_module(self, uri):
184
184
if filename is None :
185
185
print (filename , 'erk' )
186
186
# nothing that we could handle here.
187
- return ([],[])
187
+ return ([], [])
188
188
189
189
f = open (filename , 'rt' )
190
190
functions , classes = self ._parse_lines (f )
@@ -207,7 +207,7 @@ def _parse_module_with_import(self, uri):
207
207
classes : list of str
208
208
A list of (public) class names in the module.
209
209
"""
210
- mod = __import__ (uri , fromlist = [uri ])
210
+ mod = __import__ (uri , fromlist = [uri . split ( '.' )[ - 1 ] ])
211
211
# find all public objects in the module.
212
212
obj_strs = [obj for obj in dir (mod ) if not obj .startswith ('_' )]
213
213
functions = []
@@ -276,7 +276,7 @@ def generate_api_doc(self, uri):
276
276
277
277
# Make a shorter version of the uri that omits the package name for
278
278
# titles
279
- uri_short = re .sub (r'^%s\.' % self .package_name ,'' ,uri )
279
+ uri_short = re .sub (r'^%s\.' % self .package_name , '' , uri )
280
280
281
281
head = '.. AUTO-GENERATED FILE -- DO NOT EDIT!\n \n '
282
282
body = ''
@@ -300,10 +300,10 @@ def generate_api_doc(self, uri):
300
300
body += '\n .. autoclass:: ' + c + '\n '
301
301
# must NOT exclude from index to keep cross-refs working
302
302
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 '
307
307
head += '.. autosummary::\n \n '
308
308
for f in classes + functions :
309
309
head += ' ' + f + '\n '
@@ -402,7 +402,7 @@ def discover_modules(self):
402
402
package_uri = '.' .join ((root_uri , subpkg_name ))
403
403
package_path = self ._uri2path (package_uri )
404
404
if (package_path and
405
- self ._survives_exclude (package_uri , 'package' )):
405
+ self ._survives_exclude (package_uri , 'package' )):
406
406
modules .append (package_uri )
407
407
408
408
return sorted (modules )
@@ -425,12 +425,12 @@ def write_modules_api(self, modules, outdir):
425
425
written_modules = []
426
426
427
427
for ulm , mods in module_by_ulm .items ():
428
- print "Generating docs for %s:" % ulm
428
+ print ( "Generating docs for %s:" % ulm )
429
429
document_head = []
430
430
document_body = []
431
431
432
432
for m in mods :
433
- print " -> " + m
433
+ print ( " -> " + m )
434
434
head , body = self .generate_api_doc (m )
435
435
436
436
document_head .append (head )
@@ -467,7 +467,7 @@ def write_api_docs(self, outdir):
467
467
os .mkdir (outdir )
468
468
# compose list of modules
469
469
modules = self .discover_modules ()
470
- self .write_modules_api (modules ,outdir )
470
+ self .write_modules_api (modules , outdir )
471
471
472
472
def write_index (self , outdir , froot = 'gen' , relative_to = None ):
473
473
"""Make a reST API index file from written files
@@ -493,10 +493,11 @@ def write_index(self, outdir, froot='gen', relative_to=None):
493
493
path = os .path .join (outdir , froot + self .rst_extension )
494
494
# Path written into index is relative to rootpath
495
495
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 , '' )
497
498
else :
498
499
relpath = outdir
499
- idx = open (path ,'wt' )
500
+ idx = open (path , 'wt' )
500
501
w = idx .write
501
502
w ('.. AUTO-GENERATED FILE -- DO NOT EDIT!\n \n ' )
502
503
@@ -505,5 +506,5 @@ def write_index(self, outdir, froot='gen', relative_to=None):
505
506
w ("=" * len (title ) + "\n \n " )
506
507
w ('.. toctree::\n \n ' )
507
508
for f in self .written_modules :
508
- w (' %s\n ' % os .path .join (relpath ,f ))
509
+ w (' %s\n ' % os .path .join (relpath , f ))
509
510
idx .close ()
0 commit comments