m %Gc@sfdklZdkZdZdZdefdYZddZdd Zd Zd ZdS( (s spyceModuleNs The TOC module provides support for constructing a table contents for a lengthy document, such as this user documentation. The primary task of the TOC module is to maintain a document tree, and initiate callbacks at the appropriate points in the document. Note that this module may automatically force a secondary processing of the Spyce file to resolve forward references.

The module provides the following methods to segment the document:

The following methods provide access to document information:

The TOC modules can make callbacks to handlers that format the document correctly. The handlers should be defined and registered before the first section break in the document. The following functions register handlers:

Each callback function should be of the form:

f(depth, tag, numbering, data),
where: depth is the nesting depth, tag is the associated tag, numbering is the position array, and data is the associated data of the section for which the callback was made.

The DOC callbacks are made as the sections are encountered. The TOC callbacks are made while printing the table of contents. If the modules detects that forward references exist in the document, the document will be processed twice, and only the second output will be sent. Note that buffering MUST be turned on for this to function correctly.

To display a table of contents, define the appropriate TOC callback functions and call:

trootttoccBstZdZdZdZdZdZdZdZdZ d Z d Z dd d Z d Zdd dZedZe ZeZeZddZddZddZddZddZddZddZddZddZddZdZdZ ddZ!ddZ"ddZ#ddZ$dd Z%dd!Z&dd"Z'dd#Z(d$Z)d%Z*RS(&NcCsO|iididph|iidd((Rtlevels      cCs|id||dS(Ni(RR@R5R4(RR5R4((Rtl1scCs|id||dS(Ni(RR@R5R4(RR5R4((Rtl2 scCs|id||dS(Ni(RR@R5R4(RR5R4((Rtl3 scCs|id||dS(Ni(RR@R5R4(RR5R4((Rtl4scCs|id||dS(Ni(RR@R5R4(RR5R4((Rtl5scCs|id||dS(Ni(RR@R5R4(RR5R4((Rtl6scCs|id||dS(Ni(RR@R5R4(RR5R4((Rtl7scCs|id||dS(Ni(RR@R5R4(RR5R4((Rtl8scCs|id||dS(Ni (RR@R5R4(RR5R4((Rtl9scCsd|_|i|idS(Ni(RRt _tocHelperR(R((RtshowTOCs cCsl|i||i|ioK|i||ix|iD]}|i|q:W|i||indS(N( RR/RRtchildrenRtcRJR(RRRM((RRJs  cCs3d|_|p |i}n|i\}}}|S(Ni(RRRR5R4R(RRR5R4R((RtgetTag(s   cCsbd|_y;|i}|o|i|}n|i\}}}|SWntj o dSnXdS(Ni( RRRR4R R5RR R(RR4RRR5((Rt getNumbering-s  cCsbd|_y;|i}|o|i|}n|i\}}}|SWntj o dSnXdS(Ni( RRRR4R R5RR R(RR4RRR5((RtgetData6s  cCsSd|_y,|i}|o|i|}n|iSWntj o dSnXdS(Ni(RRRR4RR?R R(RR4R((RR=?s   cCstd|_yM|p|i}n|i|i}|djodSn|i|SWntj o dSnXdS(Ni(RRR4RNR R;RR (RR4((Rt getNextTagGs  cCstd|_yM|p|i}n|i|i}|djodSn|i|SWntj o dSnXdS(Ni( RRR4RNR tprevRRR (RR4R((Rt getPrevTagPs  cCstd|_yM|p|i}n|i|i}|djodSn|i|SWntj o dSnXdS(Ni( RRR4RNR R9RRR (RR4R((Rt getParentTagYs  cCsbd|_y;|p|i}n|i|i}t|i|SWntj o dSnXdS(Ni( RRR4RNR RLtnodestmapR R(RR4RU((RtgetChildrenTagsbs cCs'dt|i}|id|_|S(Ntauto_i(tstrRRR4(RR4((RR6lscCs9|i\}}}|o||i|||}ndS(N(RR5R4RR'R?ts(RRR'RRZR4R5((RR/ps(+t__name__t __module__RRR&R(R)R*R+R,R-R.RR7R:R;R R<tbtetnR@RARBRCRDRERFRGRHRIRKRJRNRORPR=RQRSRTRWR6R/(((RRsN                         icCs|d |d|gS(Ni(Rtinc(RR`((RR2usicCs ||gS(N(RR(RR((RR0wscCs|d S(Ni(R(R((RR8yscCs!td|ddt|S(NcCsd||fS(Ns%s%d.(RZti(RZRa((Rt}stt (treduceRRYR5(R4RR5((Rt defaultOutput|s( t spyceModuleR t__doc__R RR2R0R8Rf( RgR0RfR R R2R8RRh((Rt? s