Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to add a center section to the footer #1432

Merged
merged 6 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,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,
Expand Down
4 changes: 2 additions & 2 deletions docs/user_guide/layout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/pydata_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion src/pydata_sphinx_theme/assets/styles/sections/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
{% endfor %}
</div>
{% endif %}
{% if theme_footer_center %}
<div class="footer-items__center">
{% for item in theme_footer_center %}
<div class="footer-item">{% include item %}</div>
{% endfor %}
</div>
{% endif %}
{% if theme_footer_end %}
<div class="footer-items__end">
{% for item in theme_footer_end %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ article_footer_items =
content_footer_items =
primary_sidebar_end = sidebar-ethical-ads.html
footer_start = copyright.html, sphinx-version.html
footer_center =
footer_end = theme-version.html
secondary_sidebar_items = page-toc.html, edit-this-page.html, sourcelink.html
show_version_warning_banner = False
Expand Down
16 changes: 16 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,22 @@ def test_included_toc(sphinx_build_factory) -> None:
assert included_page_html is not None


def test_footer(sphinx_build_factory) -> None:
"""Test for expected footer contents."""
overrides = {
"html_theme_options.footer_start": ["copyright.html"],
"html_theme_options.footer_center": ["sphinx-version.html"],
}
sphinx_build = sphinx_build_factory("base", confoverrides=overrides).build()
index_html = sphinx_build.html_tree("index.html")
footer_sta = index_html.select("div.footer-items__start")[0]
footer_ctr = index_html.select("div.footer-items__center")[0]
footer_end = index_html.select("div.footer-items__end")[0]
assert "Pydata community" in footer_sta.text
assert "Created using" in footer_ctr.text
assert "Built with the" in footer_end.text


# html contexts for `show_edit_button`

# these are "good" context fragments that should yield a working link
Expand Down