o
    N=&bÀŽ  ã                   @   sÚ   d Z dZddlmZmZ ddlmZ G dd„ deƒZG dd„ deƒZG d	d
„ d
eƒZ	G dd„ deƒZ
G dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ dejƒZdS )z&
Transforms for resolving references.
ZreStructuredTexté    )ÚnodesÚutils)Ú	Transformc                   @   ó   e Zd ZdZdZdd„ ZdS )ÚPropagateTargetsa}  
    Propagate empty internal targets to the next element.

    Given the following nodes::

        <target ids="internal1" names="internal1">
        <target anonymous="1" ids="id1">
        <target ids="internal2" names="internal2">
        <paragraph>
            This is a test.

    PropagateTargets propagates the ids and names of the internal
    targets preceding the paragraph to the paragraph itself::

        <target refid="internal1">
        <target anonymous="1" refid="id1">
        <target refid="internal2">
        <paragraph ids="internal2 id1 internal1" names="internal2 internal1">
            This is a test.
    i  c                 C   sˆ  | j  tj¡D ]º}t|jtjƒs| d¡s| d¡s| d¡r qt|ƒdks*J dƒ‚|j	dd}t|tj
ƒrC|j	ddd	}t|tj
ƒs6|d u sVt|tjtjfƒrWt|tjƒsWq|d
  |d
 ¡ |d  |d ¡ t|dƒsqi |_t|dƒsyi |_|d
 D ]}|| j j|< ||j|< q}|d D ]}||j|< q|j t|di ƒ¡ |j t|di ƒ¡ |d
 d |d< g |d
< g |d< | j  |¡ qd S )NÚrefidÚrefuriÚrefnamer   z&error: block-level target has childrenT)ÚascendF)r
   ZdescendÚidsÚnamesÚexpect_referenced_by_nameÚexpect_referenced_by_id)ÚdocumentÚfindallr   ÚtargetÚ
isinstanceÚparentZTextElementÚhasattrÚlenÚ	next_nodeZsystem_messageZ	InvisibleZ
TargetableÚextendr   r   r   ÚupdateÚgetattrÚ
note_refid)Úselfr   r   ÚidÚname© r   úBusr/lib/python3.10/site-packages/docutils/transforms/references.pyÚapply(   sT   ÿÿþÿÿ
þ


ÿ
ÿÓzPropagateTargets.applyN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__Údefault_priorityr    r   r   r   r   r      s    r   c                   @   r   )ÚAnonymousHyperlinksa¥  
    Link anonymous references to targets.  Given::

        <paragraph>
            <reference anonymous="1">
                internal
            <reference anonymous="1">
                external
        <target anonymous="1" ids="id1">
        <target anonymous="1" ids="id2" refuri="http://external">

    Corresponding references are linked via "refid" or resolved via "refuri"::

        <paragraph>
            <reference anonymous="1" refid="id1">
                text
            <reference anonymous="1" refuri="http://external">
                external
        <target anonymous="1" ids="id1">
        <target anonymous="1" ids="id2" refuri="http://external">
    i¸  c           
      C   sJ  g }g }| j  tj¡D ]}| d¡r| |¡ q| j  tj¡D ]}| d¡r+| |¡ qt|ƒt|ƒkrj| j j 	dt|ƒt|ƒf ¡}| j  
|¡}|D ]}tj|j|j|d}| j  
|¡}| |¡ | |¡ qKd S t||ƒD ]3\}}	d|	_	 |	 d¡r†|	d |d< d|_n|	d s“| j j|	d  }	qv|	d d	 |d< | j  |¡ 	 qod S )
NÚ	anonymousz]Anonymous hyperlink mismatch: %s references but %s targets.
See "backrefs" attribute for IDs.©r   é   Tr   r   r   r   )r   r   r   Ú	referenceÚgetÚappendr   r   ÚreporterÚerrorÚset_idÚproblematicÚ	rawsourceÚadd_backrefÚreplace_selfÚzipÚ
referencedr   Úresolvedr   r   )
r   Zanonymous_refsZanonymous_targetsÚnodeÚmsgÚmsgidÚrefÚprbÚprbidr   r   r   r   r    s   sP   

€

€þÿ
ÿ

