File: 0001-Use-local-objects.inv-file-for-intersphinx.patch

package info (click to toggle)
python-django-otp 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 584 kB
  • sloc: python: 2,230; makefile: 152; sh: 6
file content (47 lines) | stat: -rw-r--r-- 1,524 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
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Sun, 26 Feb 2017 17:19:06 +0100
Subject: Use local objects.inv file for intersphinx.

This makes sure that no online resources are used during package build.
---
 docs/source/conf.py | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/docs/source/conf.py b/docs/source/conf.py
index e1eed78..9c6479b 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -60,11 +60,28 @@ django.conf.settings.configure(
 )
 django.setup()
 
-intersphinx_mapping = {
-    'python': ('https://docs.python.org/3/', None),
-    'django': ('https://docs.djangoproject.com/en/2.2/',
-               'https://docs.djangoproject.com/en/2.2/_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/{v}/'.format(
+        v='.'.join(map(str, sys.version_info[0:2]))
+    ),
+    '/usr/share/doc/python{v}/html/objects.inv'.format(
+        v='.'.join(map(str, sys.version_info[0:2]))
+    )
+))
+intersphinx_mapping.update(check_object_path(
+    'django',
+    'https://docs.djangoproject.com/en/{v}/'.format(
+        v='.'.join(map(str, django.VERSION[:2]))
+    ),
+    '/usr/share/doc/python-django-doc/html/objects.inv'
+))
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']