From e871cdfac913a050e368fbf6d15c95c5c590a569 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Wed, 6 Jul 2022 15:58:13 +0300 Subject: [PATCH 1/4] DOC: Add theme switcher and default to lightmode. --- doc/conf.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 4b36f7e8..d8d233ab 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -83,11 +83,16 @@ html_theme_options = { "github_url": "https://github.com/numpy/numpydoc", "show_prev_next": False, - "navbar_end": ["search-field.html", "navbar-icon-links.html"], + "navbar_end": [ + "theme-switcher", "search-field.html", "navbar-icon-links.html" + ], } html_sidebars = { "**": [], } +html_context = { + "default_mode": "light", +} html_title = f"{project} v{version} Manual" html_last_updated_fmt = "%b %d, %Y" From a194b5b5c399d3ede0fad06e91da50b8d8586a4d Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Wed, 6 Jul 2022 16:02:22 +0300 Subject: [PATCH 2/4] Make linter happy. --- doc/conf.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index d8d233ab..3379c11b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -83,9 +83,7 @@ html_theme_options = { "github_url": "https://github.com/numpy/numpydoc", "show_prev_next": False, - "navbar_end": [ - "theme-switcher", "search-field.html", "navbar-icon-links.html" - ], + "navbar_end": ["theme-switcher", "search-field.html", "navbar-icon-links.html"], } html_sidebars = { "**": [], From 26caf959742151714def426b89c35d7bb4a99472 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Wed, 6 Jul 2022 16:18:16 +0300 Subject: [PATCH 3/4] Add workaround for theme versions that don't support mode switcher. --- doc/conf.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 3379c11b..f51ccf4a 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -83,8 +83,17 @@ html_theme_options = { "github_url": "https://github.com/numpy/numpydoc", "show_prev_next": False, - "navbar_end": ["theme-switcher", "search-field.html", "navbar-icon-links.html"], + "navbar_end": ["search-field.html", "navbar-icon-links.html"], } +# Add version switcher for versions of pydata_sphinx_theme that support it +import packaging +import pydata_sphinx_theme + +if packaging.version.parse(pydata_sphinx_theme.__version__) >= packaging.version.parse( + "0.9.0" +): + html_theme_options["navbar_end"].insert(0, "theme-switcher") + html_sidebars = { "**": [], } From 7d109d4be4b37d2e7428578f3baa138b1b64cf84 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Thu, 7 Jul 2022 15:31:23 +0300 Subject: [PATCH 4/4] Add comment about theme version checking in conf. --- doc/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index f51ccf4a..560334d9 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -85,6 +85,10 @@ "show_prev_next": False, "navbar_end": ["search-field.html", "navbar-icon-links.html"], } +# NOTE: The following is required for supporting of older sphinx toolchains. +# The "theme-switcher" templated should be added directly to navbar_end +# above and the following lines removed when the minimum supported +# version of pydata_sphinx_theme is 0.9.0 # Add version switcher for versions of pydata_sphinx_theme that support it import packaging import pydata_sphinx_theme @@ -94,6 +98,7 @@ ): html_theme_options["navbar_end"].insert(0, "theme-switcher") + html_sidebars = { "**": [], }