diff --git a/docs/_templates/custom-template.html b/docs/_templates/custom-template.html new file mode 100644 index 000000000..aaf11cec2 --- /dev/null +++ b/docs/_templates/custom-template.html @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 3e6ed5011..6fec3bfb7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -49,6 +49,9 @@ # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] +html_sidebars = { + "contributing": ["sidebar-search-bs.html", "custom-template.html"], +} # -- Options for HTML output ------------------------------------------------- diff --git a/docs/user_guide/configuring.rst b/docs/user_guide/configuring.rst index 06a1a8a88..3dbfa121b 100644 --- a/docs/user_guide/configuring.rst +++ b/docs/user_guide/configuring.rst @@ -48,6 +48,17 @@ an external site. You can add external links to the nav bar like so: ] } +Configure the sidebar +===================== + +``pydata_sphinx_theme`` provides two new sidebar items by default: + +- ``sidebar-nav-bs.html`` - a bootstrap-friendly navigation section +- ``sidebar-search-bs.html`` - a bootstrap-friendly search bar + +By default, this theme's sidebar has these two elements in it. If you'd like to +override this behavior and control the sidebar on a per-page basis, use the +`Sphinx html-sidebars configuration value `_. Hiding the previous and next buttons ==================================== diff --git a/pydata_sphinx_theme/__init__.py b/pydata_sphinx_theme/__init__.py index 2b60c40a0..6bfba11c3 100644 --- a/pydata_sphinx_theme/__init__.py +++ b/pydata_sphinx_theme/__init__.py @@ -199,4 +199,9 @@ def setup(app): app.connect("html-page-context", setup_edit_url) app.connect("html-page-context", add_toctree_functions) + # Update templates for sidebar + pkgdir = os.path.abspath(os.path.dirname(__file__)) + path_templates = os.path.join(pkgdir, "_templates") + app.config.templates_path.append(path_templates) + return {"parallel_read_safe": True, "parallel_write_safe": True} diff --git a/pydata_sphinx_theme/_templates/sidebar-nav-bs.html b/pydata_sphinx_theme/_templates/sidebar-nav-bs.html new file mode 100644 index 000000000..b3713ad52 --- /dev/null +++ b/pydata_sphinx_theme/_templates/sidebar-nav-bs.html @@ -0,0 +1,32 @@ + diff --git a/pydata_sphinx_theme/_templates/sidebar-search-bs.html b/pydata_sphinx_theme/_templates/sidebar-search-bs.html new file mode 100644 index 000000000..3ccb6fbaa --- /dev/null +++ b/pydata_sphinx_theme/_templates/sidebar-search-bs.html @@ -0,0 +1,3 @@ +{% if theme_search_bar_position == "sidebar" %} + {%- include "search-field.html" %} +{% endif %} \ No newline at end of file diff --git a/pydata_sphinx_theme/docs-sidebar.html b/pydata_sphinx_theme/docs-sidebar.html index 1578f7395..e69de29bb 100644 --- a/pydata_sphinx_theme/docs-sidebar.html +++ b/pydata_sphinx_theme/docs-sidebar.html @@ -1,38 +0,0 @@ - - -{% if theme_search_bar_position == "sidebar" %} - {%- include "search-field.html" %} -{% endif %} - - diff --git a/pydata_sphinx_theme/layout.html b/pydata_sphinx_theme/layout.html index e9bebd678..e7fc38ebd 100644 --- a/pydata_sphinx_theme/layout.html +++ b/pydata_sphinx_theme/layout.html @@ -46,7 +46,9 @@
{% block docs_sidebar %}
- {%- include "docs-sidebar.html" %} + {%- for sidebartemplate in sidebars %} + {%- include sidebartemplate %} + {%- endfor %}
{% endblock %} diff --git a/pydata_sphinx_theme/theme.conf b/pydata_sphinx_theme/theme.conf index 116b96cf9..f045f552b 100644 --- a/pydata_sphinx_theme/theme.conf +++ b/pydata_sphinx_theme/theme.conf @@ -1,6 +1,7 @@ [theme] inherit = basic pygments_style = tango +sidebars = sidebar-search-bs.html, sidebar-nav-bs.html [options] sidebarwidth = 270 diff --git a/tests/sites/base/conf.py b/tests/sites/base/conf.py index 22ae567c7..1ee178b01 100644 --- a/tests/sites/base/conf.py +++ b/tests/sites/base/conf.py @@ -18,3 +18,5 @@ # Base options, we can add other key/vals later html_theme_options = {} + +html_sidebars = {"section1/index": ["sidebar-nav-bs.html"]} diff --git a/tests/test_build/sidebar_subpage.html b/tests/test_build/sidebar_subpage.html index 82e0378fb..629909d54 100644 --- a/tests/test_build/sidebar_subpage.html +++ b/tests/test_build/sidebar_subpage.html @@ -1,9 +1,4 @@
-