From e2abc95e8d149ac2d71f0baacf821de5b3d394bf Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 6 Feb 2024 06:48:59 -0600 Subject: [PATCH 01/16] docs(window,session): Remove inaccurate docstring comment --- src/libtmux/session.py | 3 --- src/libtmux/window.py | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/libtmux/session.py b/src/libtmux/session.py index 1b0969b21..d0487f87e 100644 --- a/src/libtmux/session.py +++ b/src/libtmux/session.py @@ -228,9 +228,6 @@ def show_options( """ Return a dict of options for the window. - For familiarity with tmux, the option ``option`` param forwards to pick - a single option, forwarding to :meth:`Session.show_option`. - Parameters ---------- _global : bool, optional diff --git a/src/libtmux/window.py b/src/libtmux/window.py index 2d19eabc6..0e1c6e50e 100644 --- a/src/libtmux/window.py +++ b/src/libtmux/window.py @@ -366,9 +366,6 @@ def show_window_options(self, g: t.Optional[bool] = False) -> "WindowOptionDict" """ Return a dict of options for the window. - For familiarity with tmux, the option ``option`` param forwards to - pick a single option, forwarding to :meth:`Window.show_window_option`. - .. versionchanged:: 0.13.0 ``option`` removed, use show_window_option to return an individual option. From c8c01b021b556afd1e5706c6578b7123ac48fb61 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 6 Feb 2024 06:40:26 -0600 Subject: [PATCH 02/16] chore: set_(window_)option: Fix docstring --- src/libtmux/session.py | 2 +- src/libtmux/window.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libtmux/session.py b/src/libtmux/session.py index d0487f87e..b20c00f60 100644 --- a/src/libtmux/session.py +++ b/src/libtmux/session.py @@ -264,7 +264,7 @@ def show_options( def show_option( self, option: str, _global: bool = False ) -> t.Optional[t.Union[str, int, bool]]: - """Return a list of options for the window. + """Return option value for the target session. Parameters ---------- diff --git a/src/libtmux/window.py b/src/libtmux/window.py index 0e1c6e50e..55a46eccf 100644 --- a/src/libtmux/window.py +++ b/src/libtmux/window.py @@ -404,7 +404,7 @@ def show_window_option( self, option: str, g: bool = False ) -> t.Optional[t.Union[str, int]]: """ - Return a list of options for the window. + Return option value for the target window. todo: test and return True/False for on/off string From f17f188dc4e8366b45382bdfae2529fb00d110b6 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 6 Feb 2024 06:53:30 -0600 Subject: [PATCH 03/16] docs(Pane): Tighten docstrings --- src/libtmux/pane.py | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/libtmux/pane.py b/src/libtmux/pane.py index c3c49a4f3..b73d01948 100644 --- a/src/libtmux/pane.py +++ b/src/libtmux/pane.py @@ -27,8 +27,7 @@ @dataclasses.dataclass() class Pane(Obj): - """ - A :term:`tmux(1)` :term:`Pane` [pane_manual]_. + """:term:`tmux(1)` :term:`Pane` [pane_manual]_. ``Pane`` instances can send commands directly to a pane, or traverse between linked tmux objects. @@ -107,7 +106,7 @@ def session(self) -> "Session": """ def cmd(self, cmd: str, *args: t.Any, **kwargs: t.Any) -> tmux_cmd: - """Return :meth:`Server.cmd` defaulting to ``target_pane`` as target. + """Execute tmux subcommand against target pane. See also: :meth:`Server.cmd`. Send command to tmux with :attr:`pane_id` as ``target-pane``. @@ -124,8 +123,7 @@ def cmd(self, cmd: str, *args: t.Any, **kwargs: t.Any) -> tmux_cmd: """ def resize_pane(self, *args: t.Any, **kwargs: t.Any) -> "Pane": - """ - ``$ tmux resize-pane`` of pane and return ``self``. + """Resize tmux pane. Parameters ---------- @@ -161,8 +159,7 @@ def capture_pane( start: t.Union["t.Literal['-']", t.Optional[int]] = None, end: t.Union["t.Literal['-']", t.Optional[int]] = None, ) -> t.Union[str, t.List[str]]: - """ - Capture text from pane. + """Capture text from pane. ``$ tmux capture-pane`` to pane. ``$ tmux capture-pane -S -10`` to pane. @@ -259,8 +256,7 @@ def display_message(self, cmd: str, get_text: "t.Literal[False]") -> None: def display_message( self, cmd: str, get_text: bool = False ) -> t.Optional[t.Union[str, t.List[str]]]: - """ - ``$ tmux display-message`` to the pane. + """Display message to pane. Displays a message in target-client status line. @@ -286,8 +282,7 @@ def display_message( """ def select_pane(self) -> "Pane": - """ - Select pane. Return ``self``. + """Select pane. To select a window object asynchrously. If a ``pane`` object exists and is no longer longer the current window, ``w.select_pane()`` @@ -306,8 +301,7 @@ def split_window( start_directory: t.Optional[str] = None, percent: t.Optional[int] = None, ) -> "Pane": # New Pane, not self - """ - Split window at pane and return newly created :class:`Pane`. + """Split window at pane and return newly created :class:`Pane`. Parameters ---------- @@ -333,8 +327,7 @@ def split_window( """ def set_width(self, width: int) -> "Pane": - """ - Set width of pane. + """Set pane width. Parameters ---------- @@ -345,8 +338,7 @@ def set_width(self, width: int) -> "Pane": return self def set_height(self, height: int) -> "Pane": - """ - Set height of pane. + """Set pane height. Parameters ---------- @@ -357,8 +349,7 @@ def set_height(self, height: int) -> "Pane": return self def enter(self) -> "Pane": - """ - Send carriage return to pane. + """Send carriage return to pane. ``$ tmux send-keys`` send Enter to the pane. """ From 147132200f45b6286c055548d8063df035e2e7a6 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 6 Feb 2024 06:57:35 -0600 Subject: [PATCH 04/16] docs(Window): Tighten and correct docstrings --- src/libtmux/window.py | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/libtmux/window.py b/src/libtmux/window.py index 55a46eccf..79ce0abab 100644 --- a/src/libtmux/window.py +++ b/src/libtmux/window.py @@ -29,8 +29,7 @@ @dataclasses.dataclass() class Window(Obj): - """ - A :term:`tmux(1)` :term:`Window` [window_manual]_. + """:term:`tmux(1)` :term:`Window` [window_manual]_. Holds :class:`Pane` objects. @@ -110,7 +109,7 @@ def session(self) -> "Session": @property def panes(self) -> QueryList["Pane"]: # type: ignore - """Panes belonging windows. + """Panes contained by window. Can be accessed via :meth:`.panes.get() ` and @@ -133,7 +132,7 @@ def panes(self) -> QueryList["Pane"]: # type: ignore """ def cmd(self, cmd: str, *args: t.Any, **kwargs: t.Any) -> tmux_cmd: - """Return :meth:`Server.cmd` defaulting to ``target_window`` as target. + """Execute tmux subcommand against target window. See :meth:`Server.cmd`. Send command to tmux with :attr:`window_id` as ``target-window``. @@ -150,8 +149,9 @@ def cmd(self, cmd: str, *args: t.Any, **kwargs: t.Any) -> tmux_cmd: """ def select_pane(self, target_pane: t.Union[str, int]) -> t.Optional["Pane"]: - """ - Return selected :class:`Pane` through ``$ tmux select-pane``. + """Select pane and return selected :class:`Pane`. + + ``$ tmux select-pane``. Parameters ---------- @@ -182,8 +182,7 @@ def split_window( percent: t.Optional[int] = None, environment: t.Optional[t.Dict[str, str]] = None, ) -> "Pane": - """ - Split window and return the created :class:`Pane`. + """Split window and return the created :class:`Pane`. Used for splitting window and holding in a python object. @@ -363,8 +362,7 @@ def set_window_option(self, option: str, value: t.Union[int, str]) -> "Window": return self def show_window_options(self, g: t.Optional[bool] = False) -> "WindowOptionDict": - """ - Return a dict of options for the window. + """Return dict of options for window. .. versionchanged:: 0.13.0 @@ -403,8 +401,7 @@ def show_window_options(self, g: t.Optional[bool] = False) -> "WindowOptionDict" def show_window_option( self, option: str, g: bool = False ) -> t.Optional[t.Union[str, int]]: - """ - Return option value for the target window. + """Return option value for the target window. todo: test and return True/False for on/off string @@ -445,8 +442,7 @@ def show_window_option( return value def rename_window(self, new_name: str) -> "Window": - """ - Return :class:`Window` object ``$ tmux rename-window ``. + """Rename window. Parameters ---------- @@ -492,8 +488,7 @@ def kill_window(self) -> None: def move_window( self, destination: str = "", session: t.Optional[str] = None ) -> "Window": - """ - Move the current :class:`Window` object ``$ tmux move-window``. + """Move current :class:`Window` object ``$ tmux move-window``. Parameters ---------- @@ -525,8 +520,7 @@ def move_window( # Climbers # def select_window(self) -> "Window": - """ - Select window. Return ``self``. + """Select window. To select a window object asynchrously. If a ``window`` object exists and is no longer longer the current window, ``w.select_window()`` @@ -540,7 +534,7 @@ def select_window(self) -> "Window": # @property def attached_pane(self) -> t.Optional["Pane"]: - """Return the attached :class:`Pane`.""" + """Return attached :class:`Pane`.""" for pane in self.panes: if pane.pane_active == "1": return pane From b514bb41ca7116ee78266d7e3cdfbd9778b0ced2 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 6 Feb 2024 07:03:11 -0600 Subject: [PATCH 05/16] docs(Session): Tighten and correct docstrings --- src/libtmux/session.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/libtmux/session.py b/src/libtmux/session.py index b20c00f60..78e579689 100644 --- a/src/libtmux/session.py +++ b/src/libtmux/session.py @@ -36,8 +36,7 @@ @dataclasses.dataclass() class Session(Obj, EnvironmentMixin): - """ - A :term:`tmux(1)` :term:`Session` [session_manual]_. + """:term:`tmux(1)` :term:`Session` [session_manual]_. Holds :class:`Window` objects. @@ -97,7 +96,7 @@ def from_session_id(cls, server: "Server", session_id: str) -> "Session": # @property def windows(self) -> QueryList["Window"]: # type:ignore - """Windows belonging session. + """Windows contained by session. Can be accessed via :meth:`.windows.get() ` and @@ -117,7 +116,7 @@ def windows(self) -> QueryList["Window"]: # type:ignore @property def panes(self) -> QueryList["Pane"]: # type:ignore - """Panes belonging session. + """Panes contained by session's windows. Can be accessed via :meth:`.panes.get() ` and @@ -139,8 +138,7 @@ def panes(self) -> QueryList["Pane"]: # type:ignore # Command # def cmd(self, *args: t.Any, **kwargs: t.Any) -> tmux_cmd: - """ - Return :meth:`server.cmd`. + """Execute tmux subcommand against target session. See :meth:`server.cmd`. Returns ------- @@ -173,8 +171,7 @@ def cmd(self, *args: t.Any, **kwargs: t.Any) -> tmux_cmd: def set_option( self, option: str, value: t.Union[str, int], _global: bool = False ) -> "Session": - """ - Set option ``$ tmux set-option