€òzAnonymousHyperlinks.applyNr!   r   r   r   r   r'   Y   s    r'   c                   @   sD   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dS )ÚIndirectHyperlinksaN  
    a) Indirect external references::

           <paragraph>
               <reference refname="indirect external">
                   indirect external
           <target id="id1" name="direct external"
               refuri="http://indirect">
           <target id="id2" name="indirect external"
               refname="direct external">

       The "refuri" attribute is migrated back to all indirect targets
       from the final direct target (i.e. a target not referring to
       another indirect target)::

           <paragraph>
               <reference refname="indirect external">
                   indirect external
           <target id="id1" name="direct external"
               refuri="http://indirect">
           <target id="id2" name="indirect external"
               refuri="http://indirect">

       Once the attribute is migrated, the preexisting "refname" attribute
       is dropped.

    b) Indirect internal references::

           <target id="id1" name="final target">
           <paragraph>
               <reference refname="indirect internal">
                   indirect internal
           <target id="id2" name="indirect internal 2"
               refname="final target">
           <target id="id3" name="indirect internal"
               refname="indirect internal 2">

       Targets which indirectly refer to an internal target become one-hop
       indirect (their "refid" attributes are directly set to the internal
       target's "id"). References which indirectly refer to an internal
       target become direct internal references::

           <target id="id1" name="final target">
           <paragraph>
               <reference refid="id1">
                   indirect internal
           <target id="id2" name="indirect internal 2" refid="id1">
           <target id="id3" name="indirect internal" refid="id1">
    iÌ  c                 C   s,   | j jD ]}|js|  |¡ |  |¡ qd S ©N)r   Zindirect_targetsr7   Úresolve_indirect_targetÚresolve_indirect_references©r   r   r   r   r   r    Ð   s
   
