o
    Ì^½^L  ã                   @   s4   d Z dd„ ZG dd„ dƒZG dd„ dƒZdd„ Zd	S )
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.
c                 C   s(   dd„ | D ƒ}t |ƒrd|d _t|ƒS )Nc                 S   ó   g | ]}t |ƒ‘qS © )Ú_parse_toc_token)Ú.0Úir   r   ú6/usr/lib/python3/dist-packages/mkdocs/structure/toc.pyÚ
<listcomp>   ó    zget_toc.<locals>.<listcomp>Té    )ÚlenÚactiveÚTableOfContents)Ú
toc_tokensÚtocr   r   r   Úget_toc
   s   
r   c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )r   z<
    Represents the table of contents for a given page.
    c                 C   s
   || _ d S ©N)Úitems)Úselfr   r   r   r   Ú__init__   ó   
zTableOfContents.__init__c                 C   ó
   t | jƒS r   )Úiterr   ©r   r   r   r   Ú__iter__   r   zTableOfContents.__iter__c                 C   r   r   )r
   r   r   r   r   r   Ú__len__   r   zTableOfContents.__len__c                 C   s   d  dd„ | D ƒ¡S )NÚ c                 S   r   r   )Ústr)r   Úitemr   r   r   r       r   z+TableOfContents.__str__.<locals>.<listcomp>)Újoinr   r   r   r   Ú__str__   s   zTableOfContents.__str__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s    r   c                   @   s6   e Zd ZdZdd„ Zedd„ ƒZdd„ Zdd	d
„ZdS )Ú
AnchorLinkz2
    A single entry in the table of contents.
    c                 C   s    |||| _ | _| _g | _d S r   )ÚtitleÚidÚlevelÚchildren)r   r$   r%   r&   r   r   r   r   '   s   
zAnchorLink.__init__c                 C   s
   d| j  S )Nú#)r%   r   r   r   r   Úurl+   s   
zAnchorLink.urlc                 C   s   |   ¡ S r   )Úindent_printr   r   r   r   r   /   s   zAnchorLink.__str__r	   c                 C   s<   d| }d  || j| j¡}| jD ]}|| |d ¡7 }q|S )Nz    z
{}{} - {}
é   )Úformatr$   r)   r'   r*   )r   ÚdepthÚindentÚretr   r   r   r   r*   2   s
   
zAnchorLink.indent_printN)r	   )	r   r    r!   r"   r   Úpropertyr)   r   r*   r   r   r   r   r#   #   s    
r#   c                 C   s:   t | d | d | d ƒ}| d D ]
}|j t|ƒ¡ q|S )NÚnamer%   r&   r'   )r#   r'   Úappendr   )ÚtokenÚanchorr   r   r   r   r   :   s   r   N)r"   r   r   r#   r   r   r   r   r   Ú<module>   s
    	