1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
From: =?utf-8?q?Karsten_Sch=C3=B6ke?= <karsten.schoeke@geobasis-bb.de>
Date: Sun, 8 Mar 2026 15:50:08 +0100
Subject: Mock selectolax modules in docs
This patch updates the Sphinx documentation configuration to prevent the import
of selectolax during the documentation build.
Since selectolax depends on compiled C extensions, the import would fail.
This change simulates the selectolax modules using `autodoc_mock_imports`
and suppresses any warnings. Instead of importing the package to obtain
the version, it now extracts it directly from `selectolax/__init__.py` using a
regular expression. This ensures that the documentation can be reliably
built without requiring the compiled extensions.
Forwarded: not-needed
Last-Update: 2026-01-02
---
docs/conf.py | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/docs/conf.py b/docs/conf.py
index b416185..2ae2892 100755
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -16,6 +16,7 @@
import os
import platform
import sys
+import re
# If extensions (or modules to document with autodoc) are in another
# directory, add these directories to sys.path here. If the directory is
@@ -36,7 +37,14 @@ project_root = os.path.dirname(cwd)
if platform.system() == 'Darwin':
sys.path.insert(0, project_root)
-import selectolax
+# Mock the C-Extensions
+autodoc_mock_imports = ["selectolax", "selectolax.lexbor", "selectolax.parser", "selectolax.modest"]
+
+autodoc_typehints = "none"
+
+suppress_warnings = [
+ "autodoc.mocked_object",
+]
# -- General configuration ---------------------------------------------
@@ -74,9 +82,16 @@ copyright = u"2018-2025, Artem Golubin"
# the built documents.
#
# The short X.Y version.
-version = selectolax.__version__
-# The full version, including alpha/beta/rc tags.
-release = selectolax.__version__
+init_py = os.path.abspath(os.path.join('..', 'selectolax', '__init__.py'))
+
+with open(init_py, 'r', encoding='utf-8') as f:
+ content = f.read()
+
+version_match = re.search(r"^__version__\s*=\s*['\"]([^'\"]*)['\"]", content, re.MULTILINE)
+if version_match:
+ version = release = version_match.group(1)
+else:
+ version = release = "0.0.0"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
|