mς hγΈEc@sdZdZdkZdkZdklZlZdklZl Z de fd„ƒYZ de fd„ƒYZ d ei fd „ƒYZ dS( s' Transforms related to document parts. treStructuredTextN(snodessutils(sTransformErrors TransformtSectNumcBs,tZdZdZd„Zfdd„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­|iiidtiƒ|_|iiiddƒ|_|iiiddƒ|_|iiiddƒ|_ |ii i |iƒ|i i io|i|i ƒndS(Ntdepthtstartitprefixttsuffix(tselft startnodetdetailstgettsystmaxinttmaxdeptht startvalueRRtparenttremovetdocumenttsettingst sectnum_xformtupdate_section_numbers(R((t8/data/zmath/zope/lib/python/docutils/transforms/parts.pytapply"sic Csς|d7}|o d}n |i}xΗ|D]Ώ}t|ti ƒo¦|t |ƒf}|d}ti d|idi|ƒ|iddddgƒ}|id|ƒd|d <||ijo|i|||ƒn|d7}q+q+WdS( NiiRt.uΒ itclassestsectnumtauto(RRRRRtnodetchildt isinstancetnodestsectiontstrtnumbersttitlet generatedtjoinRtinsertR R( RRRRR"RR!RR#((RR+s     + (t__name__t __module__t__doc__tdefault_priorityRR(((RRs  tContentscBs2tZdZdZd„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 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 |ii}|idƒoJ|iii}xAt|tiƒpt|tiƒp |i}q.Wn |i}|iidd|_ |idƒo|d|_ n|ii i |_ |i |ƒ}t|ƒo|ii|ƒn|iiii|iiƒdS(Ntlocaltidsit backlinks(RRR thas_keyRRRRRttoc_idR-Rt toc_backlinkstbuild_contentstcontentstlent replace_selfR(RRR R2((RRSs &  icCs|d7}g} t|ƒd} xD| djo6t|| tiƒo| i|| ƒ| d8} q#W| i ƒg} d}|i iidtiƒ}x8| D]0}|d}|idƒ} |i|ƒ}tiddd|dd|Œ}|ii|ƒ}tidd|ƒ}tid|ƒ} |id jo\|i tiƒdjoC|idjo||dR"RIR9RR=R:RFRR@R6R((RR1hsF $  #) cCs&t|iƒ}|i|ƒ|iƒS(s@Return a copy of a title, with references, images, etc. removed.N(tContentsFilterRRtvisitorRt walkabouttget_entry_text(RRRL((RR?Žs (R&R'R(R)RR1R?(((RR*As   &RKcBsMtZd„Zd„Zd„Zd„Zd„ZeZeZeZ eZ RS(NcCs |iƒiS(N(Rt get_tree_copytchildren(R((RRN—scCs ti‚dS(N(RtSkipNode(RR((Rtvisit_citation_referencešscCs ti‚dS(N(RRQ(RR((Rtvisit_footnote_referencescCs>|idƒo!|iiti|dƒƒnti‚dS(Ntalt(RthasattrRRR;RtTextRQ(RR((Rt visit_image s!cCs ti‚dS(N(Rt SkipDeparture(RR((Rt ignore_node_but_process_children₯s( R&R'RNRRRSRWRYtvisit_interpretedtvisit_problematictvisit_referencet visit_target(((RRK•s     (R(t __docformat__treR tdocutilsRtutilstdocutils.transformstTransformErrort TransformRR*tTreeCopyVisitorRK( RcRaRRdR^R R_RRKR*((Rt? s  -T