diff options
Diffstat (limited to 'sphinx/ext/autodoc/__init__.py')
-rw-r--r-- | sphinx/ext/autodoc/__init__.py | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 058fd7765..7d34e185d 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -32,7 +32,7 @@ from sphinx.util import rpartition, force_decode from sphinx.util.docstrings import prepare_docstring from sphinx.util.inspect import Signature, isdescriptor, safe_getmembers, \ safe_getattr, object_description, is_builtin_class_method, \ - isenumattribute, isclassmethod, isstaticmethod, getdoc + isenumattribute, isclassmethod, isstaticmethod, isfunction, isbuiltin, ispartial, getdoc if False: # For type annotation @@ -399,7 +399,9 @@ class Documenter(object): return True modname = self.get_attr(self.object, '__module__', None) - if modname and modname != self.modname: + if ispartial(self.object) and modname == '_functools': # for pypy + return True + elif modname and modname != self.modname: return False return True @@ -473,9 +475,8 @@ class Documenter(object): def get_doc(self, encoding=None, ignore=1): # type: (unicode, int) -> List[List[unicode]] """Decode and return lines of the docstring(s) for the object.""" - docstring = self.get_attr(self.object, '__doc__', None) - if docstring is None and self.env.config.autodoc_inherit_docstrings: - docstring = getdoc(self.object) + docstring = getdoc(self.object, self.get_attr, + self.env.config.autodoc_inherit_docstrings) # make sure we have Unicode docstrings, then sanitize and split # into lines if isinstance(docstring, text_type): @@ -599,9 +600,7 @@ class Documenter(object): # if isattr is True, the member is documented as an attribute isattr = False - doc = self.get_attr(member, '__doc__', None) - if doc is None and self.env.config.autodoc_inherit_docstrings: - doc = getdoc(member) + doc = getdoc(member, self.get_attr, self.env.config.autodoc_inherit_docstrings) # if the member __doc__ is the same as self's __doc__, it's just # inherited and therefore not the member's doc @@ -1022,12 +1021,11 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ @classmethod def can_document_member(cls, member, membername, isattr, parent): # type: (Any, unicode, bool, Any) -> bool - return inspect.isfunction(member) or inspect.isbuiltin(member) + return isfunction(member) or isbuiltin(member) def format_args(self): # type: () -> unicode - if inspect.isbuiltin(self.object) or \ - inspect.ismethoddescriptor(self.object): + if isbuiltin(self.object) or inspect.ismethoddescriptor(self.object): # cannot introspect arguments of a C function or method return None try: @@ -1095,7 +1093,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: # __init__ written in C? if initmeth is None or \ is_builtin_class_method(self.object, '__init__') or \ - not(inspect.ismethod(initmeth) or inspect.isfunction(initmeth)): + not(inspect.ismethod(initmeth) or isfunction(initmeth)): return None try: return Signature(initmeth, bound_method=True, has_retval=False).format_args() @@ -1304,8 +1302,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type: def format_args(self): # type: () -> unicode - if inspect.isbuiltin(self.object) or \ - inspect.ismethoddescriptor(self.object): + if isbuiltin(self.object) or inspect.ismethoddescriptor(self.object): # can never get arguments of a C function or method return None if isstaticmethod(self.object, cls=self.parent, name=self.object_name): @@ -1336,7 +1333,7 @@ class AttributeDocumenter(DocstringStripSignatureMixin, ClassLevelDocumenter): @staticmethod def is_function_or_method(obj): - return inspect.isfunction(obj) or inspect.isbuiltin(obj) or inspect.ismethod(obj) + return isfunction(obj) or isbuiltin(obj) or inspect.ismethod(obj) @classmethod def can_document_member(cls, member, membername, isattr, parent): |