summaryrefslogtreecommitdiff
path: root/sphinx/ext/autodoc.py
diff options
context:
space:
mode:
authorTakayuki Shimizukawa <shimizukawa@gmail.com>2013-10-07 09:47:28 +0000
committerTakayuki Shimizukawa <shimizukawa@gmail.com>2013-10-07 09:47:28 +0000
commit1d995479168acb259a52d1b8997a984919edcc96 (patch)
treef37d4bd2b20021b49edc1aa594a2027789e81955 /sphinx/ext/autodoc.py
parent313559116dc469e710ca8bff3457b949c1703fb4 (diff)
downloadsphinx-git-1d995479168acb259a52d1b8997a984919edcc96.tar.gz
Now sphinx.ext.autodoc on PyPy ignoring the method of built-in classes.
For example:: class CustomDict(dict): """Docstring.""" From this code, autoclass directive on PyPy generate a document output as ``class foo.CustomDict(obj, *args, **keywords)`` instead of ``class foo.CustomDict`` before this change.
Diffstat (limited to 'sphinx/ext/autodoc.py')
-rw-r--r--sphinx/ext/autodoc.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py
index a224fe61e..4d8a44fa6 100644
--- a/sphinx/ext/autodoc.py
+++ b/sphinx/ext/autodoc.py
@@ -28,7 +28,7 @@ from sphinx.application import ExtensionError
from sphinx.util.nodes import nested_parse_with_titles
from sphinx.util.compat import Directive
from sphinx.util.inspect import getargspec, isdescriptor, safe_getmembers, \
- safe_getattr, safe_repr
+ safe_getattr, safe_repr, is_builtin_class_method
from sphinx.util.pycompat import base_exception, class_types
from sphinx.util.docstrings import prepare_docstring
@@ -957,6 +957,10 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter):
try:
argspec = getargspec(self.object)
except TypeError:
+ if (is_builtin_class_method(self.object, '__new__') and
+ is_builtin_class_method(self.object, '__init__')):
+ raise TypeError('%r is a builtin class' % self.object)
+
# if a class should be documented as function (yay duck
# typing) we try to use the constructor signature as function
# signature without the first argument.
@@ -1009,8 +1013,9 @@ class ClassDocumenter(ModuleLevelDocumenter):
initmeth = self.get_attr(self.object, '__init__', None)
# classes without __init__ method, default __init__ or
# __init__ written in C?
- if initmeth is None or initmeth is object.__init__ or not \
- (inspect.ismethod(initmeth) or inspect.isfunction(initmeth)):
+ if initmeth is None or \
+ is_builtin_class_method(self.object, '__init__') or \
+ not(inspect.ismethod(initmeth) or inspect.isfunction(initmeth)):
return None
try:
argspec = getargspec(initmeth)