From dc9acef4f278424c06ac5e6d507b43616ac3fa27 Mon Sep 17 00:00:00 2001 From: dkunhamb Date: Thu, 27 Jun 2024 13:06:30 -0500 Subject: [PATCH 1/4] add intersphinx --- doc/source/conf.py | 43 +++++++++++++++++++++++++ doc/source/user_guide_session/index.rst | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 431d3a4ae..1c0908efe 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -13,6 +13,7 @@ import warnings from ansys_sphinx_theme import ansys_favicon, get_version_match, pyansys_logo_black +import requests from sphinx_gallery.sorting import FileNameSortKey import ansys.mechanical.core as pymechanical @@ -31,6 +32,7 @@ "so cannot show the figure.", ) + # -- Project information ----------------------------------------------------- project = "ansys.mechanical.core" @@ -38,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 @@ -73,6 +109,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 12ae35436..557e42f74 100644 --- a/doc/source/user_guide_session/index.rst +++ b/doc/source/user_guide_session/index.rst @@ -21,7 +21,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 From 016ee2d0824089131dbaa40503fb323153262766 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot Date: Thu, 27 Jun 2024 18:09:43 +0000 Subject: [PATCH 2/4] chore: adding changelog file 795.changed.md --- doc/changelog.d/795.changed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/795.changed.md diff --git a/doc/changelog.d/795.changed.md b/doc/changelog.d/795.changed.md new file mode 100644 index 000000000..162e5789e --- /dev/null +++ b/doc/changelog.d/795.changed.md @@ -0,0 +1 @@ +MAINT: Add intersphinx mapping for pymechanical \ No newline at end of file From 6cfe2fb2ca0d0fe8abf175d1cdbdd32a6708a180 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:43:41 +0000 Subject: [PATCH 3/4] chore: adding changelog file 795.changed.md --- doc/changelog.d/795.changed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.d/795.changed.md b/doc/changelog.d/795.changed.md index 162e5789e..d7663ba24 100644 --- a/doc/changelog.d/795.changed.md +++ b/doc/changelog.d/795.changed.md @@ -1 +1 @@ -MAINT: Add intersphinx mapping for pymechanical \ No newline at end of file +[do not merge] Add intersphinx mapping for pymechanical \ No newline at end of file From 832e48b297e7f29822114b49a296ea02d5cbe056 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:30:43 +0000 Subject: [PATCH 4/4] chore: adding changelog file 795.documentation.md --- doc/changelog.d/{795.changed.md => 795.documentation.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/changelog.d/{795.changed.md => 795.documentation.md} (100%) diff --git a/doc/changelog.d/795.changed.md b/doc/changelog.d/795.documentation.md similarity index 100% rename from doc/changelog.d/795.changed.md rename to doc/changelog.d/795.documentation.md