@@ -200,33 +200,40 @@ class PaneContentWaiter:
200
200
>>> hasattr(waiter, 'wait_until_ready')
201
201
True
202
202
203
- .. code-block:: python
204
-
205
- # Real-world usage examples
206
- # Basic usage
207
- result = PaneContentWaiter(pane).wait_for_text("hello world")
208
-
209
- # With options
210
- result = (
211
- PaneContentWaiter(pane)
212
- .with_timeout(10.0)
213
- .wait_for_exact_text("completed successfully")
214
- )
215
-
216
- # Wait for regex pattern
217
- result = (
218
- PaneContentWaiter(pane)
219
- .with_timeout(10.0)
220
- .wait_for_regex(r"Process \d+ completed")
221
- )
222
-
223
- # Custom predicate
224
- def is_ready(content):
225
- return any("ready" in line.lower() for line in content)
226
-
227
- result = PaneContentWaiter(pane).wait_for_predicate(is_ready)
203
+ >>> # Real-world usage examples
204
+ >>> # A functional example: send text to the pane and wait for it
205
+ >>> # First, send "hello world" to the pane
206
+ >>> pane.send_keys("echo 'hello world'", enter=True)
207
+ >>>
208
+ >>> # Then wait for it to appear in the pane content
209
+ >>> result = PaneContentWaiter(pane).wait_for_text("hello world")
210
+ >>> result.success
211
+ True
212
+ >>> "hello world" in result.matched_content
213
+ True
214
+ >>>
215
+ >>> # Basic usage (showing API only, other examples)
216
+ >>> # result = PaneContentWaiter(pane).wait_for_text("other example")
217
+ >>>
218
+ >>> # With options
219
+ >>> # result = (
220
+ >>> # PaneContentWaiter(pane)
221
+ >>> # .with_timeout(10.0)
222
+ >>> # .wait_for_exact_text("completed successfully")
223
+ >>> # )
224
+ >>>
225
+ >>> # Wait for regex pattern
226
+ >>> # result = (
227
+ >>> # PaneContentWaiter(pane)
228
+ >>> # .with_timeout(10.0)
229
+ >>> # .wait_for_regex(r"Process \d+ completed")
230
+ >>> # )
231
+ >>>
232
+ >>> # Custom predicate
233
+ >>> def is_ready(content):
234
+ ... return any("ready" in line.lower() for line in content)
235
+ >>> # result = PaneContentWaiter(pane).wait_for_predicate(is_ready)
228
236
"""
229
-
230
237
def __init__ (self , pane : Pane ) -> None :
231
238
"""Initialize with a tmux pane.
232
239
@@ -455,22 +462,29 @@ def expect(pane: Pane) -> PaneContentWaiter:
455
462
>>> type(expect(pane)) == type(PaneContentWaiter(pane)) # Same class
456
463
True
457
464
458
- .. code-block:: python
459
-
460
- # Real-world usage examples
461
- # Wait for text with a longer timeout
462
- result = (
463
- expect(pane)
464
- .with_timeout(10.0)
465
- .wait_for_text("Operation completed")
466
- )
467
-
468
- # Wait for a regex match without raising exceptions on timeout
469
- result = (
470
- expect(pane)
471
- .without_raising()
472
- .wait_for_regex(r"Process \d+ completed")
473
- )
465
+ >>> # A functional example showing actual usage
466
+ >>> # Send a command to the pane
467
+ >>> pane.send_keys("echo 'testing expect'", enter=True)
468
+ >>>
469
+ >>> # Wait for the output using the expect function
470
+ >>> result = expect(pane).wait_for_text("testing expect")
471
+ >>> result.success
472
+ True
473
+ >>>
474
+ >>> # Real-world usage examples (showing API only, not executed)
475
+ >>> # Wait for text with a longer timeout
476
+ >>> # result = (
477
+ >>> # expect(pane)
478
+ >>> # .with_timeout(10.0)
479
+ >>> # .wait_for_text("Operation completed")
480
+ >>> # )
481
+ >>>
482
+ >>> # Wait for a regex match without raising exceptions on timeout
483
+ >>> # result = (
484
+ >>> # expect(pane)
485
+ >>> # .without_raising()
486
+ >>> # .wait_for_regex(r"Process \d+ completed")
487
+ >>> # )
474
488
"""
475
489
return PaneContentWaiter (pane )
476
490
@@ -569,37 +583,35 @@ def wait_for_pane_content(
569
583
>>> isinstance(result_pred, WaitResult)
570
584
True
571
585
572
- .. code-block:: python
573
-
574
- # Real-world usage examples
575
- # Wait for a $ shell prompt
576
- result = wait_for_pane_content(pane, "$", ContentMatchType.CONTAINS)
577
-
578
- # Wait for exact text
579
- result = wait_for_pane_content(
580
- pane,
581
- "Success",
582
- ContentMatchType.EXACT,
583
- timeout=10.0
584
- )
585
-
586
- # Use regex pattern matching
587
- import re
588
- result = wait_for_pane_content(
589
- pane,
590
- re.compile(r"Error: .*"),
591
- ContentMatchType.REGEX
592
- )
593
-
594
- # Use custom predicate function
595
- def has_at_least_3_lines(content):
596
- return len(content) >= 3
597
-
598
- result = wait_for_pane_content(
599
- pane,
600
- has_at_least_3_lines,
601
- ContentMatchType.PREDICATE
602
- )
586
+ >>> # Real-world usage examples (showing API only, not executed)
587
+ >>> # Wait for a $ shell prompt
588
+ >>> # result = wait_for_pane_content(pane, "$", ContentMatchType.CONTAINS)
589
+ >>>
590
+ >>> # Wait for exact text
591
+ >>> # result = wait_for_pane_content(
592
+ >>> # pane,
593
+ >>> # "Success",
594
+ >>> # ContentMatchType.EXACT,
595
+ >>> # timeout=10.0
596
+ >>> # )
597
+ >>>
598
+ >>> # Use regex pattern matching
599
+ >>> import re
600
+ >>> # result = wait_for_pane_content(
601
+ >>> # pane,
602
+ >>> # re.compile(r"Error: .*"),
603
+ >>> # ContentMatchType.REGEX
604
+ >>> # )
605
+ >>>
606
+ >>> # Use custom predicate function
607
+ >>> def has_at_least_3_lines(content):
608
+ ... return len(content) >= 3
609
+ >>>
610
+ >>> # result = wait_for_pane_content(
611
+ >>> # pane,
612
+ >>> # has_at_least_3_lines,
613
+ >>> # ContentMatchType.PREDICATE
614
+ >>> # )
603
615
"""
604
616
result = WaitResult (success = False )
605
617
@@ -974,35 +986,34 @@ def wait_for_any_content(
974
986
975
987
Examples
976
988
--------
977
- .. code-block:: python
978
-
979
- # Wait for any of the specified patterns
980
- result = wait_for_any_content(
981
- pane,
982
- ["pattern1", "pattern2"],
983
- ContentMatchType.CONTAINS
984
- )
985
-
986
- # Wait for any of the specified regex patterns
987
- import re
988
- result = wait_for_any_content(
989
- pane,
990
- [re.compile(r"Error: .*"), re.compile(r"Success: .*")],
991
- ContentMatchType.REGEX
992
- )
993
-
994
- # Wait for any of the specified predicate functions
995
- def has_at_least_3_lines(content):
996
- return len(content) >= 3
997
-
998
- def has_at_least_5_lines(content):
999
- return len(content) >= 5
1000
-
1001
- result = wait_for_any_content(
1002
- pane,
1003
- [has_at_least_3_lines, has_at_least_5_lines],
1004
- ContentMatchType.PREDICATE
1005
- )
989
+ >>> # Example patterns for wait_for_any_content (showing API only, not executed)
990
+ >>> # Wait for any of the specified patterns
991
+ >>> # result = wait_for_any_content(
992
+ >>> # pane,
993
+ >>> # ["pattern1", "pattern2"],
994
+ >>> # ContentMatchType.CONTAINS
995
+ >>> # )
996
+ >>>
997
+ >>> # Wait for any of the specified regex patterns
998
+ >>> import re
999
+ >>> # result = wait_for_any_content(
1000
+ >>> # pane,
1001
+ >>> # [re.compile(r"Error: .*"), re.compile(r"Success: .*")],
1002
+ >>> # ContentMatchType.REGEX
1003
+ >>> # )
1004
+ >>>
1005
+ >>> # Wait for any of the specified predicate functions
1006
+ >>> def has_at_least_3_lines(content):
1007
+ ... return len(content) >= 3
1008
+ >>>
1009
+ >>> def has_at_least_5_lines(content):
1010
+ ... return len(content) >= 5
1011
+ >>>
1012
+ >>> # result = wait_for_any_content(
1013
+ >>> # pane,
1014
+ >>> # [has_at_least_3_lines, has_at_least_5_lines],
1015
+ >>> # ContentMatchType.PREDICATE
1016
+ >>> # )
1006
1017
"""
1007
1018
if not content_patterns :
1008
1019
msg = "At least one content pattern must be provided"
@@ -1172,35 +1183,34 @@ def wait_for_all_content(
1172
1183
1173
1184
Examples
1174
1185
--------
1175
- .. code-block:: python
1176
-
1177
- # Wait for all of the specified patterns
1178
- result = wait_for_all_content(
1179
- pane,
1180
- ["pattern1", "pattern2"],
1181
- ContentMatchType.CONTAINS
1182
- )
1183
-
1184
- # Wait for all of the specified regex patterns
1185
- import re
1186
- result = wait_for_all_content(
1187
- pane,
1188
- [re.compile(r"Error: .*"), re.compile(r"Success: .*")],
1189
- ContentMatchType.REGEX
1190
- )
1191
-
1192
- # Wait for all of the specified predicate functions
1193
- def has_at_least_3_lines(content):
1194
- return len(content) >= 3
1195
-
1196
- def has_at_least_5_lines(content):
1197
- return len(content) >= 5
1198
-
1199
- result = wait_for_all_content(
1200
- pane,
1201
- [has_at_least_3_lines, has_at_least_5_lines],
1202
- ContentMatchType.PREDICATE
1203
- )
1186
+ >>> # Example patterns for wait_for_all_content (showing API only, not executed)
1187
+ >>> # Wait for all of the specified patterns
1188
+ >>> # result = wait_for_all_content(
1189
+ >>> # pane,
1190
+ >>> # ["pattern1", "pattern2"],
1191
+ >>> # ContentMatchType.CONTAINS
1192
+ >>> # )
1193
+ >>>
1194
+ >>> # Wait for all of the specified regex patterns
1195
+ >>> import re
1196
+ >>> # result = wait_for_all_content(
1197
+ >>> # pane,
1198
+ >>> # [re.compile(r"Error: .*"), re.compile(r"Success: .*")],
1199
+ >>> # ContentMatchType.REGEX
1200
+ >>> # )
1201
+ >>>
1202
+ >>> # Wait for all of the specified predicate functions
1203
+ >>> def has_at_least_3_lines(content):
1204
+ ... return len(content) >= 3
1205
+ >>>
1206
+ >>> def has_at_least_5_lines(content):
1207
+ ... return len(content) >= 5
1208
+ >>>
1209
+ >>> # result = wait_for_all_content(
1210
+ >>> # pane,
1211
+ >>> # [has_at_least_3_lines, has_at_least_5_lines],
1212
+ >>> # ContentMatchType.PREDICATE
1213
+ >>> # )
1204
1214
"""
1205
1215
if not content_patterns :
1206
1216
msg = "At least one content pattern must be provided"
0 commit comments