
    dd                         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	  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)
directivesc                   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     G/usr/lib/python3/dist-packages/docutils/parsers/rst/directives/parts.py	backlinkszContents.backlinks   s)    !!#x'@'@AF?L       T)depthlocalr   classc                 z   | j                   j                  sLt        | j                   j                  t        j
                        s| 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	        j*                  dg      }|dxx   | j&                  j-                  dg       z  cc<   | j                   j/                         \  |_        |_        |xj2                  d	z  c_        d| j&                  v r|d   j5                  d       |r|j7                         }||z  }n|j(                  d   }t	        j8                  |      }|j;                  |      s|d
   j5                  |       |j=                  |       t	        j>                  t@        jB                  | jD                        }	|	jF                  jI                  | j&                         |jK                  |	       ||	z  }|g|z   S )NzBThe "%s" directive may not be used within topics or body elements.r    r   contents)classesr   r   r   names)	rawsource)&state_machinematch_titles
isinstancenoder   sidebar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messagesr0   r3   r&   r=   s
             r   runzContents.run-   s4   ""//d0055u}}E** 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_specrG    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   SectNumr?   r@   r1   r    r'   rA   )rB   r=   s     r   rG   zSectnum.run`   sL    --.t||,##009yr   N)	rH   rI   rJ   rK   intr   unchanged_requiredrQ   rG   rR   r   r   rT   rT   W   s)    &'::'::<K
r   rT   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 rY   )	assert_has_contentr    r'   get_decoration
get_headerr-   nested_parsecontentcontent_offset)rB   headers     r   rG   z
Header.runm   V    !##,,;;=HHJ

d.A.A6J	r   NrH   rI   rJ   rK   has_contentrG   rR   r   r   r^   r^   g       &Kr   r^   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 rY   )	r`   r    r'   ra   
get_footerr-   rc   rd   re   )rB   footers     r   rG   z
Footer.runz   rg   r   Nrh   rR   r   r   rl   rl   t   rj   r   rl   N)rK   __docformat__docutilsr   r   docutils.transformsr   docutils.parsers.rstr   r   r
   rT   r^   rl   rR   r   r   <module>rt      sP   
 # % % * +C"y C"Li  
Y 

Y 
r   