
    -Ph"@                    `   d dl mZ d dl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 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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% er$d dl&m'Z' d dlm(Z(m)Z) d dl*m+Z+m,Z, d dl-m.Z. d dl/m0Z0m1Z1  ej2        d          Z3 ej4        e5          Z6d1dZ7 G d de           Z8 G d d e           Z9 G d! d"e           Z: G d# d$e           Z; G d% d&e           Z< G d' d(e           Z= G d) d*e           Z> G d+ d,ee           Zd2d0Z?dS )3    )annotationsN)relpath)Path)TYPE_CHECKINGcast)nodes)
directives)Class)Include)StateMachine)addnodes)StandardDomain)___)docname_joinloggingurl_re)SphinxDirective)Matcher	patfilter)explicit_title_re)Sequence)AnyClassVar)ElementNode)Sphinx)ExtensionMetadata
OptionSpecz
.*[*?\[].*argumentstrreturnintc                (    | sdS t          |           S )Ni  )r#   )r    s    W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/directives/other.pyint_or_nothingr&   $   s     sx==    c                      e Zd ZdZdZdZdZdZee	j
        e	j        e	j        e	j        e	j        e	j        ee	j        e	j        d
ZddZddZdS )TocTreezDirective to notify Sphinx about the hierarchical structure of the docs,
    and to include a table-of-contents like tree in the current document.
    Tr   F)
maxdepthnameclasscaptionglobhiddenincludehiddennumbered
titlesonlyreversedr"   
list[Node]c                |   t          j                    }| j        j        |d<   g |d<   g |d<   | j                            dd          |d<   | j                            d          |d<   d| j        v |d<   d| j        v |d<   d	| j        v |d	<   | j                            d
d          |d
<   d| j        v |d<   |                     |           |                     |           t          j	        dg| j                            dd                    }|
                    |           |                     |           |gS )Nparententriesincludefilesr*   r-   r.   r/   r0   r1   r   r2   ztoctree-wrapperr,    )classes)r   toctreeenvdocnameoptionsgetset_source_infoparse_contentr   compoundappendadd_name)selfsubnodewrappernodes      r%   runzTocTree.run@   sU   "$$ H,  	"$"l..z2>>
!\--i88	 DL0$4#2dl#B "l..z1==
 , <W%%%7###n&G)9)9'2)F)FG
 
 
 	7###k"""}r'   r<   addnodes.toctreeNonec           	     `   t          t          j                  | j        j        }| j        j        }|d         }| j        j                                        z  }|	                    |           t          |          }t          | j        j                  }| j        D ]}|st          j        |          }	t          j        |          du}
|rt                               |          r|	s|
st#          ||          }t%          fdt'          ||          D                       }|s+t(                              t-          d          ||d           |D ]O}|	                    |           |d                             d|f           |d                             |           P
|	r-|	                    d	          }|	                    d
          }|}n|x}}d}|D ].}|                    |          r|                    |          } n/t#          ||          }|
s|dk    r|d                             ||f           ||vr |t7          | j                            |d                              rt-          d          }d}nt-          d          }d}t(                              |||d|           | j                                         9||v r|	                    |           n,t(                              t-          d          ||dd           |d                             ||f           |d                             |           d| j        v rLt?          tA          |d                             |d<   t?          tA          |d                             |d<   dS dS )zMPopulate ``toctree['entries']`` and ``toctree['includefiles']`` from content.r.   Nc              3  $   K   | ]
}|v|V  d S )Nr:   ).0r>   generated_docnamess     r%   	<genexpr>z(TocTree.parse_content.<locals>.<genexpr>o   s=       # #&888  9888	# #r'   z2toctree glob pattern %r didn't match any documents
empty_glob)locationsubtyper7   r8         rF   Fz2toctree contains reference to excluded document %rexcludedz5toctree contains reference to nonexisting document %rnot_readabletoc)rR   typerS   z%duplicated entry found in toctree: %sduplicate_entryr3   )!	frozensetr   _virtual_doc_namesconfigsource_suffixr=   r>   
found_docscopyremover   exclude_patternscontentr   matchr   glob_rer   sortedr   loggerwarningr   rD   groupendswithremovesuffixr!   doc2pathnote_rereadr?   listr3   )rF   r<   suffixescurrent_docnamer.   all_docnamesfrozen_all_docnamesrV   entryexplicit	url_matchpat_name	doc_namesr>   reftitlesuffixmsgrS   rO   s                      @r%   rB   zTocTree.parse_contentY   s)   &~'HII;,(*v x*//114FFO,,,'554;788\ K	4 K	4E  ).u55HU++47I e,, X i '??" # # # ##,\8#D#D# # #  	 ! NNOPP!( ,	 #     ) < <G ''000I&--tWo>>>N+227;;;; nnQ'' q)) %%g #  ##F++ %226::GE
 #?G<<G C6MM	"))5#,7771118C 1 1'5 A ABBCC -QRRC(GGTUUC,G7     $$&&&,&&##G,,,,>??$-     I%%ug&6777N#**73333 %%!%hwy/A&B&B!C!CGI&*8GN4K+L+L&M&MGN### &%r'   Nr"   r4   )r<   rJ   r"   rK   )__name__
