| 1 |
From: Michael Fladischer <[email protected]> |
| 2 |
Date: Sun, 21 Aug 2016 13:17:22 +0200 |
| 3 |
Subject: use local objects.inv where possible |
| 4 |
|
| 5 |
Upstream uses intersphinx mappings that fetch the objects.inv for python django |
| 6 |
through HTTP from a remote host. Using the local objects.inv from python and |
| 7 |
django enables the package to build without network connection. |
| 8 |
--- |
| 9 |
docs/conf.py | 54 +++++++++++++++++++++++++++++++++++++++++++++--------- |
| 10 |
1 file changed, 45 insertions(+), 9 deletions(-) |
| 11 |
|
| 12 |
diff --git a/docs/conf.py b/docs/conf.py |
| 13 |
index 28385d1..0de4570 100644 |
| 14 |
--- a/docs/conf.py |
| 15 |
+++ b/docs/conf.py |
| 16 |
@@ -27,6 +27,7 @@ os.environ["DJANGO_SETTINGS_MODULE"] = "polymorphic.tests.settings" |
| 17 |
django.setup() |
| 18 |
|
| 19 |
import polymorphic # noqa: E402 |
| 20 |
+import guardian # noqa: E402 |
| 21 |
|
| 22 |
# -- General configuration ----------------------------------------------------- |
| 23 |
|
| 24 |
@@ -276,17 +277,52 @@ texinfo_documents = [ |
| 25 |
# texinfo_show_urls = 'footnote' |
| 26 |
|
| 27 |
|
| 28 |
+def check_object_path(key, url, path): |
| 29 |
+ if os.path.isfile(path): |
| 30 |
+ return {key: (url, path)} |
| 31 |
+ return {} |
| 32 |
+ |
| 33 |
+ |
| 34 |
intersphinx_mapping = { |
| 35 |
- "django": ( |
| 36 |
- "https://docs.djangoproject.com/en/stable", |
| 37 |
- "https://docs.djangoproject.com/en/stable/_objects/", |
| 38 |
+ **check_object_path( |
| 39 |
+ "django", |
| 40 |
+ "https://docs.djangoproject.com/en/{v}".format( |
| 41 |
+ v=".".join(map(str, django.VERSION[:2])) |
| 42 |
+ ), |
| 43 |
+ "/usr/share/doc/python-django-doc/html/objects.inv", |
| 44 |
+ ), |
| 45 |
+ **check_object_path( |
| 46 |
+ "python", |
| 47 |
+ f"https://docs.python.org/{sys.version_info.major}.{sys.version_info.minor}/", |
| 48 |
+ f"/usr/share/doc/python{sys.version_info.major}.{sys.version_info.minor}/html/objects.inv", |
| 49 |
+ ), |
| 50 |
+ **check_object_path( |
| 51 |
+ "typing-extensions", |
| 52 |
+ "https://typing-extensions.readthedocs.io/en/latest/", |
| 53 |
+ "/usr/share/doc/python-typing-extensions-doc/html/objects.inv", |
| 54 |
+ ), |
| 55 |
+ **check_object_path( |
| 56 |
+ "django-guardian", |
| 57 |
+ "https://django-guardian.readthedocs.io/en/{v}/".format( |
| 58 |
+ v=".".join(map(str, guardian.VERSION)) |
| 59 |
+ ), |
| 60 |
+ "/usr/share/doc/python3-django-guardian/html/objects.inv", |
| 61 |
+ ), |
| 62 |
+ **check_object_path( |
| 63 |
+ "django-reversion", |
| 64 |
+ "https://django-reversion.readthedocs.io/en/stable", |
| 65 |
+ "/usr/share/doc/python-django-reversion-doc/html/objects.inv", |
| 66 |
+ ), |
| 67 |
+ **check_object_path( |
| 68 |
+ "django-extra-views", |
| 69 |
+ "https://django-extra-views.readthedocs.io/en/stable", |
| 70 |
+ "/usr/share/doc/python-django-extra-views-doc/html/objects.inv", |
| 71 |
+ ), |
| 72 |
+ **check_object_path( |
| 73 |
+ "model-bakery", |
| 74 |
+ "https://model-bakery.readthedocs.io/en/stable", |
| 75 |
+ "/usr/share/doc/python-model-bakery-doc/objects.inv", |
| 76 |
), |
| 77 |
- "python": ("https://docs.python.org/3", None), |
| 78 |
- "typing-extensions": ("https://typing-extensions.readthedocs.io/en/latest/", None), |
| 79 |
- "django-guardian": ("https://django-guardian.readthedocs.io/en/stable", None), |
| 80 |
- "django-reversion": ("https://django-reversion.readthedocs.io/en/stable", None), |
| 81 |
- "django-extra-views": ("https://django-extra-views.readthedocs.io/en/stable", None), |
| 82 |
- "model-bakery": ("https://model-bakery.readthedocs.io/en/stable", None), |
| 83 |
} |
| 84 |
|
| 85 |
# autodoc settings |