diff --git a/docs/conf.py b/docs/conf.py index 382ca03..f7262a7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,12 +20,20 @@ # ones. extensions = [ "myst_nb", + "sphinx.ext.autodoc", "autoapi.extension", "sphinx.ext.napoleon", "sphinx.ext.viewcode", ] +autodoc_typehints = "both" autoapi_dirs = ["../masterblaster"] - +autoapi_options = [ + "members", + "undoc-members", + "show-inheritance", + "show-module-summary", + "imported-members", +] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. @@ -36,4 +44,12 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = "sphinx_rtd_theme" +html_theme = "pydata_sphinx_theme" + +html_sidebars = {"": ["list", "of", "templates"]} +html_theme_options = { + "navbar_start": ["navbar-logo"], + "navbar_center": ["navbar-nav"], + "navbar_end": ["navbar-icon-links"], + "navbar_persistent": ["search-button"], +} diff --git a/masterblaster/gameaccount.py b/masterblaster/gameaccount.py index d3eaf0c..9bb599b 100644 --- a/masterblaster/gameaccount.py +++ b/masterblaster/gameaccount.py @@ -5,8 +5,32 @@ if TYPE_CHECKING: from _typeshed import SupportsRead +__all__ = [ + "GameAccount", +] + class GameAccount: + """ + Class for GameAccount objects, related to one player + + Supported games: ["Counter-Strike", "Rocket League", "Chess"] + + :param id: The gameaccount id + :param nick: The gameaccount nickname + :param avatarUrl: The gameaccount avatar url + :param gameId: The game id + :param isConnected: Whether or not the gameaccount is connected + :param connectedAt: When the gameaccount was connected + + :ivar id: The gameaccount id + :ivar nick: The gameaccount nickname + :ivar avatar_url: The gameaccount avatar url + :ivar gameId: The game id + :ivar isConnected: Whether or not the gameaccount is connected + :ivar connectedAt: When the gameaccount was connected + """ + def __init__( self, id: str, diff --git a/masterblaster/headers.py b/masterblaster/headers.py index df38431..60cd679 100644 --- a/masterblaster/headers.py +++ b/masterblaster/headers.py @@ -4,7 +4,18 @@ from typing import Any, Iterator +__all__ = [ + "Header", +] + + class Header(abc.MutableMapping): + """ + Wrapper for http header-fields + + :ivar fields: The header fields + """ + def __init__(self) -> None: self.fields: dict[str, Any] = {} diff --git a/masterblaster/image.py b/masterblaster/image.py index 5c300c0..1391529 100644 --- a/masterblaster/image.py +++ b/masterblaster/image.py @@ -1,4 +1,16 @@ class Image: + """ + MasterBlaster Image Object + + :param imageType: The type of image + :param imageId: The id of the image + :param originalImageId: The id of the original image + + :ivar type: The type of image + :ivar id: The id of the image + :ivar original_id: The id of the original image + """ + def __init__(self, imageType: int, imageId: str, originalImageId: str) -> None: self.type: int = imageType self.id: str = imageId diff --git a/masterblaster/masterblaster.py b/masterblaster/masterblaster.py index 7d354f3..e2fb3fc 100644 --- a/masterblaster/masterblaster.py +++ b/masterblaster/masterblaster.py @@ -6,8 +6,28 @@ BASE = "https://app.masterblaster.gg/api" +__all__ = [ + "MasterBlaster", +] + class MasterBlaster: + """ + MasterBlaster is the main class for interacting with the MasterBlaster API + + :param access_token: The access token for the organization + :param org_name: The name of the organization + + :ivar id: The id of the organization + :ivar name: The name of the organization + :ivar is_admin: Whether or not the current token is an admin for the organization + :ivar access_token: The access token for the organization + :ivar members: A list of all members in the organization + :ivar images: A list of all images in the organization + :ivar headers: The headers used for the session + + """ + def __init__(self, access_token: Optional[str], org_name: str) -> None: self.id: str = "" self.name: str = org_name @@ -19,10 +39,16 @@ def __init__(self, access_token: Optional[str], org_name: str) -> None: self._session: aiohttp.ClientSession | None = None async def __aenter__(self) -> "MasterBlaster": + """ + :meta private: + """ await self._setup(self.name) return self async def __aexit__(self, exc_type, exc_value, traceback) -> None: + """ + :meta private: + """ await self._session.close() async def teardown(self) -> None: @@ -42,7 +68,7 @@ async def teardown(self) -> None: @classmethod async def create(cls, access_token: str, org_name: str) -> "MasterBlaster": """ - Create a new MasterBlaster instance + Create a new fully setup MasterBlaster instance Parameters ---------- @@ -54,13 +80,15 @@ async def create(cls, access_token: str, org_name: str) -> "MasterBlaster": Returns ------- MasterBlaster - A new MasterBlaster instance """ self = cls(access_token, org_name) await self._setup(org_name) return self async def _setup(self, org_name: str) -> "MasterBlaster": + """ + :meta private: + """ if not self._session.closed: await self._session.close() self.name = org_name @@ -139,6 +167,9 @@ async def change_org(self, org_name: str) -> None: await self._setup(org_name) async def _set_org_id(self, org_name: str) -> None: + """ + :meta private: + """ orgs = await self.get_all_orgs() for org in orgs: # Parse out the one we want @@ -151,14 +182,23 @@ async def _set_org_id(self, org_name: str) -> None: raise Exception(f"Organization '{org_name}' not found for current token") async def _set_org_members(self) -> None: + """ + :meta private: + """ org_info = await self.get_org(self.id) self.members = [Member(**member) for member in org_info["members"]] async def _set_org_images(self) -> None: + """ + :meta private: + """ org_info = await self.get_org(self.id) self.images = [Image(**image) for image in org_info["images"]] async def _update_members(self) -> None: + """ + :meta private: + """ members = await self.get_org(self.id) self.members = [Member(**member) for member in members["members"]] @@ -179,6 +219,9 @@ async def get_members(self) -> list[Member]: return self.members async def _update_images(self) -> None: + """ + :meta private: + """ images = await self.get_org(self.id) self.images = [Image(**image) for image in images["images"]] diff --git a/masterblaster/member.py b/masterblaster/member.py index 13c66fc..1d6058a 100644 --- a/masterblaster/member.py +++ b/masterblaster/member.py @@ -8,8 +8,32 @@ if TYPE_CHECKING: from _typeshed import SupportsRead +__all__ = [ + "Member", +] + class Member: + """ + Class for organization members + + :param player: The player object + :param email: The member email + :param name: The member name + :param playerId: The player id + :param role: The member role + :param addedAt: When the member was added + :param invitedAt: When the member was invited + + :ivar player: The member's related player object + :ivar email: The member's email-address + :ivar name: The member's name + :ivar player_id: The member's player id + :ivar role: The member's role + :ivar added_at: When the member was added + :ivar invited_at: When the member was invited + """ + def __init__( self, player: dict, diff --git a/masterblaster/player.py b/masterblaster/player.py index 1a11f7a..e3575aa 100644 --- a/masterblaster/player.py +++ b/masterblaster/player.py @@ -2,8 +2,23 @@ from dateutil import parser from .gameaccount import GameAccount +__all__ = [ + "Player", +] + class Player: + """ + Class for Player objects, related to zero or more gameaccounts + + :param id: The masterblaster id of the player + :param nickName: The internal nickname of the player + :param avatarUrl: The avatar url of the player + :param registered: When the player was registered + :param isProfileComplete: Whether or not the player has completed their profile + :param gameAccounts: List of gameaccounts related to the player + """ + def __init__( self, id: str, diff --git a/poetry.lock b/poetry.lock index 654e4ca..733966d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,5 +1,19 @@ # This file is automatically @generated by Poetry 1.5.0 and should not be changed by hand. +[[package]] +name = "accessible-pygments" +version = "0.0.4" +description = "A collection of accessible pygments styles" +optional = false +python-versions = "*" +files = [ + {file = "accessible-pygments-0.0.4.tar.gz", hash = "sha256:e7b57a9b15958e9601c7e9eb07a440c813283545a20973f2574a5f453d0e953e"}, + {file = "accessible_pygments-0.0.4-py2.py3-none-any.whl", hash = "sha256:416c6d8c1ea1c5ad8701903a20fcedf953c6e720d64f33dc47bfb2d3f2fa4e8d"}, +] + +[package.dependencies] +pygments = ">=1.5" + [[package]] name = "aiohttp" version = "3.8.5" @@ -1455,28 +1469,28 @@ files = [ [[package]] name = "jupyterlab-server" -version = "2.24.0" +version = "2.25.0" description = "A set of server components for JupyterLab and JupyterLab like applications." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "jupyterlab_server-2.24.0-py3-none-any.whl", hash = "sha256:5f077e142bb8dc9b843d960f940c513581bceca3793a0d80f9c67d9522c4e876"}, - {file = "jupyterlab_server-2.24.0.tar.gz", hash = "sha256:4e6f99e0a5579bbbc32e449c4dbb039561d4f1a7827d5733273ed56738f21f07"}, + {file = "jupyterlab_server-2.25.0-py3-none-any.whl", hash = "sha256:c9f67a98b295c5dee87f41551b0558374e45d449f3edca153dd722140630dcb2"}, + {file = "jupyterlab_server-2.25.0.tar.gz", hash = "sha256:77c2f1f282d610f95e496e20d5bf1d2a7706826dfb7b18f3378ae2870d272fb7"}, ] [package.dependencies] babel = ">=2.10" jinja2 = ">=3.0.3" json5 = ">=0.9.0" -jsonschema = ">=4.17.3" +jsonschema = ">=4.18.0" jupyter-server = ">=1.21,<3" packaging = ">=21.3" -requests = ">=2.28" +requests = ">=2.31" [package.extras] docs = ["autodoc-traits", "jinja2 (<3.2.0)", "mistune (<4)", "myst-parser", "pydata-sphinx-theme", "sphinx", "sphinx-copybutton", "sphinxcontrib-openapi (>0.8)"] -openapi = ["openapi-core (>=0.16.1,<0.17.0)", "ruamel-yaml"] -test = ["hatch", "ipykernel", "jupyterlab-server[openapi]", "openapi-spec-validator (>=0.5.1,<0.7.0)", "pytest (>=7.0)", "pytest-console-scripts", "pytest-cov", "pytest-jupyter[server] (>=0.6.2)", "pytest-timeout", "requests-mock", "sphinxcontrib-spelling", "strict-rfc3339", "werkzeug"] +openapi = ["openapi-core (>=0.18.0,<0.19.0)", "ruamel-yaml"] +test = ["hatch", "ipykernel", "openapi-core (>=0.18.0,<0.19.0)", "openapi-spec-validator (>=0.6.0,<0.7.0)", "pytest (>=7.0)", "pytest-console-scripts", "pytest-cov", "pytest-jupyter[server] (>=0.6.2)", "pytest-timeout", "requests-mock", "ruamel-yaml", "sphinxcontrib-spelling", "strict-rfc3339", "werkzeug"] [[package]] name = "jupyterlab-widgets" @@ -2143,6 +2157,32 @@ files = [ {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, ] +[[package]] +name = "pydata-sphinx-theme" +version = "0.13.3" +description = "Bootstrap-based Sphinx theme from the PyData community" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pydata_sphinx_theme-0.13.3-py3-none-any.whl", hash = "sha256:bf41ca6c1c6216e929e28834e404bfc90e080b51915bbe7563b5e6fda70354f0"}, + {file = "pydata_sphinx_theme-0.13.3.tar.gz", hash = "sha256:827f16b065c4fd97e847c11c108bf632b7f2ff53a3bca3272f63f3f3ff782ecc"}, +] + +[package.dependencies] +accessible-pygments = "*" +Babel = "*" +beautifulsoup4 = "*" +docutils = "!=0.17.0" +packaging = "*" +pygments = ">=2.7" +sphinx = ">=4.2" +typing-extensions = "*" + +[package.extras] +dev = ["nox", "pre-commit", "pydata-sphinx-theme[doc,test]", "pyyaml"] +doc = ["ablog (>=0.11.0rc2)", "colorama", "ipyleaflet", "jupyter_sphinx", "linkify-it-py", "matplotlib", "myst-nb", "nbsphinx", "numpy", "numpydoc", "pandas", "plotly", "rich", "sphinx-copybutton", "sphinx-design", "sphinx-favicon (>=1.0.1)", "sphinx-sitemap", "sphinx-togglebutton", "sphinxcontrib-youtube", "sphinxext-rediraffe", "xarray"] +test = ["codecov", "pytest", "pytest-cov", "pytest-regressions"] + [[package]] name = "pygments" version = "2.16.1" @@ -3377,4 +3417,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "8927a73b3f257100ba3f21974949ee67f9fc558b26153c73a0f50ffa81bc7506" +content-hash = "b7d6baf9ca57b9f476aca1a2249673fc27db7060d3776d3b5af7cda489f2f4c7" diff --git a/pyproject.toml b/pyproject.toml index 37a814b..60f45b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,3 +31,4 @@ jupyter = "^1.0.0" sphinx-autoapi = "^2.1.1" sphinx-rtd-theme = "^1.3.0" myst-nb = "^0.17.2" +pydata-sphinx-theme = "^0.13.3"