__module____qualname____doc__has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacer#   r	   	unchangedclass_optionunchanged_requiredflagr&   option_specrI   rB   r:   r'   r%   r)   r)   *   s          K %$(0/#" oO K   2]N ]N ]N ]N ]N ]Nr'   r)   c                  :    e Zd ZU dZdZdZdZdZi Zde	d<   dd
Z
dS )AuthorzDirective to give the name of the author of the current document
    or section. Shown in the output only if the show_authors option is on.
    FrU   r   TClassVar[OptionSpec]r   r"   r4   c                   | j         j        sg S t          j        d          }t          j                    }||z  }| j        dk    rt          d          }nE| j        dk    rt          d          }n*| j        dk    rt          d          }nt          d	          }|t          j        |          z  }|                     | j	        d
                   \  }}|
                    |           |g}||z  }|S )NF)translatablesectionauthorzSection author: moduleauthorzModule author: 
codeauthorzCode author: zAuthor: r   )r]   show_authorsr   	paragraphemphasisr+   r   Textparse_inline	argumentsextend)rF   paraemphtextinodesmessagesrets          r%   rI   z
Author.run   s    {' 	IU;;;~9'''((DDY.((&''DDY,&&_%%DDZ==D
4   ,,T^A->??F&x
r'   Nr|   r}   r~   r   r   r   r   r   r   r   __annotations__rI   r:   r'   r%   r   r      s^           K $(*K****     r'   r   c                  :    e Zd ZU dZdZdZdZdZi Zde	d<   dd
Z
dS )TabularColumnszBDirective to give an explicit tabulary column definition to LaTeX.FrU   r   Tr   r   r"   r4   c                x    t          j                    }| j        d         |d<   |                     |           |gS )Nr   spec)r   tabular_col_specr   rA   )rF   nodes     r%   rI   zTabularColumns.run   s;    (**~a(VT"""vr'   Nr|   r   r:   r'   r%   r   r      sX         LLK $(*K****     r'   r   c                  :    e Zd ZU dZdZdZdZdZi Zde	d<   dd
Z
dS )Centeredz1Directive to create a centered line of bold text.FrU   r   Tr   r   r"   r4   c                    | j         sg S t          j                    }|                     | j         d                   \  }}|                    |           |g}||z  }|S )Nr   )r   r   centeredr   r   )rF   rG   r   r   r   s        r%   rI   zCentered.run   se    ~ 	I#,..,,T^A->??v")x
r'   Nr|   r   r:   r'   r%   r   r      sX         ;;K $(*K****	 	 	 	 	 	r'   r   c                  :    e Zd ZU dZdZdZdZdZi Zde	d<   dd	Z
d
S )AckszDirective for a list of names.Tr   Fr   r   r"   r4   c                .   |                                  }t          |          dk    s t          |d         t          j                  s<t
                              t          d          | j        j	        | j
        f           g S t          j        dg|R  gS )NrU   r   z.. acks content is not a listrR    )parse_content_to_nodeslen
isinstancer   bullet_listrg   rh   r   r=   r>   linenor   acks)rF   childrens     r%   rI   zAcks.run	  s    ..00x==AZU=N%O%ONN233(*DK8     Ib,8,,,--r'   Nr|   r   r:   r'   r%   r   r      sX         ((K %(*K****. . . . . .r'   r   c                  >    e Zd ZU dZdZdZdZdZdeiZ	de
d<   dd
ZdS )HListz6Directive for a list that gets compacted horizontally.Tr   Fcolumnsr   r   r"   r4   c                   | j                             dd          }|                                 }t          |          dk    s t	          |d         t
          j                  s<t                              t          d          | j
        j        | j        f           g S |d         }t          t          |          |          \  }}d}t          j                    }t!          |          |d<   t#          |          D ]Q}|||k     r|dz   n|z   }	t          j                    }
|
|j        ||	         z  }
|t          j        d|
          z  }|	}R|gS )	Nr   rT   rU   r   z.. hlist content is not a listr   ncolumnsr   )r?   r@   r   r   r   r   r   rg   rh   r   r=   r>   r   divmodr   hlistr!   ranger   hlistcol)rF   r   r   fulllistnpercolnmoreindexnewnodecolumnendindexr   s              r%   rI   z	HList.run  sK   <##Iq11..00x==AZU=N%O%ONN344(*DK8     IA;Hx88.""!(mm
Hoo 	 	F%1WMH+--K8,U8^<<Kx([999GEEyr'   Nr|   )r}   r~   r   r   r   r   r   r   r#   r   r   rI   r:   r'   r%   r   r     sg         @@K %3)K         r'   r   c                  :    e Zd ZU dZdZdZdZdZi Zde	d<   dd	Z
d
S )Onlyz?Directive to only include text if the given tag(s) are enabled.TrU   r   r   r   r"   r4   c                4   t          j                    }| j        j        |_        |                     |           | j        d         |d<   | j        j        }|j        }|j        }g |_        d|_        	 | j        	                    | j
        | j        |d           |j        }|r|r|d         |vs| j        j        s|g||_        ||_        S d}| j        j        }|r|dz  }|j        }||dz  }|d         }t          |          }	||v r|                    |          }	||	z
  dz   }
