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
|
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Thu, 3 Nov 2022 19:50:17 +0000
Subject: Use local objects.inv in intersphinx mapping.
---
docs/conf.py | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/docs/conf.py b/docs/conf.py
index 3526dd1..8472602 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -6,6 +6,7 @@
import os
import re
import sys
+import django
from datetime import datetime
@@ -91,7 +92,23 @@ texinfo_documents = [
]
# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {
- "python": ("https://docs.python.org/3", None),
- "django": ("https://docs.djangoproject.com/en/dev/", "https://docs.djangoproject.com/en/dev/_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/" + ".".join([str(x) for x in sys.version_info[0:2]]),
+ "/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"
+ )
+)
|