From 7b5cedd22e61d2eabcbe328ec5caa5515d424601 Mon Sep 17 00:00:00 2001 From: Wes Turner Date: Sun, 26 Jan 2025 23:51:43 -0500 Subject: [PATCH 1/3] BUG: do not add icon links if theme_options[icon_links] is None --- src/pydata_sphinx_theme/__init__.py | 36 +++++++++++++++-------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/pydata_sphinx_theme/__init__.py b/src/pydata_sphinx_theme/__init__.py index 92944f4c4..07295df4c 100644 --- a/src/pydata_sphinx_theme/__init__.py +++ b/src/pydata_sphinx_theme/__init__.py @@ -40,11 +40,12 @@ def update_config(app): ) # Validate icon links - if not isinstance(theme_options.get("icon_links", []), list): - raise ExtensionError( - "`icon_links` must be a list of dictionaries, you provided " - f"type {type(theme_options.get('icon_links'))}." - ) + if theme_options.get("icon_links") is not None: + if not isinstance(theme_options.get("icon_links", []), list): + raise ExtensionError( + "`icon_links` must be a list of dictionaries, you provided " + f"type {type(theme_options.get('icon_links'))}." + ) # Set the anchor link default to be # if the user hasn't provided their own if not utils.config_provided_by_user(app, "html_permalinks_icon"): @@ -140,18 +141,19 @@ def update_config(app): # Add extra icon links entries if there were shortcuts present # TODO: Deprecate this at some point in the future? icon_links = theme_options.get("icon_links", []) - for url, icon, name in shortcuts: - if theme_options.get(url): - # This defaults to an empty list so we can always insert - icon_links.insert( - 0, - { - "url": theme_options.get(url), - "icon": icon, - "name": name, - "type": "fontawesome", - }, - ) + if icon_links is not None: + for url, icon, name in shortcuts: + if theme_options.get(url): + # This defaults to an empty list so we can always insert + icon_links.insert( + 0, + { + "url": theme_options.get(url), + "icon": icon, + "name": name, + "type": "fontawesome", + }, + ) theme_options["icon_links"] = icon_links # Prepare the logo config dictionary From 2477db017eb9bf9c30dc7b6224c0c723bd80a718 Mon Sep 17 00:00:00 2001 From: Wes Turner Date: Sun, 26 Jan 2025 23:52:59 -0500 Subject: [PATCH 2/3] BUG: do not shorten links if theme_options['shorten_urls'] is not True --- src/pydata_sphinx_theme/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pydata_sphinx_theme/__init__.py b/src/pydata_sphinx_theme/__init__.py index 07295df4c..ed8ccc0ff 100644 --- a/src/pydata_sphinx_theme/__init__.py +++ b/src/pydata_sphinx_theme/__init__.py @@ -284,7 +284,10 @@ def setup(app: Sphinx) -> Dict[str, str]: app.add_html_theme("pydata_sphinx_theme", str(theme_path)) - app.add_post_transform(short_link.ShortenLinkTransform) + + theme_options = utils.get_theme_options_dict(app) + if theme_options.get("shorten_urls") is True: + app.add_post_transform(short_link.ShortenLinkTransform) app.connect("builder-inited", translator.setup_translators) app.connect("builder-inited", update_config) From 91c3609719239a07281b76dcc12b4a03582dd288 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 04:56:23 +0000 Subject: [PATCH 3/3] [pre-commit.ci] Automatic linting and formatting fixes --- src/pydata_sphinx_theme/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pydata_sphinx_theme/__init__.py b/src/pydata_sphinx_theme/__init__.py index ed8ccc0ff..ce53bef2d 100644 --- a/src/pydata_sphinx_theme/__init__.py +++ b/src/pydata_sphinx_theme/__init__.py @@ -284,7 +284,6 @@ def setup(app: Sphinx) -> Dict[str, str]: app.add_html_theme("pydata_sphinx_theme", str(theme_path)) - theme_options = utils.get_theme_options_dict(app) if theme_options.get("shorten_urls") is True: app.add_post_transform(short_link.ShortenLinkTransform)