Skip to content

Commit de703a4

Browse files
authored
Documentation shows typehints correctly (#153)
- Updated Sphinx from 1.3 to 6.1. - Set autodoc_typehints = 'description' - Fixed project to be compatible with Sphinx 6.1
1 parent b17bc83 commit de703a4

File tree

10 files changed

+63
-20
lines changed

10 files changed

+63
-20
lines changed

.readthedocs.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the version of Python and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.10"
13+
# You can also specify other tool versions:
14+
# nodejs: "19"
15+
# rust: "1.64"
16+
# golang: "1.19"
17+
18+
# Build documentation in the docs/ directory with Sphinx
19+
sphinx:
20+
configuration: doc/source/conf.py
21+
22+
# If using Sphinx, optionally build your docs in additional formats such as PDF
23+
# formats:
24+
# - pdf
25+
26+
# Optionally declare the Python requirements required to build your docs
27+
python:
28+
install:
29+
- requirements: doc/requirements.txt

doc/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
sphinx_rtd_theme>=0.3.1
2-
sphinx==1.6.3
1+
sphinx_rtd_theme>=1.2
2+
sphinx==6.1.3
33

doc/source/_static/theme_overrides.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ dl.class dd dl.attribute,dl.data {
55

66
div.wy-nav-content {
77
max-width:1200px ! important;
8-
}
8+
}

doc/source/conf.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
'sphinx.ext.autodoc',
3434
'sphinx.ext.mathjax',
3535
'sphinx.ext.viewcode',
36+
"sphinxcontrib.jquery"
3637
]
3738

3839
# Add any paths that contain templates here, relative to this directory.
@@ -68,7 +69,7 @@
6869
#
6970
# This is also used if you do content translation via gettext catalogs.
7071
# Usually you set "language" from the command line for these cases.
71-
language = None
72+
language = 'en'
7273

7374
# There are two options for replacing |today|: either, you set today to some
7475
# non-false value, then it is used:
@@ -107,19 +108,23 @@
107108
# If true, `todo` and `todoList` produce output, else they produce nothing.
108109
todo_include_todos = False
109110

111+
primary_domain = 'py'
110112

111113
# -- Options for HTML output ----------------------------------------------
112114

113115
# The theme to use for HTML and HTML Help pages. See the documentation for
114116
# a list of builtin themes.
115117
html_theme = 'sphinx_rtd_theme'
116118

119+
toc_object_entries = False
120+
117121
# Theme options are theme-specific and customize the look and feel of a theme
118122
# further. For a list of options available for each theme, see the
119123
# documentation.
120124
html_theme_options = {
121-
'sticky_navigation': False,
122-
'collapse_navigation': True
125+
'sticky_navigation': True,
126+
'collapse_navigation': True,
127+
'navigation_depth': 3,
123128
}
124129

125130
# Add any paths that contain custom themes here, relative to this directory.
@@ -216,6 +221,8 @@
216221
# Output file base name for HTML help builder.
217222
htmlhelp_basename = 'udsoncandoc'
218223

224+
autodoc_typehints = 'description'
225+
219226
# -- Options for LaTeX output ---------------------------------------------
220227

221228
latex_elements = {
@@ -299,4 +306,4 @@
299306

300307

301308
def setup(app):
302-
app.add_stylesheet('theme_overrides.css')
309+
app.add_css_file('theme_overrides.css')

doc/source/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ Python implementation of UDS standard (ISO-14229)
22
=================================================
33

44
.. toctree::
5-
:maxdepth: 2
65
:hidden:
7-
6+
87
Home <self>
98
udsoncan/intro
109
udsoncan/connection

doc/source/udsoncan/client.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Client
22
======
3+
.. toctree::
4+
:maxdepth: 3
35

46
.. _Client:
57

doc/source/udsoncan/exceptions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Exceptions
2-
===========
2+
==========
33

44
This section explains the different exceptions used in the project.
55

@@ -27,13 +27,13 @@ UnexpectedResponseException
2727
.. _TimeoutException:
2828

2929
TimeoutException
30-
---------------------------
30+
----------------
3131

3232
.. autoclass:: udsoncan.exceptions.TimeoutException
3333

3434
.. _ConfigError:
3535

3636
ConfigError
37-
---------------------------
37+
-----------
3838

3939
.. autoclass:: udsoncan.exceptions.ConfigError

doc/source/udsoncan/request_response.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ Request
2424
2525
.. autoclass:: udsoncan.Request
2626
.. automethod:: udsoncan.Request.get_payload
27+
:noindex:
2728
.. automethod:: udsoncan.Request.from_payload
29+
:noindex:
2830

2931
.. _Response:
3032

@@ -41,15 +43,19 @@ Response
4143
response2 = Response.from_payload(payload)
4244
print(response2) # <PositiveResponse: [ECUReset] - 2 data bytes at 0x7f9367e619b0>
4345
46+
4447
.. autoclass:: udsoncan.Response
48+
:members:
4549
.. automethod:: udsoncan.Response.get_payload
50+
:noindex:
4651
.. automethod:: udsoncan.Response.from_payload
52+
:noindex:
4753

4854
Response Codes
4955
##############
5056

5157
.. autoclass:: udsoncan::Response.Code
52-
:members:
53-
:undoc-members:
54-
:member-order: bysource
55-
:exclude-members: get_name, is_negative, is_supported_by_standard
58+
:members:
59+
:undoc-members:
60+
:member-order: bysource
61+
:exclude-members: get_name, is_negative, is_supported_by_standard

doc/source/udsoncan/services.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Each service is represented by a class that extends the ``BaseService`` class. T
3030
.. _AccessTimingParameter:
3131

3232
AccessTimingParameter (0x83)
33-
--------------------------------------
33+
----------------------------
3434

3535
.. automethod:: udsoncan.services.AccessTimingParameter.make_request
3636
.. automethod:: udsoncan.services.AccessTimingParameter.interpret_response

udsoncan/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ def clear_dtc(self, group: int = 0xFFFFFF, memory_selection: Optional[int] = Non
552552
:type group: int
553553
554554
:param memory_selection: MemorySelection byte (0-0xFF). This value is user defined and introduced in 2020 version of ISO-14229-1.
555-
Only added to the request payload when different from None. Default : None
555+
Only added to the request payload when different from None. Default : None
556556
:type memory_selection: int
557557
558558
:return: The server response parsed by :meth:`ClearDiagnosticInformation.interpret_response<udsoncan.services.ClearDiagnosticInformation.interpret_response>`
@@ -1619,8 +1619,8 @@ def get_dtc_extended_data_by_record_number(self, record_number: int, data_size:
16191619
:type record_number: int
16201620
16211621
:param data_size: The number of bytes of each extended data record. If not specified ``config['extended_data_size']`` will be used.
1622-
Since this method can return data for multiple DTCs and data size might be different for each DTC, it is possible to pass a dictionary
1623-
with a size for each DTC id (just like ``extended_data_size`` configuration). Example : size = {0x123456 : 5, 0x112233 : 10}
1622+
Since this method can return data for multiple DTCs and data size might be different for each DTC, it is possible to pass a dictionary
1623+
with a size for each DTC id (just like ``extended_data_size`` configuration). Example : size = {0x123456 : 5, 0x112233 : 10}
16241624
:type data_size: int, dict or None
16251625
16261626
:return: The server response parsed by :meth:`ReadDTCInformation.interpret_response<udsoncan.services.ReadDTCInformation.interpret_response>`

0 commit comments

Comments
 (0)