Skip to content

Commit 03bd968

Browse files
committed
more doc improvements
1 parent 979ec3a commit 03bd968

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

shared-bindings/canio/Listener.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,20 @@
3434
//| class Listener:
3535
//| """Listens for CAN message
3636
//|
37-
//| canio.Listener is not constructed directly, but instead by calling
38-
//| `~canio.CAN.listen`."""
37+
//| `canio.Listener` is not constructed directly, but instead by calling
38+
//| `canio.CAN.listen`.
39+
//|
40+
//| In addition to using the `receive` method to retrieve a message or
41+
//| the `in_waiting` method to check for an available message, a
42+
//| listener can be used as an iterable, yielding messages until no
43+
//| message arrives within ``self.timeout`` seconds."""
3944
//|
4045

4146
//| def receive(self) -> Optional[Union[RemoteTransmissionRequest,Message]]:
42-
//| """Reads a message, after waiting up to self.timeout seconds
47+
//| """Reads a message, after waiting up to ``self.timeout`` seconds
4348
//|
44-
//| If no message is received in time, None is returned. Otherwise,
45-
//| a Message is returned."""
49+
//| If no message is received in time, `None` is returned. Otherwise,
50+
//| a `Message` or `RemoteTransmissionRequest` is returned."""
4651
//| ...
4752
//|
4853
STATIC mp_obj_t canio_listener_receive(mp_obj_t self_in) {
@@ -60,7 +65,8 @@ STATIC mp_obj_t canio_listener_receive(mp_obj_t self_in) {
6065
STATIC MP_DEFINE_CONST_FUN_OBJ_1(canio_listener_receive_obj, canio_listener_receive);
6166

6267
//| def in_waiting(self) -> int:
63-
//| """Returns the number of messages waiting"""
68+
//| """Returns the number of messages (including remote
69+
//| transmission requests) waiting"""
6470
//| ...
6571
//|
6672
STATIC mp_obj_t canio_listener_in_waiting(mp_obj_t self_in) {
@@ -70,15 +76,21 @@ STATIC mp_obj_t canio_listener_in_waiting(mp_obj_t self_in) {
7076
}
7177
STATIC MP_DEFINE_CONST_FUN_OBJ_1(canio_listener_in_waiting_obj, canio_listener_in_waiting);
7278

73-
//| def __iter__(self):
74-
//| """Returns self, unless the object is deinitialized"""
79+
//| def __iter__(self) -> Listener:
80+
//| """Returns self, unless the object is deinitialized.
81+
//|
82+
//| This method exists so that `Listener` can be used as an
83+
//| iterable"""
7584
//| ...
7685
//|
77-
//| def __next__(self):
86+
//| def __next__(self) -> Union[RemoteTransmissionRequest,Message]:
7887
//| """Reads a message, after waiting up to self.timeout seconds
7988
//|
8089
//| If no message is received in time, raises StopIteration. Otherwise,
81-
//| a Message is returned."""
90+
//| a Message or is returned.
91+
//|
92+
//| This method enables the `Listener` to be used as an
93+
//| iterable, for instance in a for-loop."""
8294
//| ...
8395
//|
8496
STATIC mp_obj_t canio_iternext(mp_obj_t self_in) {

0 commit comments

Comments
 (0)