File: Use-local-inventory-for-intersphinx.patch

package info (click to toggle)
django-cas-server 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,112 kB
  • sloc: python: 6,036; makefile: 262; xml: 100; javascript: 92; sh: 17
file content (65 lines) | stat: -rw-r--r-- 2,099 bytes parent folder | download | duplicates (2)
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
From: Carsten Schoenert <c.schoenert@t-online.de>
Date: Sun, 12 Sep 2021 21:07:44 +0200
Subject: Use local inventory for intersphinx

The upstream way is to fetch the interspinx inventary by https from
docs.djangoproject.com.
Using instead the packages stuff from python3-django-doc.

This patch is basicaly completely taken from python-testfixtures and was
written by Michael Fladischer <FladischerMichael@fladi.at>.

Forwarded: not-needed
---
 docs/conf.py | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 3f2fafe..8625c90 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -348,22 +348,29 @@ texinfo_documents = [
 # texinfo_no_detailmenu = False
 
 # Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {
-    "python": ('https://docs.python.org/', None),
-    "django": ('https://docs.djangoproject.com/en/3.2/', 'django.inv'),
-}
+
+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://django.readthedocs.org/en/latest/',
+    '/usr/share/doc/python-django-doc/html/objects.inv'
+))
 
 autodoc_member_order = 'bysource'
 
 locale_dirs = ['../test_venv/lib/python2.7/site-packages/django/conf/locale/']
-
-
-def _download_django_inv():
-    import requests
-    with open(_download_django_inv.path, 'wb') as f:
-        r = requests.get("https://docs.djangoproject.com/en/3.2/_objects")
-        f.write(r.content)
-_download_django_inv.path = os.path.abspath(os.path.join(os.path.dirname(__file__), "django.inv"))
-
-if not os.path.isfile(_download_django_inv.path):
-    _download_django_inv()