Skip to content

Commit

Permalink
docs: add detailed docstrings to properties of Item (#2683)
Browse files Browse the repository at this point in the history
Enhance Item Class with Detailed Docstrings for Properties and Methods.

Signed-off-by: Error44 <hello@error44.tech>
  • Loading branch information
Error44s authored Dec 29, 2024
1 parent b4b2bdb commit 6937df6
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion discord/ui/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ def __repr__(self) -> str:

@property
def row(self) -> int | None:
"""Gets or sets the row position of this item within its parent view.
The row position determines the vertical placement of the item in the UI.
The value must be an integer between 0 and 4 (inclusive), or ``None`` to indicate
that no specific row is set.
Returns
-------
Optional[:class:`int`]
The row position of the item, or ``None`` if not explicitly set.
Raises
------
ValueError
If the row value is not ``None`` and is outside the range [0, 4].
"""
return self._row

@row.setter
Expand All @@ -110,11 +126,29 @@ def row(self, value: int | None):

@property
def width(self) -> int:
"""Gets the width of the item in the UI layout.
The width determines how much horizontal space this item occupies within its row.
Returns
-------
:class:`int`
The width of the item. Defaults to 1.
"""
return 1

@property
def view(self) -> V | None:
"""The underlying view for this item."""
"""Gets the parent view associated with this item.
The view refers to the container that holds this item. This is typically set
automatically when the item is added to a view.
Returns
-------
Optional[:class:`View`]
The parent view of this item, or ``None`` if the item is not attached to any view.
"""
return self._view

async def callback(self, interaction: Interaction):
Expand Down

0 comments on commit 6937df6

Please sign in to comment.