From ef89431a083f8cc5a6a2d09b3090fc8d89034e24 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Thu, 26 May 2022 20:34:05 +0200 Subject: [PATCH 1/2] Move version switcher next to the logo. This is in preparation for adding the search field to the navbar. IMHO placing the version next to the logo also rhymes better. Styling of the switcher is more muted (not the strong blue). It's colors are taken from the panels on the index page. --- doc/_static/mpl.css | 19 +++++++++++++++++++ doc/conf.py | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/_static/mpl.css b/doc/_static/mpl.css index 2d26f8738406..bb7806a58db9 100644 --- a/doc/_static/mpl.css +++ b/doc/_static/mpl.css @@ -277,3 +277,22 @@ div.twocol > div { display: inline-block; margin: 0 0.5em; } + + +/* styling for version switcher */ +.navbar-brand { + /* pydata-sphinx-theme sets this as flex for some reason + but we cannot place the version switcher to its right then. + */ + display: inline-block; +} + +#version_switcher { + display: inline-block; +} + +#version_switcher_button { + color: rgba(var(--pst-color-text-base),1); + background-color: rgba(0,0,0,.03); + border: 1px solid rgba(0,0,0,.125); +} diff --git a/doc/conf.py b/doc/conf.py index 4b8609e5ec01..928729f4ca7b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -341,7 +341,8 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf, "url_template": "https://matplotlib.org/{version}/", "version_match": version, }, - "navbar_end": ["version-switcher", "mpl_icon_links"] + "navbar_start": ["mpl_navbar_logo", "version-switcher"], + "navbar_end": ["mpl_icon_links"] } include_analytics = is_release_build if include_analytics: From a18aa85cd8fe8d1f859490cdd8850be49b63e19e Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sun, 29 May 2022 22:45:33 +0200 Subject: [PATCH 2/2] Point the version switcher to a name listed in switcher.json --- doc/conf.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 928729f4ca7b..6bc0d4351e2b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -339,7 +339,11 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf, "switcher": { "json_url": "https://matplotlib.org/devdocs/_static/switcher.json", "url_template": "https://matplotlib.org/{version}/", - "version_match": version, + "version_match": ( + # The start version to show. This must be in switcher.json. + # We either go to 'stable' or to 'devdocs' + 'stable' if matplotlib.__version_info__.releaselevel == 'final' + else 'devdocs') }, "navbar_start": ["mpl_navbar_logo", "version-switcher"], "navbar_end": ["mpl_icon_links"]