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 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Sat, 6 Aug 2022 20:43:38 +0000
Subject: Use local objects.inv in intersphinx mapping.
---
docs/conf.py | 53 +++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 43 insertions(+), 10 deletions(-)
diff --git a/docs/conf.py b/docs/conf.py
index 561d24d..066c3b7 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -18,6 +18,8 @@ __location__ = os.path.join(
import pypandoc
+from pkg_resources import get_distribution
+
# Manually convert documentation
pypandoc.convert_file(
os.path.join(__location__, "../README.md"),
@@ -326,13 +328,44 @@ latex_documents = [
# latex_domain_indices = True
# -- External mapping ------------------------------------------------------------
-python_version = ".".join(map(str, sys.version_info[0:2]))
-intersphinx_mapping = {
- "sphinx": ("http://www.sphinx-doc.org/en/stable", None),
- "python": ("https://docs.python.org/" + python_version, None),
- "matplotlib": ("https://matplotlib.org", None),
- "numpy": ("https://docs.scipy.org/doc/numpy", None),
- "sklearn": ("http://scikit-learn.org/stable", None),
- "pandas": ("http://pandas.pydata.org/pandas-docs/stable", None),
- "scipy": ("https://docs.scipy.org/doc/scipy/reference", 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/' + '.'.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(
+ 'sphinx',
+ 'https://www.sphinx-doc.org/en/master/',
+ '/usr/share/doc/sphinx-doc/html/objects.inv'
+ )
+)
+intersphinx_mapping.update(
+ check_object_path(
+ 'sklearn',
+ 'http://scikit-learn.org/{v.major}.{v.minor}/'.format(v=get_distribution("scikit-learn").parsed_version),
+ '/usr/share/doc/python-sklearn-doc/html/objects.inv'
+ )
+)
+intersphinx_mapping.update(
+ check_object_path(
+ 'pandas',
+ 'http://pandas.pydata.org/pandas-docs/{v.major}.{v.minor}/'.format(v=get_distribution("pandas").parsed_version),
+ '/usr/share/doc/python-pandas-doc/html/objects.inv'
+ )
+)
+intersphinx_mapping.update(
+ check_object_path(
+ 'scipy',
+ 'nump://docs.scipy.org/doc/scipy-{v}/'.format(v=get_distribution("scipy").version),
+ '/usr/share/doc/python-scipy-doc/html/objects.inv'
+ )
+)
|