ýzIndirectHyperlinks.applyc                 C   sH  |  d¡}|d u r|d }n| jj  |¡}|s-| jjjD ]	}||ƒr% d S q|  |¡ d S | jj| }|j|d t|t	j
ƒr]|js]| d¡r]t|dƒrS|  |¡ d S d|_|  |¡ |`| d¡rp|d |d< d|v ro|d= n(| d¡r‚|d |d< | j |¡ n|d r‘||d< | j |¡ n|  |¡ d S |d urŸ|d= d|_d S )Nr	   r   ©r   Úmultiply_indirectr*   r   r   )r,   r   ÚnameidsÚtransformerÚunknown_reference_resolversÚnonexistent_indirect_targetr   Únote_referenced_byr   r   r   r7   r   Úcircular_indirect_referencerD   r@   r   )r   r   r	   Zreftarget_idÚresolver_functionZ	reftargetr   r   r   r@   Ö   sT   

ÿü
ÿþ



€


z*IndirectHyperlinks.resolve_indirect_targetc                 C   s0   |d | j jv r|  |d¡ d S |  |d¡ d S )Nr	   z>which is a duplicate, and cannot be used as a unique referencezwhich does not exist)r   rE   Úindirect_target_errorrB   r   r   r   rH     s   z.IndirectHyperlinks.nonexistent_indirect_targetc                 C   s   |   |d¡ d S )Nzforming a circular reference)rL   rB   r   r   r   rJ   	  s   z.IndirectHyperlinks.circular_indirect_referencec                 C   sþ   d}g }|d rd|d d  }|d D ]}|  | jj |g ¡¡ q|d D ]}|  | jj |g ¡¡ q&|d rB|d|d d  7 }| jjjd||d |f |d	}| j |¡}t 	|¡D ]}	t
j|	j|	j|d
}
| j |
¡}| |¡ |	 |
¡ q]d|_d S )NÚ r   z"%s" r   r   z	(id="%s")z7Indirect hyperlink target %s refers to target "%s", %s.r	   ©Ú	base_noder)   r*   )r   r   Úrefnamesr,   Úrefidsr.   r/   r0   r   Zuniqr   r1   r2   r3   r4   r7   )r   r   ZexplanationÚnamingÚreflistr   r   r9   r:   r;   r<   r=   r   r   r   rL     s2   ÿþ
ÿ

z(IndirectHyperlinks.indirect_target_errorc           	      C   s(  |  d¡rd}| jj}n|  d¡rd}d }nd S || }|d D ]6}| jj |g ¡}|r2|j|d |D ]!}|jr:q4|d= |||< |rG||ƒ d|_t|tj	ƒrU|  
|¡ q4q |d D ]6}| jj |g ¡}|rm|j|d |D ]!}|jruqo|d= |||< |r‚||ƒ d|_t|tj	ƒr|  
|¡ qoq[d S )	Nr   r   r   ©r   r	   r*   r   rC   )r   r   r   rP   r,   rI   r7   r   r   r   rA   rQ   )	r   r   ZattnameÚcall_methodZattvalr   rS   r;   r   r   r   r   rA   #  sR   



€÷

€÷üz.IndirectHyperlinks.resolve_indirect_referencesN)r"   r#   r$   r%   r&   r    r@   rH   rJ   rL   rA   r   r   r   r   r>   š   s    2,r>   c                   @   r   )ÚExternalTargetsa¸  
    Given::

        <paragraph>
            <reference refname="direct external">
                direct external
        <target id="id1" name="direct external" refuri="http://direct">

    The "refname" attribute is replaced by the direct "refuri" attribute::

        <paragraph>
            <reference refuri="http://direct">
                direct external
        <target id="id1" name="direct external" refuri="http://direct">
    i€  c                 C   s~   | j  tj¡D ]5}| d¡r<|d }|d D ]%}| j j |g ¡}|r(|j|d |D ]}|jr0q*|d= ||d< d|_q*qqd S )Nr   r   rT   r	   r*   )	r   r   r   r   r   rP   r,   rI   r7   )r   r   r   r   rS   r;   r   r   r   r    _  s    
û€ùzExternalTargets.applyNr!   r   r   r   r   rV   K  s    rV   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚInternalTargetsi”  c                 C   s6   | j  tj¡D ]}| d¡s| d¡s|  |¡ qd S )Nr   r   )r   r   r   r   r   Úresolve_reference_idsrB   r   r   r   r    s  s
   
€þzInternalTargets.applyc                 C   sj   |d D ].}| j j |¡}| j j |g ¡}|r|j|d |D ]}|jr%q|r.|d= ||d< d|_qqdS )aº  
        Given::

            <paragraph>
                <reference refname="direct internal">
                    direct internal
            <target id="id1" name="direct internal">

        The "refname" attribute is replaced by "refid" linking to the target's
        "id"::

            <paragraph>
                <reference refid="id1">
                    direct internal
            <target id="id1" name="direct internal">
        r   rT   r	   r   r*   N)r   rE   r,   rP   rI   r7   )r   r   r   r   rS   r;   r   r   r   rX   x  s   úûz%InternalTargets.resolve_reference_idsN)r"   r#   r$   r&   r    rX   r   r   r   r   rW   o  s    rW   c                   @   sR   e Zd ZdZdZdZ	 g d¢Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ ZdS )Ú	Footnotesaì  
    Assign numbers to autonumbered footnotes, and resolve links to footnotes,
    citations, and their references.

    Given the following ``document`` as input::

        <document>
            <paragraph>
                A labeled autonumbered footnote reference:
                <footnote_reference auto="1" id="id1" refname="footnote">
            <paragraph>
                An unlabeled autonumbered footnote reference:
                <footnote_reference auto="1" id="id2">
            <footnote auto="1" id="id3">
                <paragraph>
                    Unlabeled autonumbered footnote.
            <footnote auto="1" id="footnote" name="footnote">
                <paragraph>
                    Labeled autonumbered footnote.

    Auto-numbered footnotes have attribute ``auto="1"`` and no label.
    Auto-numbered footnote_references have no reference text (they're
    empty elements). When resolving the numbering, a ``label`` element
    is added to the beginning of the ``footnote``, and reference text
    to the ``footnote_reference``.

    The transformed result will be::

        <document>
            <paragraph>
                A labeled autonumbered footnote reference:
                <footnote_reference auto="1" id="id1" refid="footnote">
                    2
            <paragraph>
                An unlabeled autonumbered footnote reference:
                <footnote_reference auto="1" id="id2" refid="id3">
                    1
            <footnote auto="1" id="id3" backrefs="id2">
                <label>
                    1
                <paragraph>
                    Unlabeled autonumbered footnote.
            <footnote auto="1" id="footnote" name="footnote" backrefs="id1">
                <label>
                    2
                <paragraph>
                    Labeled autonumbered footnote.

    Note that the footnotes are not in the same order as the references.

    The labels and reference text are added to the auto-numbered ``footnote``
    and ``footnote_reference`` elements.  Footnote elements are backlinked to
    their references via "refids" attributes.  References are assigned "id"
    and "refid" attributes.

    After adding labels and reference text, the "auto" attributes can be
    ignored.
    il  N)
Ú*u   â€ u   â€¡õ   Â§õ   Â¶ú#u   â™ u   â™¥u   â™¦u   â™£c                 C   s:   g | _ | jj}|  |¡| j_|  |¡ |  ¡  |  ¡  d S r?   )Úautofootnote_labelsr   Zautofootnote_startÚnumber_footnotesÚnumber_footnote_referencesÚsymbolize_footnotesÚresolve_footnotes_and_citations)r   Ústartnumr   r   r   r    ê  s   
zFootnotes.applyc                 C   s  | j jD ]‡}	 t|ƒ}|d7 }|| j jvrnq| dt d|¡¡ |d D ]I}| j j |g ¡D ]>}|t 	|¡7 }| 
d¡ t|d ƒt|d ƒ  krPdksSJ ‚ J ‚|d d |d< | |d d ¡ | j  |¡ d|_q/q%|d s‹|d	 s‹|d  |¡ | j  ||¡ | j |¡ q|S )
z«
        Assign numbers to autonumbered footnotes.

        For labeled autonumbered footnotes, copy the number over to
        corresponding footnote references.
        Tr*   r   rM   r   r	   r   r   Zdupnames)r   ZautofootnotesÚstrrE   Úinsertr   ÚlabelÚfootnote_refsr,   ÚTextÚdelattrr   r3   r   r7   r-   Únote_explicit_targetr^   )r   rc   Úfootnoterf   r   r;   r   r   r   r_   ò  s0   ü
,ù€zFootnotes.number_footnotesc              
   C   s@  d}| j jD ]—}|js| d¡rqz| j| }W nM tye   | j jjdt| jƒ |d}| j  	|¡}| j j|d… D ]%}|jsE| d¡rFq;t
j|j|j|d}| j  	|¡}| |¡ | |¡ q;Y  dS w |t
 |¡7 }| j j| }	| j j|	 }
|	|d< | j  |¡ t|d ƒd	ksJ ‚|
 |d d ¡ d	|_|d	7 }qdS )
z3Assign numbers to autonumbered footnote references.r   r   zUToo many autonumbered footnote references: only %s corresponding footnotes available.rN   Nr	   r)   r   r*   )r   Zautofootnote_refsr7   r   r^   Ú
IndexErrorr.   r/   r   r0   r   r1   r2   r3   r4   rh   rE   r   r   )r   rc   Úir;   rf   r9   r:   r<   r=   r   rk   r   r   r   r`     sF   þý
ÿ
ò
äz$Footnotes.number_footnote_referencesc              
   C   s’  g }| j jD ]4}t| j jt| jƒƒ\}}| j| |d  }| |¡ | dt 	d|¡¡ | j  jd7  _| j  
