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
|
From: Michael Fladischer <fladi@debian.org>
Date: Mon, 20 Nov 2023 22:18:15 +0000
Subject: Use local objects.inv in intersphinx mapping.
---
docs/conf.py | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/docs/conf.py b/docs/conf.py
index a9fb6ad..86ff36a 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -5,6 +5,7 @@
import os
import pathlib
import sys
+import django
current_dir = pathlib.Path(__file__).parent
# Find current settings module for doctests.
@@ -41,10 +42,23 @@ html_static_path = []
# -- Options for extensions --------------------------------------------------
-intersphinx_mapping = {
- "django": (
- "https://docs.djangoproject.com/en/dev/",
- "https://docs.djangoproject.com/en/dev/_objects/",
- ),
- "python": ("https://docs.python.org/3/", 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/{v.major}.{v.minor}/'.format(v=sys.version_info),
+ '/usr/share/doc/python{v.major}.{v.minor}/html/objects.inv'.format(v=sys.version_info)
+ )
+)
+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'
+ )
+)
|