Skip to content

Commit

Permalink
docs(window): Fill in more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Nov 25, 2023
1 parent 376ab14 commit c5dcc70
Showing 1 changed file with 42 additions and 5 deletions.
47 changes: 42 additions & 5 deletions src/libtmux/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,22 +626,48 @@ def width(self) -> t.Optional[str]:
# Legacy: Redundant stuff we want to remove
#
def get(self, key: str, default: t.Optional[t.Any] = None) -> t.Any:
""".. deprecated:: 0.16."""
"""Return key-based lookup. Deprecated by attributes.
.. deprecated:: 0.16.
Deprecated by attribute lookup.e.g. ``window['window_name']`` is now
accessed via ``window.window_name``.
"""
warnings.warn("Window.get() is deprecated", stacklevel=2)
return getattr(self, key, default)

def __getitem__(self, key: str) -> t.Any:
""".. deprecated:: 0.16."""
"""Return item lookup by key. Deprecated in favor of attributes.
.. deprecated:: 0.16
Deprecated in favor of attributes. e.g. ``window['window_name']`` is now
accessed via ``window.window_name``.
"""
warnings.warn(f"Item lookups, e.g. window['{key}'] is deprecated", stacklevel=2)
return getattr(self, key)

def get_by_id(self, id: str) -> t.Optional[Pane]:
""".. deprecated:: 0.16."""
"""Return pane by id. Deprecated in favor of :meth:`.panes.get()`.
.. deprecated:: 0.16.
Deprecated by :meth:`.panes.get()`.
"""
warnings.warn("Window.get_by_id() is deprecated", stacklevel=2)
return self.panes.get(pane_id=id, default=None)

def where(self, kwargs: t.Dict[str, t.Any]) -> t.List[Pane]:
""".. deprecated:: 0.16."""
"""Filter through panes, return list of :class:`Pane`.
.. deprecated:: 0.16
Deprecated by :meth:`.panes.filter()`.
"""
warnings.warn("Window.where() is deprecated", stacklevel=2)
try:
return self.panes.filter(**kwargs)
Expand All @@ -654,7 +680,12 @@ def find_where(self, kwargs: t.Dict[str, t.Any]) -> t.Optional[Pane]:
return self.panes.get(default=None, **kwargs)

def _list_panes(self) -> t.List[PaneDict]:
""".. deprecated:: 0.16."""
"""Return list of panes (deprecated in favor of :meth:`.panes`).
.. deprecated:: 0.16.
Slated to be removed in favor of :meth:`.panes`.
"""
warnings.warn("Window._list_panes() is deprecated", stacklevel=2)
return [pane.__dict__ for pane in self.panes]

Expand All @@ -663,6 +694,8 @@ def _panes(self) -> t.List[PaneDict]:
"""Property / alias to return :meth:`~._list_panes`.
.. deprecated:: 0.16
Slated to be removed in favor of :meth:`.panes`.
"""
warnings.warn("_panes is deprecated", stacklevel=2)
return self._list_panes()
Expand All @@ -671,6 +704,8 @@ def list_panes(self) -> t.List["Pane"]:
"""Return list of :class:`Pane` for the window.
.. deprecated:: 0.16
Slated to be removed in favor of :meth:`.panes`.
"""
warnings.warn("list_panes() is deprecated", stacklevel=2)
return self.panes
Expand All @@ -680,6 +715,8 @@ def children(self) -> QueryList["Pane"]: # type:ignore
"""Was used by TmuxRelationalObject (but that's longer used in this class).
.. deprecated:: 0.16
Slated to be removed in favor of :meth:`.panes`.
"""
warnings.warn("Server.children is deprecated", stacklevel=2)
return self.panes

0 comments on commit c5dcc70

Please sign in to comment.