ó V!¶\c@s™dZdZddlZddlZddlmZmZddlmZm Z de fd„ƒYZ de fd „ƒYZ d ej fd „ƒYZ dS( s' Transforms related to document parts. treStructuredTextiÿÿÿÿN(tnodestutils(tTransformErrort TransformtSectNumcBs,eZdZdZd„Zddd„ZRS(sS Automatically assigns numbers to the titles of document sections. It is possible to limit the maximum section level for which the numbers are added. For those sections that are auto-numbered, the "autonum" attribute is set, informing the contents table generator that a different form of the TOC should be used. iÆcCs|jjjddƒ|_|jjjddƒ|_|jjjddƒ|_|jjjddƒ|_|jjj |jƒ|j j j rÂ|jdkr¯t j|_n|j|j ƒnH|j|j j _|j|j j _|j|j j _|j|j j _dS(Ntdepthtstartitprefixttsuffix(t startnodetdetailstgettNonetmaxdeptht startvalueRR tparenttremovetdocumenttsettingst sectnum_xformtsystmaxinttupdate_section_numberst sectnum_deptht sectnum_starttsectnum_prefixtsectnum_suffix(tself((s=/tmp/pip-install-usGedi/docutils/docutils/transforms/parts.pytapply sic Csè|d7}|rd}n |j}x¿|D]·}t|tjƒr)|t|ƒf}|d}tjd|jdj|ƒ|jd ddgƒ}|j d|ƒd|d <||j krÓ|j |||ƒn|d7}q)q)WdS( NiiR t.u itclassestsectnumtautou   ( Rt isinstanceRtsectiontstrt generatedRtjoinR tinsertRR( RtnodeRRR!tchildtnumbersttitleR&((s=/tmp/pip-install-usGedi/docutils/docutils/transforms/parts.pyR0s"     !  ((t__name__t __module__t__doc__tdefault_priorityRR(((s=/tmp/pip-install-usGedi/docutils/docutils/transforms/parts.pyRs  tContentscBs2eZdZdZd„Zdd„Zd„ZRS(sè This transform generates a table of contents from the entire document tree or from a single branch. It locates "section" elements and builds them into a nested bullet list, which is placed within a "topic" created by the contents directive. A title is either explicitly specified, taken from the appropriate language module, or omitted (local table of contents). The depth may be specified. Two-way references between the table of contents and section titles are generated (requires Writer support). This transform requires a startnode, which contains generation options and provides the location for the generated table of contents (the startnode is replaced by the table of contents "topic"). iÐcCs\y|jjj}Wntk r,t}nX|jj}d|kr‹|jjj}x=t|t j ƒpxt|t jƒs‡|j}qWWn |j}|jjdd|_ d|krÇ|d|_ n|jjj |_ |r|jjjj|ƒ|jjj|jƒnJ|j|ƒ}t|ƒr<|jj|ƒn|jjjj|jjƒdS(Ntlocaltidsit backlinks(RRt use_latex_toctAttributeErrortFalseR R RR#RR$ttoc_idR4t toc_backlinkst attributestupdateRtbuild_contentstlent replace_self(Rt toc_by_writerR R tcontents((s=/tmp/pip-install-usGedi/docutils/docutils/transforms/parts.pyRXs,       icCsÌ|d7}g|D]}t|tjƒr|^q}g}d}|jjjdtjƒ}x/|D]'}|d} | jdƒ} |j| ƒ} tj ddd|dd| Œ} |j j | ƒ} tj dd| ƒ}tj d|ƒ}|jd krR| jtj ƒdkrR|jdkr0| | ds  4X