|¡ qd}| j jD ]…}z|t || ¡7 }W nL tyš   | j jjdt|ƒ |d}| j  
|¡}	| j j|d… D ]%}|jsz| d¡r{qptj|j|j|	d}
| j  
|
¡}| |¡ | |
¡ qpY  dS w | j j| }t|d	 ƒdks«J ‚|d	 d |d< | j  |¡ | |d	 d ¡ |d7 }qAdS )
z<Add symbols indexes to "[*]"-style footnotes and references.r*   r   rM   zOToo many symbol footnote references: only %s corresponding footnotes available.rN   Nr   r)   r   )r   Zsymbol_footnotesÚdivmodZsymbol_footnote_startr   Úsymbolsr-   re   r   rf   r0   Zsymbol_footnote_refsrh   rl   r.   r/   r7   r   r1   r2   r3   r4   r   )r   Úlabelsrk   ZrepsÚindexZ	labeltextrm   r;   r9   r:   r<   r=   r   r   r   ra   0  sP   ÿ
ÿý
ÿ
ò
ézFootnotes.symbolize_footnotesc                 C   s„   | j jD ]}|d D ]}|| j jv r| j j| }|  ||¡ q
q| j jD ]}|d D ]}|| j jv r>| j j| }|  ||¡ q*q$dS )za
        Link manually-labeled footnotes and citations to/from their
        references.
        r   N)r   Z	footnotesrg   Úresolve_referencesZ	citationsZcitation_refs)r   rk   rf   rS   Zcitationr   r   r   rb   U  s   €ý€ýÿz)Footnotes.resolve_footnotes_and_citationsc                 C   sz   t |d ƒdks
