diff --git a/src/pydata_sphinx_theme/toctree.py b/src/pydata_sphinx_theme/toctree.py index f20e80cd8..73bf73778 100644 --- a/src/pydata_sphinx_theme/toctree.py +++ b/src/pydata_sphinx_theme/toctree.py @@ -113,24 +113,13 @@ def unique_html_id(base_id: str): return next(get_or_create_id_generator(base_id)) @cache - def generate_header_nav_before_dropdown( - n_links_before_dropdown, - ) -> Tuple[str, List[str]]: - """Return html for navbar and dropdown. - - Given the number of links before the dropdown, return the html for the navbar, - as well as the list of links to put in a dropdown. + def _generate_nav_info() -> List[LinkInfo]: + """Generate informations necessary to generate nav. - Returns: - - HTML str for the navbar - - list of HTML str for the dropdown + Instead of messing with html later, having this as a util function + should make it slightly easier to generate different html snippet for + sidebar or navbar. """ - try: - n_links_before_dropdown = int(n_links_before_dropdown) - except Exception: - raise ValueError( - f"n_links_before_dropdown is not an int: {n_links_before_dropdown}" - ) toctree = TocTree(app.env) # Find the active header navigation item so we decide whether to highlight @@ -156,7 +145,6 @@ def generate_header_nav_before_dropdown( # just below the root of our site root_toc = app.env.tocs[app.config.root_doc] - links_html = [] links_data = [] # Iterate through each node in the root document toc. @@ -169,7 +157,6 @@ def generate_header_nav_before_dropdown( page = toc.attributes["parent"] if page == "self" else page # If this is the active ancestor page, add a class so we highlight it - current = "current active" if page == active_header_page else "" # sanitize page title for use in the html output if needed if title is None: @@ -186,7 +173,6 @@ def generate_header_nav_before_dropdown( # If it's an absolute one then we use the external class and # the complete url. is_absolute = bool(urlparse(page).netloc) - link_status = "nav-external" if is_absolute else "nav-internal" link_href = page if is_absolute else context["pathto"](page) links_data.append( @@ -198,19 +184,6 @@ def generate_header_nav_before_dropdown( ) ) - # create the html output - links_html.append( - dedent( - f""" -