Sphinx & Furo Sidebar Navigation Architecture (ADR)¶
This document records the technical feasibility analysis and Architecture Decision Record (ADR) for expandable hierarchical heading navigation in the Sphinx and Furo left sidebar (Issue #309, Epic #379).
1. Context & Problem Statement¶
In standard Sphinx documentation built with the Furo theme, the left navigation drawer (.sidebar-tree)
displays only document-level titles, while in-page headings (H2, H3) appear exclusively in the right-hand
« On this page » table of contents (.toc-tree).
For multi-section reference documentation—such as User Guides (guides/index.md), CLI Reference
(cli/index.md), and API Reference (api/findfmt.md)—readers could not expand a document entry in the
left sidebar to jump directly to nested sections or module anchors without first loading the target page.
2. Technical Feasibility Investigation¶
2.1. Sphinx toctree Resolution vs. Furo titles_only Default¶
Sphinx’s TocTree adapter (sphinx.environment.adapters.toctree._resolve_toctree) supports two modes when
constructing the global navigation tree:
titles_only=True: Emits only top-level document titles (H1), ignoring all in-page subsections regardless of:maxdepth:directives in MyST Markdown sources.titles_only=False: Includes nested document headings (H2,H3,H4) and Python autodoc object anchors up to the activemaxdepthceiling.
By default, Furo’s _compute_navigation_tree(context) function in furo/__init__.py sets titles_only=True:
toctree_html = toctree(
collapse=False,
titles_only=True,
maxdepth=-1,
includehidden=True,
)
Because titles_only=True is passed directly to Sphinx’s toctree() template callable, increasing
:maxdepth: in docs/source/index.md or section index files alone has no effect on Furo’s left sidebar.
2.2. Furo Navigation Tree Post-Processing (get_navigation_tree)¶
Furo transforms Sphinx’s raw toctree HTML via furo.navigation.get_navigation_tree(toctree_html).
Inspection of furo.navigation confirms that this post-processor is completely depth-agnostic:
It parses the
toctreeHTML fragment withBeautifulSoupand iterates recursively over every<li>element (soup.find_all("li", recursive=True)).Whenever an
<li>element contains a child<ul>(whether that<ul>represents child documents or nested in-page headings), Furo appends thehas-childrenCSS class, injects an<input type="checkbox" class="toctree-checkbox" role="switch" aria-label="Toggle navigation of ...">, and inserts a<label>containing the#svg-arrow-rightexpand/collapse chevron icon.Any
<li>along the active document ancestry carrying thecurrentclass has its checkbox markedchecked=""by default.Furo’s CSS rules (
.toctree-checkbox ~ ul { display: none; }and.toctree-checkbox:checked ~ ul { display: block; }) operate on general sibling selectors and therefore support arbitrary nesting depths (toctree-l1throughtoctree-l4).
2.3. Evaluation of Implementation Alternatives¶
Architecture Candidate |
Mechanism |
Accessibility & Mobile Drawer Behavior |
Maintenance Overhead |
Verdict |
|---|---|---|---|---|
Option A: |
Increase |
No change; Furo’s default |
None, but fails to meet functional requirements. |
Rejected |
Option B: Client-Side DOM Mirroring (Custom JS) |
Inject custom JavaScript to clone |
Only populates headings for the currently loaded page; causes layout shift without JavaScript. |
High; fragile across Furo DOM updates. |
Rejected |
Option C: Document Splitting into Micro-Pages |
Split every |
Works with |
High; multiplies |
Rejected |
Option D: Sphinx |
Rebuild |
Preserves native CSS-only checkboxes, mobile drawer behavior, and |
Low; uses public Sphinx events and standard Furo transformers. |
Selected |
3. Architecture Decision & Implementation Details¶
Status: Accepted (Milestone
v1.3.1, Issue #309).Selected Depth:
SIDEBAR_NAVIGATION_MAXDEPTH = 4(:maxdepth: 4across root and section toctrees).
3.1. Sphinx Event Hook (docs/source/conf.py)¶
docs/source/conf.py registers _configure_hierarchical_sidebar on Sphinx’s html-page-context event at
priority=600 (running immediately after Furo’s built-in _html_page_context handler at priority=500):
Invokes
context["toctree"](collapse=False, titles_only=False, maxdepth=4, includehidden=True).Passes the resulting HTML fragment through
furo.navigation.get_navigation_tree()so every page and heading level (toctree-l1throughtoctree-l4) receives native collapsible checkboxes and chevron labels:User Guides (
guides/index.md): Expands from guide titles (Installation,Configuration, etc.) intoH2sections (1. Installation Methods,2. Platform Notes,3. Verification & Diagnostics) andH3subsections (1.1. Standalone Execution with uvx).CLI Reference (
cli/index.md): Expands directly into1. Synopsis,2. Description,3. Options(3.1. Tag Filtering,3.2. Traversal Controls,3.3. Output Controls,3.4. Information & Diagnostics), and8. Examples.API Reference (
api/findfmt.md): ExpandsPackage Modulesinto module sections (1. Core Data Models (findfmt.models),2. File Classifier (findfmt.classifier), etc.) and individual class and function anchors (FileInfo,TraversalConfig,classify_file()).
3.2. Accessibility & Mobile Responsiveness (navigation.html & custom.css)¶
Landmark Labeling:
docs/source/_templates/sidebar/navigation.htmladdsaria-label="{{ _('Navigation') }}"to.sidebar-tree.Keyboard Switch Focus: Stock Furo styles
.toctree-checkboxwithdisplay: none, which removes the<input type="checkbox" role="switch">elements from the keyboard tab order.docs/source/_static/custom.cssoverrides.sidebar-tree .toctree-checkboxto remain positioned over the toggle button withopacity: 0and adds a high-contrast:focus-visibleoutline on the sibling<label>, enabling keyboard users to tab through and toggle any nested heading branch withSpace.Visual Hierarchy & Mobile Drawer: Subtle left border guides on
.toctree-l2 > uland.toctree-l3 > ulvisually distinguish nested heading levels in both desktop layouts and the slide-out mobile navigation drawer across light and dark Furo themes.