From 933f596f946b30c898b75ba49d5458fe7f0d6146 Mon Sep 17 00:00:00 2001 From: paugier Date: Sat, 25 Feb 2023 20:59:27 +0100 Subject: [PATCH] Better early return for add_launch_buttons if no launch buttons --- src/sphinx_book_theme/header_buttons/launch.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sphinx_book_theme/header_buttons/launch.py b/src/sphinx_book_theme/header_buttons/launch.py index 323368ec..77da4dbd 100644 --- a/src/sphinx_book_theme/header_buttons/launch.py +++ b/src/sphinx_book_theme/header_buttons/launch.py @@ -41,7 +41,14 @@ def add_launch_buttons( # If so, insert the URLs depending on the configuration config_theme = app.config["html_theme_options"] launch_buttons = config_theme.get("launch_buttons", {}) - if not launch_buttons or not _is_notebook(app, pagename): + if ( + not launch_buttons + or not _is_notebook(app, pagename) + or not any( + launch_buttons[key] + for key in ("binderhub_url", "jupyterhub_url", "thebe", "colab_url") + ) + ): return # Grab the header buttons from context as it should already exist.