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

package info (click to toggle)
python-django-constance 2.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 784 kB
  • sloc: python: 1,675; makefile: 163; javascript: 23; sh: 6
file content (50 lines) | stat: -rw-r--r-- 1,575 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
43
44
45
46
47
48
49
50
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Thu, 3 Nov 2022 19:50:17 +0000
Subject: Use local objects.inv in intersphinx mapping.

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

diff --git a/docs/conf.py b/docs/conf.py
index 2f87585..2739cdc 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -11,6 +11,7 @@
 # serve to show the default.
 import sys
 import os
+import django
 
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.settings')
 
@@ -258,9 +259,23 @@ texinfo_documents = [
 # If true, do not generate a @detailmenu in the "Top" node's menu.
 #texinfo_no_detailmenu = False
 
-# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {
-    'http://docs.python.org/': None,
-    'django': ('http://docs.djangoproject.com/en/dev/',
-               'http://docs.djangoproject.com/en/dev/_objects/'),
-}
+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',
+        'https://docs.python.org/' + '.'.join([str(x) for x in sys.version_info[0:2]]),
+        '/usr/share/doc/python' + '.'.join([str(x) for x in sys.version_info[0:2]]) + '/html/objects.inv'
+    )
+)
+intersphinx_mapping.update(
+    check_object_path(
+        'django',
+        'https://docs.djangoproject.com/en/' + django.get_version() + '/',
+        '/usr/share/doc/python-django-doc/html/objects.inv'
+    )
+)