File tree 7 files changed +71
-7
lines changed
7 files changed +71
-7
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,14 @@ def generate_nav_html(kind, **kwargs):
41
41
for li in soup ("li" , {"class" : "current" }):
42
42
li ["class" ].append ("active" )
43
43
44
+ # Remove navbar/sidebar links to sub-headers on the page
45
+ for li in soup .select ("li" ):
46
+ # Remove
47
+ if li .find ("a" ):
48
+ href = li .find ("a" )["href" ]
49
+ if "#" in href and href != "#" :
50
+ li .decompose ()
51
+
44
52
if kind == "navbar" :
45
53
# Add CSS for bootstrap
46
54
for li in soup ("li" ):
@@ -49,13 +57,6 @@ def generate_nav_html(kind, **kwargs):
49
57
out = "\n " .join ([ii .prettify () for ii in soup .find_all ("li" )])
50
58
51
59
elif kind == "sidebar" :
52
- # Remove sidebar links to sub-headers on the page
53
- for li in soup .select ("li.current ul li" ):
54
- # Remove
55
- if li .find ("a" ):
56
- href = li .find ("a" )["href" ]
57
- if "#" in href and href != "#" :
58
- li .decompose ()
59
60
60
61
# Join all the top-level `li`s together for display
61
62
current_lis = soup .select ("li.current.toctree-l1 li.toctree-l2" )
Original file line number Diff line number Diff line change
1
+ # -- Project information -----------------------------------------------------
2
+
3
+ project = "PyData Tests"
4
+ copyright = "2020, Pydata community"
5
+ author = "Pydata community"
6
+
7
+ master_doc = "index"
8
+
9
+ # -- General configuration ---------------------------------------------------
10
+
11
+ html_theme = "pydata_sphinx_theme"
12
+
13
+ html_copy_source = True
14
+ html_sourcelink_suffix = ""
Original file line number Diff line number Diff line change
1
+ test-navbar-in-page-headers
2
+ ===========================
3
+
4
+ .. toctree ::
5
+
6
+ page1
7
+ page2
Original file line number Diff line number Diff line change
1
+ Page 1
2
+ ======
3
+
4
+ Some text
5
+
6
+ Another header
7
+ ==============
8
+
9
+ Some text
10
+
11
+ Sub-header
12
+ ----------
13
+
14
+ Some text
15
+
16
+ And another one
17
+ ===============
18
+
19
+ Some text
Original file line number Diff line number Diff line change
1
+ Page 2
2
+ ======
Original file line number Diff line number Diff line change @@ -145,3 +145,12 @@ def test_navbar_align_right(sphinx_build_factory):
145
145
index_html = sphinx_build .html_tree ("index.html" )
146
146
assert "col-lg-9" not in index_html .select ("div#navbar-menu" )[0 ].attrs ["class" ]
147
147
assert "ml-auto" in index_html .select ("ul#navbar-main-elements" )[0 ].attrs ["class" ]
148
+
149
+
150
+ def test_navbar_no_in_page_headers (sphinx_build_factory , file_regression ):
151
+ # https://github.com/pandas-dev/pydata-sphinx-theme/issues/302
152
+ sphinx_build = sphinx_build_factory ("test_navbar_no_in_page_headers" ).build ()
153
+
154
+ index_html = sphinx_build .html_tree ("index.html" )
155
+ navbar = index_html .select ("ul#navbar-main-elements" )[0 ]
156
+ file_regression .check (navbar .prettify (), extension = ".html" )
Original file line number Diff line number Diff line change
1
+ < ul class ="navbar-nav mr-auto " id ="navbar-main-elements ">
2
+ < li class ="toctree-l1 nav-item ">
3
+ < a class ="reference internal nav-link " href ="page1.html ">
4
+ Page 1
5
+ </ a >
6
+ </ li >
7
+ < li class ="toctree-l1 nav-item ">
8
+ < a class ="reference internal nav-link " href ="page2.html ">
9
+ Page 2
10
+ </ a >
11
+ </ li >
12
+ </ ul >
You can’t perform that action at this time.
0 commit comments