
    7 fX_                    R   d Z ddlmZ ddlZddlZddlZddlmZmZm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZ er2dd	lmZ dd
lmZmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddl!m"Z"  ej#        e$          Z% ej&        dej'                  Z(e(Z) G d d          Z*ddZ+dddZ,ddZ-ej.        ej/        ej0        ej1        fZ2dd!Z3ej/        ej0        ej4        ej5        fZ6ej7        fZ8dd$Z9dd%Z:dd&Z;ddd*Z<dd,Z=dd.Z>	 ddd3Z?dd4Z@dd7ZAg d8ZBdd<ZCddHZDddJZE ej&        dK          ZF ej&        dL          ZGi dMdNdOdPdQdRdSdTdUdVdWdXdYdZd[dZd\d]d^dPd_d`dadbdcdVdddedfdgdhdXdidXi djdkdldmdndodpdmdqdVdrdedsdXdtdudvd]dwdxdydmdzd{d|dud}d~ddddkZHddddddZI	 dddZJddZK	 dddZLddZMddZNddZOejP        ejQ        ejR        ej7        ej5        ejS        ejT        fZUddZVddZWddZXddZYeYej        _Z        ddZ[e[ej        _\        dS )z3Docutils node-related utility functions for Sphinx.    )annotationsN)TYPE_CHECKINGAnyCallable)nodes)addnodes)__)logging)Iterable)ElementNode)	Directive)Inliner)
StringList)Builder)BuildEnvironment)Tagsz^(.+?)\s*(?<!\x00)<([^<]*?)>$c                  *    e Zd ZdZddZddZddZdS )NodeMatcheraT  A helper class for Node.findall().

    It checks that the given node is an instance of the specified node-classes and
    has the specified node-attributes.

    For example, following example searches ``reference`` node having ``refdomain``
    and ``reftype`` attributes::

        matcher = NodeMatcher(nodes.reference, refdomain='std', reftype='citation')
        doctree.findall(matcher)
        # => [<reference ...>, <reference ...>, ...]

    A special value ``typing.Any`` matches any kind of node-attributes.  For example,
    following example searches ``reference`` node having ``refdomain`` attributes::

        from __future__ import annotations
from typing import TYPE_CHECKING, Any
        matcher = NodeMatcher(nodes.reference, refdomain=Any)
        doctree.findall(matcher)
        # => [<reference ...>, <reference ...>, ...]
    node_classes
type[Node]attrsr   returnNonec                "    || _         || _        d S N)classesr   )selfr   r   s      G/var/www/equiseq/venv/lib/python3.11/site-packages/sphinx/util/nodes.py__init__zNodeMatcher.__init__;   s    #


    noder   boolc                D   	 | j         rt          || j                   sdS | j        rht          |t          j                  sdS | j                                        D ]2\  }}||vr dS |t          u r|                    |          |k    r dS 3dS # t          $ r Y dS w xY w)NFT)	r   
