
    ziOI                       d Z ddlmZ ddlmZmZmZ d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mZ dd	lmZ dd
lmZmZ erddlmZmZ ddlmZ ddlmZ ddlm Z   ej!        e"          Z#dPdZ$dQdZ%	 	 	 	 dRdSd'Z&dddddd(dTd+Z'	 dUdVd5Z(dWd9Z)dXd;Z*dYd>Z+dXd?Z,dZdBZ-d[dFZ. edGe
H          Z/d\dIZ0d]dLZ1 G dM dN          Z2dOS )^z'Toctree adapter for sphinx.environment.    )annotations)TYPE_CHECKINGAnyTypeVar)nodes)ElementNode)addnodes)__)loggingurl_re)Matcher)_only_node_keep_childrenclean_astext)IterableSet)Builder)BuildEnvironment)Tagsenvr   docnamestrtoctreenodeaddnodes.toctreereturnNonec                   |d         r| j                             |           |                    d          r| j                            |           |d         }|D ]<}| j                            |t                                                    |           =| j                            |g                               |           dS )zeNote a TOC tree directive in a document and gather information about
    file relations from it.
    globnumberedincludefilesN)	glob_toctreesaddgetnumbered_toctreesfiles_to_rebuild
setdefaultsettoctree_includesextend)r   r   r   include_filesinclude_files        n/var/www/tmov.alphamb/tmov_inventario/venv/lib/python3.11/site-packages/sphinx/environment/adapters/toctree.pynote_toctreer-      s     6 'g&&&z"" +!!'***/M% J J 	''cee<<@@IIII##GR0077FFFFF    tagsr   r	   c                ,   | j         |                             dd          }	 t          | j        |         d|d|          }n## t          $ r t          j                    cY S w xY w|                    t
          j                  D ]}|d         pd|d<   |S )zGet the (local) table of contents for a document.

    Note that this is only the sections within the document.
    For a ToC tree that shows the document's place in the
    ToC structure, use `get_toctree_for`.
    tocdepthr      F
anchorname#refuri)	metadatar#   _toctree_copytocsKeyErrorr   	paragraphfindall	reference)r   r   r/   r1   tocnodes         r,   document_tocr?   +   s     |G$((Q77H!CHW-q(E4HH ! ! !      !
 EO,, 3 3l+2sXJs   A A"!A"FTbuilderr   collapseboolincludehiddenmaxdepthinttitles_onlyElement | Nonec                6   g }| j                             t          j                  D ]>}t	          | |||dt          |          |||	  	        x}	r|                    |	           ?|sdS |d         }
|dd         D ]}	|
                    |	j                   |
S )zxGet the global ToC tree at a given document.

    This gives the global ToC, with all ancestors and their siblings.
    TprunerD   rF   rA   rC   Nr      )	master_doctreer;   r
   toctree_resolve_toctreerE   appendr)   children)r   r   r@   rA   rC   rD   rF   toctreestoctree_noderM   results              r,   global_toctree_for_docrT   @   s     !H*2283CDD % %&]]#'

 

 

 

