§
    N=&b   ã                   óŒ   — d Z dZddlZddlmZ ddlmZ  G d„ de¦  «        Z G d„ d	e¦  «        Z G d
„ dej	        ¦  «        Z
dS )z'
Transforms related to document parts.
ÚreStructuredTexté    N)Únodes)Ú	Transformc                   ó&   — e Zd ZdZdZ	 d„ Zdd„ZdS )	ÚSectNumaS  
    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Æ  c                 ó°  — | j         j                             dd ¦  «        | _        | j         j                             dd¦  «        | _        | j         j                             dd¦  «        | _        | j         j                             dd¦  «        | _        | j         j                             | j         ¦  «         | j	        j
        j        r4| j        €t          j        | _        |                      | j	        ¦  «         d S | j        | j	        j
        _        | j        | j	        j
        _        | j        | j	        j
        _        | j        | j	        j
        _        d S )NÚdepthÚstarté   ÚprefixÚ Úsuffix)Ú	startnodeÚdetailsÚgetÚmaxdepthÚ
startvaluer   r   ÚparentÚremoveÚdocumentÚsettingsÚsectnum_xformÚsysÚmaxsizeÚupdate_section_numbersÚsectnum_depthÚsectnum_startÚsectnum_prefixÚsectnum_suffix©Úselfs    ú;/usr/lib/python3/dist-packages/docutils/transforms/parts.pyÚapplyzSectNum.apply   s  € ØœÔ.×2Ò2°7¸DÑAÔAˆŒØœ.Ô0×4Ò4°W¸aÑ@Ô@ˆŒØ”nÔ,×0Ò0°¸2Ñ>Ô>ˆŒØ”nÔ,×0Ò0°¸2Ñ>Ô>ˆŒØŒÔ×$Ò$ T¤^Ñ4Ô4Ð4ØŒ=Ô!Ô/ð 	@ØŒ}Ð$Ý #¤�”Ø×'Ò'¨¬Ñ6Ô6Ð6Ð6Ð6à37´=ˆDŒMÔ"Ô0Ø37´?ˆDŒMÔ"Ô0Ø48´KˆDŒMÔ"Ô1Ø48´KˆDŒMÔ"Ô1Ð1Ð1ó    © r   c                 óœ  — |dz  }|rd}n| j         }|D ]·}t          |t          j        ¦  «        r›|t	          |¦  «        fz   }|d         }t          j        d| j        d                     |¦  «        z   | j        z   dz   dg¬¦  «        }| 	                    d|¦  «         d|d<   || j
        k     r|                      |||¦  «         |dz  }Œ¸d S )	Nr   r   r   ú.u   Â Â Â Úsectnum)ÚclassesÚauto)r   Ú
isinstancer   ÚsectionÚstrÚ	generatedr   Újoinr   Úinsertr   r   )	r!   Únoder   r	   r(   ÚchildÚnumbersÚtitler.   s	            r"   r   zSectNum.update_section_numbers/   sù   € Ø�‰
ˆØð 	&ØˆGˆGà”oˆGØð 	ð 	ˆEÝ˜%¥¤Ñ/Ô/ð Ø ¥C¨¡L¤L ?Ñ2�Ø˜aœ�å!œOØ˜œ s§x¢x°Ñ'8Ô'8Ñ8¸4¼;ÑFØ'ñ(à&˜Kð)ñ )ô )�	ð —’˜Q 	Ñ*Ô*Ð*Ø !��f‘Ø˜4œ=Ò(Ð(Ø×/Ò/°°wÀÑFÔFÐFØ˜1‘�øð	ð 	r$   N)r%   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Údefault_priorityr#   r   r%   r$   r"   r   r      sO   € € € € € ðð ð ÐØ.ð@ð @ð @ð ð ð ð ð ð r$   r   c                   ó*   — e Zd ZdZdZd„ Zdd„Zd„ ZdS )	ÚContentsaè  
    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Ð  c                 ój  — t          | j        j        dd¦  «        }| j        j        }d|v r�| j        j        j        }t          |t          j        ¦  «        sUt          |t          j        ¦  «        s;|j        }t          |t          j        ¦  «        st          |t          j        ¦  «        ¯;n| j        }| j        j        d         d         | _	        d|v r|d         | _
        n| j        j        j        | _
        |rJ| j        j        j                             |¦  «         | j        j                             | j        ¦  «         d S |                      |¦  «        }t!          |¦  «        r| j                             |¦  «         d S | j        j        j                             | j        j        ¦  «         d S )NÚuse_latex_tocFÚlocalÚidsr   Ú	backlinks)Úgetattrr   r   r   r   r   r+   r   r,   Útoc_idr@   Útoc_backlinksÚ