isinstancer   r   r   itemsr   get	Exception)r   r"   keyvalues       r   matchzNodeMatcher.match?   s    	| JtT\$B$B uz 
%!$66 ! 5"&*"2"2"4"4 % %JC$$uu# #%//$uu 0 4 	 	 	55	s(   B !B #B ($B B 
BBc                ,    |                      |          S r   )r+   )r   r"   s     r   __call__zNodeMatcher.__call__U   s    zz$r!   N)r   r   r   r   r   r   r"   r   r   r#   )__name__
__module____qualname____doc__r    r+   r-    r!   r   r   r   $   sZ         ,      ,           r!   r   r"   r   r   strc                .    | j          d| j        j         S )z
    Return full module dotted path like: 'docutils.nodes.paragraph'

    :param nodes.Node node: target node
    :return: full module dotted path
    .)r0   	__class__r/   r"   s    r   get_full_module_namer9   Y   s     o99 7999r!   P   lengthintc                    	 |                                                                  }n# t          $ r t          |           }Y nw xY w|r t	          |          |k    r|d|         dz   }|S )a  
    return DOM XML representation of the specified node like:
    '<paragraph translatable="False"><inline classes="versionmodified">New in version...'

    :param nodes.Node node: target node
    :param int length:
       length of return value to be striped. if false-value is specified, repr_domxml
       returns full of DOM XML representation.
    :return: DOM XML representation
    Nz...)asdomtoxmlr(   r4   len)r"   r;   texts      r   repr_domxmlrB   c   s{    zz||!!##   4yy %#d))f$$GVG}u$Ks   &) AAr   r   c                   t          | t          j                  ry| j        srt                              dt          |           t          |                      | j        }|j	        | _	        |j
        dz
  | _
        |                                 | _        n2t          | t          j                  r| j	        s| j        j	        | _	        t          | t          j                  r`| j	        Yt                              dt          |           t          |                      | j        j	        | j        j
        c| _	        | _
        t          | t          j                  r`| j	        Yt                              dt          |           t          |                      | j        j	        | j        j
        c| _	        | _
        t          | t          j                  rt                              dt          |           t          |                      t          t!          | j                            t          j                                      D ]I}t%          j        dt%          j        |                                          z  d| j                  | _        Jt          | t          j                  r`| j	        Yt                              dt          |           t          |                      | j        j	        | j        j
        c| _	        | _
        t          | t          j                  rL| j	        Et/          j        t2                    5  t5          |           | _	        d d d            n# 1 swxY w Y   | j        s|                                 | _        | j	        r	| j        rd S t          | t          j        t          j
        t          j        t          j        f          rlt                              dt          |           t          |                      	 t5          |           | _	        n# t2          $ r
 d| _	        Y nw xY wd	| _
        d S d S )
Nz7[i18n] PATCH: %r to have source, line and rawsource: %s   z)[i18n] PATCH: %r to have source, line: %sz#[i18n] PATCH: %r to have source: %sz&[i18n] PATCH: %r to have rawsource: %sz	\s*:\s*%s z,[i18n] PATCH: %r to have source and line: %sr   )r%   r   
classifier	rawsourceloggerdebugr9   rB   parentsourcelineastextimagetitletermreversedlistfindallresubescapetopicliteral_block
contextlibsuppress
ValueErrorget_node_sourcerubric
field_name)r"   definition_list_itemrF   s      r   apply_source_workaroundr`   w   s    $()) 	)$. 	)N)$//T1B1B	D 	D 	D#{*1(-1		D%*	+	+ )DK )k($$$ F)<@)$//T1B1B	D 	D 	D!%!3T[5ETY$$$ F)<:)$//T1B1B	D 	D 	D!%!3T[5ETY$
## 8=)$//T1B1B	D 	D 	D #4(;(;E<L(M(M#N#NOO 	8 	8JVL29Z=N=N=P=P3Q3Q$Q$&8 8DNN$$$ F)<@)$//T1B1B	D 	D 	D!%!3T[5ETY $+,, 01D ,, 	0 	0)$//DK	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 > '{ t~  	4LJK	 	 	  	C)$//T1B1B	D 	D 	D	)$//DKK 	 	 	DKKK		 s$   M''M+.M+P* *P>=P>r#   c                   t          | t          j                  rdS t          | t          j                  r,|                     d          s|                     d          rdS t          | t          j                  rd| vrdS t          | t          j                  rC| j        s8t          
                    dt          |           t          |                      dS t          | t                    r<d| vr8t          
                    dt          |           t          |                      dS |                     dd          s8t          
                    dt          |           t          |                      dS t          | t          j                  rI| j        d         d	k    r8t          
                    d
