File: 0002-Use-local-objects.inv-in-intersphinx-mapping.patch

package info (click to toggle)
python-pyluach 2.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 340 kB
  • sloc: python: 2,448; makefile: 16; sh: 6
file content (42 lines) | stat: -rw-r--r-- 1,284 bytes parent folder | download
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
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Fri, 26 Jan 2024 22:47:10 +0000
Subject: Use local objects.inv in intersphinx mapping.

---
 docs/conf.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/docs/conf.py b/docs/conf.py
index f117976..806d30b 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -10,6 +10,8 @@
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 
+import os
+import sys
 import sphinx_rtd_theme
 
 
@@ -53,7 +55,19 @@ autodoc_member_order = 'bysource'
 autosummary_generate = True
 
 # Intersphinx settings
-intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
+def check_object_path(key, url, path):
+    if os.path.isfile(path):
+        return {key: (url, path)}
+    return {}
+
+intersphinx_mapping = {}
+intersphinx_mapping.update(
+    check_object_path(
+        'python',
+        f'https://docs.python.org/{sys.version_info.major}.{sys.version_info.minor}',
+        f'/usr/share/doc/python{sys.version_info.major}.{sys.version_info.minor}/html/objects.inv'
+    )
+)
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']