Skip to content

Commit a3aa351

Browse files
committed
!squash docs waiter.md use autodoc
1 parent b34e85e commit a3aa351

File tree

1 file changed

+16
-84
lines changed

1 file changed

+16
-84
lines changed

docs/test-helpers/waiter.md

Lines changed: 16 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
(waiter)=
2+
13
# Terminal Content Waiters
24

35
The waiter module provides utilities for waiting on specific content to appear in tmux panes, making it easier to write reliable tests that interact with terminal output.
@@ -92,90 +94,20 @@ The waiter module also supports waiting for multiple conditions at once:
9294

9395
## API Reference
9496

95-
### Low-level Functions
96-
97-
* `wait_for_text(pane, text, timeout=10, interval=0.05, raises=True)`
98-
* `wait_for_exact_text(pane, text, timeout=10, interval=0.05, raises=True)`
99-
* `wait_for_regex(pane, pattern, timeout=10, interval=0.05, raises=True)`
100-
* `wait_for_predicate(pane, predicate, timeout=10, interval=0.05, raises=True)`
101-
* `wait_for_pane_content(pane, content_pattern, match_type, timeout=10, interval=0.05, raises=True)`
102-
* `wait_for_any_content(pane, patterns, match_type=ContentMatchType.CONTAINS, timeout=10, interval=0.05, raises=True)`
103-
* `wait_for_all_content(pane, patterns, match_type=ContentMatchType.CONTAINS, timeout=10, interval=0.05, raises=True)`
104-
* `wait_until_pane_ready(pane, shell_prompt=None, match_type=ContentMatchType.CONTAINS, timeout=10, interval=0.05, raises=True)`
105-
106-
### Fluent API
107-
108-
The fluent API provides a more expressive way to wait for content in panes:
109-
110-
```python
111-
# Create a waiter
112-
waiter = expect(pane)
113-
114-
# Configure the waiter
115-
waiter = waiter.to_contain_text("text")
116-
waiter = waiter.to_match_regex(pattern)
117-
waiter = waiter.with_timeout(5)
118-
waiter = waiter.with_interval(0.1)
119-
120-
# Wait for the condition and get the result
121-
result = waiter.wait()
97+
```{eval-rst}
98+
.. automodule:: libtmux.test.waiter
99+
:members:
100+
:undoc-members:
101+
:show-inheritance:
102+
:member-order: bysource
122103
```
123104

124-
#### Terminal Methods
125-
These methods perform the actual wait operation and return a `WaitResult`:
126-
127-
* `wait()`
128-
129-
#### Configurator Methods
130-
These methods configure the waiter and return a new waiter with the updated configuration:
131-
132-
* `to_contain_text(text)`
133-
* `to_contain_exact_text(text)`
134-
* `to_match_regex(pattern)`
135-
* `to_satisfy_predicate(predicate)`
136-
* `to_contain_any_text(texts)`
137-
* `to_contain_all_texts(texts)`
138-
* `with_timeout(timeout)`
139-
* `with_interval(interval)`
140-
* `without_raises()`
141-
142-
#### Parameters
105+
## Extended Retry Functionality
143106

144-
- `pane`: A tmux pane object to wait on
145-
- `content_pattern`: The pattern to match (string, regex, or function)
146-
- `match_type`: How to match the pattern (ContentMatchType.CONTAINS, EXACT, REGEX, or PREDICATE)
147-
- `timeout`: Maximum time to wait in seconds
148-
- `interval`: Time between checks in seconds
149-
- `raises`: Whether to raise an exception on timeout
150-
151-
**Returns:**
152-
* `WaitResult`: An object containing the result of the wait operation, including:
153-
* `success`: Whether the wait was successful
154-
* `content`: The content of the pane at the time of success or timeout
155-
* `matched_content`: The matched content, if successful
156-
* `match_line`: The line number of the matched content, if successful
157-
* `elapsed_time`: The time elapsed during the wait
158-
* `error`: The error message, if any
159-
* `matched_pattern_index`: The index of the matched pattern (for wait_for_any_content)
160-
161-
## Implementation Notes
162-
163-
### Error Handling
164-
165-
The waiting functions are designed to be robust and handle timing and error conditions gracefully:
166-
167-
- All wait functions properly calculate elapsed time for performance tracking
168-
- Functions handle exceptions consistently and provide clear error messages
169-
- Proper handling of return values ensures consistent behavior whether or not raises=True
170-
171-
### Type Safety
172-
173-
The waiter module is fully type-annotated to ensure compatibility with static type checkers:
174-
175-
- All functions include proper type hints for parameters and return values
176-
- The ContentMatchType enum ensures that only valid match types are used
177-
- Combined with runtime checks, this prevents type-related errors during testing
178-
179-
### Example Usage in Documentation
180-
181-
All examples in this documentation are actual test files from the libtmux test suite. The examples are included using `literalinclude` directives, ensuring that the documentation remains synchronized with the actual code.
107+
```{eval-rst}
108+
.. automodule:: libtmux.test.retry_extended
109+
:members:
110+
:undoc-members:
111+
:show-inheritance:
112+
:member-order: bysource
113+
```

0 commit comments

Comments
 (0)