Skip to content

Commit 51ef6ab

Browse files
committed
docs: Add some useful cross-references.
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent f835b74 commit 51ef6ab

File tree

6 files changed

+41
-24
lines changed

6 files changed

+41
-24
lines changed

src/frequenz/channels/anycast.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ class Anycast(Generic[T]):
1919
through a sender will be received by exactly one receiver.
2020
2121
In cases where each message need to be received by every receiver, a
22-
`Broadcast` channel may be used.
22+
[Broadcast][frequenz.channels.Broadcast] channel may be used.
2323
24-
Uses an `deque` internally, so Anycast channels are not thread-safe.
24+
Uses an [deque][collections.deque] internally, so Anycast channels are not
25+
thread-safe.
2526
2627
Example:
2728
``` python
@@ -69,10 +70,13 @@ def __init__(self, maxsize: int = 10) -> None:
6970
async def close(self) -> None:
7071
"""Close the channel.
7172
72-
Any further attempts to `send` data will return False.
73+
Any further attempts to [send()][frequenz.channels.Sender.send] data
74+
will return `False`.
7375
7476
Receivers will still be able to drain the pending items on the channel,
75-
but after that, subsequent `recv` calls will return None immediately.
77+
but after that, subsequent
78+
[receive()][frequenz.channels.Receiver.receive] calls will return `None`
79+
immediately.
7680
7781
"""
7882
self.closed = True

src/frequenz/channels/base_classes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ def into_peekable(self) -> "Peekable[T]":
9191
class Peekable(ABC, Generic[T]):
9292
"""A base class for creating Peekables for peeking into channels.
9393
94-
A Peekable provides a `peek` method that allows the user to get a peek at
95-
the latest value in the channel, without consuming anything.
94+
A Peekable provides a [peek()][frequenz.channels.Peekable] method that
95+
allows the user to get a peek at the latest value in the channel, without
96+
consuming anything.
9697
"""
9798

9899
@abstractmethod

src/frequenz/channels/bidirectional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def service_handle(self) -> "BidirectionalHandle[U, T]":
5454

5555

5656
class BidirectionalHandle(Sender[T], Receiver[U]):
57-
"""A handle to a Bidirectional instance.
57+
"""A handle to a [Bidirectional][frequenz.channels.Bidirectional] instance.
5858
5959
It can be used to send/receive values between the client and service.
6060
"""

src/frequenz/channels/broadcast.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class Broadcast(Generic[T]):
2525
receivers.
2626
2727
Internally, a broadcast receiver's buffer is implemented with just
28-
append/pop operations on either side of a `collections.deque`, which are
29-
thread-safe. Because of this, `Broadcast` channels are thread-safe.
28+
append/pop operations on either side of a [deque][collections.deque], which
29+
are thread-safe. Because of this, `Broadcast` channels are thread-safe.
3030
3131
Example:
3232
``` python
@@ -83,10 +83,13 @@ def __init__(self, name: str, resend_latest: bool = False) -> None:
8383
async def close(self) -> None:
8484
"""Close the Broadcast channel.
8585
86-
Any further attempts to `send` data will return False.
86+
Any further attempts to [send()][frequenz.channels.Sender.send] data
87+
will return `False`.
8788
8889
Receivers will still be able to drain the pending items on their queues,
89-
but after that, subsequent `recv` calls will return None immediately.
90+
but after that, subsequent
91+
[receive()][frequenz.channels.Receiver.receive] calls will return `None`
92+
immediately.
9093
"""
9194
self._latest = None
9295
self.closed = True
@@ -140,8 +143,9 @@ def get_receiver(
140143
def get_peekable(self) -> "Peekable[T]":
141144
"""Create a new Peekable for the broadcast channel.
142145
143-
A Peekable provides a `peek` method that allows the user to get a peek
144-
at the latest value in the channel, without consuming anything.
146+
A Peekable provides a [peek()][frequenz.channels.Peekable.peek] method
147+
that allows the user to get a peek at the latest value in the channel,
148+
without consuming anything.
145149
146150
Returns:
147151
A Peekable to peek into the broadcast channel with.
@@ -152,7 +156,8 @@ def get_peekable(self) -> "Peekable[T]":
152156
class Sender(BaseSender[T]):
153157
"""A sender to send messages to the broadcast channel.
154158
155-
Should not be created directly, but through the `Channel.get_sender()`
159+
Should not be created directly, but through the
160+
[Broadcast.get_sender()][frequenz.channels.Broadcast.get_sender]
156161
method.
157162
"""
158163

@@ -188,7 +193,8 @@ async def send(self, msg: T) -> bool:
188193
class Receiver(BufferedReceiver[T]):
189194
"""A receiver to receive messages from the broadcast channel.
190195
191-
Should not be created directly, but through the `Channel.get_receiver()`
196+
Should not be created directly, but through the
197+
[Broadcast.get_receiver()][frequenz.channels.Broadcast.get_receiver]
192198
method.
193199
"""
194200

@@ -253,8 +259,9 @@ async def receive(self) -> Optional[T]:
253259
them. If there are no remaining messages in the buffer and the channel
254260
is closed, returns `None` immediately.
255261
256-
If `into_peekable` is called on a broadcast `Receiver`, further calls to
257-
`receive`, will raise an `EOFError`.
262+
If [into_peekable()][frequenz.channels.Receiver.into_peekable] is called
263+
on a broadcast `Receiver`, further calls to `receive`, will raise an
264+
`EOFError`.
258265
259266
Raises:
260267
EOFError: when the receiver has been converted into a `Peekable`.
@@ -277,7 +284,8 @@ def into_peekable(self) -> "Peekable[T]":
277284
"""Convert the `Receiver` implementation into a `Peekable`.
278285
279286
Once this function has been called, the receiver will no longer be
280-
usable, and calling `receive` on the receiver will raise an exception.
287+
usable, and calling [receive()][frequenz.channels.Receiver.receive] on
288+
the receiver will raise an exception.
281289
282290
Returns:
283291
A `Peekable` instance.
@@ -290,8 +298,9 @@ def into_peekable(self) -> "Peekable[T]":
290298
class Peekable(BasePeekable[T]):
291299
"""A Peekable to peek into broadcast channels.
292300
293-
A Peekable provides a `peek` method that allows the user to get a peek at
294-
the latest value in the channel, without consuming anything.
301+
A Peekable provides a [peek()][frequenz.channels.Peekable] method that
302+
allows the user to get a peek at the latest value in the channel, without
303+
consuming anything.
295304
"""
296305

297306
def __init__(self, chan: Broadcast[T]) -> None:

src/frequenz/channels/select.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Select:
5454
messages coming in the additional async iterators are dropped, and
5555
a warning message is logged.
5656
57-
`Receivers` also function as AsyncIterator.
57+
[Receiver][frequenz.channels.Receiver]s also function as AsyncIterator.
5858
"""
5959

6060
def __init__(self, **kwargs: AsyncIterator[Any]) -> None:

src/frequenz/channels/utils/timer.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,19 @@ def reset(self) -> None:
6565
def stop(self) -> None:
6666
"""Stop the timer.
6767
68-
Once `stop` has been called, all subsequent calls to `receive` will
69-
immediately return None.
68+
Once `stop` has been called, all subsequent calls to
69+
[receive()][frequenz.channels.Timer.receive] will immediately return
70+
None.
7071
"""
7172
self._stopped = True
7273

7374
async def receive(self) -> Optional[datetime]:
7475
"""Return the current time once the next tick is due.
7576
7677
Returns:
77-
The time of the next tick.
78+
The time of the next tick or `None` if
79+
[stop()][frequenz.channels.Timer.stop] has been called on the
80+
timer.
7881
"""
7982
if self._stopped:
8083
return None

0 commit comments

Comments
 (0)