From: Andrey Rakhmatullin <wrar@debian.org>
Date: Sun, 21 Apr 2024 23:29:56 +0500
Subject: Use local intersphinx files.

---
 docs/conf.py | 40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 4d7b0d6..62734a7 100755
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -119,12 +119,40 @@ texinfo_documents = [
 
 # -- Options for the InterSphinx extension ------------------------------------
 
-intersphinx_mapping = {
-    "cssselect": ("https://cssselect.readthedocs.io/en/latest", None),
-    "python": ("https://docs.python.org/3", None),
-    "requests": ("https://requests.kennethreitz.org/en/latest", None),
-    "lxml": ("https://lxml.de/apidoc/", None),
-}
+def check_object_path(key, url, path):
+    if path and os.path.isfile(path):
+        return {key: (url, path)}
+    return {}
+
+intersphinx_mapping = {}
+intersphinx_mapping.update(
+   check_object_path(
+       "cssselect",
+       "https://cssselect.readthedocs.org/en/latest/",
+       "/usr/share/doc/python-cssselect-doc/html/objects.inv",
+   )
+)
+intersphinx_mapping.update(
+   check_object_path(
+       "lxml",
+       "https://lxml.de/apidoc/",
+       "/usr/share/doc/python-lxml-doc/html/objects.inv",
+   )
+)
+intersphinx_mapping.update(
+    check_object_path(
+        "python",
+        "https://docs.python.org/3",
+        "/usr/share/doc/python%d.%d/html/objects.inv" % sys.version_info[:2],
+    )
+)
+intersphinx_mapping.update(
+   check_object_path(
+       "requests",
+       "https://requests.kennethreitz.org/en/latest",
+       "/usr/share/doc/python-requests-doc/html/objects.inv",
+   )
+)
 
 
 # --- Nitpicking options ------------------------------------------------------
