Skip to content

Commit 65e9bcc

Browse files
committed
doc api updates for Window
1 parent a39fe45 commit 65e9bcc

File tree

1 file changed

+37
-55
lines changed

1 file changed

+37
-55
lines changed

tmuxp/window.py

Lines changed: 37 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ def tmux(self, cmd, *args, **kwargs):
8585
return self.server.tmux(cmd, *args, **kwargs)
8686

8787
def select_layout(self, layout=None):
88-
'''
89-
wrapper for ``tmux(1)``.
90-
91-
.. code-block: bash
92-
93-
$ tmux select-layout <layout>
88+
"""Wrapper for ``$ tmux select-layout <layout>``.
9489
9590
even-horizontal: Panes are spread out evenly from left to right across
9691
the window.
@@ -111,8 +106,8 @@ def select_layout(self, layout=None):
111106
112107
:param layout: string of the layout, 'even-horizontal', 'tiled', etc.
113108
:type layout: string
114-
'''
115109
110+
"""
116111

117112
proc = self.tmux(
118113
'select-layout',
@@ -123,21 +118,13 @@ def select_layout(self, layout=None):
123118
if proc.stderr:
124119
raise Exception(proc.stderr)
125120

126-
@property
127-
def target(self):
128-
return "%s:%s" % (self.session.get('session_id'), self.get('window_id'))
129-
130121
def set_window_option(self, option, value):
131-
'''
132-
wrapper for ``tmux(1)``.
133-
134-
.. code-block: bash
135-
136-
$ tmux set-window-option <option> <value>
122+
"""Wrapper for ``$ tmux set-window-option <option> <value>``.
137123
138124
:param value: window value. True/False will turn in 'on' and 'off'.
139125
:type value: string or bool
140-
'''
126+
127+
"""
141128

142129
self.server._update_windows()
143130

@@ -153,27 +140,30 @@ def set_window_option(self, option, value):
153140
option, value
154141
)
155142

156-
# tmuxp set-window-option version 1.8 has a quirk where
157-
# -t@2 window id won't work as ``target-pane``.
158-
159143
if process.stderr:
160144
if isinstance(process.stderr, list) and len(process.stderr) == int(1):
161145
process.stderr = process.stderr[0]
162146
raise ValueError(
163-
'tmux set-window-option -t%s:%s %s %s\n' % (self.get('session_id'), self.get('window_index'), option, value) +
164-
process.stderr)
147+
'tmux set-window-option -t%s:%s %s %s\n' % (
148+
self.get('session_id'),
149+
self.get('window_index'),
150+
option,
151+
value
152+
) +
153+
process.stderr
154+
)
165155

166156
def show_window_options(self, option=None):
167-
'''
168-
return a dict of options for the window.
157+
"""Return a dict of options for the window.
169158
170159
For familiarity with tmux, the option ``option`` param forwards to pick
171160
a single option, forwarding to :meth:`Window.show_window_option`.
172161
173162
:param option: optional. show a single option.
174163
:type option: string
175164
:rtype: :py:obj:`dict`
176-
'''
165+
166+
"""
177167

178168
if option:
179169
return self.show_window_option(option)
@@ -193,15 +183,15 @@ def show_window_options(self, option=None):
193183
return window_options
194184

195185
def show_window_option(self, option):
196-
'''
197-
return a list of options for the window
186+
"""Return a list of options for the window.
198187
199188
todo: test and return True/False for on/off string
200189
201190
:param option: option to return.
202191
:type option: string
203192
:rtype: string, int
204-
'''
193+
194+
"""
205195

206196
window_option = self.tmux(
207197
'show-window-options', option
@@ -219,20 +209,19 @@ def show_window_option(self, option):
219209
return window_option[1]
220210

221211
def rename_window(self, new_name):
222-
'''rename window and return new window object::
223212

224-
$ tmux rename-window <new_name>
213+
"""Return :class:`Window` object ``$ tmux rename-window <new_name>``.
225214
226215
:param new_name: name of the window
227216
:type new_name: string
228-
'''
217+
218+
"""
229219
# new_name = pipes.quote(new_name)
230220

231221
import shlex
232222
lex = shlex.shlex(new_name)
233223
lex.escape = ' '
234224
lex.whitespace_split = False
235-
# new_name = '\ '.join(new_name.split())
236225

237226
try:
238227
self.tmux(
@@ -248,12 +237,7 @@ def rename_window(self, new_name):
248237
return self
249238

250239
def kill_window(self):
251-
'''
252-
``$ tmux kill-window``
253-
254-
Kill the current :class:`Window` object.
255-
256-
'''
240+
"""Kill the current :class:`Window` object. ``$ tmux kill-window``."""
257241

258242
proc = self.tmux(
259243
'kill-window',
@@ -267,15 +251,13 @@ def kill_window(self):
267251
self.server._update_windows()
268252

269253
def move_window(self, destination):
270-
'''
271-
``$ tmux move-window``
272-
273-
move the current :class:`Window` object.
254+
"""Move the current :class:`Window` object ``$ tmux move-window``.
274255
275256
:param destination: the ``target window`` or index to move the window
276257
to.
277258
:type target_window: string
278-
'''
259+
260+
"""
279261

280262
proc = self.tmux(
281263
'move-window',
@@ -289,15 +271,14 @@ def move_window(self, destination):
289271
self.server._update_windows()
290272

291273
def select_pane(self, target_pane):
292-
'''
293-
``$ tmux select-pane``
274+
"""Return selected :class:`Pane` through ``$ tmux select-pane``.
294275
295276
:param target_pane: ``target_pane``, or ``-U``,``-D``, ``-L``, ``-R``
296277
or ``-l``.
297278
:type target_pane: string
298279
:rtype: :class:`Pane`
299280
300-
'''
281+
"""
301282

302283
if target_pane in ['-l', '-U', '-D', '-L', '-R']:
303284
proc = self.tmux('select-pane', '-t%s' % self.get('window_id'), target_pane)
@@ -310,8 +291,7 @@ def select_pane(self, target_pane):
310291
return self.attached_pane()
311292

312293
def split_window(self, attach=True):
313-
'''
314-
Splits window. Returns the created :class:`Pane`.
294+
"""Split window and return the created :class:`Pane`.
315295
316296
.. note::
317297
@@ -332,7 +312,8 @@ def split_window(self, attach=True):
332312
:param type: bool
333313
334314
:rtype: :class:`Pane`
335-
'''
315+
316+
"""
336317

337318
pformats = ['session_name', 'session_id',
338319
'window_index', 'window_id'] + formats.PANE_FORMATS
@@ -372,11 +353,11 @@ def split_window(self, attach=True):
372353
return Pane(window=self, **pane)
373354

374355
def attached_pane(self):
375-
'''
376-
Return the attached :class:`Pane`.
356+
"""Return the attached :class:`Pane`.
377357
378358
:rtype: :class:`Pane`
379-
'''
359+
360+
"""
380361
for pane in self._panes:
381362
if 'pane_active' in pane:
382363
# for now pane_active is a unicode
@@ -404,10 +385,11 @@ def _panes(self):
404385
return self._list_panes()
405386

406387
def list_panes(self):
407-
'''Return list of :class:`Pane` for the window.
388+
"""Return list of :class:`Pane` for the window.
408389
409390
:rtype: list of :class:`Pane`
410-
'''
391+
392+
"""
411393

412394
return [Pane(window=self, **pane) for pane in self._panes]
413395

0 commit comments

Comments
 (0)