7 	% OOG$$$ ta[FABB< ( (g&''''Mr.   rI   rM   rJ   c                  |                     dd          r|sdS t          | j        |          }	t          | j        j                  }
t          | j        j                  }|p|                     dd          }|s|                     dd          rd}|s|                     dd          rd}t          | |||||j        |	|
||g           }|sdS t          j
        d	d	          }|j                             d
          x}r~t          j        |d	gt          j        |          gR  }|j        |_        |j        |_        |d         |_        t%          |d          r|j        |_        |`|                    |           |                    |           d|d<   t-          |d|           t/          |d|r|nd||j                  }t1          |d         t          j                  rt5          |d                   dk    rdS |                    t          j                  D ]F}t;          j        |d                   *|                    ||d                   }||d         z   |d<   G|S )a  Resolve a *toctree* node into individual bullet lists with titles
    as items, returning None (if no containing titles are found) or
    a new node.

    If *prune* is True, the tree is pruned to *maxdepth*, or if that is 0,
    to the value of the *maxdepth* option on the *toctree* node.
    If *titles_only* is True, only toplevel document titles will be in the
    resulting tree.
    If *collapse* is True, all branches not containing docname will
    be collapsed.
    hiddenFNrD   
titlesonlyTrC    caption
rawcaptionuidrM   rK   r   r5   r3   ) r#   _get_toctree_ancestorsr(   r   configinclude_patternsexclude_patterns_entries_from_toctreer/   r
   compact_paragraph
attributesr   titleTextlinesource	rawsourcehasattrr\   rO   r)   _toctree_add_classesr7   
isinstancer   lenr;   r<   r   matchget_relative_uri)r   r   r@   rM   rJ   rD   rF   rA   rC   toctree_ancestorsincludedexcluded
tocentriesnewnoderZ   caption_noderefnoderel_uris                     r,   rN   rN   d   s   " {{8U## M t( /s/CWMMsz233Hsz233H67;;z266H 7;;|U;;  W[[%@@ &
 J  t(R00G$((333w 	%{7BG%*W2E2E1FGGG#L%n!(!67E"" 	&{L|$$$NN:GI !W---GQE(@q(GLYYG'"+u}-- #gbk2B2Ba2G2Gt ??5?33 @ @<)**2..w8IJJG '',*? ?GHNr.   ro   Set[str]rp   r   rq   parents	list[str]subtreelist[Element]c                f   g }|	d         D ]\  }}	 t          ||| |||||||	|
          \  }}n# t          $ r Y 0w xY w|j        }|ri|D ]f}t          |          dk    rQt	          |                    t          j                            x}r||d         dd<   Q|                    d           gt	          |                    t          j                            D ]}|	                    dd          r|st          t          | ||||||||||g|
z   d          |j                            |          dz             D ] \  }}|j                            ||           !|j                            |           |                    |           |st#          j                    }||z  }|gS |S )	z&Return TOC entries for a toctree node.entriesrK   NrV   FT)rz   )start)_toctree_entryLookupErrorrP   rl   listr;   r
   rM   popr#   	enumeratera   parentindexinsertremover)   r   bullet_list)r   rJ   rF   rA   rC   r/   ro   rp   rq   r   rx   rz   r}   rd   refr=   refdocrP   	top_levelsubtreessub_toc_nodeientryrets                           r,   ra   ra      s1     G#I. 3! 3!	(sC$8I(K KC  	 	 	H	 -0L  		) & ) )	y>>A%%#'	(9(9(:J(K(K#L#LLx )*2	!QQQ!a((( X-=!>!>?? 	5 	5L%00  %%!% Hw&    #)//==A   5 55" #**1e4444&&|4444x     !!wuNs   /
<<rd   r   tuple[Element, str]c           
        ddl m} 	 d}t          j        |          rt	          | |          }n|dk    rt          | |	d         |j                  }n||j        v rt          | |          }n||
v rQt          
                    t          d          |d                    |
          |dd	
           d}t          |          t          | ||j        |                             dd          |j        |         ||||          \  }}|j        s*t          
                    t          d          ||	           n# t&          $ rz |                    |d          } ||          rt          d          }n* ||          st          d          }nt          d          }t          
                    |||	            w xY w||fS )Nr   StandardDomainrY   selfr   z8circular toctree references detected, ignoring: %s <- %sz <- r=   circular)locationtypesubtypezcircular referencer1   z^toctree contains reference to document %r that doesn't have a title: no link will be generated)r   Fz2toctree contains reference to excluded document %rz6toctree contains reference to non-included document %rz5toctree contains reference to nonexisting document %r)sphinx.domains.stdr   r   rm   _toctree_url_entry_toctree_self_entrytitles_virtual_doc_names_toctree_generated_entryloggerwarningr   joinr   _toctree_standard_entryr6   r#   r8   rP   r9   doc2path)rd   r   r   rJ   rA   r/   ro   rp   rq   r   rx   r   r   r=   msgref_pathmessages                    r,   r   r     s!    211111,< 	$UC00CCF]]%e[-BCJOOCCN555*5#66CCg~~r #A  B  B"FKK$8$8(+%  M M M +!#&&&1S!%%j!44!	 	KC | 	6NN2 P Q Q  6 6 6    <<U++8H 	RMNNGG(## 	RQRRGGPQQGwk::: ;s   D-D6 6BF:nodes.bullet_listc                    | |} t          j        ddgt          j        |           gR d|dd}t          j        dd|          }t          j        d|          }t          j        d|          }|S )NrY   Finternalr5   r3   )r   r<   re   r
   rb   	list_itemr   )rd   r   r<   paraitemr=   s         r,   r   r   N  s    }B 6"'*U"3"3!46 6'*r6 6 6I %b"i88D?2t$$D

B
%
%CJr.   r   dict[str, nodes.title]c                
   | st          ||                   } t          j        ddgt          j        |           gR d|dd}t	          j        dd|          }t          j        d|          }t          j        d|          }|S )NrY   Tr   )r   r   r<   re   r
   rb   r   r   )rd   r   r   r<   r   r   r=   s          r,   r   r   Z  s    
  *VC[))B 6 #(*U"3"3!46 6'*+-6 6 6I %b"i88D?2t$$D

B
%
%CJr.   c                    ddl m} |j        |         \  }}| s|} t          j        d| d|d          }t          j        dd|          }t          j        d|          }t          j        d|          }|S )Nr   r   rY   Tr   )	r   r   r   r   r<   r
   rb   r   r   )	rd   r   r   r   sectionnamer<   r   r   r=   s	            r,   r   r   l  s    111111)<SAG[ ED'.2? ? ?I%b"i88D?2t$$D

B
%
%CJr.   r=   tuple[nodes.bullet_list, str]c                |   |}||v r|r|dk    r|                                 }nt          |d|||          }| r|j        rzt          |j                  dk    rb|j        d         }	|	                    t
          j                  D ]5}
|
d         |k    r'|
d         st          j        |           g|
j        d d <   6||fS )Nr   r2   rK   r5   r3   )deepcopyr7   rP   rl   r;   r   r<   re   )rd   r   rD   r=   ro   rJ   rA   r/   r   childru   s              r,   r   r   {  s     F
(a--llnnCHh== : :#cl"3"3q"8"8Q}}U_55 	: 	:Gx C''0E'',z%'8'8&9 #;r.   r>   r   depthc                >   | j         D ]}t          |t          j        t          j        f          r3|d                             d|dz
              t          |||           \t          |t          j                  rt          ||dz   |           t          |t          j	                  rn|d         |k    rb|d         s(|}|r$|d                             d           |j
        }|$|j
        j
                            d          r dS |rd	|d<   |j
        }|dS )
z7Add 'toctree-l%d' and 'current' classes to the toctree.classesz	toctree-lrK   r5   r3   current	iscurrentNT)rP   rk   r
   rb   r   r   rO   rj   r   r<   r   r#   )r>   r   r   subnode
branchnodes        r,   rj   rj     sW   = - -g :EOLMM 	-I%%&=%!)&=&=>>> %9999!233 	- %!)W====11 	- x G++|, 7 +2J$ 7"9-44Y???%/%6
 % 7 >(,,[99 FF -+/GK(%nG  -/- -r.   ET)boundc                   |dk    p||k    s|dk    o| pd| v }|                                  }| j        D ]}t          |t          j        t
          j        f          r'|                    t          |||||                     Pt          |t
          j	                  r,|r)|                    t          ||dz   |||                     t          |t          j
                  r(|                    |                                            t          |t          j                  rBt          ||          r0|j        D ](}|                    t          |||||                     )4t          |t
          j        t
          j        f          rR|                                 }	d |j        D             |	_        |	j        D ]	}|	|_        
|                    |	           d|j        j        d}
t%          |
          |S )z6Utility: Cut and deep-copy a TOC at a specified depth.rK   r   r   c                6    g | ]}|                                 S  )r   ).0r   s     r,   
<listcomp>z!_toctree_copy.<locals>.<listcomp>  s"    %U%U%U5enn&6&6%U%U%Ur.   zUnexpected node type !)copyrP   rk   r
   rb   r   r   rO   r7   r   rM   onlyr   r<   rd   r   	__class____name__
ValueError)r>   r   rD   rA   r/   keep_bullet_list_sub_nodesr   r   r   sub_node_copyr   s              r,   r7   r7     s   "'1* #Q','8'IHM 'P/7<+N;$;N  99;;D= " "g :EOLMM 	"KKguh$OOPPPP!233 	"
 * YM'519hRVWWXXX!122 	"KK''''// 	"'66 $-  EKKuh$! !     %/5;!?@@ 		"#LLNNM%U%UGDT%U%U%UM"&/ - -,KK&&&&I'*;*DIIICS//!Kr.   r(   dict[str, list[str]]c                0   i }|                                  D ]#\  }}|t                              ||          z  }$g }|}||v r)||vr%|                    |           ||         }||v r||v%t                              |                                          S N)itemsdictfromkeysrO   keys)r(   r   r   prP   	ancestorsds          r,   r]   r]     s      F'--// - -8$--!,,,IA
v++!9,,1I v++!9,, ==##((***r.   c                  D    e Zd Zd"dZd#d
Z	 	 d$d%dZd&dZd'dZd(d Zd!S ))TocTreer   r   r   r   c                    || _         d S r   )r   )r   r   s     r,   __init__zTocTree.__init__  s    r.   r   r   r   r   c                2    t          | j        ||           d S r   )r-   r   )r   r   r   s      r,   notezTocTree.note  s    TXw44444r.   Tr   Fr@   r   rM   rJ   rB   rD   rE   rF   rA   rC   rG   c	                <    t          | j        ||||||||	  	        S )NrI   )rN   r   )	r   r   r@   rM   rJ   rD   rF   rA   rC   s	            r,   resolvezTocTree.resolve  s5      Hgw#'
 
 
 	
r.   ry   c                :    g t          | j        j        |          S r   )r]   r   r(   )r   r   s     r,   get_toctree_ancestorszTocTree.get_toctree_ancestors  s    L'(A7KKLLr.   r	   c                V    t          | j        || j        j        j        j                  S r   )r?   r   appr@   r/   )r   r   r@   s      r,   get_toc_forzTocTree.get_toc_for  s     DHgtx|/C/HIIIr.   kwargsr   c                .    t          | j        ||fd|i|S )NrA   )rT   r   )r   r   r@   rA   r   s        r,   get_toctree_forzTocTree.get_toctree_for  s&     &dh^^8^W]^^^r.   N)r   r   r   r   )r   r   r   r   r   r   )Tr   FFF)r   r   r@   r   rM   r   rJ   rB   rD   rE   rF   rB   rA   rB   rC   rB   r   rG   )r   r   r   ry   )r   r   r@   r   r   r	   )
r   r   r@   r   rA   rB   r   r   r   rG   )	r   
__module____qualname__r   r   r   r   r   r   r   r.   r,   r   r     s           5 5 5 5 LQ>C

 

 

 

 

