Skip to content

Commit

Permalink
Update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
EvieePy committed Jul 25, 2024
1 parent b33b202 commit 08a2571
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import re
import sys


sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath(".."))
sys.path.append(os.path.abspath("extensions"))
Expand Down
18 changes: 10 additions & 8 deletions docs/extensions/attributetable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import importlib
import inspect
import re
from typing import TYPE_CHECKING, Dict, List, NamedTuple, Optional, Sequence, Tuple
from collections.abc import Sequence
from typing import TYPE_CHECKING, NamedTuple

from docutils import nodes
from sphinx import addnodes
Expand All @@ -13,6 +14,7 @@
from sphinx.util.docutils import SphinxDirective
from sphinx.util.typing import OptionSpec


if TYPE_CHECKING:
from .builder import DPYHTML5Translator

Expand Down Expand Up @@ -96,7 +98,7 @@ class PyAttributeTable(SphinxDirective):
final_argument_whitespace = False
option_spec: OptionSpec = {}

def parse_name(self, content: str) -> Tuple[str, str]:
def parse_name(self, content: str) -> tuple[str, str]:
match = _name_parser_regex.match(content)
if match is None:
raise RuntimeError(f"content {content} somehow doesn't match regex in {self.env.docname}.")
Expand All @@ -112,7 +114,7 @@ def parse_name(self, content: str) -> Tuple[str, str]:

return modulename, name

def run(self) -> List[attributetableplaceholder]:
def run(self) -> list[attributetableplaceholder]:
"""If you're curious on the HTML this is meant to generate:
<div class="py-attribute-table">
Expand Down Expand Up @@ -149,7 +151,7 @@ def run(self) -> List[attributetableplaceholder]:
return [node]


def build_lookup_table(env: BuildEnvironment) -> Dict[str, List[str]]:
def build_lookup_table(env: BuildEnvironment) -> dict[str, list[str]]:
# Given an environment, load up a lookup table of
# full-class-name: objects
result = {}
Expand Down Expand Up @@ -178,7 +180,7 @@ def build_lookup_table(env: BuildEnvironment) -> Dict[str, List[str]]:
class TableElement(NamedTuple):
fullname: str
label: str
badge: Optional[attributetablebadge]
badge: attributetablebadge | None


def process_attributetable(app: Sphinx, doctree: nodes.Node, fromdocname: str) -> None:
Expand All @@ -203,12 +205,12 @@ def process_attributetable(app: Sphinx, doctree: nodes.Node, fromdocname: str) -


def get_class_results(
lookup: Dict[str, List[str]], modulename: str, name: str, fullname: str
) -> Dict[str, List[TableElement]]:
lookup: dict[str, list[str]], modulename: str, name: str, fullname: str
) -> dict[str, list[TableElement]]:
module = importlib.import_module(modulename)
cls = getattr(module, name)

groups: Dict[str, List[TableElement]] = {
groups: dict[str, list[TableElement]] = {
_("Attributes"): [],
_("Methods"): [],
}
Expand Down
25 changes: 25 additions & 0 deletions docs/wavelink.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ An event listener in a cog.
This event can be called many times throughout your bots lifetime, as it will be called when Wavelink successfully
reconnects to your node in the event of a disconnect.

.. function:: on_wavelink_node_disconnected(payload: wavelink.NodeDisconnectedEventPayload)

Called when a Node has disconnected/lost connection to wavelink. **This is NOT** the same as a node being closed.
This event will however be called directly before the :func:`on_wavelink_node_closed` event.

The default behaviour is for wavelink to attempt to reconnect a disconnected Node. This event can change that
behaviour. If you want to close this node completely see: :meth:`Node.close`

This event can be used to manage currrently connected players to this Node.
See: :meth:`Player.switch_node`

.. versionadded:: 3.5.0

.. function:: on_wavelink_stats_update(payload: wavelink.StatsEventPayload)

Called when the ``stats`` OP is received by Lavalink.
Expand Down Expand Up @@ -128,6 +141,11 @@ Types
tracks: wavelink.Search = await wavelink.Playable.search("Ocean Drive")
.. attributetable:: PlayerBasicState

.. autoclass:: PlayerBasicState



Payloads
---------
Expand All @@ -136,6 +154,11 @@ Payloads
.. autoclass:: NodeReadyEventPayload
:members:

.. attributetable:: NodeDisconnectedEventPayload

.. autoclass:: NodeDisconnectedEventPayload
:members:

.. attributetable:: TrackStartEventPayload

.. autoclass:: TrackStartEventPayload
Expand Down Expand Up @@ -442,6 +465,8 @@ Exceptions
Exception raised when a :class:`Node` is tried to be retrieved from the
:class:`Pool` without existing, or the ``Pool`` is empty.

This exception is also raised when providing an invalid node to :meth:`Player.switch_node`.

.. py:exception:: LavalinkException
Exception raised when Lavalink returns an invalid response.
Expand Down
2 changes: 2 additions & 0 deletions wavelink/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class AuthorizationFailedException(WavelinkException):
class InvalidNodeException(WavelinkException):
"""Exception raised when a :class:`Node` is tried to be retrieved from the
:class:`Pool` without existing, or the ``Pool`` is empty.
This exception is also raised when providing an invalid node to :meth:`~wavelink.Player.switch_node`.
"""


Expand Down

0 comments on commit 08a2571

Please sign in to comment.