File tree Expand file tree Collapse file tree 6 files changed +49
-8
lines changed Expand file tree Collapse file tree 6 files changed +49
-8
lines changed Original file line number Diff line number Diff line change 5151
5252html_sidebars = {
5353 "contributing" : ["sidebar-search-bs.html" , "custom-template.html" ],
54- "index " : [],
54+ "changelog " : [],
5555}
5656
5757# -- Options for HTML output -------------------------------------------------
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
7676html_context = {
Original file line number Diff line number Diff 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+ }
Original file line number Diff line number Diff line change 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 %}
Original file line number Diff line number Diff line change 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 %}
Original file line number Diff line number Diff line change @@ -16,3 +16,4 @@ search_bar_text = Search the docs ...
1616search_bar_position = sidebar
1717navigation_with_keys = True
1818show_toc_level = 1
19+ navbar_snap_left = False
Original file line number Diff line number Diff 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 ()
You can’t perform that action at this time.
0 commit comments