attributesÚupdater   Úbuild_contentsÚlenÚreplace_self)r!   Útoc_by_writerr   r   Úcontentss        r"   r#   zContents.applyW   s‰  € å ¤Ô 6¸ÈÑOÔOˆØ”.Ô(ˆØ�gÐÐØœÔ-Ô4ˆIÝ! )­U¬]Ñ;Ô;ð -Ý$ Yµ´Ñ?Ô?ð-ð &Ô,�	õ " )­U¬]Ñ;Ô;ð -Ý$ Yµ´Ñ?Ô?ð-øð
 œˆIØ”nÔ+¨EÔ2°1Ô5ˆŒØ˜'Ð!Ð!Ø$ [Ô1ˆDŒNˆNà!œ]Ô3ÔAˆDŒNØð 		KàŒNÔ!Ô,×3Ò3°GÑ<Ô<Ð<ØŒNÔ!×(Ò(¨¬Ñ8Ô8Ð8Ð8Ð8à×*Ò*¨9Ñ5Ô5ˆHÝ�8‰}Œ}ð KØ”×+Ò+¨HÑ5Ô5Ð5Ð5Ð5à”Ô%Ô,×3Ò3°D´NÔ4IÑJÔJÐJÐJÐJr$   r   c                 ó2  — |dz  }d„ |D ¦   «         }g }| j         j                             dt          j        ¦  «        }|D �]"}|d         }|                     d¦  «        }|                      |¦  «        }	t          j        ddg|	¢R d|d         d         iŽ}
| j         	                    |
d	¬
¦  «        }t          j
        dd|
