toc.html# <!-- /overrides/partials/toc.html --> <!-- ======================================================================== --> <!-- FILE HEADER: TABLE OF CONTENTS WITH DYNAMIC COMMENTS PANEL --> <!-- ======================================================================== --> <!-- Title: Enhanced TOC Partial Template with LLM Comments Integration --> <!-- Purpose: Extends Material MkDocs TOC partial to display dynamic code --> <!-- comments in the right sidebar, enabling enhanced documentation --> <!-- with AI-generated insights alongside source code. --> <!-- Owner: Development Team --> <!-- Source: overrides/partials/toc.html --> <!-- Last-Reviewed: 2025-08-24 --> <!-- Depends-On: mkdocs.yml, docs/stylesheets/comments.css, --> <!-- scripts/gen_code_pages.py, page.meta.code_rel_path --> <!-- Change-Log: 2025-08-24 - Enhanced comments structure, added header, --> <!-- improved rationale documentation, standardized format --> <!-- Links: https://squidfunk.github.io/mkdocs-material/ --> <!-- ======================================================================== --> <!-- WHY: Enables interactive code commentary in documentation, improving --> <!-- developer understanding and maintenance by providing contextual insights --> <!-- alongside source code through automated comment generation. --> <!-- ======================================================================== --> <!-- ========================================================================= --> <!-- SECTION: STANDARD MATERIAL TOC INTEGRATION --> <!-- ========================================================================= --> <!-- WHY: Preserves original MkDocs Material TOC functionality to maintain --> <!-- user familiarity and existing navigation behavior. --> <!-- ========================================================================= --> {# Include the original Material TOC content #} {# Conditional rendering of the standard Material TOC navigation #} {% if toc %} <!-- WHY: Conditionally render TOC only when content exists to avoid empty navigation --> <nav class="md-nav md-nav--secondary" aria-label="{{ lang.t('toc.title') }}"> <!-- Expandable label with Material Design arrow icon for TOC title --> <label class="md-nav__title" for="__toc"> <span class="md-nav__icon md-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <path d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"/> </svg> </span> {{ lang.t("toc.title") }} </label> <!-- Unordered list containing TOC items with scroll synchronization --> <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix> <!-- WHY: Iterate through TOC items with simple list structure for compatibility --> {% for toc_item in toc %} <li class="md-nav__item"> <a href="{{ toc_item.url }}" class="md-nav__link"> {{ toc_item.title }} </a> </li> {% endfor %} </ul> </nav> {% endif %} <!-- ======================================================================== --> <!-- SECTION: LLM-GENERATED CODE COMMENTS PANEL (only for Source Code pages) --> <!-- ======================================================================== --> {% if page and page.meta and page.meta.code_rel_path %} {# IMPORTANT: This partial is rendered inside Material's existing .md-sidebar__scrollwrap > .md-sidebar__inner wrappers. Do not add additional wrappers here, as it breaks layout in Chrome due to nested scroll containers and flex sizing (min-content) behavior. Render comments markup directly so the theme controls sizing. #} <div style="margin-top:1rem"></div> <h2 class="comments__title" style="display:flex;justify-content:space-between;align-items:center;gap:.5rem"> <span>AI-genererade kodkommentarer (visas bäst i Firefox)</span> <span style="font-size:.8em"> <button id="__cm-lang-sv" class="md-button md-button--small" type="button">SV</button> <button id="__cm-lang-en" class="md-button md-button--small" type="button">EN</button> </span> </h2> <div id="__comments-pane" class="comments__pane md-typeset" data-rel-path="{{ page.meta.code_rel_path | e }}"></div> {# JS is handled globally in docs/javascripts/comments.js to avoid duplicate subscriptions #} {% endif %} SvenskaEnglish