t          |           t          |                      dS dS t          | t          j                  rdS dS )NTtranslatablealtFz)[i18n] SKIP %r because no node.source: %szO[i18n] SKIP %r because node is in IGNORED_NODES and no node['translatable']: %sz3[i18n] SKIP %r because not node['translatable']: %sr   orphanz&[i18n] SKIP %r because orphan node: %s)r%   r   rb   r   rN   r'   InlineTextElementrK   rH   rI   r9   rB   IGNORED_NODESr^   childrenmetar8   s    r   is_translatablerj      s   $-.. t $$$ $((>*B*B dhhuoo t$%% .*D*Du$)** { 	LLD-d33[5F5FH H H5dM** 	~T/I/ILL ;-d33[5F5FH H H 5xx-- 	LLN-d33[5F5FH H H5 dE,-- 	$-2Bh2N2NLLA-d33[5F5FH H H5t$
## t5r!   doctreeIterable[tuple[Element, str]]c              #    K   |                      t                    D ];}t          |t          j                  r|                                D ]}||fV  	;t          |t                    r|j        }|s|                                }nt          |t          j
                  r[|                    d          r||d         fV  |                    d          r"|                    d|d                   }d| }nSd}nPt          |t          j                  r	|d         }n-|j                            dd	                                          }|r||fV  =d
S )z3Extract translatable messages from a document tree.rc   rb   original_uriuriz.. image:: rE   content
 N)rS   rj   r%   r   rb   extract_original_messagesLITERAL_TYPE_NODESrG   rM   r   rN   r'   ri   replacestrip)rk   r"   msg	image_uris       r   extract_messagesry      ss     00  dH122 	5577    Cid.// 	<.C $kkmmek** 	<xx (DK''''xx''  HH^T%[AA	/I//ej)) 	<y/CC.((s3399;;C  	)OOO1 r!   c                h    t          |           D ]}|j        r	|j        c S d}t          |          )Nznode source not found)traverse_parentrK   r[   r"   pnoderw   s      r   r\   r\     sG     &&    < 	 <	 
!C
S//r!   c                h    t          |           D ]}|j        r	|j        c S d}t          |          )Nznode line not found)r{   rL   r[   r|   s      r   get_node_liner     sG     &&  : 	:	
C
S//r!   clsr   Iterable[Element]c              #  P   K   | r!|t          | |          r| V  | j        } | d S d S r   )r%   rJ   )r"   r   s     r   r{   r{   #  sO      
 ;*T3//;JJJ{      r!   Node | Nonec                f    | j                             |           }|dk    r| j         |dz
           S d S )Nr   rD   )rJ   index)r"   poss     r   get_prev_noder   *  s6    
+

D
!
!C
Qww{37##tr!   EIterable[tuple[Element, list[tuple[str, str, str, str, str | None]]]]c              #     K   t          t          j        d          }|                     |          D ]}d|v r	|d         }n|d         }||fV  dS )z6Traverse translatable index node from a document tree.F)inlineraw_entriesentriesN)r   r   r   rS   )rk   matcherr"   r   s       r   traverse_translatable_indexr   2  st       (.777G((  D  =)GG9oGGm r!   staterp   r   content_offsetc                    | j         j        }| j         j        }g | j         _        d| j         _        	 |                     |||d          || j         _        || j         _        S # || j         _        || j         _        w xY w)zVersion of state.nested_parse() that allows titles and does not require
    titles to have the same decoration as the calling document.

    This is useful when the parsed content comes from a completely different
    context, such as docstrings.
    r   rD   )match_titles)memotitle_stylessection_levelnested_parse)r   rp   r"   r   surrounding_title_stylessurrounding_section_levels         r   nested_parse_with_titlesr   ?  s      %z6 %
 8 EJ EJ=!!'>4a!PP":
#<
   #;
#<
 <<<<s   A# #A=c                2   |                                  } |                     t          j                  D ]}d|d<   t	          |                     t          j                            D ]}|j                            |           |                                 S )z&Like node.astext(), but ignore images.rE   rc   )	deepcopyrS   r   rN   rR   rawrJ   removerM   )r"   imgr   s      r   clean_astextr   S  s    ==??D||EK((  E

DLL++,,  
#;;==r!   rA   tuple[bool, str, str]c                    t                               |           }|r+d|                    d          |                    d          fS d| | fS )z3Split role content into title and target, if given.TrD      F)explicit_title_rer+   group)rA   r+   s     r   split_explicit_titler   ]  sK    ##D))E 4U[[^^U[[^^33$r!   )singlepairdoubletripleseeseealsoentrytargetid+list[tuple[str, str, str, str, str | None]]c                   ddl m} g }|                                 } | }d}|                     d          rd}| dd                                          } |D ]}|                     | d          r| t          |          dz   d                                          }||          d| }t                              t          d	          || |d
           |	                    d|||d f            nt          D ]j}|                     | d          rP| t          |          dz   d                                          }|dk    rd}|	                    ||||d f            nk|                    d          D ]h}|                                }d}|                    d          rd}|dd                                          }|sN|	                    d|||d f           i|S )Nr   )pairindextypesrE   !mainrD   :z; zK%r is deprecated for index entries (from entry %r). Use 'pair: %s' instead.r   )typer   r   ,r   )sphinx.domains.pythonr   rv   
startswithlstripr@   rH   warningr	   append
indextypessplit)r   r   r   indexentriesoentryr   
index_typer*   s           r   process_index_entryr   j  s`   444444@BLKKMMEFD #abb	  ""$ M M
z,,,-- 	#j//A-../5577E%j1<<U<<ENN2 8 9 9%ue'  C C C $ EFFFE	 % 	M 	MJ: 0 0 011 c*oo122399;;))!'J##Z$$MNNN  c** M M##C(( /!D!!""I,,..E ##Xuhd$KLLLLr!   builderr   
docnamesetset[str]docnametreenodes.document	colorfuncr   	traversed	list[str]c           
     P   |                                 }t          |                    t          j                            D ]c}g }t          t          |d                   }|D ]$}	|	|vr	 |                    |	           t          	                     ||	          dz   d           t          | ||	| j                            |	          ||          }
|                    |	           t          j        |	          }|
j        |_        |                    t           j                  D ]}d|vr|	|d<   |                    |           # t$          $ r. t                              t)          d          |	|           Y  w xY w&|j                            ||           e|S )	zwInline all toctrees in the *tree*.

    Record all docnames in *docnameset*, and output docnames with *colorfunc*.
    includefilesrr   T)nonl)r   r   z+toctree contains ref to nonexisting file %rlocation)r   rR   rS   r   toctreemapr4   r   rH   infoinline_all_toctreesenvget_doctreeaddstart_of_filerh   r   sectionr(   r   r	   rJ   ru   )r   r   r   r   r   r   toctreenodenewnodesr   includefilesubtreesofsectionnodes                r   r   r     s    ==??DDLL)9::;; : :3N ;<<' 	) 	)K)++)$$[111KK		+ 6 6 <4KHHH1':{29+2I2I+2V2V2;YH HG NN;///
 #0EEEC#*#3CL'*{{5='A'A A A$K775@K	2OOC(((( ! B B BNN2&S#T#T#. # B B B B BB ,$ 	"";9999Ks   ,A>E4FFstringc                   |                      t                    }|                     t                    }t          j        d|                              dd                              d          }t                              dd	                    |
                                                    }t                              d|          }t          |          S )a  Convert `string` into an identifier and return it.

    This function is a modified version of ``docutils.nodes.make_id()`` of
    docutils-0.16.

    Changes:

    * Allow to use capital alphabet characters
    * Allow to use dots (".") and underscores ("_") for an identifier
      without a leading character.

    # Author: David Goodger <goodger@python.org>
    # Maintainer: docutils-develop@lists.sourceforge.net
    # Copyright: This module has been placed in the public domain.
    NFKDasciiignore-rr   rE   )	translate_non_id_translate_digraphs_non_id_translateunicodedata	normalizeencodedecode_non_id_charsrU   joinr   _non_id_at_endsr4   )r   ids     r   _make_idr     s      
		4	5	5B	'	(	(B 
	vr	*	*	1	1'8	D	D	K	KG	T	TB			3 4 4	5	5B			R	$	$Br77Nr!   z[^a-zA-Z0-9._]+z^[-0-9._]+|-+$   oi  di'  hi1  iiB  lig  ti  bi  i  ci  i  fi  ki  i  ni  pi  i  i  yi  zi  gi%  i4  i5  i6  i7  ji<  i?  si@  iG  eiI  iK  qiM  riO  szaeoedbqp)      iS  i8  i9  rE   r   r   documentprefixrP   
str | Nonec                   d}|r|dz   }n|j         j        pddz   }|r|rt          ||z            }||k    rd}n|rt          |          }|dk    rd}|	||j        v r#||                     |          z  }|||j        v #|S )z>Generate an appropriate node_id for given *prefix* and *term*.Nz-%sr   z%srE   )settings	id_prefixr   idsnew_serialno)r   r  r  rP   node_ididformats         r   make_idr     s     G @E>%/744?  $ 8d?++fG	 4..b==G
/W44S--f555 /W44 Nr!   addnodes.pending_xref	conditionElement | Nonec                ~    | D ]9}t          |t          j                  r|                    d          |k    r|c S :dS )zBPick matched pending_xref_condition node up from the pending_xref.r  N)r%   r   pending_xref_conditionr'   )r"   r  subnodes      r   find_pending_xref_conditionr    sN       w ?@@ 	K((I55NNN4r!   fromdocname	todocnamechildNode | list[Node]rO   nodes.referencec                    t          j        ddd          }||k    r|r||d<   n;|r |                     ||          dz   |z   |d<   n|                     ||          |d<   |r||d<   ||z  }|S )z$Shortcut to create a reference node.rE   T)internalrefid#refurireftitle)r   	referenceget_relative_uri)r   r  r  r   r   rO   r"   s          r   make_refnoder+  $  s     ?2rD111DiH W 	N%66{INN!"$,-DNN %55k9MMDN ! ZEMDKr!   	directiver   c                ^    | j                             | j                  \  |_        |_        d S r   )state_machineget_source_and_linelinenorK   rL   )r,  r"   s     r   set_source_infor1  7  s*    33I4DEE DKr!   inlinerr   r0  c                N    | j         j        } ||          \  |_        |_        d S r   )reporterr/  rK   rL   )r2  r0  r"   gsals       r   set_role_source_infor6  <  s'    /D!T&\\DKr!   srcdstc                    t          j        t                    5  t          |           |_        t          |           |_        d d d            d S # 1 swxY w Y   d S r   )rY   rZ   r[   r\   rK   r   rL   )r7  r8  s     r   copy_source_infor:  A  s    		Z	(	( & &$S))
 %%& & & & & & & & & & & & & & & & & &s   )AAAc                    t          | j                  D ]5}t          |t                    r dS |                    dd          du r dS 6t          | dd          du rdS dS )z0Check whether the node is smart-quotable or not.Fsupport_smartquotesNT)r{   rJ   r%   NON_SMARTQUOTABLE_PARENT_NODESr'   getattr)r"   r}   s     r   is_smartquotabler?  R  s     --  e;<< 	5599*D11U::55 ; t*D11U::u4r!   tagsr   c                   |                      t          j                  D ]f}t          ||          r.|                    |j        pt          j                               @|                    t          j                               gdS )z0Filter ``only`` nodes which do not match *tags*.N)rS   r   only_only_node_keep_childrenreplace_selfrh   r   comment)r  r@  r"   s      r   process_only_nodesrF  `  s      // / /#D$// 	/dm>u}???? emoo..../ /r!   addnodes.onlyc                    	 |                     | d                   S # t          $ r5}t                              t	          d          ||            Y d}~dS d}~ww xY w)z%Keep children if tags match or error.exprz8exception while evaluating only directive expression: %sr   NT)eval_conditionr(   rH   r   r	   )r"   r@  errs      r   rC  rC  m  sz    ""4<000   IJJ 	 	 	 	 ttttts    
A*AAelc                   t                               | j                  }g |_        | j        |_        | j        |_        d | j                                        D             |_        | j        |_        | j	        |_	        |S )zMonkey-patch ```nodes.Element.copy``` to not copy the ``_document``
    attribute.

    xref: https://github.com/sphinx-doc/sphinx/issues/11116#issuecomment-1376767086
    c                6    i | ]\  }}||d vr|n	|dd         S )>   r  namesr   backrefsdupnamesNr3   ).0r   vs      r   
<dictcomp>z*_copy_except__document.<locals>.<dictcomp>  sL     = = = #a !"*]!]!]  a#$QQQ4= = =r!   )
object__new__r7   rh   rG   tagname
attributesr&   rL   rK   )rL  newnodes     r   _copy_except__documentrZ  y  s|     nnR\**GGGjGO= = ')m&9&9&;&;= = =G 7GLYGNNr!   c                   |                                  }d | j        D             |_        |j        D ]L}||_        | j        r<| j        |_        |j        | j        j        |_        |j        | j        j        |_        M|S )z4Monkey-patch ```nodes.Element.deepcopy``` for speed.c                6    g | ]}|                                 S r3   )r   )rR  r   s     r   
<listcomp>z_deepcopy.<locals>.<listcomp>  s"    BBBU((BBBr!   )copyrh   rJ   r  rK   current_sourcerL   current_line)rL  rY  r   s      r   	_deepcopyra    s    ggiiGBBbkBBBG! 6 6; 	6[EN|#!{9z![5
Nr!   )r"   r   r   r4   )r:   )r"   r   r;   r<   r   r4   )r"   r   r   r   r.   )rk   r   r   rl   )r"   r   r   r4   )r"   r   r   r<   r   )r"   r   r   r   r   r   )r"   r   r   r   )rk   r   r   r   )r   )
r   r   rp   r   r"   r   r   r<   r   r4   )rA   r4   r   r   )r   r4   r   r4   r   r   )r   r   r   r   r   r4   r   r   r   r   r   r   r   r   )r   r4   r   r4   )rE   N)
r   r   r  r   r  r4   rP   r  r   r4   )r"   r  r  r4   r   r  )r   r   r  r4   r  r4   r   r  r   r!  rO   r  r   r"  )r,  r   r"   r   r   r   )r2  r   r0  r<   r"   r   r   r   )r7  r   r8  r   r   r   )r  r   r@  r   r   r   )r"   rG  r@  r   r   r#   )rL  r   r   r   )]r2   
__future__r   rY   rT   r   typingr   r   r   docutilsr   sphinxr   sphinx.localer	   sphinx.utilr
   collections.abcr   docutils.nodesr   r   docutils.parsers.rstr   docutils.parsers.rst.statesr   docutils.statemachiner   sphinx.buildersr   sphinx.environmentr   sphinx.util.tagsr   	getLoggerr/   rH   compileDOTALLr   caption_ref_rer   r9   rB   r`   	InvisiblerX   doctest_blockversionmodifiedrg   rj   
math_blockr   rt   rN   IMAGE_TYPE_NODESry   r\   r   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r+  r1  r6  r:  FixedTextElementliteralmathproblematicnot_smartquotabler=  r?  rF  rC  rZ  r^  ra  r   r3   r!   r   <module>r~     s{   9 9 " " " " " "     				     / / / / / / / / / /                         
&((((((,,,,,,,,......333333000000''''''333333%%%%%%		8	$	$ BJ?KK "2  2  2  2  2  2  2  2 j: : : :    (? ? ? ?F 
O			& & & &T 
			I	  
K 
   :             
 
 
 
 45= = = = =(        

( ( ( (V   D   6 
,--"*-.."
C"
C" C" C	"
 C" C" C" C" C" C" C" C" C" C" C"  C!"" C#" "$ C%"& C'"( C)"* C+", C-". C/"0 C1"2 C3"4 C5"6 C7"8 C9": C;"< C="> C?"@ CA"B CC" " H    26    4    @D    &F F F F
* * * *
& & & & 
	M	J	K	I	"    
/ 
/ 
/ 
/	 	 	 	   * ,     #   r!   