{#
Custom navbar-nav.html for pytorch_sphinx_theme2
Renders toctree items as dropdowns showing their subsections.
This template overrides pydata_sphinx_theme's navbar-nav.html to display
top-level navigation items with dropdown menus containing their children.
Pure CSS/Jinja implementation - no JavaScript required.
Uses the `hierarchical_header_nav` context variable populated by __init__.py
Uses theme_header_links_before_dropdown to control how many items show before "More".
Uses theme_enable_navbar_dropdowns to enable/disable dropdown menus (default: true).
Mobile: Dropdowns are collapsed by default, parent link is clickable,
toggle button expands/collapses children.
Supports external URLs (http://, https://) in toctree entries.
#}
{% set max_visible_items = theme_header_links_before_dropdown|default(4)|int %}
{% set dropdowns_enabled = theme_enable_navbar_dropdowns|default('true')|lower == 'true' %}
{# Macro to generate the correct href for internal or external links #}
{% macro item_href(item) %}
{%- if item.external -%}
{{ item.url }}
{%- else -%}
{{ pathto(item.url) }}
{%- endif -%}
{% endmacro %}
{# Macro to generate link attributes for external links #}
{% macro external_attrs(item) %}
{%- if item.external %} target="_blank" rel="noopener noreferrer"{% endif -%}
{% endmacro %}
{# Macro to generate external link icon #}
{% macro external_icon(item) %}
{%- if item.external -%} {%- endif -%}
{% endmacro %}
{% if hierarchical_header_nav %}
{% else %}
{# Fallback: use the default header navigation if hierarchical nav is empty #}
{{ generate_header_nav_html()|safe }}
{% endif %}