From 4a90ce165efb82deb0dc6517fe6165016f86f7d9 Mon Sep 17 00:00:00 2001
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Sun, 21 Aug 2016 13:17:22 +0200
Subject: use local objects.inv where possible

Upstream uses intersphinx mappings that fetch the objects.inv for python django
through HTTP from a remote host. Using the local objects.inv from python and
django enables the package to build without network connection.
---
 docs/conf.py | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index f14fa5f..e826275 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -249,8 +249,17 @@ texinfo_documents = [
 #texinfo_show_urls = 'footnote'
 
 
-# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {
-    #'http://docs.python.org/': None,
-    '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',
+                                             'http://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/dev',
+                                             '/usr/share/doc/python-django-doc/html/objects.inv'))
