Skip to content

Commit a6cb7d7

Browse files
committed
Document readline() and readlines()
1 parent d919b7f commit a6cb7d7

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

shared-bindings/usb_cdc/Serial.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
//| descriptor and are included in the ``usb_cdc.serials`` tuple."""
4646
//| ...
4747
//|
48-
4948
//| def read(self, size: int = 1) -> bytes:
5049
//| """Read at most ``size`` bytes. If ``size`` exceeds the internal buffer size
5150
//| only the bytes in the buffer will be read. If `timeout` is > 0 or ``None``,
@@ -64,6 +63,28 @@
6463
//| :rtype: bytes"""
6564
//| ...
6665
//|
66+
//| def readline(self, size=-1) -> Optional[bytes]:
67+
//| r"""Read a line, ending in a newline character ("\\n"), or
68+
//| return everything readable if no newline is found and ``timeout`` is 0.
69+
//| Return ``None`` in case of error.
70+
//|
71+
//| This is a binary stream: the newline character cannot be changed.
72+
//|
73+
//| :param int size: maximum number of characters to read. ``-1`` means as many as possible.
74+
//| :return: the line read
75+
//| :rtype: bytes or None"""
76+
//| ...
77+
//|
78+
//| def readlines(self) -> list:
79+
//| """Read multiple lines as a list, using `readline()`
80+
//|
81+
//| .. warning:: If ``timeout`` is ``None``,
82+
//| `readlines()` will never return, because there is no way to indicate end of stream.
83+
//|
84+
//| :return: a list of the line read
85+
//| :rtype: list"""
86+
//| ...
87+
//|
6788
//| def write(self, buf: ReadableBuffer) -> int:
6889
//| """Write as many bytes as possible from the buffer of bytes.
6990
//|

0 commit comments

Comments
 (0)