diff --git a/src/pydata_sphinx_theme/__init__.py b/src/pydata_sphinx_theme/__init__.py index bbf080920..efc4ade74 100644 --- a/src/pydata_sphinx_theme/__init__.py +++ b/src/pydata_sphinx_theme/__init__.py @@ -171,6 +171,28 @@ def update_config(app): ): app.config.fontawesome_included = True + # Handle icon link shortcuts + shortcuts = [ + ("twitter_url", "fa-brands fa-square-twitter", "Twitter"), + ("bitbucket_url", "fa-brands fa-bitbucket", "Bitbucket"), + ("gitlab_url", "fa-brands fa-square-gitlab", "GitLab"), + ("github_url", "fa-brands fa-square-github", "GitHub"), + ] + # Add extra icon links entries if there were shortcuts present + # TODO: Deprecate this at some point in the future? + for url, icon, name in shortcuts: + if theme_options.get(url): + # This defaults to an empty list so we can always insert + theme_options["icon_links"].insert( + 0, + { + "url": theme_options.get(url), + "icon": icon, + "name": name, + "type": "fontawesome", + }, + ) + # Prepare the logo config dictionary theme_logo = theme_options.get("logo") if not theme_logo: @@ -720,7 +742,6 @@ def soup_to_python(soup, only_pages=False): # ... def extract_level_recursive(ul, navs_list): - for li in ul.find_all("li", recursive=False): ref = li.a url = ref["href"] diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html index 467b981d5..78c595b9e 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html @@ -25,15 +25,11 @@ {%- endif -%} {%- endmacro -%} +{%- if theme_icon_links -%} +{%- endif -%} diff --git a/tests/check_warnings.py b/tests/check_warnings.py index 90df68478..1b08eb5b7 100644 --- a/tests/check_warnings.py +++ b/tests/check_warnings.py @@ -53,7 +53,6 @@ def check_warnings(file): if __name__ == "__main__": - # cast the file to path and resolve to an absolute one file = Path.cwd() / "warnings.txt" diff --git a/tests/test_build.py b/tests/test_build.py index dff676d70..c97193648 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -918,10 +918,17 @@ def test_empty_templates(sphinx_build_factory): """If a template is empty (e.g., via a config), it should be removed.""" # When configured to be gone, the template should be removed w/ its parent. # ABlog needs to be added so we can test that template rendering works w/ it. - confoverrides = {"html_show_sourcelink": False} + confoverrides = { + "html_show_sourcelink": False, + } sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build() - toc_items = sphinx_build.html_tree("page1.html").select(".toc-item") - assert not any(ii.select(".tocsection.sourcelink") for ii in toc_items) + html = sphinx_build.html_tree("page1.html") + + # We've set this to fase in the config so the template shouldn't show up at all + assert not html.select(".tocsection.sourcelink") + + # Should not be any icon link wrapper because none are given in conf + assert not html.select(".navbar-icon-links") def test_translations(sphinx_build_factory): diff --git a/tests/test_build/sidebar_subpage.html b/tests/test_build/sidebar_subpage.html index 1fffac84c..17bbffa91 100644 --- a/tests/test_build/sidebar_subpage.html +++ b/tests/test_build/sidebar_subpage.html @@ -46,10 +46,6 @@ `); -