From d742f34c3339df2d58b51e8b2359449806e0ad2f Mon Sep 17 00:00:00 2001 From: Vamsi-2581 <245859299+Vamsi-2581@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:02:19 +0530 Subject: [PATCH 1/2] Add Python docs version switcher --- python/doc/source/conf.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/python/doc/source/conf.py b/python/doc/source/conf.py index 4a80c3dd6..0f13f580b 100644 --- a/python/doc/source/conf.py +++ b/python/doc/source/conf.py @@ -142,16 +142,17 @@ def setup(app): html_theme = "pydata_sphinx_theme" -# FIXME: Implement a version switch like NumPy. -# Set up the version switcher. The versions.json is stored in the doc repo. -# if os.environ.get('CIRCLE_JOB', False) and \ -# os.environ.get('CIRCLE_BRANCH', '') != 'main': -# # For PR, name is set to its ref -# switcher_version = os.environ['CIRCLE_BRANCH'] -# elif ".9999" in version: -# switcher_version = "devdocs" -# else: -# switcher_version = f"{version}" +# Use the version switcher metadata maintained in the gh-pages branch. +# Pull request builds use the PR ref so preview pages are not labelled as a +# released version. +if os.environ.get("GITHUB_ACTIONS") and os.environ.get("GITHUB_HEAD_REF"): + switcher_version = os.environ["GITHUB_HEAD_REF"] +elif ".dev" in version: + switcher_version = "dev" +else: + switcher_version = version + +switcher_json_url = f"{html_site_root}versions.json" html_theme_options = { "collapse_navigation": True, @@ -169,8 +170,7 @@ def setup(app): }, "navbar_align": "content", # Add light/dark mode and documentation version switcher: - # "navbar_end": ["theme-switcher", "version-switcher", "navbar-icon-links"], - "navbar_end": ["theme-switcher", "navbar-icon-links"], + "navbar_end": ["theme-switcher", "version-switcher", "navbar-icon-links"], "navbar_start": ["navbar-logo"], "navigation_with_keys": False, # https://sphinx-gallery.github.io/stable/advanced.html#using-sphinx-gallery-sidebar-components @@ -180,6 +180,10 @@ def setup(app): "sg_launcher_links", ], "show_prev_next": True, + "switcher": { + "json_url": switcher_json_url, + "version_match": switcher_version, + }, "show_toc_level": 2, # On this page sidebar "sidebar_includehidden": True, "use_edit_page_button": True, From 705e0968e79844abf72fa1d0724e69b57aae72e4 Mon Sep 17 00:00:00 2001 From: Vamsi-2581 <245859299+Vamsi-2581@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:02:53 +0530 Subject: [PATCH 2/2] Enable Python docs version switcher