From 76713c359806f07eeb3e3ffcb27def7664159959 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Fri, 8 Sep 2023 23:30:32 +0100 Subject: [PATCH] Add the ability to add a center section to the footer (#1432) * Add a center section for the footer * Add docs for footer_center * Add a test site for the center footer * test it in our own docs * remove new test site * add footer test --------- Co-authored-by: Daniel McCloy --- docs/conf.py | 3 ++- docs/user_guide/layout.rst | 4 ++-- src/pydata_sphinx_theme/__init__.py | 1 + .../assets/styles/sections/_footer.scss | 7 ++++++- .../pydata_sphinx_theme/sections/footer.html | 7 +++++++ .../theme/pydata_sphinx_theme/theme.conf | 1 + tests/test_build.py | 16 ++++++++++++++++ 7 files changed, 35 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 986b4ba4e..77bedc9a2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -174,7 +174,8 @@ # "primary_sidebar_end": ["custom-template.html", "sidebar-ethical-ads.html"], # "article_footer_items": ["test.html", "test.html"], # "content_footer_items": ["test.html", "test.html"], - # "footer_start": ["test.html", "test.html"], + "footer_start": ["copyright.html"], + "footer_center": ["sphinx-version.html"], # "secondary_sidebar_items": ["page-toc.html"], # Remove the source buttons "switcher": { "json_url": json_url, diff --git a/docs/user_guide/layout.rst b/docs/user_guide/layout.rst index ee822eb40..a562f9d8c 100644 --- a/docs/user_guide/layout.rst +++ b/docs/user_guide/layout.rst @@ -488,9 +488,9 @@ Footer Located in ``sections/footer.html``. The footer is just below a page's main content, and is configured in ``conf.py`` -with ``html_theme_options['footer_start']`` and ``html_theme_options['footer_end']``. +with ``html_theme_options['footer_start']``, ``html_theme_options['footer_center']`` and ``html_theme_options['footer_end']``. -By default, ``footer_end`` is empty, and ``footer_start`` has the following templates: +By default, ``footer_center`` is empty, and ``footer_start`` and ``footer_end`` have the following templates: .. code-block:: python diff --git a/src/pydata_sphinx_theme/__init__.py b/src/pydata_sphinx_theme/__init__.py index 146da7fc8..6af8a38c2 100644 --- a/src/pydata_sphinx_theme/__init__.py +++ b/src/pydata_sphinx_theme/__init__.py @@ -190,6 +190,7 @@ def update_and_remove_templates( "theme_article_footer_items", "theme_content_footer_items", "theme_footer_start", + "theme_footer_center", "theme_footer_end", "theme_secondary_sidebar_items", "theme_primary_sidebar_end", diff --git a/src/pydata_sphinx_theme/assets/styles/sections/_footer.scss b/src/pydata_sphinx_theme/assets/styles/sections/_footer.scss index ce79172d0..86484733c 100644 --- a/src/pydata_sphinx_theme/assets/styles/sections/_footer.scss +++ b/src/pydata_sphinx_theme/assets/styles/sections/_footer.scss @@ -10,15 +10,20 @@ } .footer-items__start, + .footer-items__center, .footer-items__end { display: flex; flex-direction: column; gap: 0.5rem; justify-content: center; + flex-grow: 1; + } + + .footer-items__center { + text-align: center; } .footer-items__end { - margin-left: auto; text-align: end; } diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/footer.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/footer.html index fb845596d..691cd5f6d 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/footer.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/footer.html @@ -7,6 +7,13 @@ {% endfor %} {% endif %} + {% if theme_footer_center %} + + {% endif %} {% if theme_footer_end %}