o Uw#[@sdZdZddlmZmZddlmZddlmZddlm Z GdddeZ Gd d d eZ Gd d d eZ Gd ddeZ dS)z Directives for document parts. reStructuredText)nodes languages)parts) Directive) directivesc@s@eZdZdZdZddZdZdZej ej eej dZ dd 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. )topentrynonecCst|tj}|dkr dS|S)Nr )rchoicerbacklinks_values)argvaluerG/usr/lib/python3/dist-packages/docutils/parsers/rst/directives/parts.py backlinksszContents.backlinksT)depthlocalrclassc Cs|jjst|jjtjs|d|j|jj}t |j j |j }|jr>|jd}|j||j\}}tj|dg|R}ng}d|jvrHd}n td|jd}tjdgd}|d|jdg7<|j\|_|_|jd 8_d|jvr|dd|r|}||7}n|jd}t|}||s|d |||tjt j!|j"d } | j#$|j|%| || 7}|g|S) NzBThe "%s" directive may not be used within topics or body elements.rrcontents)classesrrrnames) rawsource)& state_machine match_titles isinstancenodersidebarerrornamedocumentr get_languagesettings language_codereporter argumentsstate inline_textlinenotitleoptionslabelstopicgetget_source_and_linesourcelineappendastextfully_normalize_namehas_namenote_implicit_targetpendingrr block_textdetailsupdate note_pending) selfr#language title_text text_nodesmessagesr,r/r"r9rrrrun-sN           z Contents.runN)__name__ __module__ __qualname____doc__r roptional_argumentsfinal_argument_whitespacernonnegative_intflag class_option option_specrCrrrrrs  rc@s*eZdZdZeeejejdZddZdS)SectnumzAutomatic section numbering.)rstartprefixsuffixcCs.ttj}|j|j|jj ||gSN) rr9rSectNumr;r<r-rr#r=)r>r9rrrrC`s z Sectnum.runN) rDrErFrGintrunchanged_requiredrMrCrrrrrNWs rNc@eZdZdZdZddZdS)HeaderzContents of document header.TcC0||jj}|j|j|j|gSrR) assert_has_contentrr#get_decoration get_headerr) nested_parsecontentcontent_offset)r>headerrrrrCmz Header.runNrDrErFrG has_contentrCrrrrrWg rWc@rV)FooterzContents of document footer.TcCrXrR) rYrr#rZ get_footerr)r\r]r^)r>footerrrrrCzr`z Footer.runNrarrrrrdtrcrdN)rG __docformat__docutilsrrdocutils.transformsrdocutils.parsers.rstrrrrNrWrdrrrrs   F