J ‚|d d }|D ]%}|jrq| d¡ ||d< t |d ƒdks+J ‚| |d d ¡ d|_qd|_d S )Nr   r*   r   r	   r   )r   r7   ri   r3   )r   ZnoterS   r   r;   r   r   r   rr   e  s   

zFootnotes.resolve_references)r"   r#   r$   r%   r&   r^   ro   r    r_   r`   ra   rb   rr   r   r   r   r   rY   —  s    ;!%rY   c                   @   s   e Zd ZdS )Ú#CircularSubstitutionDefinitionErrorN)r"   r#   r$   r   r   r   r   rs   s  s    rs   c                   @   s   e Zd ZdZdZ	 dd„ ZdS )ÚSubstitutionsaD  
    Given the following ``document`` as input::

        <document>
            <paragraph>
                The
                <substitution_reference refname="biohazard">
                    biohazard
                 symbol is deservedly scary-looking.
            <substitution_definition name="biohazard">
                <image alt="biohazard" uri="biohazard.png">

    The ``substitution_reference`` will simply be replaced by the
    contents of the corresponding ``substitution_definition``.

    The transformed result will be::

        <document>
            <paragraph>
                The
                <image alt="biohazard" uri="biohazard.png">
                 symbol is deservedly scary-looking.
            <substitution_definition name="biohazard">
                <image alt="biohazard" uri="biohazard.png">
    éÜ   c              
   C   s   | j j}| j j}i }t| j jddƒ}t| j  tj¡ƒ}|D ]o}d}|d }||v r-|}	n
| 	¡ }
| 
|
d ¡}	|	d u rG| j jjd| |d}n||	 }t| ¡ ƒ|kr\| j j d|	 ¡}|r| j  |¡}tj|j|j|d}| j  |¡}| |¡ | |¡ q|j}| |¡}d	|jv s‘d
|jv r«|dkr«t||d  tjƒr«||d   ¡ ||d < d|jv sµd
|jv rÓt|ƒ|d krÓt||d  tjƒrÓ||d   ¡ ||d < | ¡ }z-| tj¡D ]$}||d  	¡  }|| |g ¡v ròt‚||  |	¡ ||d< | |¡ qÞW ni tym   |j}t|tjƒr.| j jjdt  |j|j¡|j!|d}| |¡ n=|}| "d¡r@|d }| "d¡s6| j jjd| |d}| j  |¡}tj|j|j|d}| j  |¡}| |¡ | |¡ Y qw | |j#¡ |j#D ]}t|tj$ƒr‹d|v r‹| j  %|¡ qwqd S )NÚline_length_limiti'  rM   r	   z(Undefined substitution referenced: "%s".rN   z;Substitution definition "%s" exceeds the line-length-limit.r)   ZltrimÚtrimr   r*   Zrtrimz
ref-originz*Circular substitution definition detected:)ÚlinerO   z2Circular substitution definition referenced: "%s".)&r   Zsubstitution_defsZsubstitution_namesr   ÚsettingsÚlistr   r   Zsubstitution_referenceÚlowerr,   r.   r/   r   Zastextr0   r1   r2   r3   r4   r   rq   Z
attributesr   rh   ÚrstripÚlstripÚdeepcopyÚ
setdefaultrs   r-   Zsubstitution_definitionZliteral_blockrx   r   ÚchildrenZReferentialZnote_refname)r   ZdefsZnormedÚnestedrv   Z
subreflistr;   r9   r	   ÚkeyZnormed_nameZsubdefr:   r<   r=   r   rq   Zsubdef_copyZ
nested_refZnested_nameZ
ref_originr8   r   r   r   r    —  sÊ   ÿ
ÿþÿÿ
ÿ




ÿ

ÿÿùÿüÿÿþ
ÿ

é

€û³zSubstitutions.applyNr!   r   r   r   r   rt   w  s
    rt   c                   @   s.   e Zd ZdZdZ	 dd„ Zdd„ Zdd„ Zd	S )
ÚTargetNotesz‚
    Creates a footnote for each external target in the text, and corresponding
    footnote references after each reference.
    i  c                 C   s$   t j| ||d |j dg ¡| _d S )N)Ú	startnodeÚclass)r   Ú__init__Údetailsr,   Úclasses)r   r   r„   r   r   r   r†   ÿ  s   zTargetNotes.__init__c           	      C   sþ   i }g }| j  tj¡D ];}| d¡sq|d }g }|D ]}| | j j |g ¡¡ q|s,q|  |d ||¡}|d |vrF|||d < | 	|¡ q| j  tj
