Skip to content

Commit 68d2ad9

Browse files
committed
docs(docstrings): Add Returns/Raises sections for RST field list compliance
why: Sphinx/Napoleon requires proper field list structure to avoid "Field list ends without a blank line" warnings when processing NumPy-style docstrings. what: - Add Raises sections to EnvironmentMixin methods (common.py) - Add Returns sections to capture_pane, display_message, set_width, set_height (pane.py) - Fix attached_sessions Returns format (server.py) - Add Raises section to kill_window (session.py) - Add Returns/Raises sections to split, select_layout, move_window (window.py) - Standardize parameter descriptions (capitalize, add periods)
1 parent 62bc6a6 commit 68d2ad9

File tree

5 files changed

+91
-25
lines changed

5 files changed

+91
-25
lines changed

src/libtmux/common.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,14 @@ def set_environment(self, name: str, value: str) -> None:
6565
Parameters
6666
----------
6767
name : str
68-
the environment variable name. such as 'PATH'.
68+
The environment variable name, e.g. 'PATH'.
6969
value : str
70-
environment value.
70+
Environment value.
71+
72+
Raises
73+
------
74+
ValueError
75+
If tmux returns an error.
7176
"""
7277
args = ["set-environment"]
7378
if self._add_option:
@@ -92,7 +97,12 @@ def unset_environment(self, name: str) -> None:
9297
Parameters
9398
----------
9499
name : str
95-
the environment variable name. such as 'PATH'.
100+
The environment variable name, e.g. 'PATH'.
101+
102+
Raises
103+
------
104+
ValueError
105+
If tmux returns an error.
96106
"""
97107
args = ["set-environment"]
98108
if self._add_option:
@@ -116,7 +126,12 @@ def remove_environment(self, name: str) -> None:
116126
Parameters
117127
----------
118128
name : str
119-
the environment variable name. such as 'PATH'.
129+
The environment variable name, e.g. 'PATH'.
130+
131+
Raises
132+
------
133+
ValueError
134+
If tmux returns an error.
120135
"""
121136
args = ["set-environment"]
122137
if self._add_option:

src/libtmux/pane.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ def capture_pane(
341341
Negative numbers are lines in the history.
342342
``-`` is the end of the visible pane.
343343
Default: None
344+
345+
Returns
346+
-------
347+
str | list[str]
348+
Captured pane content.
344349
"""
345350
cmd = ["capture-pane", "-p"]
346351
if start is not None:
@@ -428,6 +433,11 @@ def display_message(
428433
get_text : bool, optional
429434
Returns only text without displaying a message in
430435
target-client status line.
436+
437+
Returns
438+
-------
439+
str | list[str] | None
440+
Message output if get_text is True, otherwise None.
431441
"""
432442
if get_text:
433443
return self.cmd("display-message", "-p", cmd).stdout
@@ -710,7 +720,12 @@ def set_width(self, width: int) -> Pane:
710720
Parameters
711721
----------
712722
width : int
713-
pane width, in cells
723+
Pane width, in cells.
724+
725+
Returns
726+
-------
727+
:class:`Pane`
728+
Self, for method chaining.
714729
"""
715730
self.resize_pane(width=width)
716731
return self
@@ -721,7 +736,12 @@ def set_height(self, height: int) -> Pane:
721736
Parameters
722737
----------
723738
height : int
724-
height of pain, in cells
739+
Pane height, in cells.
740+
741+
Returns
742+
-------
743+
:class:`Pane`
744+
Self, for method chaining.
725745
"""
726746
self.resize_pane(height=height)
727747
return self

src/libtmux/server.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def cmd(
313313

314314
@property
315315
def attached_sessions(self) -> list[Session]:
316-
"""Return active :class:`Session`s.
316+
"""Return active :class:`Session` instances.
317317
318318
Examples
319319
--------
@@ -322,7 +322,8 @@ def attached_sessions(self) -> list[Session]:
322322
323323
Returns
324324
-------
325-
list of :class:`Session`
325+
list[:class:`Session`]
326+
Sessions that are attached.
326327
"""
327328
return self.sessions.filter(session_attached__noeq="1")
328329

src/libtmux/session.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,12 @@ def kill_window(self, target_window: str | None = None) -> None:
578578
Parameters
579579
----------
580580
target_window : str, optional
581-
window to kill
581+
Window to kill.
582+
583+
Raises
584+
------
585+
:exc:`libtmux.exc.LibTmuxException`
586+
If tmux returns an error.
582587
"""
583588
if target_window:
584589
if isinstance(target_window, int):

src/libtmux/window.py

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -284,27 +284,32 @@ def split(
284284
Parameters
285285
----------
286286
attach : bool, optional
287-
make new window the current window after creating it, default
287+
Make new window the current window after creating it, default
288288
True.
289289
start_directory : str or PathLike, optional
290-
specifies the working directory in which the new window is created.
290+
Specifies the working directory in which the new window is created.
291291
direction : PaneDirection, optional
292-
split in direction. If none is specified, assume down.
293-
full_window_split: bool, optional
294-
split across full window width or height, rather than active pane.
295-
zoom: bool, optional
296-
expand pane
292+
Split in direction. If none is specified, assume down.
293+
full_window_split : bool, optional
294+
Split across full window width or height, rather than active pane.
295+
zoom : bool, optional
296+
Expand pane.
297297
shell : str, optional
298-
execute a command on splitting the window. The pane will close
298+
Execute a command on splitting the window. The pane will close
299299
when the command exits.
300300
301-
NOTE: When this command exits the pane will close. This feature
301+
NOTE: When this command exits the pane will close. This feature
302302
is useful for long-running processes where the closing of the
303303
window upon completion is desired.
304-
size: int, optional
304+
size : int, optional
305305
Cell/row or percentage to occupy with respect to current window.
306-
environment: dict, optional
306+
environment : dict, optional
307307
Environmental variables for new pane. Passthrough to ``-e``.
308+
309+
Returns
310+
-------
311+
:class:`Pane`
312+
The newly created pane.
308313
"""
309314
active_pane = self.active_pane or self.panes[0]
310315
return active_pane.split(
@@ -409,7 +414,7 @@ def select_layout(self, layout: str | None = None) -> Window:
409414
Parameters
410415
----------
411416
layout : str, optional
412-
string of the layout, 'even-horizontal', 'tiled', etc. Entering
417+
String of the layout, 'even-horizontal', 'tiled', etc. Entering
413418
None (leaving this blank) is same as ``select-layout`` with no
414419
layout. In recent tmux versions, it picks the most recently
415420
set layout.
@@ -430,7 +435,17 @@ def select_layout(self, layout: str | None = None) -> Window:
430435
Panes are spread out as evenly as possible over the window in
431436
both rows and columns.
432437
'custom'
433-
custom dimensions (see :term:`tmux(1)` manpages).
438+
Custom dimensions (see :term:`tmux(1)` manpages).
439+
440+
Returns
441+
-------
442+
:class:`Window`
443+
Self, for method chaining.
444+
445+
Raises
446+
------
447+
:exc:`libtmux.exc.LibTmuxException`
448+
If tmux returns an error.
434449
"""
435450
cmd = ["select-layout"]
436451

@@ -539,11 +554,21 @@ def move_window(
539554
Parameters
540555
----------
541556
destination : str, optional
542-
the ``target window`` or index to move the window to, default:
543-
empty string
557+
The ``target window`` or index to move the window to, default:
558+
empty string.
544559
session : str, optional
545-
the ``target session`` or index to move the window to, default:
560+
The ``target session`` or index to move the window to, default:
546561
current session.
562+
563+
Returns
564+
-------
565+
:class:`Window`
566+
Self, for method chaining.
567+
568+
Raises
569+
------
570+
:exc:`libtmux.exc.LibTmuxException`
571+
If tmux returns an error.
547572
"""
548573
session = session or self.session_id
549574
proc = self.cmd(

0 commit comments

Comments
 (0)