Sphinx: autodoc loses the first staticmethod parameter

Created on 22 Mar 2018  路  4Comments  路  Source: sphinx-doc/sphinx

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.

autodoc bug

Most helpful comment

This bug seems to still be occurring using Sphinx 1.7.4 and Python 2.7. My example:

Source

class GraphUtils():

    @staticmethod
    def toTransitionMatrix(graph):

        """
        Generates a transition matrix for the given graph along three dimensions: source x target x type

        :returns: A pandas DataFrame containing the transition matrix
        :rtype: DataFrame

        :param Graph graph: The graph for which you wish to calculate the transition matrix
        """       

        pass

    # END toTransitionMatrix
# END GraphUtils

.rst

.. automodule:: analytics.graphs.GraphUtils
    :members:
    :undoc-members:
    :show-inheritance:

HTML output
missing argument in signature

The first parameter for the static method is missing (should be graph).

All 4 comments

Confirmed. Surely this is a bug.

Fixed by #4774.
Thank you for reporting!

This bug seems to still be occurring using Sphinx 1.7.4 and Python 2.7. My example:

Source

class GraphUtils():

    @staticmethod
    def toTransitionMatrix(graph):

        """
        Generates a transition matrix for the given graph along three dimensions: source x target x type

        :returns: A pandas DataFrame containing the transition matrix
        :rtype: DataFrame

        :param Graph graph: The graph for which you wish to calculate the transition matrix
        """       

        pass

    # END toTransitionMatrix
# END GraphUtils

.rst

.. automodule:: analytics.graphs.GraphUtils
    :members:
    :undoc-members:
    :show-inheritance:

HTML output
missing argument in signature

The first parameter for the static method is missing (should be graph).

I have the same issue with Sphinx 1.7.4 and Python 2.7.

(Commit 9e0089b2 should be in the 1.7.4 release though, so it's weird...)

Was this page helpful?
0 / 5 - 0 ratings