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

package info (click to toggle)
python-drf-spectacular 0.28.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,748 kB
  • sloc: python: 14,174; javascript: 114; sh: 61; makefile: 30
file content (53 lines) | stat: -rw-r--r-- 1,656 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
51
52
53
From: Michael Fladischer <fladi@debian.org>
Date: Sun, 1 Oct 2023 21:23:57 +0000
Subject: Use local objects.inv in intersphinx mapping.

Forwarded: not-needed
---
 docs/conf.py | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index eb59b36..9acd3bc 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -13,6 +13,7 @@
 import os
 import sys
 
+import django
 from django.conf import settings
 
 settings.configure(USE_I18N=False, USE_L10N=False)
@@ -76,11 +77,26 @@ nitpick_ignore_regex = [
     ('py:class', r'drf_spectacular\.utils\.F'),
 ]
 
-intersphinx_mapping = {
-    'python': ('https://docs.python.org/3/', None),
-    'django': ('https://docs.djangoproject.com/en/stable/', 'https://docs.djangoproject.com/en/stable/_objects/'),
-    'drf-yasg': ('https://drf-yasg.readthedocs.io/en/stable/', 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',
+        'https://docs.python.org/{}/'.format('.'.join((str(x) for x in sys.version_info[:2]))),
+        '/usr/share/doc/python{}/html/objects.inv'.format('.'.join((str(x) for x in sys.version_info[:2])))
+    )
+)
+intersphinx_mapping.update(
+    check_object_path(
+        'django',
+        'https://docs.djangoproject.com/en/' + '.'.join((str(c) for c in django.VERSION[:2])) + '/_objects/',
+        '/usr/share/doc/python-django-doc/html/objects.inv'
+    )
+)
 
 # -- Options for HTML output -------------------------------------------------