Skip to content

Commit 85e1274

Browse files
authored
Feature travis to build sphinx docs (#342)
* Get travis CI to build the sphinx docs * Various documentation updates (primarily to minimize sphinx warnings) * Pypy is having issues with building sphinx docs so just build for python 3.6 * Enabled nitpick mode, but not turn warnings into errors Closes #340
1 parent 66540e3 commit 85e1274

File tree

12 files changed

+88
-51
lines changed

12 files changed

+88
-51
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ python:
77
- "3.4"
88
- "3.5"
99
- "3.6"
10-
- "3.7-dev" # TODO: change to "3.7" once it gets released
10+
- "3.7-dev" # TODO: change to "3.7" once it is supported by travis-ci
1111
- "nightly"
1212
# PyPy:
1313
- "pypy"
@@ -46,6 +46,11 @@ matrix:
4646
install:
4747
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo bash test/open_vcan.sh ; fi
4848
- travis_retry pip install .[test]
49+
- travis_retry pip install sphinx
4950

5051
script:
5152
- pytest -v --timeout=300
53+
# Build Docs with Sphinx
54+
#
55+
# -a Write all files
56+
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then python -m sphinx -an doc build; fi

can/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515

1616
rc = dict()
1717

18+
1819
class CanError(IOError):
19-
"""
20-
Indicates an error with the CAN network.
20+
"""Indicates an error with the CAN network.
21+
2122
"""
2223
pass
2324

can/broadcastmanager.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010

1111
import abc
1212
import logging
13-
import sched
13+
1414
import threading
1515
import time
1616

17-
import can
1817

1918
log = logging.getLogger('can.bcm')
2019

@@ -77,7 +76,7 @@ def modify_data(self, message):
7776
"""Update the contents of this periodically sent message without altering
7877
the timing.
7978
80-
:param message: The :class:`~can.Message` with new :attr:`Message.data`.
79+
:param message: The :class:`~can.Message` with new :attr:`can.Message.data`.
8180
"""
8281
self.message = message
8382

@@ -136,9 +135,12 @@ def _run(self):
136135

137136

138137
def send_periodic(bus, message, period, *args, **kwargs):
138+
"""Send a message every `period` seconds on the given channel.
139+
140+
:param bus: The :class:`can.BusABC` to transmit to.
141+
:param message: The :class:`can.Message` instance to periodically send
142+
:return: A started task instance
139143
"""
140-
Send a message every `period` seconds on the given channel.
141-
"""
142-
log.warn("The method `can.send_periodic` is deprecated and will "
144+
log.warning("The function `can.send_periodic` is deprecated and will " +
143145
"be removed in version 2.3. Please use `can.Bus.send_periodic` instead.")
144146
return bus.send_periodic(message, period, *args, **kwargs)

can/bus.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def send_periodic(self, msg, period, duration=None):
159159
no duration is provided, the task will continue indefinitely.
160160
161161
:return: A started task instance
162-
:rtype: can.CyclicSendTaskABC
162+
:rtype: can.broadcastmanager.CyclicSendTaskABC
163163
164164
.. note::
165165
@@ -211,7 +211,7 @@ def set_filters(self, filters=None):
211211
Calling without passing any filters will reset the applied
212212
filters to `None`.
213213
214-
:param Iterator[dict] filters:
214+
:param filters:
215215
A iterable of dictionaries each containing a "can_id", a "can_mask",
216216
and an optional "extended" key.
217217
@@ -221,7 +221,6 @@ def set_filters(self, filters=None):
221221
If ``extended`` is set as well, it only matches messages where
222222
``<received_is_extended> == extended``. Else it matches every messages based
223223
only on the arbitration ID and mask.
224-
225224
"""
226225
self._filters = filters or None
227226
self._apply_filters(self._filters)

can/interface.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
log = logging.getLogger('can.interface')
3030
log_autodetect = log.getChild('detect_available_configs')
3131

32+
3233
def _get_class_for_interface(interface):
3334
"""
3435
Returns the main bus class for the given interface.
@@ -66,7 +67,8 @@ def _get_class_for_interface(interface):
6667

6768

6869
class Bus(BusABC):
69-
"""
70+
"""Bus wrapper with configuration loading.
71+
7072
Instantiates a CAN Bus of the given ``interface``, falls back to reading a
7173
configuration file from default locations.
7274
"""
@@ -130,9 +132,9 @@ def detect_available_configs(interfaces=None):
130132
- the name of an interface to be searched in as a string,
131133
- an iterable of interface names to search in, or
132134
- `None` to search in all known interfaces.
133-
:rtype: list of `dict`s
135+
:rtype: list[dict]
134136
:return: an iterable of dicts, each suitable for usage in
135-
:class:`can.interface.Bus`'s constructor.
137+
:class:`can.interface.Bus`\ 's constructor.
136138
"""
137139

138140
# Figure out where to search

can/notifier.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def __init__(self, bus, listeners, timeout=1):
1818
"""Manages the distribution of **Messages** from a given bus/buses to a
1919
list of listeners.
2020
21-
:param can.Bus bus: The :ref:`bus` or a list of buses to listen to.
22-
:param list listeners: An iterable of :class:`~can.Listener`s
21+
:param can.BusABC bus: The :ref:`bus` or a list of buses to listen to.
22+
:param list listeners: An iterable of :class:`~can.Listener`
2323
:param float timeout: An optional maximum number of seconds to wait for any message.
2424
"""
2525
self.listeners = listeners

can/thread_safe_bus.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#!/usr/bin/env python
22
# coding: utf-8
33

4-
"""
5-
"""
6-
74
from __future__ import print_function, absolute_import
8-
9-
from abc import ABCMeta
105
from threading import RLock
116

127
try:
@@ -19,7 +14,6 @@
1914
import_exc = exc
2015

2116
from .interface import Bus
22-
from .bus import BusABC
2317

2418

2519
class NullContextManager(object):

doc/api.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ A form of CAN interface is also required.
1818
bcm
1919

2020

21-
2221
Utilities
2322
---------
2423

@@ -27,14 +26,20 @@ Utilities
2726

2827
.. automethod:: can.detect_available_configs
2928

30-
.. _notifier:
3129

3230

3331

32+
.. _notifier:
33+
3434
Notifier
3535
--------
3636

3737
The Notifier object is used as a message distributor for a bus.
3838

3939
.. autoclass:: can.Notifier
4040
:members:
41+
42+
Errors
43+
------
44+
45+
.. autoclass:: can.CanError

doc/bcm.rst

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,42 @@ This example shows the socketcan_ctypes backend using the broadcast manager:
1616
:linenos:
1717

1818

19-
.. note::
20-
The functional APi in :meth:`can.send_periodic` is now deprected.
21-
Use the object oriented APi in :meth:`can.BusABC.send_periodic` instead.
22-
23-
2419
Class based API
2520
---------------
2621

27-
.. autoclass:: can.CyclicSendTaskABC
22+
.. autoclass:: can.broadcastmanager.CyclicTask
23+
:members:
24+
25+
26+
.. autoclass:: can.broadcastmanager.CyclicSendTaskABC
27+
:members:
28+
29+
.. autoclass:: can.broadcastmanager.LimitedDurationCyclicSendTaskABC
30+
:members:
31+
32+
33+
.. autoclass:: can.broadcastmanager.RestartableCyclicTaskABC
2834
:members:
2935

3036

31-
.. autoclass:: can.MultiRateCyclicSendTaskABC
37+
.. autoclass:: can.broadcastmanager.ModifiableCyclicTaskABC
3238
:members:
39+
40+
.. autoclass:: can.broadcastmanager.MultiRateCyclicSendTaskABC
41+
:members:
42+
43+
.. autoclass:: can.broadcastmanager.ThreadBasedCyclicSendTask
44+
:members:
45+
46+
47+
48+
Functional API
49+
--------------
50+
51+
.. note::
52+
The functional API in :func:`can.broadcastmanager.send_periodic` is now deprecated.
53+
Use the object oriented API via :meth:`can.BusABC.send_periodic` instead.
54+
55+
56+
.. autofunction:: can.broadcastmanager.send_periodic
57+

doc/bus.rst

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,25 @@
33
Bus
44
---
55

6-
The :class:`~can.Bus` class, as the name suggests, provides an abstraction of a CAN bus.
6+
The :class:`can.BusABC` class, as the name suggests, provides an abstraction of a CAN bus.
77
The bus provides an abstract wrapper around a physical or virtual CAN Bus.
88

99
A thread safe bus wrapper is also available, see `Thread safe bus`_.
1010

1111

12-
Filtering
13-
'''''''''
14-
15-
Message filtering can be set up for each bus. Where the interface supports it, this is carried
16-
out in the hardware or kernel layer - not in Python.
17-
18-
1912
API
2013
''''
2114

2215
.. autoclass:: can.BusABC
2316
:members:
2417
:special-members: __iter__
2518

26-
.. autoclass:: can.interface.Bus
27-
:members:
28-
:special-members: __iter__
29-
3019

3120
Transmitting
3221
''''''''''''
3322

34-
Writing to the bus is done by calling the :meth:`~can.BusABC.send()` method and
35-
passing a :class:`~can.Message` object.
23+
Writing to the bus is done by calling the :meth:`~can.BusABC.send` method and
24+
passing a :class:`~can.Message` instance.
3625

3726

3827
Receiving
@@ -48,14 +37,21 @@ Alternatively the :class:`~can.Listener` api can be used, which is a list of :cl
4837
subclasses that receive notifications when new messages arrive.
4938

5039

40+
Filtering
41+
'''''''''
42+
43+
Message filtering can be set up for each bus. Where the interface supports it, this is carried
44+
out in the hardware or kernel layer - not in Python.
45+
46+
5147
Thread safe bus
5248
---------------
5349

54-
This thread safe version of the :class:`~can.Bus` class can be used by multiple threads at once.
55-
Sending and receiving is locked seperatly to avoid unnessesary delays.
50+
This thread safe version of the :class:`~can.BusABC` class can be used by multiple threads at once.
51+
Sending and receiving is locked separately to avoid unnecessary delays.
5652
Conflicting calls are executed by blocking until the bus is accessible.
5753

58-
It can be used exactly like the normal :class:`~can.Bus`:
54+
It can be used exactly like the normal :class:`~can.BusABC`:
5955

6056
# 'socketcan' is only an exemple interface, it works with all the others too
6157
my_bus = can.ThreadSafeBus(interface='socketcan', channel='vcan0')
@@ -64,3 +60,11 @@ It can be used exactly like the normal :class:`~can.Bus`:
6460

6561
.. autoclass:: can.ThreadSafeBus
6662
:members:
63+
64+
Autoconfig Bus
65+
--------------
66+
67+
.. autoclass:: can.interface.Bus
68+
:members:
69+
:special-members: __iter__
70+

0 commit comments

Comments
 (0)