diff options
Diffstat (limited to 'sphinx/ext/autodoc.py')
-rw-r--r-- | sphinx/ext/autodoc.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 5ea64bf30..571f36cbe 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -450,9 +450,10 @@ class Documenter(object): # into lines if isinstance(docstring, unicode): return [prepare_docstring(docstring, ignore)] - elif docstring: + elif isinstance(docstring, str): # this will not trigger on Py3 return [prepare_docstring(force_decode(docstring, encoding), ignore)] + # ... else it is something strange, let's ignore it return [] def process_doc(self, docstrings): @@ -1052,7 +1053,7 @@ class ClassDocumenter(ModuleLevelDocumenter): # add inheritance info, if wanted if not self.doc_as_attr and self.options.show_inheritance: self.add_line(u'', '<autodoc>') - if len(self.object.__bases__): + if hasattr(self.object, '__bases__') and len(self.object.__bases__): bases = [b.__module__ == '__builtin__' and u':class:`%s`' % b.__name__ or u':class:`%s.%s`' % (b.__module__, b.__name__) @@ -1084,7 +1085,8 @@ class ClassDocumenter(ModuleLevelDocumenter): initdocstring = self.get_attr( self.get_attr(self.object, '__init__', None), '__doc__') # for new-style classes, no __init__ means default __init__ - if initdocstring == object.__init__.__doc__: + if (initdocstring == object.__init__.__doc__ or # for pypy + initdocstring.strip() == object.__init__.__doc__): #for !pypy initdocstring = None if initdocstring: if content == 'init': @@ -1243,7 +1245,8 @@ class AttributeDocumenter(ClassLevelDocumenter): def can_document_member(cls, member, membername, isattr, parent): isdatadesc = isdescriptor(member) and not \ isinstance(member, cls.method_types) and not \ - type(member).__name__ in ("type", "method_descriptor") + type(member).__name__ in ("type", "method_descriptor", + "instancemethod") return isdatadesc or (not isinstance(parent, ModuleDocumenter) and not inspect.isroutine(member) and not isinstance(member, class_types)) @@ -1383,8 +1386,15 @@ class AutoDirective(Directive): not negated: self.options[flag] = None # process the options with the selected documenter's option_spec - self.genopt = Options(assemble_option_dict( - self.options.items(), doc_class.option_spec)) + try: + self.genopt = Options(assemble_option_dict( + self.options.items(), doc_class.option_spec)) + except (KeyError, ValueError, TypeError), err: + # an option is either unknown or has a wrong type + msg = self.reporter.error('An option to %s is either unknown or ' + 'has an invalid value: %s' % (self.name, err), + line=self.lineno) + return [msg] # generate the output documenter = doc_class(self, self.arguments[0]) documenter.generate(more_content=self.content) |