I have a class called WebAPI that instantiates and stores a UserEndpoints object inside its constructor:
# /src/minim/api/spotify/_core.py
... # other imports
from .._shared import OAuth2API
from ._web_api.users import UserEndpoints
class WebAPI(OAuth2API):
"""
Spotify Web API client.
"""
def __init__(self, ...) -> None:
"""
Parameters
----------
...
"""
self.users = UserEndpoints(self)
... # other logic
def some_method(self) -> None:
"""
Do nothing.
"""
pass
... # other methods
The WebAPI class is imported in /src/minim/api/spotify/__init__.py so that Sphinx autosummary can find it:
# /src/minim/api/spotify/__init__.py
from ._core import WebAPI
__all__ = ["WebAPI"]
UserEndpoints is defined in /src/minim/api/spotify/_web_api/users.py:
# /src/minim/api/spotify/_web_api/users.py
... # imports
class UserEndpoints:
"""
Spotify Web API user endpoints.
"""
def __init__(self, client: "WebAPI") -> None:
"""
Parameters
----------
...
"""
self._client = client
def get_me(self) -> dict[str, Any]:
"""
...
"""
self._client._require_scope(
"get_me", {"user-read-private", "user-read-email"}
)
return self._client._request("get", "me").json()
Currently, Sphinx autosummary generates a page for WebAPI and all its methods. Is it possible to have Sphinx include UserEndpoint's methods as users.<method> in WebAPI's documentation?
For example, a text mockup of the WebAPI documentation page might look like:
class minim.api.spotify.WebAPI(...)
Spotify Web API client.
Parameters:
...
Methods:
some_method | Do nothing.
users.get_me | ...
some_method(...) -> None
Do nothing.
Parameters:
...
users.get_me(...) -> dict[str, Any]
...
Parameters:
...