t          d| j        j                  }t!          |
          D ]}|j        r|j        }|                    |           g ||_        ||_        S # ||_        ||_        w xY w)Nr   exprT)match_titlesrU   rT   znodes.Element)r   onlystatedocumentrA   r   memotitle_stylessection_levelnested_parserc   content_offsetr6   r   r   r   r   rD   )rF   r   r   surrounding_title_stylessurrounding_section_levelr   current_depthr6   title_stylenested_depthn_sects_to_raise_is               r%   rI   zOnly.run@  s   }
+T"""~a(V JO#'#4 $($6!#	;J##d14d $     ,L,#  ?*BBBz( C v, !9D!:D+ MZ&F '"  ' QM&q/K788L6667==kJJ  -|;a?/4:+<==F,-- + += +#]FMM$ 8D!:D !9D!:D::::s   3AF B+F FNr|   r   r:   r'   r%   r   r   7  sX         IIK $(*K****0; 0; 0; 0; 0; 0;r'   r   c                  $     e Zd ZdZd fdZ xZS )r   z}Like the standard "Include" directive, but interprets absolute paths
    "correctly", i.e. relative to source directory.
    r"   Sequence[Node]c                $    d fd} j         j        j                            d          r| j        _         j        d	                             d
          r@ j        d	                             d          r t                      
                                S  j                              j        d	                   \  }}t          |           j        d	<    j                             |           t                      
                                S )Ninclude_lines	list[str]sourcer!   r"   rK   c                   d                     | d d                   }t          t          t          |                                          j        j                            }j        j        }|g}j        j                            d|||           |d         }|	                                | dd          z   } t          j        j        | |          S )N
)startinclude-readr   )joinr   r   resolver=   srcdirr>   eventsemit
splitlinesr   insert_inputstate_machine)r   r   r   pathr>   argrF   s         r%   _insert_inputz"Include.run.<locals>._insert_input~  s     99]3B3/00DV 4 4 6 6dhoNNNOODh&G &CHO  wDDDq6D !OO--bcc0BBM
  ,T-?PVWWWr'   r   r   <>)r   r   r   r!   r"   rK   )r=   r   	listenersr@   r   r   r   
startswithrj   superrI   
relfn2pathr!   note_included)rF   r   rel_filenamefilename	__class__s   `   r%   rI   zInclude.runx  s    	X 	X 	X 	X 	X 	X2 8?$((88 	<.;D+>!'',, 	!1B1K1KC1P1P 	!77;;== !%!4!4T^A5F!G!GhMMqx(((ww{{}}r'   )r"   r   )r}   r~   r   r   rI   __classcell__)r   s   @r%   r   r   s  sG         ) ) ) ) ) ) ) ) ) )r'   r   appr   r   c                ~   t          j        dt                     t          j        dt                     t          j        dt                     t          j        dt                     t          j        dt                     t          j        dt
                     t          j        dt                     t          j        dt                     t          j        d	t                     t          j        d
t                     t          j        dt                     t          j        dt                     ddddS )Nr<   r   r   r   tabularcolumnsr   r   r   r   includecssclassz	rst-classbuiltinT)versionparallel_read_safeparallel_write_safe)r	   register_directiver)   r   r   r   r   r   r   r   r
   )r   s    r%   setupr    s   !)W555!/6:::!.&999!,777!"2NCCC!*h777!&$///!'5111!&$///!)W555 !*e444!+u555 "#  r'   )r    r!   r"   r#   )r   r   r"   r   )@
__future__r   reos.pathr   pathlibr   typingr   r   docutilsr   docutils.parsers.rstr	   $docutils.parsers.rst.directives.miscr
   r   BaseIncludedocutils.statemachiner   sphinxr   sphinx.domains.stdr   sphinx.localer   r   sphinx.utilr   r   r   sphinx.util.docutilsr   sphinx.util.matchingr   r   sphinx.util.nodesr   collections.abcr   r   r   docutils.nodesr   r   sphinx.applicationr   sphinx.util.typingr   r   compilere   	getLoggerr}   rg   r&   r)   r   r   r   r   r   r   r  r:   r'   r%   <module>r     s   " " " " " " 				             & & & & & & & &       + + + + + + 6 6 6 6 6 6 G G G G G G . . . . . .       - - - - - -         5 5 5 5 5 5 5 5 5 5 0 0 0 0 0 0 3 3 3 3 3 3 3 3 / / / / / / A(((((($$$$$$$$,,,,,,,,))))))@@@@@@@@ "*]
#
#		8	$	$   LN LN LN LN LNo LN LN LN^    _   D    _           *. . . . .? . . .(         O      F9; 9; 9; 9; 9;? 9; 9; 9;x. . . . .k? . . .b     r'   