Repository: sphinx-doc/sphinx

Issue:
autodoc loses the first staticmethod parameter
As an example, if I have

```
class BaseStorage:
    @staticmethod
    def get_username(user, flags):
        """
        Get the username of the user.

        :param user: user object
        :param flags: flags
        :return: username
        """
        return None

```

and

```
.. autoclass:: storage.BaseStorage
    :members:

```
then the signature of the method in the HTML output is

static get_username(flags)

That is, the first parameter is missing.

This is using Python 3.6.3, and Sphinx 1.7.1, on Ubuntu 17.10.


Discussion:

Patch:
diff --git a/CHANGES b/CHANGES
index 18149fed9..d7b8221b5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -16,6 +16,8 @@ Features added
 Bugs fixed
 ----------
 
+* #4769: autodoc loses the first staticmethod parameter
+
 Testing
 --------
 
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py
index 89ca1f44c..d516146bf 100644
--- a/sphinx/ext/autodoc/__init__.py
+++ b/sphinx/ext/autodoc/__init__.py
@@ -1300,7 +1300,10 @@ def format_args(self):
                 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


Test patch:
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py
index 881df1fda..9398edc34 100644
--- a/tests/test_autodoc.py
+++ b/tests/test_autodoc.py
@@ -804,7 +804,7 @@ def assert_order(items, objtype, name, member_order, **kw):
                   '   .. 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']