o
    i                     @   s   d Z dZddlmZmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ G dd	 d	eZG d
d deZG dd deZG dd deZdS )z 
Directives for document parts.
reStructuredText    )nodes	languages)parts)	Directive)
directives)BasePseudoSectionc                   @   s@   e Zd ZdZdZdd ZdZdZej	ej
eejdZdd	 Zd
S )Contentsa  
    Table of contents.

    The table of contents is generated in two passes: initial parse and
    transform.  During the initial parse, a 'pending' element is generated
    which acts as a placeholder, storing the TOC title and any options
    internally.  At a later stage in the processing, the 'pending' element is
    replaced by a 'topic' element, a title and the table of contents proper.
    )topentrynonec                 C   s   t | tj}|dkrd S |S )Nr   )r   choicer	   backlinks_values)argvalue r   k/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/docutils/parsers/rst/directives/parts.py	backlinks    s   zContents.backlinks   T)depthlocalr   classc           
      C   s  t | jjtjr| d| j | jj}t	|j
j|j}| jr:| jd }| j|| j\}}tj|dg|R  }ng }d| jv rDd }n	td|jd }tjdgd}|d  | jdg 7  < | j \|_|_| jd	8  _d| jv r}|d d |r| }||7 }n|jd }t|}||s|d
 | || tjt j!| j"d}	|	j#$| j |%|	 ||	7 }|g| S )NzBThe "%s" directive may not be used within topics or body elements.r    r   contents)classesr   r   r   names)	rawsource)&
isinstancestate_machinenoder   invalid_parentserrornamedocumentr   get_languagesettingslanguage_codereporter	argumentsstateinline_textlinenor   titleoptionslabelstopicgetget_source_and_linesourcelineappendastextfully_normalize_namehas_namenote_implicit_targetpendingr   r	   
block_textdetailsupdatenote_pending)
selfr#   language
title_text
text_nodesmessagesr,   r/   r"   r9   r   r   r   run.   sN   










zContents.runN)__name__
__module____qualname____doc__r   r   optional_argumentsfinal_argument_whitespacer   nonnegative_intflagclass_optionoption_specrC   r   r   r   r   r	      s    
r	   c                   @   s*   e Zd ZdZeeejejdZdd ZdS )SectnumzAutomatic section numbering.)r   startprefixsuffixc                 C   s.   t tj}|j| j | jj	| |gS N)
r   r9   r   SectNumr;   r<   r-   r   r#   r=   )r>   r9   r   r   r   rC   a   s   zSectnum.runN)	rD   rE   rF   rG   intr   unchanged_requiredrM   rC   r   r   r   r   rN   X   s    rN   c                   @      e Zd ZdZdZdd ZdS )HeaderzContents of document header.Tc                 C   0   |    | jj  }| j| j| j| g S rR   )	assert_has_contentr   r#   get_decoration
get_headerr)   nested_parsecontentcontent_offset)r>   headerr   r   r   rC   n      z
Header.runNrD   rE   rF   rG   has_contentrC   r   r   r   r   rW   h       rW   c                   @   rV   )FooterzContents of document footer.Tc                 C   rX   rR   )	rY   r   r#   rZ   
get_footerr)   r\   r]   r^   )r>   footerr   r   r   rC   {   r`   z
Footer.runNra   r   r   r   r   rd   u   rc   rd   N)rG   __docformat__docutilsr   r   docutils.transformsr   docutils.parsers.rstr   r   $docutils.parsers.rst.directives.bodyr   r	   rN   rW   rd   r   r   r   r   <module>   s   F