¦  «        }t          j        d|¦  «        }| j        dv rE|                     t          j        ¦  «        €&| j        dk    r||d<   n| j        dk    r
| j        |d<   ||k     r|                      ||¦  «        }||z  }|                     |¦  «         �Œ$|r1t          j        dg|¢R Ž }|r|d                              d¦  «         |S g S )Nr   c                 óF   — g | ]}t          |t          j        ¦  «        ¯|‘ŒS r%   )r+   r   r,   )Ú.0Úsects     r"   ú
<listcomp>z+Contents.build_contents.<locals>.<listcomp>u   s)   € ÐMÐMÐM˜T­Z¸½e¼mÑ-LÔ-LÐM�DÐMÐMÐMr$   r	   r   r*   r   Úrefidr?   z	toc-entry)Úsuggested_prefix)ÚentryÚtoprR   rS   r)   zauto-toc)r   r   r   r   r   Úcopy_and_filterr   Ú	referencer   Úset_idÚ	paragraphÚ	list_itemr@   Ú	next_noderB   rF   ÚappendÚbullet_list)r!   r1   ÚlevelÚsectionsÚentriesr	   r,   r4   r*   Ú	entrytextrU   Úref_idrR   ÚitemÚsubsectsrJ   s                   r"   rF   zContents.build_contentss   sÓ  € Ø�‰
ˆØMÐM TÐMÑMÔMˆØˆØ”Ô&×*Ò*¨7µC´KÑ@Ô@ˆØð 	!ñ 	!ˆGØ˜A”JˆEØ—9’9˜VÑ$Ô$ˆDØ×,Ò,¨UÑ3Ô3ˆIÝœ¨¨Bð 4Ø)2ð4ð 4ð 4°g¸e´nÀQÔ6Gð 4ð 4ˆIà”]×)Ò)¨)Ø;Fð *ñ Hô HˆFå”O B¨¨IÑ6Ô6ˆEÝ”? 2 uÑ-Ô-ˆDØ”Ð"2Ð2Ð2Ø—O’O¥E¤OÑ4Ô4Ð<Ø”> WÒ,Ð,Ø%+�E˜'‘N�NØ”^ uÒ,Ð,Ø%)¤[�E˜'‘NØ�uŠ}ˆ}Ø×.Ò.¨w¸Ñ>Ô>�Ø˜Ñ �Ø�NŠN˜4Ñ Ô Ð Ñ Øð 	ÝÔ(¨Ð6¨gÐ6Ð6Ð6ˆHØð 7Ø˜Ô#×*Ò*¨:Ñ6Ô6Ð6ØˆOàˆIr$   c                 ó|   — t          | j        ¦  «        }|                     |¦  «         |                     ¦   «         S )z@Return a copy of a title, with references, images, etc. removed.)ÚContentsFilterr   Ú	walkaboutÚget_entry_text)r!   r1   Úvisitors      r"   rT   zContents.copy_and_filter”   s5   € å  ¤Ñ/Ô/ˆØ�Š�wÑÔÐØ×%Ò%Ñ'Ô'Ð'r$   N)r   )r5   r6   r7   r8   r9   r#   rF   rT   r%   r$   r"   r;   r;   E   s\   € € € € € ðð ð ÐðKð Kð Kð8ð ð ð ðB(ð (ð (ð (ð (r$   r;   c                   ó8   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ ZeZeZ	eZ
dS )rd   c                 ó4   — |                       ¦   «         j        S ©N)Úget_tree_copyÚchildrenr    s    r"   rf   zContentsFilter.get_entry_text�   s   € Ø×!Ò!Ñ#Ô#Ô,Ð,r$   c                 ó   — t           j        ‚rj   ©r   ÚSkipNode©r!   r1   s     r"   Úvisit_citation_referencez'ContentsFilter.visit_citation_reference    ó
   € ÝŒnÐr$   c                 ó   — t           j        ‚rj   rn   rp   s     r"   Úvisit_footnote_referencez'ContentsFilter.visit_footnote_reference£   rr   r$   c                 ó¨   — |                      d¦  «        r2| j                             t          j        |d         ¦  «        ¦  «         t          j        ‚)NÚalt)Úhasattrr   rZ   r   ÚTextro   rp   s     r"   Úvisit_imagezContentsFilter.visit_image¦   sB   € Ø�<Š<˜ÑÔð 	8ØŒK×Ò�uœz¨$¨u¬+Ñ6Ô6Ñ7Ô7Ð7ÝŒnÐr$   c                 ó   — t           j        ‚rj   )r   ÚSkipDeparturerp   s     r"   Ú ignore_node_but_process_childrenz/ContentsFilter.ignore_node_but_process_children«   s   € ÝÔ!Ð!r$   N)r5   r6   r7   rf   rq   rt   ry   r|   Úvisit_problematicÚvisit_referenceÚvisit_targetr%   r$   r"   rd   rd   ›   sk   € € € € € ð-ð -ð -ðð ð ðð ð ðð ð ð
"ð "ð "ð 9ÐØ6€OØ3€L€L€Lr$   rd   )r8   Ú__docformat__r   Údocutilsr   Údocutils.transformsr   r   r;   ÚTreeCopyVisitorrd   r%   r$   r"   ú<module>r„      sÚ   ðð
ð ð #€ð €
€
€
Ø Ð Ð Ð Ð Ð Ø )Ð )Ð )Ð )Ð )Ð )ð1ð 1ð 1ð 1ð 1ˆiñ 1ô 1ð 1ðhS(ð S(ð S(ð S(ð S(ˆyñ S(ô S(ð S(ðl4ð 4ð 4ð 4ð 4�UÔ*ñ 4ô 4ð 4ð 4ð 4r$   