
    2yi                    ~    d Z ddlmZ ddlmZmZmZ  G d de      ZddZ G d d	      Z	 G d
 dee	         Z
ddZy)a  
Deals with generating the per-page table of contents.

For the sake of simplicity we use the Python-Markdown `toc` extension to
generate a list of dicts for each toc item, and then store it as AnchorLinks to
maintain compatibility with older versions of MkDocs.
    )annotations)IterableIterator	TypedDictc                  6    e Zd ZU ded<   ded<   ded<   ded<   y)		_TocTokenintlevelstridnamelist[_TocToken]childrenN)__name__
__module____qualname____annotations__     V/var/www/html/content_weaver/venv/lib/python3.12/site-packages/mkdocs/structure/toc.pyr   r      s    JG
Ir   r   TableOfContentsc                |    | D cg c]  }t        |       }}t        |      r
d|d   _        t        |      S c c}w )NTr   )_parse_toc_tokenlenactiver   )
toc_tokensitocs      r   get_tocr      s=    (2
31A
3C
3
3xA3	 4s   9c                  b    e Zd ZU dZddZded<   	 edd       Zded<   	 ded	<   	 dd
ZdddZ	y)
AnchorLinkz(A single entry in the table of contents.titler   r
   r	   c                >    |||c| _         | _        | _        g | _        y N)r"   r   r
   r   )selfr"   r   r
   s       r   __init__zAnchorLink.__init__   s    */U'
DGTZr   c                     d| j                   z   S )z0The hash fragment of a URL pointing to the item.#)r   r%   s    r   urlzAnchorLink.url&   s     TWW}r   list[AnchorLink]r   c                "    | j                         S r$   )indent_printr)   s    r   __str__zAnchorLink.__str__1   s      ""r   c                    d|z  }| | j                    d| j                   d}| j                  D ]  }||j                  |dz         z  } |S )Nz    z - 
   )r"   r*   r   r-   )r%   depthindentretitems        r   r-   zAnchorLink.indent_print4   sZ    %Cz4MM 	0D4$$UQY//C	0
r   N)r"   r   r   r   r
   r	   returnNoner6   r   )r   )r2   r	   r6   r   )
r   r   r   __doc__r&   r   propertyr*   r.   r-   r   r   r   r!   r!      sC    2 J(  J+)#r   r!   c                  0    e Zd ZdZddZddZd	dZd
dZy)r   z2Represents the table of contents for a given page.c                    || _         y r$   )items)r%   r=   s     r   r&   zTableOfContents.__init__?   s	    
r   c                ,    t        | j                        S r$   )iterr=   r)   s    r   __iter__zTableOfContents.__iter__B   s    DJJr   c                ,    t        | j                        S r$   )r   r=   r)   s    r   __len__zTableOfContents.__len__E   s    4::r   c                2    dj                  d | D              S )N c              3  2   K   | ]  }t        |        y wr$   )r   ).0r5   s     r   	<genexpr>z*TableOfContents.__str__.<locals>.<genexpr>I   s     2Ts4y2s   )joinr)   s    r   r.   zTableOfContents.__str__H   s    ww2T222r   N)r=   r+   r6   r7   )r6   zIterator[AnchorLink])r6   r	   r8   )r   r   r   r9   r&   r@   rB   r.   r   r   r   r   r   <   s    < 3r   c                    t        | d   | d   | d         }| d   D ]&  }|j                  j                  t        |             ( |S )Nr   r   r
   r   )r!   r   appendr   )tokenanchorr   s      r   r   r   L   sM    fuT{E'NCF: 4/234Mr   N)r   r   r6   r   )rK   r   r6   r!   )r9   
__future__r   typingr   r   r   r   r   r!   r   r   r   r   r   <module>rO      sG    # 0 0	   @3hz* 3 r   