Autodoc class with multiple signatures

Viewed 196

I have the following http client class

class MyClient:
  """Class docstring"""

  @overload
  def __init__(self, url): ...

  @overload
  def __init__(self, *, scheme, auth, host, port, path): ...

  def __init__(self, url=None, **kwargs): ...

and I'd like to generate the Sphinx documentation for the class's two signatures.

I can use py:class and write the two signatures by hand, but this solution requires me to copy the docstring violating DRY.

.. py:class:: MyClient(url)
              MyClient(*, scheme, auth, host, port, path)

    Class docstring

On the other hand, using autoclass will fetch the docstring automatically, but does not allow specifying multiple singatures.

.. autoclass:: MyClient

generates

class MyClient(url=None, **kwargs)
    Class docstring

Is there a way to write two signatures and insert class' docstring automatically at the same time?

0 Answers
Related