Skip to content

Commit 3f45075

Browse files
fix: solve issues with intersphinx when releasing (#1123)
Co-authored-by: pyansys-ci-bot <pyansys.github.bot@ansys.com>
1 parent aaf2b49 commit 3f45075

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

doc/changelog.d/1123.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix: solve issues with intersphinx when releasing

doc/source/conf.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,40 @@ def get_wheelhouse_assets_dictionary():
5858
return assets
5959

6060

61+
def intersphinx_pyansys_geometry(switcher_version: str):
62+
"""
63+
Auxiliary method to build the intersphinx mapping for PyAnsys Geometry.
64+
65+
Notes
66+
-----
67+
If the objects.inv file is not found whenever it is a release, the method
68+
will default to the "dev" version. If the objects.inv file is not found
69+
for the "dev" version, the method will return an empty string.
70+
71+
Parameters
72+
----------
73+
switcher_version : str
74+
Version of the PyAnsys Geometry package.
75+
76+
Returns
77+
-------
78+
str
79+
The intersphinx mapping for PyAnsys Geometry.
80+
"""
81+
prefix = "https://geometry.docs.pyansys.com/version"
82+
83+
# Check if the object.inv file exists
84+
response = requests.get(f"{prefix}/{switcher_version}/objects.inv")
85+
86+
if response.status_code == 404:
87+
if switcher_version == "dev":
88+
return ""
89+
else:
90+
return intersphinx_pyansys_geometry("dev")
91+
else:
92+
return f"{prefix}/{switcher_version}"
93+
94+
6195
# Project information
6296
project = "ansys-geometry-core"
6397
copyright = f"(c) {datetime.now().year} ANSYS, Inc. All rights reserved"
@@ -136,9 +170,15 @@ def get_wheelhouse_assets_dictionary():
136170
"beartype": ("https://beartype.readthedocs.io/en/stable/", None),
137171
"docker": ("https://docker-py.readthedocs.io/en/stable/", None),
138172
"pypim": ("https://pypim.docs.pyansys.com/version/stable", None),
139-
"ansys.geometry.core": (f"https://geometry.docs.pyansys.com/version/{switcher_version}", None),
140173
}
141174

175+
# Conditional intersphinx mapping
176+
if intersphinx_pyansys_geometry(switcher_version):
177+
intersphinx_mapping["ansys.geometry.core"] = (
178+
intersphinx_pyansys_geometry(switcher_version),
179+
None,
180+
)
181+
142182
# numpydoc configuration
143183
numpydoc_show_class_members = False
144184
numpydoc_xref_param_type = True

0 commit comments

Comments
 (0)