| 1 |
From: Michael Fladischer <[email protected]> |
| 2 |
Date: Fri, 7 Jul 2023 06:24:43 +0000 |
| 3 |
Subject: Use local objects.inv in intersphinx mapping. |
| 4 |
|
| 5 |
--- |
| 6 |
docs/source/conf.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++------- |
| 7 |
1 file changed, 53 insertions(+), 8 deletions(-) |
| 8 |
|
| 9 |
diff --git a/docs/source/conf.py b/docs/source/conf.py |
| 10 |
index ab0d1e5..7ab42de 100755 |
| 11 |
--- a/docs/source/conf.py |
| 12 |
+++ b/docs/source/conf.py |
| 13 |
@@ -32,6 +32,8 @@ if TYPE_CHECKING: |
| 14 |
from sphinx.application import Sphinx |
| 15 |
from sphinx.util.typing import Inventory |
| 16 |
|
| 17 |
+import OpenSSL |
| 18 |
+ |
| 19 |
# For our local_customization module |
| 20 |
sys.path.insert(0, os.path.abspath(".")) |
| 21 |
|
| 22 |
@@ -239,14 +241,57 @@ extensions = [ |
| 23 |
"typevars", |
| 24 |
] |
| 25 |
|
| 26 |
-intersphinx_mapping = { |
| 27 |
- "python": ("https://docs.python.org/3", None), |
| 28 |
- "outcome": ("https://outcome.readthedocs.io/en/latest/", None), |
| 29 |
- "pyopenssl": ("https://www.pyopenssl.org/en/stable/", None), |
| 30 |
- "sniffio": ("https://sniffio.readthedocs.io/en/latest/", None), |
| 31 |
- "trio-util": ("https://trio-util.readthedocs.io/en/latest/", None), |
| 32 |
- "flake8-async": ("https://flake8-async.readthedocs.io/en/latest/", None), |
| 33 |
-} |
| 34 |
+def check_object_path( |
| 35 |
+ key: str, url: str, path: str |
| 36 |
+) -> dict[str, tuple[str, str]]: |
| 37 |
+ if os.path.isfile(path): |
| 38 |
+ return {key: (url, path)} |
| 39 |
+ return {} |
| 40 |
+ |
| 41 |
+ |
| 42 |
+intersphinx_mapping = {} |
| 43 |
+intersphinx_mapping.update( |
| 44 |
+ check_object_path( |
| 45 |
+ "python", |
| 46 |
+ "https://docs.python.org/", |
| 47 |
+ "/usr/share/doc/python" + ".".join((str(x) for x in sys.version_info[:2])) + "/html/objects.inv" |
| 48 |
+ ) |
| 49 |
+) |
| 50 |
+intersphinx_mapping.update( |
| 51 |
+ check_object_path( |
| 52 |
+ "pyopenssl", |
| 53 |
+ "https://www.pyopenssl.org/en/{v}".format(v=OpenSSL.__version__), |
| 54 |
+ "/usr/share/doc/python-openssl-doc/html/objects.inv" |
| 55 |
+ ) |
| 56 |
+) |
| 57 |
+intersphinx_mapping.update( |
| 58 |
+ check_object_path( |
| 59 |
+ "outcome", |
| 60 |
+ "https://outcome.readthedocs.io/en/latest/", |
| 61 |
+ "/usr/share/doc/python-outcome-doc/html/objects.inv" |
| 62 |
+ ) |
| 63 |
+) |
| 64 |
+intersphinx_mapping.update( |
| 65 |
+ check_object_path( |
| 66 |
+ "sniffio", |
| 67 |
+ "https://sniffio.readthedocs.io/en/latest/", |
| 68 |
+ "/usr/share/doc/python-sniffio-doc/html/objects.inv" |
| 69 |
+ ) |
| 70 |
+) |
| 71 |
+intersphinx_mapping.update( |
| 72 |
+ check_object_path( |
| 73 |
+ "trio-util", |
| 74 |
+ "https://trio-util.readthedocs.io/en/latest/", |
| 75 |
+ "/usr/share/doc/python-trio-util-doc/html/objects.inv" |
| 76 |
+ ) |
| 77 |
+) |
| 78 |
+intersphinx_mapping.update( |
| 79 |
+ check_object_path( |
| 80 |
+ "flake8-async", |
| 81 |
+ "https://flake8-async.readthedocs.io/en/latest/", |
| 82 |
+ "/usr/share/doc/python-flake8-async-doc/html/objects.inv" |
| 83 |
+ ) |
| 84 |
+) |
| 85 |
|
| 86 |
# See https://sphinx-codeautolink.readthedocs.io/en/latest/reference.html#configuration |
| 87 |
codeautolink_autodoc_inject = False |