Commits

Georg Brandl  committed a548126

A few more fixes in autodoc.

  • Participants
  • Parent commits a73ed4d

Comments (0)

Files changed (1)

File sphinx/ext/autodoc.py

             todoc = module = sys.modules[mod]
             for part in objpath:
                 todoc = getattr(todoc, part)
-        except (ImportError, AttributeError, PycodeError), err:
+        except (ImportError, AttributeError), err:
             self.warn('autodoc can\'t import/find %s %r, it reported error: "%s", '
                       'please check your spelling and sys.path' %
                       (what, str(fullname), err))
                 if todoc.__module__ != mod:
                     return
 
+        # make sure that the result starts with an empty line.  This is
+        # necessary for some situations where another directive preprocesses
+        # reST and no starting newline is present
+        self.result.append(u'', '')
+
         # format the object's signature, if any
         try:
             sig = self.format_signature(what, fullname, todoc, args, retann)
                       (fullname, err))
             sig = ''
 
-        # make sure that the result starts with an empty line.  This is
-        # necessary for some situations where another directive preprocesses
-        # reST and no starting newline is present
-        self.result.append(u'', '')
-
         # now, create the directive header
         if what == 'method':
             directive = get_method_type(todoc)
             self.result.append(indent + u'   :noindex:', '<autodoc>')
         self.result.append(u'', '<autodoc>')
 
+        # add inheritance info, if wanted
         if self.options.show_inheritance and what in ('class', 'exception'):
             if len(todoc.__bases__):
                 bases = [b.__module__ == '__builtin__' and
                          u':class:`%s`' % b.__name__ or
                          u':class:`%s.%s`' % (b.__module__, b.__name__)
                          for b in todoc.__bases__]
-                self.result.append(indent + u'   Bases: %s' % ', '.join(bases),
+                self.result.append(indent + _(u'   Bases: %s') % ', '.join(bases),
                                    '<autodoc>')
                 self.result.append(u'', '<autodoc>')
 
                                                       fullname, todoc)):
                 self.result.append(indent + line, sourcename, i)
 
-        # add source content, if present
+        # add additional content (e.g. from document), if present
         if add_content:
             for line, src in zip(add_content.data, add_content.items):
                 self.result.append(indent + line, src[0], src[1])
         if objpath:
             self.env.autodoc_current_class = objpath[0]
 
-        # add members, if possible
-        all_members = members == ['__all__']
+        # look for members to include
+        want_all_members = members == ['__all__']
         members_check_module = False
-        if all_members:
+        if want_all_members:
             # unqualified :members: given
             if what == 'module':
                 if hasattr(todoc, '__all__'):
             # if content is not None, no extra content from docstrings will be added
             content = None
 
-            if all_members and membername.startswith('_'):
+            if want_all_members and membername.startswith('_'):
                 # ignore members whose name starts with _ by default
                 skip = True
             else:
             if skip:
                 continue
 
+            # determine member type
             if what == 'module':
                 if isinstance(member, (FunctionType, BuiltinFunctionType)):
                     memberwhat = 'function'
                     memberwhat = 'attribute'
                 else:
                     continue
+
             # give explicitly separated module name, so that members of inner classes
             # can be documented
             full_membername = mod + '::' + '.'.join(objpath + [membername])