Skip to content

Commit ea59bf4

Browse files
add Sphinx docs config file
1 parent 3c003b3 commit ea59bf4

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

docs/conf.py

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
3+
import os
4+
import sys
5+
from pathlib import Path
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
sys.path.insert(0, os.path.abspath('../'))
14+
here = Path(__file__).parent.resolve()
15+
16+
try:
17+
import umodbus
18+
except ImportError:
19+
raise SystemExit("umodbus has to be importable")
20+
else:
21+
# Inject mock modules so that we can build the
22+
# documentation without having the real stuff available
23+
from mock import Mock
24+
25+
for mod_name in ['micropython', 'machine', 'urequests']:
26+
sys.modules[mod_name] = Mock()
27+
print("Mocked {}".format(mod_name))
28+
29+
# load elements of version.py
30+
exec(open(here / '..' / 'umodbus' / 'version.py').read())
31+
32+
# -- Project information
33+
34+
project = 'micropython-modbus'
35+
copyright = '2022, brainelectronics'
36+
author = 'brainelectronics'
37+
38+
version = __version__
39+
release = version
40+
41+
# -- General configuration
42+
43+
# Add any Sphinx extension module names here, as strings. They can be
44+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
45+
# ones.
46+
extensions = [
47+
'myst_parser',
48+
'sphinx.ext.autodoc',
49+
'sphinx.ext.autosectionlabel',
50+
'sphinx.ext.autosummary',
51+
'sphinx.ext.doctest',
52+
'sphinx.ext.duration',
53+
'sphinx.ext.intersphinx',
54+
'sphinx.ext.viewcode',
55+
]
56+
autosectionlabel_prefix_document = True
57+
58+
# The suffix of source filenames.
59+
source_suffix = ['.rst', '.md']
60+
61+
intersphinx_mapping = {
62+
'python': ('https://docs.python.org/3/', None),
63+
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
64+
}
65+
intersphinx_disabled_domains = ['std']
66+
suppress_warnings = [
67+
# throws an error due to not found reference targets to files not in docs/
68+
'ref.myst',
69+
# throws an error due to multiple "Added" labels in "changelog.md"
70+
'autosectionlabel.*'
71+
]
72+
73+
# A list of regular expressions that match URIs that should not be checked
74+
# when doing a linkcheck build.
75+
linkcheck_ignore = [
76+
# tag 2.0.0 did not exist during docs introduction
77+
'https://github.com/brainelectronics/micropython-modbus/tree/2.0.0',
78+
# RTD page did not exist during docs introduction
79+
'https://micropython-modbus.readthedocs.io/en/latest/',
80+
]
81+
82+
templates_path = ['_templates']
83+
84+
# -- Options for HTML output
85+
86+
# The theme to use for HTML and HTML Help pages. See the documentation for
87+
# a list of builtin themes.
88+
#
89+
html_theme = 'sphinx_rtd_theme'
90+
91+
# -- Options for EPUB output
92+
epub_show_urls = 'footnote'

0 commit comments

Comments
 (0)