Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support functools.singledispatchmethod rendering #428

Closed
9y2070m opened this issue Aug 9, 2022 · 2 comments
Closed

Support functools.singledispatchmethod rendering #428

9y2070m opened this issue Aug 9, 2022 · 2 comments
Labels

Comments

@9y2070m
Copy link

9y2070m commented Aug 9, 2022

Problem Description

A clear and concise description of what the bug is.

Steps to reproduce the behavior:

  1. minimal example
import functools
from typing import Union


class SingleDispatchMethodExample:
    """Fancy class to show the behaviour of pdoc."""
    def __init__(self):
        """The `__init__` method is empty."""

    @functools.singledispatchmethod
    def fancymethod(self, str_or_int: Union[str, int]):
        """A fancy method which is capable of handling either `str` or `int`.

        :param str_or_int: string or integr to handle
        """
        raise NotImplementedError(f"{type(str_or_int)=} not implemented!")

    @fancymethod.register
    def fancymethod_handle_str(self, str_to_handle: str):
        """Fancy method handles a string.

        :param str_to_handle: string which will be handled
        """
        print(f"{type(str_to_handle)} = '{str_to_handle}")

    @fancymethod.register
    def fancymethod_handle_int(self, int_to_handle: int):
        """Fancy method handles int.

        :param int_to_handle: int which will be handled
        """
        print(f"{type(int_to_handle)} = '{int_to_handle:x}'")
  1. pdoc output shows always a copy of singledispatchmethod docstring and not the docstring from the method. (run pdoc on the example)

System Information

Paste the output of "pdoc --version" here.

pdoc: 12.0.2
Python: 3.8.10
Platform: Windows-10-10.0.19042-SP0
@9y2070m 9y2070m added the bug label Aug 9, 2022
@9y2070m
Copy link
Author

9y2070m commented Aug 9, 2022

ideally we would like to keep the individual methods private, but still have pdoc document them

link to documentation of singledsipatchmethod https://docs.python.org/3/library/functools.html#functools.singledispatchmethod

@mhils mhils closed this as completed in e6fcc57 Aug 11, 2022
@9y2070m
Copy link
Author

9y2070m commented Aug 23, 2022

Thanks for the fast fix 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant