Skip to content

Commit 89d6260

Browse files
committed
Improve documentation
1 parent fe1c390 commit 89d6260

File tree

2 files changed

+30
-36
lines changed

2 files changed

+30
-36
lines changed

adafruit_mcp2515/__init__.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -266,21 +266,7 @@ def _tx_buffer_status_decode(status_byte):
266266

267267

268268
class MCP2515: # pylint:disable=too-many-instance-attributes
269-
"""A common shared-bus protocol."""
270-
271-
def __init__(
272-
self,
273-
spi_bus,
274-
cs_pin,
275-
*,
276-
baudrate: int = 250000,
277-
crystal_freq: Literal[8000000, 10000000, 16000000] = 16000000,
278-
loopback: bool = False,
279-
silent: bool = False,
280-
auto_restart: bool = False,
281-
debug: bool = False,
282-
):
283-
"""A common shared-bus protocol.
269+
"""A common shared-bus protocol.
284270
285271
:param ~busio.SPI spi: The SPI bus used to communicate with the MCP2515
286272
:param ~digitalio.DigitalInOut cs_pin: SPI bus enable pin
@@ -297,10 +283,22 @@ def __init__(
297283
:param bool auto_restart: **Not supported by hardware. An `AttributeError` will be raised\
298284
if `auto_restart` is set to `True`** If `True`, will restart communications after entering\
299285
bus-off state. Defaults to `False`.
300-
301286
:param bool debug: If `True`, will enable printing debug information. Defaults to `False`.
302287
"""
303288

289+
def __init__(
290+
self,
291+
spi_bus,
292+
cs_pin,
293+
*,
294+
baudrate: int = 250000,
295+
crystal_freq: Literal[8000000, 10000000, 16000000] = 16000000,
296+
loopback: bool = False,
297+
silent: bool = False,
298+
auto_restart: bool = False,
299+
debug: bool = False,
300+
):
301+
304302
if loopback and not silent:
305303
raise AttributeError("Loopback mode requires silent to be set")
306304
if auto_restart:

adafruit_mcp2515/canio/__init__.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@
88

99

1010
class Message:
11-
"""A class representing a CANbus data frame"""
11+
"""A class representing a CANbus data frame
12+
13+
:param int id: The numeric ID of the message
14+
:param bytes data: The content of the message, from 0 to 8 bytes of data
15+
:param bool extended: True if the message has an extended identifier,
16+
False if it has a standard identifier
17+
"""
1218

1319
# pylint:disable=too-many-arguments,invalid-name,redefined-builtin
1420
def __init__(self, id, data, extended=False):
15-
"""Create a `Message` to send
16-
17-
:param int id: The numeric ID of the message
18-
:param bytes data: The content of the message, from 0 to 8 bytes of data
19-
:param bool extended: True if the message has an extended identifier,
20-
False if it has a standard identifier
21-
"""
22-
2321
self._data = None
2422
self.id = id
2523
self.data = data
@@ -53,17 +51,15 @@ def data(self, new_data):
5351

5452

5553
class RemoteTransmissionRequest:
56-
"""A class representing a CANbus remote frame"""
54+
"""A class representing a CANbus remote frame
5755
58-
def __init__(self, id: int, length: int, *, extended: bool = False):
59-
"""Construct a RemoteTransmissionRequest to send on a CAN bus
56+
:param int id: The numeric ID of the message
57+
:param length int: The length of the requested message
58+
:param bool extended: True if the message has an extended identifier,
59+
False if it has a standard identifier
60+
"""
6061

61-
Args:
62-
:param int id: The numeric ID of the message
63-
:param length int: The length of the requested message
64-
:param bool extended: True if the message has an extended identifier,
65-
False if it has a standard identifier
66-
"""
62+
def __init__(self, id: int, length: int, *, extended: bool = False):
6763
self.id = id
6864
self.length = length
6965
self.extended = extended
@@ -88,8 +84,8 @@ def __init__(self, id: int, length: int, *, extended: bool = False):
8884
class Listener:
8985
"""Listens for a CAN message
9086
91-
canio.Listener is not constructed directly, but instead by calling the `listen` method of a\
92-
canio.CAN object.
87+
canio.Listener is not constructed directly, but instead by calling the
88+
``listen`` method of a canio.CAN object.
9389
"""
9490

9591
def __init__(self, can_bus_obj, timeout=1.0):

0 commit comments

Comments
 (0)