From: Michael Fladischer 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 | 54 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 28385d1..18d7b74 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,6 +10,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. +import importlib.metadata import os import shutil import sys @@ -276,17 +277,52 @@ texinfo_documents = [ # texinfo_show_urls = 'footnote' +def check_object_path(key, url, path): + if os.path.isfile(path): + return {key: (url, path)} + return {} + + intersphinx_mapping = { - "django": ( - "https://docs.djangoproject.com/en/stable", - "https://docs.djangoproject.com/en/stable/_objects/", + **check_object_path( + "django", + "https://docs.djangoproject.com/en/{v}".format( + v=".".join(map(str, django.VERSION[:2])) + ), + "/usr/share/doc/python-django-doc/html/objects.inv", + ), + **check_object_path( + "python", + f"https://docs.python.org/{sys.version_info.major}.{sys.version_info.minor}/", + f"/usr/share/doc/python{sys.version_info.major}.{sys.version_info.minor}/html/objects.inv", + ), + **check_object_path( + "typing-extensions", + "https://typing-extensions.readthedocs.io/en/latest/", + "/usr/share/doc/python-typing-extensions-doc/html/objects.inv", + ), + **check_object_path( + "django-guardian", + "https://django-guardian.readthedocs.io/en/{v}/".format( + v=importlib.metadata.version("django-guardian") + ), + "/usr/share/doc/python3-django-guardian/html/objects.inv", + ), + **check_object_path( + "django-reversion", + "https://django-reversion.readthedocs.io/en/stable", + "/usr/share/doc/python-django-reversion-doc/html/objects.inv", + ), + **check_object_path( + "django-extra-views", + "https://django-extra-views.readthedocs.io/en/stable", + "/usr/share/doc/python-django-extra-views-doc/html/objects.inv", + ), + **check_object_path( + "model-bakery", + "https://model-bakery.readthedocs.io/en/stable", + "/usr/share/doc/python-model-bakery-doc/objects.inv", ), - "python": ("https://docs.python.org/3", None), - "typing-extensions": ("https://typing-extensions.readthedocs.io/en/latest/", None), - "django-guardian": ("https://django-guardian.readthedocs.io/en/stable", None), - "django-reversion": ("https://django-reversion.readthedocs.io/en/stable", None), - "django-extra-views": ("https://django-extra-views.readthedocs.io/en/stable", None), - "model-bakery": ("https://model-bakery.readthedocs.io/en/stable", None), } # autodoc settings