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 77 78 79 80 81 82 83 84 85 86 87
|
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Fri, 7 Jul 2023 06:24:43 +0000
Subject: Use local objects.inv in intersphinx mapping.
docs/source/conf.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 53 insertions(+), 8 deletions(-)
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 5d30ec2..4f4a946 100755
@@ -29,6 +29,8 @@ if TYPE_CHECKING:
from sphinx.application import Sphinx
from sphinx.util.typing import Inventory
+import OpenSSL
+
# For our local_customization module
sys.path.insert(0, os.path.abspath("."))
@@ -207,14 +209,57 @@ extensions = [
"typevars",
]
-intersphinx_mapping = {
- "python": ("https://docs.python.org/3", None),
- "outcome": ("https://outcome.readthedocs.io/en/latest/", None),
- "pyopenssl": ("https://www.pyopenssl.org/en/stable/", None),
- "sniffio": ("https://sniffio.readthedocs.io/en/latest/", None),
- "trio-util": ("https://trio-util.readthedocs.io/en/latest/", None),
- "flake8-async": ("https://flake8-async.readthedocs.io/en/latest/", None),
-}
+def check_object_path(
+ key: str, url: str, path: str
+) -> dict[str, tuple[str, str]]:
+ if os.path.isfile(path):
+ return {key: (url, path)}
+ return {}
+
+
+intersphinx_mapping = {}
+intersphinx_mapping.update(
+ check_object_path(
+ "python",
+ "https://docs.python.org/",
+ "/usr/share/doc/python" + ".".join((str(x) for x in sys.version_info[:2])) + "/html/objects.inv"
+ )
+)
+intersphinx_mapping.update(
+ check_object_path(
+ "pyopenssl",
+ "https://www.pyopenssl.org/en/{v}".format(v=OpenSSL.__version__),
+ "/usr/share/doc/python-openssl-doc/html/objects.inv"
+ )
+)
+intersphinx_mapping.update(
+ check_object_path(
+ "outcome",
+ "https://outcome.readthedocs.io/en/latest/",
+ "/usr/share/doc/python-outcome-doc/html/objects.inv"
+ )
+)
+intersphinx_mapping.update(
+ check_object_path(
+ "sniffio",
+ "https://sniffio.readthedocs.io/en/latest/",
+ "/usr/share/doc/python-sniffio-doc/html/objects.inv"
+ )
+)
+intersphinx_mapping.update(
+ check_object_path(
+ "trio-util",
+ "https://trio-util.readthedocs.io/en/latest/",
+ "/usr/share/doc/python-trio-util-doc/html/objects.inv"
+ )
+)
+intersphinx_mapping.update(
+ check_object_path(
+ "flake8-async",
+ "https://flake8-async.readthedocs.io/en/latest/",
+ "/usr/share/doc/python-flake8-async-doc/html/objects.inv"
+ )
+)
# See https://sphinx-hoverxref.readthedocs.io/en/latest/configuration.html
hoverxref_auto_ref = True
|