M M M MJ J J J_ _ _ _ _ _r.   r   N)r   r   r   r   r   r   r   r   )r   r   r   r   r/   r   r   r	   )FTr   F)r   r   r   r   r@   r   rA   rB   rC   rB   rD   rE   rF   rB   r   rG   )r   r   r   r   r@   r   rM   r   rJ   rB   rD   rE   rF   rB   rA   rB   rC   rB   r   rG   )F)r   r   rJ   rB   rF   rB   rA   rB   rC   rB   r/   r   ro   rw   rp   r   rq   r   r   r   rx   ry   rz   rB   r   r{   )rd   r   r   r   r   r   rJ   rB   rA   rB   r/   r   ro   rw   rp   r   rq   r   r   r   rx   ry   r   r   )rd   r   r   r   r   r   )rd   r   r   r   r   r   r   r   )rd   r   r   r   rD   rE   r=   r   ro   rw   rJ   rB   rA   rB   r/   r   r   r   )r>   r   r   rE   r   r   r   r   )r>   r   r   rE   rD   rE   rA   rB   r/   r   r   r   )r(   r   r   r   r   rw   )3__doc__
__future__r   typingr   r   r   docutilsr   docutils.nodesr   r	   sphinxr
   sphinx.localer   sphinx.utilr   r   sphinx.util.matchingr   sphinx.util.nodesr   r   collections.abcr   r   sphinx.buildersr   sphinx.environmentr   sphinx.util.tagsr   	getLoggerr   r   r-   r?   rT   rN   ra   r   r   r   r   r   rj   r   r7   r]   r   r   r.   r,   <module>r      s   - - " " " " " " . . . . . . . . . .       ( ( ( ( ( ( ( (             ' ' ' ' ' ' ' ' ( ( ( ( ( ( D D D D D D D D &--------''''''333333%%%%%% 
	8	$	$G G G G    2 ! ! ! ! !L u%[ [ [ [ [ [T J J J J JZ< < < <~	 	 	 	   $      0- - - -< WT!!!& & & &R+ + + +_ _ _ _ _ _ _ _ _ _r.   