File: 0003-Make-intersphinx-use-local-copies-of-objects.inv-fil.patch

package info (click to toggle)
python-django-parler 2.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,012 kB
  • sloc: python: 4,291; makefile: 164; sh: 6
file content (56 lines) | stat: -rw-r--r-- 1,834 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
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Fri, 12 Nov 2021 14:02:42 +0000
Subject: Make intersphinx use local copies of objects.inv files.

---
 docs/conf.py | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 2f3f587..53d50d5 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -15,6 +15,7 @@ import os
 import sys
 
 import django
+import polymorphic
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -282,8 +283,30 @@ texinfo_documents = [
 
 
 # Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {
-    "https://docs.python.org/3/": None,
-    "https://docs.djangoproject.com/en/dev": "https://docs.djangoproject.com/en/dev/_objects/",
-    "polymorphic": ("https://django-polymorphic.readthedocs.io/en/latest/", 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/',
+        '/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'
+    )
+)
+intersphinx_mapping.update(
+    check_object_path(
+        'polymorphic',
+        'https://django-polymorphic.readthedocs.io/en/' + polymorphic.__version__ + '/',
+        '/usr/share/doc/python-django-polymorphic-doc/html/objects.inv'
+    )
+)