Skip to content

Commit 3348a9c

Browse files
committed
docs(README): Overhaul doctests
1 parent d35bb01 commit 3348a9c

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

README.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,30 +130,44 @@ Direct lookup:
130130
Session($1 ...)
131131
```
132132

133-
Find session by dict lookup:
133+
Filter sesions:
134134

135135
```python
136136
>>> server.sessions[0].rename_session('foo')
137137
Session($1 foo)
138-
>>> server.sessions.filter(session_name="foo")[0]
138+
>>> server.sessions.filter(session_name="foo")
139+
[Session($1 foo)]
140+
>>> server.sessions.get(session_name="foo")
139141
Session($1 foo)
140142
```
141143

142144
Control your session:
143145

144146
```python
145-
>>> session.rename_session('foo')
146-
Session($1 foo)
147-
>>> session.new_window(attach=False, window_name="ha in the bg")
148-
Window(@2 2:ha in the bg, Session($1 foo))
149-
>>> session.kill_window("ha in")
147+
>>> session
148+
Session($1 ...)
149+
150+
>>> session.rename_session('my-session')
151+
Session($1 my-session)
150152
```
151153

152154
Create new window in the background (don't switch to it):
153155

154156
```python
155-
>>> session.new_window(attach=False, window_name="ha in the bg")
156-
Window(@2 2:ha in the bg, Session($1 ...))
157+
>>> bg_window = session.new_window(attach=False, window_name="ha in the bg")
158+
>>> bg_window
159+
Window(@... 2:ha in the bg, Session($1 ...))
160+
161+
# Session can search the window
162+
>>> session.windows.filter(window_name__startswith="ha")
163+
[Window(@... 2:ha in the bg, Session($1 ...))]
164+
165+
# Directly
166+
>>> session.windows.get(window_name__startswith="ha")
167+
Window(@... 2:ha in the bg, Session($1 ...))
168+
169+
# Clean up
170+
>>> bg_window.kill()
157171
```
158172

159173
Close window:

0 commit comments

Comments
 (0)