
    KiR                         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	e      Z G d
 de      Z G d de      Z G d de      Zy)z 
Directives for document parts.
reStructuredText    )nodes	languages)parts)	Directive)
directives)BasePseudoSectionc                   r    e Zd ZdZdZd ZdZdZej                  ej                  eej                  dZd Zy)	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                 Z    t        j                  | t        j                        }|dk(  ry |S )Nr   )r   choicer   backlinks_values)argvalues     q/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/docutils/parsers/rst/directives/parts.py	backlinkszContents.backlinks    s)    !!#x'@'@AF?L       T)depthlocalr   classc                    t        | j                  j                  t        j                  t        j
                  t        j                  f      sLt        | j                  j                  t        j                        r| j                  d| j                  z        | j                  j                  }t        j                  |j                  j                  |j                         }| j"                  rP| j"                  d   }| j$                  j'                  || j(                        \  }}t        j*                  |dg| }n6g }d| j,                  v rd }n#t        j*                  d|j.                  d         }t        j0                  dg      }|dxx   | j,                  j3                  dg       z  cc<   | j                  j5                         \  |_        |_        |xj8                  d	z  c_        d| j,                  v r|d   j;                  d       |r|j=                         }||z  }n|j.                  d   }t        j>                  |      }|jA                  |      s|d
   j;                  |       |jC                  |       t        jD                  tF        jH                  | jJ                        }	|	jL                  jO                  | j,                         |jQ                  |	       ||	z  }|g|z   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   Rootsectionsidebarr	   invalid_parentserrornamedocumentr   get_languagesettingslanguage_codereporter	argumentsstateinline_textlineno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messagesr3   r6   r)   r@   s
             r   runzContents.run.   sW   4--22!JJu}}EG4--22,<<>** 8:>))D E E%%..))(*;*;*I*I*2*;*;=>>*J#'::#9#9*:>++$G JKK
B<<EH$,,&B
(CDZL1iDLL,,Wb99#'#5#5#I#I#K ej

a
dll")##G,<<>DUNE??:.D))$/  &'N!!$'%%e,--$//Jt||,g&w!!r   N)__name__
__module____qualname____doc__r   r   optional_argumentsfinal_argument_whitespacer   nonnegative_intflagclass_optionoption_specrJ    r   r   r   r      sJ     0  $&66&OO )&335K
)"r   r   c                   L    e Zd ZdZeeej                  ej                  dZd Zy)SectnumzAutomatic section numbering.)r   startprefixsuffixc                     t        j                  t        j                        }|j                  j                  | j                         | j                  j                  j                  |       |gS N)
r   r@   r   SectNumrB   rC   r4   r"   r*   rD   )rE   r@   s     r   rJ   zSectnum.runc   sL    --.t||,##009yr   N)	rK   rL   rM   rN   intr   unchanged_requiredrT   rJ   rU   r   r   rW   rW   Z   s)    &'::'::<K
r   rW   c                       e Zd ZdZdZd Zy)HeaderzContents of document header.Tc                     | j                          | j                  j                  j                         j	                         }| j
                  j                  | j                  | j                  |       g S r\   )	assert_has_contentr"   r*   get_decoration
get_headerr0   nested_parsecontentcontent_offset)rE   headers     r   rJ   z
Header.runp   V    !##,,;;=HHJ

d.A.A6J	r   NrK   rL   rM   rN   has_contentrJ   rU   r   r   ra   ra   j       &Kr   ra   c                       e Zd ZdZdZd Zy)FooterzContents of document footer.Tc                     | j                          | j                  j                  j                         j	                         }| j
                  j                  | j                  | j                  |       g S r\   )	rc   r"   r*   rd   
get_footerr0   rf   rg   rh   )rE   footers     r   rJ   z
Footer.run}   rj   r   Nrk   rU   r   r   ro   ro   w   rm   r   ro   N)rN   __docformat__docutilsr   r   docutils.transformsr   docutils.parsers.rstr   r   $docutils.parsers.rst.directives.bodyr	   r   rW   ra   ro   rU   r   r   <module>rx      sS   
 # % % * + BE"y E"Pi  
Y 

Y 
r   