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 57 58 59 60 61 62
|
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Fri, 27 Jan 2017 09:50:38 +0100
Subject: Use local objects.inv where possible
Upstream uses intersphinx mappings that fetch the objects.inv for python by
HTTP from a remote host. Using the local objects.inv from python enables the
package to build without network connection.
---
docs/conf.py | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/docs/conf.py b/docs/conf.py
index 592df8b..775c575 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
import datetime
import os
+import sys
import time
+import django
import pkg_resources
@@ -13,11 +15,31 @@ extensions = [
'sphinx.ext.intersphinx'
]
-intersphinx_mapping = {
- 'http://docs.python.org': None,
- 'http://django.readthedocs.org/en/latest/': None,
- 'http://sybil.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/{v}/'.format(
+ v='.'.join(map(str, sys.version_info[0:2]))
+ ),
+ '/usr/share/doc/python{v}/html/objects.inv'.format(
+ v='.'.join(map(str, sys.version_info[0:2]))
+ )
+))
+intersphinx_mapping.update(check_object_path(
+ 'django',
+ 'https://django.readthedocs.org/en/latest/',
+ '/usr/share/doc/python-django-doc/html/objects.inv'
+))
+intersphinx_mapping.update(check_object_path(
+ 'sybil',
+ 'http://sybil.readthedocs.io/en/latest/',
+ '/usr/share/doc/python-sybil-doc/html/objects.inv'
+))
# General
source_suffix = '.txt'
|