Skip to content

Commit 8e2c275

Browse files
gijzelaerrclaude
andcommitted
Fix Read the Docs build for v2 documentation
Update .readthedocs.yaml to install from pyproject.toml extras instead of missing requirements-dev.txt. Add mock imports in conf.py so autodoc works without the native snap7 C library. Use sphinx_rtd_theme for consistent styling. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0810f36 commit 8e2c275

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

.readthedocs.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ sphinx:
1212

1313
python:
1414
install:
15-
- requirements: requirements-dev.txt
15+
- method: pip
16+
path: .
17+
extra_requirements:
18+
- doc

doc/conf.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@
1111

1212
import sys
1313
from pathlib import Path
14+
from unittest.mock import MagicMock
1415

1516
# If extensions (or modules to document with autodoc) are in another directory,
1617
# add these directories to sys.path here. If the directory is relative to the
1718
# documentation root, use os.path.abspath to make it absolute, like shown here.
1819
# sys.path.insert(0, os.path.abspath('.'))
1920
sys.path.insert(0, str(Path("..").resolve()))
2021

21-
import snap7 # noqa: E402
22+
# Mock the snap7 C library loading for Read the Docs builds where the native
23+
# library is not available.
24+
try:
25+
import snap7 # noqa: E402
26+
except (RuntimeError, OSError):
27+
snap7 = MagicMock() # type: ignore[misc]
28+
snap7.__version__ = "2.1.0"
2229

2330
# -- General configuration -----------------------------------------------------
2431

@@ -29,6 +36,10 @@
2936
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
3037
extensions = ["sphinx.ext.autodoc", "sphinx.ext.coverage", "sphinx.ext.viewcode", "sphinx.ext.napoleon"]
3138

39+
# Mock modules that depend on the native snap7 C library, so autodoc works
40+
# on Read the Docs where the library is not available.
41+
autodoc_mock_imports = ["snap7.common", "snap7.protocol"]
42+
3243
# Add any paths that contain templates here, relative to this directory.
3344
templates_path = ["_templates"]
3445

@@ -93,7 +104,7 @@
93104

94105
# The theme to use for HTML and HTML Help pages. See the documentation for
95106
# a list of builtin themes.
96-
html_theme = "default"
107+
html_theme = "sphinx_rtd_theme"
97108

98109
# Theme options are theme-specific and customize the look and feel of a theme
99110
# further. For a list of options available for each theme, see the

0 commit comments

Comments
 (0)