¡D ](}| d¡sVqN| d¡rv|  |d |g|¡}|d |vrv|||d < | 	|¡ qN| j |¡ d S )Nr   r   r(   )r   r   r   r   r   r   rP   r,   Úmake_target_footnoter-   r+   r„   r4   )	r   ÚnotesZnodelistr   r   Úrefsr   rk   r;   r   r   r   r      s<   
ÿ
€

ÿ
€zTargetNotes.applyc                 C   sV  ||v r|| }t |d ƒdksJ ‚|d d }n6t ¡ }| j |¡}d| }d|d< |g|d< t ¡ }|tjd||d7 }||7 }| j |¡ | j ||¡ |D ]W}t	|tj
ƒrZqQtj|dd}	|	d	  | j7  < | j |	¡ | j |	¡ |j |¡d }
|	g}t | jj¡s¡| jr˜| dtjd
| jd¡ n	| dt d
¡¡ |j |
|¡ qQ|S )Nr   r*   r   zTARGET_NOTE: ÚautorM   )r   )r	   rŒ   rˆ   ú )ÚtextZClasses)r   r   rk   r   r0   Z	paragraphr+   Znote_autofootnoterj   r   r   Zfootnote_referencerˆ   Znote_autofootnote_refZnote_footnote_refr   rq   r   Zget_trim_footnote_ref_spacery   re   Úinlinerh   )r   r   r‹   rŠ   rk   Zfootnote_nameZfootnote_idZfootnote_paragraphr;   Zrefnoderq   rS   r   r   r   r‰   "  s>   
ÿz TargetNotes.make_target_footnoteN)r"   r#   r$   r%   r&   r†   r    r‰   r   r   r   r   rƒ   ô  s    rƒ   c                   @   r   )ÚDanglingReferencesze
    Check for dangling references (incl. footnote & citation) and for
    unreferenced targets.
    iR  c                 C   s’   t | j| jjjƒ}| j |¡ | j tj¡D ]0}|jsF| 	d¡r!q|d r,|d d }n|d r7|d d }n|d }| jj
jd| |d qd S )Nr(   r   r   r   r   z(Hyperlink target "%s" is not referenced.rN   )ÚDanglingReferencesVisitorr   rF   rG   Úwalkr   r   r   r6   r,   r.   Úinfo)r   Úvisitorr   rR   r   r   r   r    P  s,   þ
ÿþ€ðzDanglingReferences.applyNr!   r   r   r   r   r   G  s    r   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Ze ZZdS )r‘   c                 C   s   t j | |¡ || _|| _d S r?   )r   ÚSparseNodeVisitorr†   r   rG   )r   r   rG   r   r   r   r†   n  s   
z"DanglingReferencesVisitor.__init__c                 C   s   d S r?   r   )r   r8   r   r   r   Úunknown_visits  s   z'DanglingReferencesVisitor.unknown_visitc           	      C   s"  |j s| d¡s
d S |d }| jj |¡}|d u r{| jD ]	}||ƒr% d S q|| jjv r:| jjjd|d  |d}n| jjjd|d  |d}| j |¡}t	j
|j|j|d}z|d d }W n tyn   | j |¡}Y nw | |¡ | |¡ d S |d= ||d< | jj| j|d	 d
|_ d S )Nr	   zBDuplicate target name, cannot be used as a unique reference: "%s".rN   zUnknown target name: "%s".r)   r   r   r   rC   r*   )r7   r   r   rE   r,   rG   r.   r/   r0   r   r1   r2   rl   r3   r4   r   rI   )	r   r8   r	   r   rK   r9   r:   r<   r=   r   r   r   Úvisit_referencev  sF   
ÿÿþ
þ
ÿÿ

z)DanglingReferencesVisitor.visit_referenceN)r"   r#   r$   r†   r–   r—   Zvisit_footnote_referenceZvisit_citation_referencer   r   r   r   r‘   l  s
    !r‘   N)r%   Z__docformat__Údocutilsr   r   Zdocutils.transformsr   r   r'   r>   rV   rW   rY   Ú	Exceptionrs   rt   rƒ   r   r•   r‘   r   r   r   r   Ú<module>   s"   JA 2$( ]}S%