Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge] Add intersphinx mapping for pymechanical #795

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions doc/changelog.d/795.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[do not merge] Add intersphinx mapping for pymechanical
42 changes: 42 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,48 @@
"so cannot show the figure.",
)


# -- Project information -----------------------------------------------------

project = "ansys.mechanical.core"
copyright = f"(c) {datetime.now().year} ANSYS, Inc. All rights reserved"
author = "ANSYS Inc."
release = version = pymechanical.__version__
cname = os.getenv("DOCUMENTATION_CNAME", default="mechanical.docs.pyansys.com")
switcher_version = get_version_match(version)


def intersphinx_pymechanical(switcher_version: str):
"""Auxiliary method to build the intersphinx mapping for PyMechanical.

Notes
-----
If the objects.inv file is not found whenever it is a release, the method
will default to the "dev" version. If the objects.inv file is not found
for the "dev" version, the method will return an empty string.

Parameters
----------
switcher_version : str
Version of the PyMechanical package.

Returns
-------
str
The intersphinx mapping for PyMechanical.
"""
prefix = "https://mechanical.docs.pyansys.com/version"

# Check if the object.inv file exists
response = requests.get(f"{prefix}/{switcher_version}/objects.inv")

if response.status_code == 404:
if switcher_version == "dev":
return ""
else:
return intersphinx_pymechanical("dev")
else:
return f"{prefix}/{switcher_version}"


# Add any Sphinx extension module names here, as strings. They can be
Expand Down Expand Up @@ -71,6 +106,13 @@
"pypim": ("https://pypim.docs.pyansys.com/version/dev/", None),
}

# Conditional intersphinx mapping
if intersphinx_pymechanical(switcher_version):
intersphinx_mapping["ansys.mechanical.core"] = (
intersphinx_pymechanical(switcher_version),
None,
)

suppress_warnings = ["label.*", "autoapi.python_import_resolution", "design.grid", "config.cache"]
# supress_warnings = ["ref.option"]

Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide_session/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ to a remote Mechanical session.
Overview
--------

The `launch_mechanical() <../api/ansys/mechanical/core/mechanical/index.html#mechanical.launch_mechanical>`_ method
The :func:`launch_mechanical()<ansys.mechanical.core.mechanical.launch_mechanical>` method
creates an instance of the `Mechanical <../api/ansys/mechanical/core/mechanical/Mechanical.html>`_
class in the background and sends commands to it as a service. Because errors and warnings
are processed Pythonically, you can develop a script in real time without worrying about
Expand Down
Loading