diff --git a/doc/changelog.d/795.documentation.md b/doc/changelog.d/795.documentation.md new file mode 100644 index 000000000..d7663ba24 --- /dev/null +++ b/doc/changelog.d/795.documentation.md @@ -0,0 +1 @@ +[do not merge] Add intersphinx mapping for pymechanical \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index e377d3b71..90ee38c4c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -32,6 +32,7 @@ "so cannot show the figure.", ) + # -- Project information ----------------------------------------------------- project = "ansys.mechanical.core" @@ -39,6 +40,40 @@ 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 @@ -76,6 +111,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"] diff --git a/doc/source/user_guide_session/index.rst b/doc/source/user_guide_session/index.rst index e3e4b6aef..514c606f5 100644 --- a/doc/source/user_guide_session/index.rst +++ b/doc/source/user_guide_session/index.rst @@ -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()` 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