mkdocstrings / pytkdocs

Load Python objects documentation.
https://mkdocstrings.github.io/pytkdocs
ISC License
50 stars 32 forks source link

parser not picking up methods of enums if not explicitly told to #62

Closed FlixMa closed 2 years ago

FlixMa commented 4 years ago

Describe the bug The parser is not picking up methods of enums, only their attributes when told to parse a enum subclass, e.g. Direction. However, if instructed to parse a method of that enum directly (e.g. Direction.to_vector) it will get picked up correctly.

To Reproduce

class Direction(IntEnum):
    """This enum represents a direction in the 2d plane."""

    X = 0
    """X direction"""

    Y = 1
    """Y direction"""

    def to_vector(self) -> np.ndarray:
        """Turns a direction into its corresponding vector.

            Returns:
                the vector representation
        """
        if self == Direction.X:
            return np.array([1, 0])
        if self == Direction.Y:
            return np.array([0, 1])

Expected behavior I expected to get the attributes as well as the methods.

System (please complete the following information):

pawamoy commented 4 years ago

Thanks for the report! I was able to confirm the bug. It seems inspect.getmembers does not return the methods of enums. However they are available through the class' __dict__ attribute. I'll work on a fix later, PRs welcome!

pawamoy commented 2 years ago

This is likely solved by the new handler. Feedback appreciated!