Fix #4769: autodoc loses the first staticmethod parameter

This commit is contained in:
Takeshi KOMIYA
2018-03-24 00:53:07 +09:00
parent 991b471025
commit 9e0089b252
3 changed files with 7 additions and 2 deletions

View File

@@ -16,6 +16,8 @@ Features added
Bugs fixed
----------
* #4769: autodoc loses the first staticmethod parameter
Testing
--------

View File

@@ -1300,7 +1300,10 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type:
inspect.ismethoddescriptor(self.object):
# can never get arguments of a C function or method
return None
args = Signature(self.object, bound_method=True).format_args()
if isstaticmethod(self.object, cls=self.parent, name=self.object_name):
args = Signature(self.object, bound_method=False).format_args()
else:
args = Signature(self.object, bound_method=True).format_args()
# escape backslashes for reST
args = args.replace('\\', '\\\\')
return args

View File

@@ -804,7 +804,7 @@ def test_generate():
' .. py:attribute:: Class._private_inst_attr',
' .. py:classmethod:: Class.inheritedclassmeth()',
' .. py:method:: Class.inheritedmeth()',
' .. py:staticmethod:: Class.inheritedstaticmeth()',
' .. py:staticmethod:: Class.inheritedstaticmeth(cls)',
],
'class', 'Class', member_order='bysource', all_members=True)
del directive.env.ref_context['py:module']