U n^@sdZdZddlmZmZddlmZddlmZddlm Z GdddeZ Gd d d eZ Gd d d eZ Gd ddeZ dS)z Directives for document parts. ZreStructuredText)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. )topentrynonecCs"t|tj}|dkrdS|SdS)Nr )rchoicerbacklinks_values)argvaluer/private/var/folders/sd/whlwsn6x1_qgglc0mjv25_695qk2gl/T/pip-install-4zq3fp6i/docutils/docutils/parsers/rst/directives/parts.py backlinksszContents.backlinksT)depthlocalrclassc Cs|jjs(t|jjtjs(|d|j|jj}t |j j |j }|jrz|jd}|j||j\}}tj|df|}n&g}d|jkrd}ntd|jd}tjdgd}|d|jdg7<|j\|_|_|jd 8_d|jkr|dd|r|}||7}n |jd}t|}||sH|d |||tjt j!|j"d } | j#$|j|%| || 7}|g|S) NzBThe "%s" directive may not be used within topics or body elements.rrcontents)classesrrrnames)Z rawsource)& state_machineZ match_titles isinstancenoderZsidebarerrornamedocumentrZ get_languagesettingsZ language_codeZreporter argumentsstateZ inline_textlinenotitleoptionslabelstopicgetZget_source_and_linesourcelineappendZastextZfully_normalize_nameZhas_nameZnote_implicit_targetpendingrrZ block_textdetailsupdate note_pending) selfrlanguageZ title_textZ text_nodesmessagesr$r'rr,rrrrun-sN          z Contents.runN)__name__ __module__ __qualname____doc__r rZoptional_argumentsZfinal_argument_whitespacerZnonnegative_intflagZ class_option option_specr3rrrrrs rc@s*eZdZdZeeejejdZddZdS)SectnumzAutomatic section numbering.)rstartprefixsuffixcCs.ttj}|j|j|jj ||gSN) rr,rZSectNumr-r.r%rrr/)r0r,rrrr3`s z Sectnum.runN) r4r5r6r7intrZunchanged_requiredr9r3rrrrr:Wsr:c@seZdZdZdZddZdS)HeaderzContents of document header.TcCs0||jj}|j|j|j|gSr>) assert_has_contentrrget_decoration get_headerr" nested_parsecontentcontent_offset)r0headerrrrr3msz Header.runNr4r5r6r7Z has_contentr3rrrrr@gsr@c@seZdZdZdZddZdS)FooterzContents of document footer.TcCs0||jj}|j|j|j|gSr>) rArrrBZ get_footerr"rDrErF)r0footerrrrr3zsz Footer.runNrHrrrrrItsrIN)r7Z __docformat__ZdocutilsrrZdocutils.transformsrZdocutils.parsers.rstrrrr:r@rIrrrrs   F