Skip to content

Commit c475f4f

Browse files
committed
addressing PR comments
1 parent 94bc5db commit c475f4f

File tree

7 files changed

+50
-9
lines changed

7 files changed

+50
-9
lines changed

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
html_sidebars = {
5353
"contributing": ["sidebar-search-bs.html", "custom-template.html"],
54-
"index": [],
54+
"changelog": [],
5555
}
5656

5757
# -- Options for HTML output -------------------------------------------------
@@ -70,7 +70,7 @@
7070
"twitter_url": "https://twitter.com/pandas_dev",
7171
"use_edit_page_button": True,
7272
"show_toc_level": 1,
73-
"search_bar_position": "navbar",
73+
# "navbar_snap_left": True, # For testing that the navbar items snap to left properly
7474
}
7575

7676
html_context = {

docs/user_guide/configuring.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,19 @@ use this pattern:
214214
}
215215
216216
For information about configuring the sidebar's contents, see :ref:`configure-sidebar`.
217+
218+
219+
Make navbar menu items snap to the left
220+
=======================================
221+
222+
By default, the navigation bar menu items will begin in-line with the content on your
223+
page. If instead you'd like these items to snap to the left (closer to the logo), then
224+
use the following configuration:
225+
226+
.. code-block:: python
227+
228+
html_theme_options = {
229+
...
230+
"navbar_snap_left": True
231+
...
232+
}

pydata_sphinx_theme/docs-navbar.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
<span class="navbar-toggler-icon"></span>
1313
</button>
1414

15-
<div id="navbar-menu" class="col-11 collapse navbar-collapse">
15+
{% if theme_navbar_snap_left in [True, "True"] %}
16+
{% set navbar_col_class = "col-11" %}
17+
{% else %}
18+
{% set navbar_col_class = "col-lg-9" %}
19+
{% endif %}
20+
<div id="navbar-menu" class="{{ navbar_col_class }} collapse navbar-collapse">
1621
<ul id="navbar-main-elements" class="navbar-nav mr-auto">
1722
{% set nav = get_nav_object(maxdepth=1, collapse=True) %}
1823
{% for main_nav_item in nav %}

pydata_sphinx_theme/layout.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@
6666
{% endblock %}
6767

6868
{% block docs_main %}
69-
<main class="col py-md-5 pl-md-5 pr-md-4 bd-content" role="main">
69+
{% if sidebars %}
70+
{% set content_col_class = "col-md-9 col-xl-7" %}
71+
{% else %}
72+
{% set content_col_class = "col-md-11 col-xl-10" %}
73+
{% endif %}
74+
<main class="col-12 {{ content_col_class }} py-md-5 pl-md-5 pr-md-4 bd-content" role="main">
7075
{% block docs_body %}
7176
<div>
7277
{% block body %} {% endblock %}

pydata_sphinx_theme/theme.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ search_bar_text = Search the docs ...
1616
search_bar_position = sidebar
1717
navigation_with_keys = True
1818
show_toc_level = 1
19+
navbar_snap_left = False

tests/test_build.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,29 @@ def test_logo_name(file_regression, sphinx_build):
9999
assert "PyData Tests" in index_html.select(".navbar-brand")[0].text.strip()
100100

101101

102-
def test_sidebar_visible(file_regression, sphinx_build):
102+
def test_sidebar_visible(sphinx_build):
103103
"""The sidebar is shrunk when no sidebars specified in html_sidebars."""
104104
sphinx_build.copy()
105105

106106
sphinx_build.build()
107-
index_html = sphinx_build.get("index.html")
107+
index_html = sphinx_build.get("page1.html")
108108
assert "col-md-3" in index_html.select(".bd-sidebar")[0].attrs["class"]
109109

110-
sphinx_build.build(["-D", "html_sidebars.index="])
111-
index_html = sphinx_build.get("index.html")
110+
sphinx_build.build(["-D", "html_sidebars.page1="])
111+
index_html = sphinx_build.get("page1.html")
112112
assert "col-md-1" in index_html.select(".bd-sidebar")[0].attrs["class"]
113113
sphinx_build.clean()
114+
115+
116+
def test_navbar_snap_left(sphinx_build):
117+
"""The sidebar is shrunk when no sidebars specified in html_sidebars."""
118+
sphinx_build.copy()
119+
120+
sphinx_build.build()
121+
index_html = sphinx_build.get("index.html")
122+
assert "col-lg-9" in index_html.select("div#navbar-menu")[0].attrs["class"]
123+
124+
sphinx_build.build(["-D", "html_theme_options.navbar_snap_left=True"])
125+
index_html = sphinx_build.get("index.html")
126+
assert "col-11" in index_html.select("div#navbar-menu")[0].attrs["class"]
127+
sphinx_build.clean()

tests/test_build/navbar_ix.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="col-11 collapse navbar-collapse" id="navbar-menu">
1+
<div class="col-lg-9 collapse navbar-collapse" id="navbar-menu">
22
<ul class="navbar-nav mr-auto" id="navbar-main-elements">
33
<li class="nav-item">
44
<a class="nav-link" href="page1.html">

0 commit comments

Comments
 (0)