
    kKj4(                    L   d Z ddlmZ ddlZddlmZ ddlZddlZddlZddl	Z	ddl
mZmZmZmZmZmZmZmZmZmZ ddlmZ ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m!Z! ddl"m#Z# dd	l$m%Z%m&Z&m'Z'm(Z(m)Z) dd
l*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@mAZA ddlBmCZCmDZD ddlEmFZF ddlGZHdZIdZJeHj                  j                  eMxs eN      ZOdeeP   deeP   fdZQ G d dej                  j                  ej                  j                  ej                  j                        ZV G d dej                  j                  ej                  j                        ZX G d  d!ej                  j                  ej                  j                  ej                  j                        ZY G d" d#ej                  j                  ej                  j                  ej                  j                        ZZ G d$ d%ej                  j                  ej                  j                  ej                  j                        Z[ G d& d'ej                  j                  ej                  j                  ej                  j                        Z\ G d( d)ej                  j                  ej                  j                  ej                  j                        Z] G d* d+ej                  j                  ej                  j                  ej                  j                        Z^ G d, d-ej                  j                  ej                  j                  ej                  j                        Z_ G d. d/ej                  j                  ej                  j                  ej                  j                        Z` G d0 d1ej                  j                  ej                  j                  ej                  j                        Za G d2 d3ej                  j                  j                        Ze G d4 d5ej                  j                  j                        Zf G d6 d7ej                  j                  j                        Zg G d8 d9ej                  j                  j                        Zh G d: d;ej                  j                  j                        Zi G d< d=ej                  j                  j                        Zj G d> d?ej                  j                  j                        Zk G d@ dAej                  j                  j                        Zl G dB dCej                  j                  j                        Zm G dD dEej                  j                  j                        ZndFeeP   deofdGZp G dH dIej                  j                  j                        Zq G dJ dKej                  j                  j                        Zr G dL dMej                  j                  j                        Zs G dN dOej                  j                  j                        Zt G dP dQej                  j                  j                        Zu G dR dSej                  j                  j                        Zv G dT dUej                  j                  j                        Zw G dV dWej                  j                  j                        Zx G dX dYej                  j                  j                        Zy G dZ d[ej                  j                  j                        Zz G d\ d]ej                  j                  j                        Z{ G d^ d_ej                  j                  ej                  j                        Z| G d` daej                  j                  ej                  j                        Z}	 	 dSdbePdcePddePdeeodfedgeeePef      dheeeP      deeej                  j                     eej                  j                     f   fdiZ	 	 dSdbePdcePddePdeeodfedgeeePef      dheeeP      deeej                  j                     eej                  j                     f   fdjZ G dk dlej                  j                  j                  j                  jl                        Z G dm dn      Zdoa e	j                         Zdpedqef   dedqef   fdrZdTdsZdoadTdtZ G du dve      ZdwePdePfdxZi dydzd{d|d}d~ddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddi ddddddddddēddƓddȓddʓdd̓ddΓddГddғddԓdd֓ddؓddړddړi ddݓddݓddddddddddddddddddddddddddddddi ddddd dddddddddd	d
ddddddddddddddddddi dddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKZ e eej%                         dL M            ZddePdePfdNZ G dO dPej                  j*                        Z G dQ dRe+      ZexZxZxZZy(U  z
reStructuredText parser for rich

Initial few lines gotten from: https://github.com/willmcgugan/rich/discussions/1263#discussioncomment-808898
There are a lot of improvements are added by me
    )StringION)
HTMLParser)
AnyCallableClassVarDictListLiteralOptionalTupleTypeUniondocutils)box)Align)ConsoleConsoleOptionsRenderResultNewLineGroup)JupyterMixin)Panel)Style)SyntaxSyntaxTheme)Text)Table)Rule)Segmentcell_len)Styled)TerminalThemeDEFAULT_TERMINAL_THEME)guess_lexerget_lexer_by_name)ClassNotFound)RSTReStructuredTextreStructuredTextRestructuredText
RSTVisitorz$Arian Mollik Wasi (aka. Wasi Master)default_lexerreturnc                 f    | | S 	 t        |        | S # t        $ r}t        d|       |d}~ww xY w)z@Validate that ``default_lexer`` is a known Pygments lexer alias.NzUnknown Pygments lexer name: )r'   r(   
ValueError)r.   errors     b/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/rich_rst/__init__.py_validate_default_lexer_namer4   8   sO    W-(   W88IJKQVVWs    	0+0c                       e Zd ZdZy)versionmodifiedzMNode produced by the versionadded, versionchanged, and deprecated directives.N__name__
__module____qualname____doc__     r3   r6   r6   E   s    Wr=   r6   c                       e Zd ZdZy)seealsoz'Node produced by the seealso directive.Nr7   r<   r=   r3   r?   r?   J       1r=   r?   c                       e Zd ZdZy)centered_blockz!Node for .. centered:: directive.Nr7   r<   r=   r3   rB   rB   O       +r=   rB   c                       e Zd ZdZy)py_descz>Node for Python/C/C++/JS domain object-description directives.Nr7   r<   r=   r3   rE   rE   T       Hr=   rE   c                       e Zd ZdZy)toctree_stubz Node for .. toctree:: directive.Nr7   r<   r=   r3   rH   rH   Y   s    *r=   rH   c                       e Zd ZdZy)literalinclude_stubz'Node for .. literalinclude:: directive.Nr7   r<   r=   r3   rJ   rJ   ^   r@   r=   rJ   c                       e Zd ZdZy)glossary_blockz!Node for .. glossary:: directive.Nr7   r<   r=   r3   rL   rL   c   rC   r=   rL   c                       e Zd ZdZy)hlist_blockz=Node for .. hlist:: directive carrying column-count metadata.Nr7   r<   r=   r3   rN   rN   h   s    Gr=   rN   c                       e Zd ZdZy)availabilityz,Node produced by the availability directive.Nr7   r<   r=   r3   rP   rP   m   s    6r=   rP   c                       e Zd ZdZy)soft_deprecatedz/Node produced by the soft-deprecated directive.Nr7   r<   r=   r3   rR   rR   r   s    9r=   rR   c                       e Zd ZdZy)impl_detailz+Node produced by the impl-detail directive.Nr7   r<   r=   r3   rT   rT   w   s    5r=   rT   c                   ^    e Zd ZdZdZdZdZi ZdZde	e
j                  j                     fdZy)_VersionDirectivea  Handles ``.. versionadded::``, ``.. versionchanged::``, and ``.. deprecated::``.

    Matches Sphinx's signature: the version is the first argument and an
    optional explanation is the second. ``final_argument_whitespace`` lets
    the explanation span the indented line(s) immediately following the
    directive (no blank line required), per the Python devguide form
    ``.. versionchanged:: 2.0\n   Added the *spam* parameter.``.
       Tr/   c                    t        | j                  | j                  d         }t        | j                        dkD  ra| j                  d   }| j                  j                  || j                        \  }}|t        j                  j                  |dg| z  }||z  }| j                  r1| j                  j                  | j                  | j                  |       |gS )Nr   typeversionrW    )r6   name	argumentslenstateinline_textlinenor   nodes	paragraphcontentnested_parsecontent_offsetselfnodeexplanationinline_nodesmessagess        r3   runz_VersionDirective.run   s    DIIt~~a7HIt~~"..+K%)ZZ%;%;K%U"L(HNN,,["L|LLDHD<<JJ##DLL$2E2EtLvr=   Nr8   r9   r:   r;   required_argumentsoptional_argumentsfinal_argument_whitespaceoption_spechas_contentr	   r   rc   Nodern   r<   r=   r3   rV   rV   ~   s@      $KK	T(..--. 	r=   rV   c                   ^    e Zd ZdZdZdZdZi ZdZde	e
j                  j                     fdZy)_SeeAlsoDirectivezHandles ``.. seealso::``.r   rW   Tr/   c                 (   t               }| j                  r=|t        j                  j	                  | j                  d   | j                  d         z  }| j
                  r1| j                  j                  | j
                  | j                  |       |gS Nr   )	r?   r^   r   rc   rd   re   r`   rf   rg   ri   rj   s     r3   rn   z_SeeAlsoDirective.run   sk    y>>HNN,,T^^A->q@QRRD<<JJ##DLL$2E2EtLvr=   Nro   r<   r=   r3   rw   rw      s<    # $KKT(..--. r=   rw   c            
       B   e Zd ZdZdZdZdZdZej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  d	Zdeej"                  j$                     fdZy	)
_CodeBlockDirectivez@Handles ``.. code-block::``, ``.. sourcecode::``, ``.. code::``.r   rW   FT)	linenosemphasize-linescaptionr]   dedentforceclassnumber-lineslineno-startr/   c                    | j                   r| j                   d   nd }dj                  | j                        }| j                  j	                  d      }|}|dk(  s|du rt        j                  |      }n^	 t        |      }g }|j                         D ],  }|j                  t        j                  d| dd|             . dj                  |      }t        j                  j!                  ||      }|rd|g|d	<   ndg|d	<   | j                  j	                  d
      }|r||d
<   | j                  j	                  d      }	|	r|	|d<   d| j                  v }
|
rd|d<   d| j                  v r)	 t        | j                  j	                  d            |d<   n6d| j                  v r(	 t        | j                  j	                  d            |d<   | j                  j	                  d      }|rt#               }|j%                  d      D ]  }|j'                         }|sd|v rP	 |j%                  dd      \  }}t        |      }t        |      }||k  r|j)                  t+        ||dz                j	 |j-                  t        |              |r||d<   |gS # t        t        f$ r t        j                  |      }Y w xY w# t        t        f$ r Y w xY w# t        t        f$ r Y w xY w# t        $ r Y w xY w# t        $ r Y w xY w)Nr   
r   r\   Tz^ {0,}codeclassesr   r]   r}   r   
start_liner   r~   ,-rW   highlight_lines)r^   joinre   optionsgettextwrapr   int
splitlinesappendresub	TypeErrorr1   r   rc   literal_blocksetsplitstripupdaterangeadd)ri   languager   
dedent_optn	new_lineslinerj   caption_optname_optr}   	emphasizer   partstart_send_sstartends                     r3   rn   z_CodeBlockDirective.run   s   (,4>>!$Dyy& \\%%h/
!R:#5t,	0JA !#I $ 1!((6!BT)JK !2  99Y/D~~++D$7%x0DO%hDO ll&&y1)DO<<##F+#DLt||+"DOT\\)%()9)9.)I%J\" t||+%()9)9.)I%J\" LL$$%67	!eO!,zz|$;!)-C); #G!%j C<+225a3HI
!'++CI6! -( *9&'v ":. 1#??40D1< z* 
 z* " & ! ! & ! !s[   6J +'J= "'K AK),K8$J:9J:=KKK&%K&)	K54K58	LLN)r8   r9   r:   r;   rp   rq   rr   rt   r   parsersrst
directivesflag	unchangednonnegative_intrs   r	   rc   ru   rn   r<   r=   r3   r|   r|      s3   J %K##''2277#++//::DD##''22<<  $$//99""&&11;;!!%%0055!!%%00:: ((,,77GG ((,,77GG
KKT(..--. Kr=   r|   c                      e Zd ZdZdZdZdZdZej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  dZdeej"                  j$                     fdZy)	_MathDirectivez<Handles ``.. math::`` with Sphinx-compatible option parsing.r   rW   T)r   r]   nowraplabelr/   c                    g }| j                   r0| j                   d   j                         }|r|j                  |       | j                  r@|j	                  d dj                  | j                        j                  d      D               g }|D ]  }t        j                  j                  | j                  |      }|dxx   | j                  j                  dg       z  cc<   d| j                  v rd|d<   d	| j                  v r| j                  d	   |d	<   | j                  j                  | j                        \  }}||_        ||_        | j%                  |       |j                  |        |S )
Nr   c              3   &   K   | ]	  }|s|  y wNr<   ).0blocks     r3   	<genexpr>z%_MathDirective.run.<locals>.<genexpr>$  s     \-REV[%-Rs   r   

r   r   r   Tr   )r^   r   r   re   extendr   r   r   rc   
math_block
block_textr   r   state_machineget_source_and_linerb   sourcer   add_name)ri   blocksargumentrc   r   rj   r   r   s           r3   rn   z_MathDirective.run  s+   >>~~a(..0Hh'<<MM\TYYt||-D-J-J6-R\\+-E>>,,T__eDDOt||//<<O4<<'!%X$,,& $W 5W--AA$++NLFD DKDIMM$LL  r=   N)r8   r9   r:   r;   rp   rq   rr   rt   r   r   r   r   class_optionr   r   rs   r	   rc   ru   rn   r<   r=   r3   r   r     s    F $K!!%%00==  $$//99 ""&&1166!!%%00::KT(..--. r=   r   c                      e Zd ZdZdZdZdZdZej                  j                  j                  j                  ej                  j                  j                  j                  dZdeej                   j"                     fdZy)	_HighlightDirectivezHandles ``.. highlight::``.rW   r   F)linenothresholdr   r/   c                     g S r   r<   ri   s    r3   rn   z_HighlightDirective.runB      	r=   N)r8   r9   r:   r;   rp   rq   rr   rt   r   r   r   r   r   r   rs   r	   rc   ru   rn   r<   r=   r3   r   r   6  st    % %K#++//::JJ!!%%0055K
T(..--. r=   r   c                   ^    e Zd ZdZdZdZdZdZi Zde	e
j                  j                     fdZy)_SilentDirectivez/No-op directive for index, tabularcolumns, etc.r   rW   Tr/   c                     g S r   r<   r   s    r3   rn   z_SilentDirective.runO  r   r=   Nr8   r9   r:   r;   rp   rq   rr   rt   rs   r	   r   rc   ru   rn   r<   r=   r3   r   r   F  s<    9 $KKT(..--. r=   r   c                   ^    e Zd ZdZdZdZdZdZi Zde	e
j                  j                     fdZy)_CurrentModuleDirectivez4No-op directive for currentmodule, py:currentmodule.rW   r   Fr/   c                     g S r   r<   r   s    r3   rn   z_CurrentModuleDirective.run\  r   r=   Nr   r<   r=   r3   r   r   S  s<    > %KKT(..--. r=   r   c                   ^    e Zd ZdZdZdZdZdZi Zde	e
j                  j                     fdZy)_OnlyDirectiveu1   Handles ``.. only::`` — always renders content.rW   r   Tr/   c                     t         j                  j                         }| j                  r1| j                  j                  | j                  | j                  |       |j                  S r   )r   rc   	containerre   r`   rf   rg   children)ri   r   s     r3   rn   z_OnlyDirective.runi  sG    NN,,.	<<JJ##DLL$2E2EyQ!!!r=   Nr   r<   r=   r3   r   r   `  s<    ; $KK"T(..--. "r=   r   c                   ^    e Zd ZdZdZdZdZdZi Zde	e
j                  j                     fdZy)	_CenteredDirectivezHandles ``.. centered::``.rW   r   TFr/   c                 6    t        | j                  d         gS )Nr   text)rB   r^   r   s    r3   rn   z_CenteredDirective.runy  s    DNN1$5677r=   Nr   r<   r=   r3   r   r   p  s<    $ $KK8T(..--. 8r=   r   c                       e Zd ZdZdZdZdZdZdej                  j                  j                  j                  iZdeej                  j                      fdZy)	_HlistDirectiveu;   Handles ``.. hlist::`` — renders as a multi-column table.r   FTcolumnsr/   c                     | j                   j                  dd      xs d}t        |      }| j                  r1| j                  j                  | j                  | j                  |       |gS )Nr      )r   )r   r   rN   re   r`   rf   rg   )ri   r   rj   s      r3   rn   z_HlistDirective.run  sU    ,,""9a05A7+<<JJ##DLL$2E2EtLvr=   N)r8   r9   r:   r;   rp   rq   rr   rt   r   r   r   r   r   rs   r	   rc   ru   rn   r<   r=   r3   r   r   }  s[    E %K8##''22BBKT(..--. r=   r   r   c                     | y| j                         }|syt        j                  j                  j                  j                  |      S ry   )r   r   r   r   r   r   )r   values     r3   _parse_toctree_numberedr     s@    NNE**::5AAr=   c            
          e Zd ZdZdZdZdZdZej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ed	Zdeej$                  j&                     fdZy)	_ToctreeDirectivezHandles ``.. toctree::``.r   FT)	maxdepthr   r]   
titlesonlyglobhiddenincludehiddenreversednumberedr/   c                    | j                   j                  dd      }| j                   j                  dd      }| j                  D cg c]A  }|j                         r/|j                         j	                  d      s|j                         C }}d| j                   v }d| j                   v }| j                   j                  dd      }t               }||d<   ||d<   ||d<   ||d<   ||d	<   ||d<   |gS c c}w )
Nr   Contentsr   r   :r   r   entriesnumbered_enabled)r   r   re   r   
startswithrH   )	ri   r   r   r   r   reversed_entriesr   numbered_depthrj   s	            r3   rn   z_ToctreeDirective.run  s    ,,""9j9<<##J2%)\\
%1Tzz|DJJL$;$;C$@ JJL\ 	 
 &5%5))*a8~!Y!Y#Z+Z#3 )Zv
s   AC2N)r8   r9   r:   r;   rp   rq   rr   rt   r   r   r   r   r   r   r   r   rs   r	   rc   ru   rn   r<   r=   r3   r   r     s   # %K$$((33CC##''22<<  $$//99&&**55::  $$//44""&&1166!))--88==$$((3388+
KT(..--. r=   r   c                      e Zd ZdZdZdZdZdZi dej                  j                  j                  j                  dej                  j                  j                  j                  dej                  j                  j                  j                  dej                  j                  j                  j                  d	ej                  j                  j                  j                  d
ej                  j                  j                  j                  dej                  j                  j                  j                  dej                  j                  j                  j                  dej                  j                  j                  j                  dej                  j                  j                  j                  dej                  j                  j                  j                  dej                  j                  j                  j                  dej                  j                  j                  j                  dej                  j                  j                  j                  dej                  j                  j                  j                  dej                  j                  j                  j                  Zdeej"                  j$                     fdZy)_LiteralIncludeDirectivez Handles ``.. literalinclude::``.rW   r   Fr   r}   lineszstart-afterz
end-beforeencodingr   z	tab-widthr   r]   zstart-atzend-atprependr   r   diffr/   c                    t               }| j                  d   |d<   | j                  d   }| j                  j                  | j                        }|ra|dvr]t
        j                  j                  t
        j                  j                  |            }t
        j                  j                  ||      }nt
        j                  j                  |      }| j                  j                  dd      }| j                  j                  dd      }| j                  j                  dd      }d	| j                  v }		 t        ||
      5 }
|
j                         }d d d        |rj                  d      }g }|j                  d      D ]x  }|j!                         }d|v r?|j                  dd      \  }}|j#                  |t%        |      dz
  t%        |              V|sY|j'                  |t%        |      dz
            z dj                  |      }|d<   ||d<   |	|d	<   |gS # 1 sw Y   xY w# t(        t*        t,        f$ r Y |gS w xY w)Nr   filenamez<string>z<stdin><rst-document>r   r\   r   utf-8r   r}   r   T)keependsr   r   rW   re   )rJ   r^   r   
get_sourcerb   ospathdirnameabspathr   r   r   openreadr   r   r   r   r   r   OSErrorr1   
IndexError)ri   rj   rel_pathsource_filebase_dirabs_pathr   r   	lines_optr}   fhre   	all_linesselectedr   r   r   s                    r3   rn   z_LiteralIncludeDirective.run  s   "$>>!,Z >>!$((33DKK@;.WWwwrww{'CDHww||Hh7Hwwx0H<<##J3<<##J8LL$$Wb1	t||+	h2b'') 3 #...=	%OOC0D::<Dd{)-C); 	#g,2BSZ(PQ 	#d)a-(@A 1 ''(+%DO'D%DO
 v/ 32& Z0 	v		s2   6H- H!BH- AH- !H*&H- -IIN)r8   r9   r:   r;   rp   rq   rr   rt   r   r   r   r   r   r   r   rs   r	   rc   ru   rn   r<   r=   r3   r   r     sz   * %KH$$((33==8##''2277 	!!%%00:: 	x''++66@@	
 	h&&**55?? 	H$$((33== 	(""&&11;; 	X%%))44DD 	8##''22<< 	  $$//99 	H$$((33== 	(""&&11;; 	8##''22<< 	(""&&11;; 	!!%%0055  	  $$//99!K&+T(..--. +r=   r   c                   ^    e Zd ZdZdZdZdZdZi Zde	e
j                  j                     fdZy)_ProductionListDirectivez Handles ``.. productionlist::``.r   rW   Tr/   c                     | j                   rdj                  | j                         }n| j                  r| j                  d   }nd}t        j                  j                  ||      }ddg|d<   |gS )Nr   r   r\   r   productionlistr   )re   r   r^   r   rc   r   )ri   r   rj   s      r3   rn   z_ProductionListDirective.run  sa    <<99T\\*D^^>>!$DD~~++D$7!#34Yvr=   Nr   r<   r=   r3   r  r    s<    * $KK	T(..--. 	r=   r  c                   V   e Zd ZdZdZdZdZdZej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  dZdeej                   j"                     fdZy)	_IncludeDirectiveu^  Handles ``.. include::`` — reads an external RST file and inlines it.

    Paths are resolved relative to the source document.  When ``safe_include``
    is ``True`` (the default), path traversal outside the source directory is
    rejected.  If the file cannot be read the directive emits a warning
    admonition instead of raising an error.
    rW   r   F)r   
start-lineend-liner/   c                    | j                   d   }| j                  j                  | j                        }|rA|dvr=t        j
                  j                  t        j
                  j                  |            }nt	        j                         }t        j
                  j                  t        j
                  j                  ||            }	 t        j
                  j                  ||g      }||k7  rGt        j                  j                         }|t        j                  j!                  d|      z  }|gS | j"                  j%                  dd      }| j"                  j%                  dd       }| j"                  j%                  dd       }		 t'        ||	      5 }
|
j)                         }d d d        ||	(j+                         }d
j                  ||xs d|	       }dd lmc mc m} |j3                  j+                         |      }t        j                  j5                         }| j6                  j9                  |d|       |j:                  S # t        $ r d }Y uw xY w# 1 sw Y   xY w# t<        t>        f$ rJ t        j                  j                         }|t        j                  j!                  d|      z  }|gcY S w xY w)Nr   r   z0Rejected include path outside source directory: r   r   r  r  r  r  r   )r   zCould not include file: ) r^   r   r  rb   r  r  r  r  getcwdnormpathr   
commonpathr1   r   rc   warningrd   r   r   r	  r
  r   &rich_rst._vendor.docutils.statemachine_vendorstatemachine
StringListr   r`   rf   r   r  UnicodeDecodeError)ri   r  r  r  r  commonstubr   r   end_liner  re   r   _smcontent_linesr   s                   r3   rn   z_IncludeDirective.run0  sb   >>!$((33DKK@;.WWwwrww{'CDHyy{H77##BGGLL8$DE	WW''8(<=F
 X>>))+DHNN,,G|T -  D 6M<<##J8\\%%lD9
<<##J5	h2b'') 3 %)=**,))E*/($CD A@NN""$X + M !002IJJ##M1i@%%%=  	 F	  32  +, 	>>))+DHNN,,/|< -  D 6M	s>   
!I I0 I$*B'I0 I! I!$I-)I0 0AK	K	N)r8   r9   r:   r;   rp   rq   rr   rt   r   r   r   r   r   r   rs   r	   rc   ru   rn   r<   r=   r3   r  r    s      %K$$((33==&&**55EE$$((33CCK2T(..--. 2r=   r  c                       e Zd ZdZdZdZdZdZdej                  j                  j                  j                  iZdeej                  j                      fdZy)	_GlossaryDirectivezHandles ``.. glossary::``.r   FTsortedr/   c                 X   t               }| j                  r1| j                  j                  | j                  | j                  |       d| j
                  v rS|j                  D ]D  }t        |t        j                  j                        s(|j                  j                  d        F |gS )Nr.  c                     | j                   r9| j                   d   j                         j                         j                         S dS )Nr   r\   )r   astextr   casefolditems    r3   <lambda>z(_GlossaryDirective.run.<locals>.<lambda>x  s?    == *.q)9)@)@)B)H)H)J)S)S)U * * r=   key)rL   re   r`   rf   rg   r   r   
isinstancer   rc   definition_listsort)ri   r   childs      r3   rn   z_GlossaryDirective.runp  s    "$	<<JJ##DLL$2E2EyQt||#"++eX^^%C%CDNN''  (  , {r=   N)r8   r9   r:   r;   rp   rq   rr   rt   r   r   r   r   r   rs   r	   rc   ru   rn   r<   r=   r3   r-  r-  e  s[    $ %K(""&&1166KT(..--. r=   r-  c                   ^    e Zd ZdZdZdZdZdZi Zde	e
j                  j                     fdZy)	_DeprecatedRemovedDirectivez$Handles ``.. deprecated-removed::``.r   r   FTr/   c                     | j                   d    d| j                   d    d}t        d|      }| j                  r1| j                  j	                  | j                  | j
                  |       |gS )Nr   z (removed in rW   )deprecated-removedrY   )r^   r6   re   r`   rf   rg   )ri   version_strrj   s      r3   rn   z_DeprecatedRemovedDirective.run  sc    *+=9J8K1M$8+N<<JJ##DLL$2E2EtLvr=   Nr   r<   r=   r3   r=  r=    s<    . %KKT(..--. r=   r=  c                   ^    e Zd ZdZdZdZdZdZi Zde	e
j                  j                     fdZy)_AvailabilityDirectivezHandles ``.. availability::``.

    The version is the first required argument. An optional explanation can
    follow on the next indented line(s).
    rW   Tr/   c                    t        | j                  d         }t        | j                        dkD  ra| j                  d   }| j                  j	                  || j
                        \  }}|t        j                  j                  |dg| z  }||z  }| j                  r1| j                  j                  | j                  | j                  |       |gS Nr   )r[   rW   r\   )rP   r^   r_   r`   ra   rb   r   rc   rd   re   rf   rg   rh   s        r3   rn   z_AvailabilityDirective.run  s    DNN1$56t~~"..+K%)ZZ%;%;K%U"L(HNN,,["L|LLDHD<<JJ##DLL$2E2EtLvr=   Nr   r<   r=   r3   rC  rC    @      $KK	T(..--. 	r=   rC  c                   ^    e Zd ZdZdZdZdZdZi Zde	e
j                  j                     fdZy)_SoftDeprecatedDirectivezHandles ``.. soft-deprecated::``.

    The version is the first required argument. An optional explanation can
    follow on the next indented line(s).
    rW   Tr/   c                    t        | j                  d         }t        | j                        dkD  ra| j                  d   }| j                  j	                  || j
                        \  }}|t        j                  j                  |dg| z  }||z  }| j                  r1| j                  j                  | j                  | j                  |       |gS rE  )rR   r^   r_   r`   ra   rb   r   rc   rd   re   rf   rg   rh   s        r3   rn   z_SoftDeprecatedDirective.run  s    t~~a'89t~~"..+K%)ZZ%;%;K%U"L(HNN,,["L|LLDHD<<JJ##DLL$2E2EtLvr=   Nr   r<   r=   r3   rH  rH    rF  r=   rH  c                   ^    e Zd ZdZdZdZdZdZi Zde	e
j                  j                     fdZy)_ImplDetailDirectivezHandles ``.. impl-detail::``.r   FTr/   c                     t               }| j                  r1| j                  j                  | j                  | j                  |       |gS r   )rT   re   r`   rf   rg   rz   s     r3   rn   z_ImplDetailDirective.run  s7    }<<JJ##DLL$2E2EtLvr=   Nr   r<   r=   r3   rK  rK    s<    ' %KKT(..--. r=   rK  c                   .   e Zd ZdZdZdZdZdZej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  dZdeej                   j"                     fdZy)	_PyObjectDirectivez=Handles Python/C/C++/JS domain object-description directives.rW   r   T)no-indexnoindexmodule
annotationrZ   r   asyncclassmethodstaticmethodabstractfinal	canonicalplatformsynopsis
deprecatedr/   c                 x   d| j                   v r | j                   j                  d      \  }}}nd}| j                   }t        ||| j                  d         }| j                  rt        | j                        |d<   | j                  r1| j                  j                  | j                  | j                  |       |gS )Nr   pyr   )domainobjtypesigr   )
r]   	partitionrE   r^   r   dictre   r`   rf   rg   )ri   r^  _r_  rj   s        r3   rn   z_PyObjectDirective.run  s    $))!%!4!4S!9FAwFiiGfg4>>!;LM<<"4<<0DO<<JJ##DLL$2E2EtLvr=   N)r8   r9   r:   r;   rp   rq   rr   rt   r   r   r   r   r   r   rs   r	   rc   ru   rn   r<   r=   r3   rN  rN    s   G $K$$((3388##''2277""&&11;;&&**55??  $$//99!!%%00::!!%%0055''++66;; ((,,77<<$$((3388!!%%0055%%))44>>$$((33==$$((33==&&**55::K$T(..--. r=   rN  c                      e Zd ZdZdZdZdZdZej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  ej                  j                  j                  j                  dZdeej                   j"                     fdZy)	_AutodocDirectivez9Handles autodoc directives (automodule, autoclass, etc.).rW   r   T)memberszundoc-memberszshow-inheritancezmember-orderzexclude-memberszprivate-memberszspecial-memberszinherited-membersrO  rP  rZ  rY  r[  zignore-module-allr/   c                     g S r   r<   r   s    r3   rn   z_AutodocDirective.run  r   r=   N)r8   r9   r:   r;   rp   rq   rr   rt   r   r   r   r   r   r   rs   r	   rc   ru   rn   r<   r=   r3   re  re    s   C $K##''22<<!))--88==$,,00;;@@ ((,,77AA#++//::DD#++//::DD#++//::DD%--11<<FF$$((3388##''2277$$((33==$$((33==&&**55::%--11<<AAK"T(..--. r=   re  c                       e Zd ZdZy)_rowSpanz;Inline node carrying a row-span value for flat-table cells.Nr7   r<   r=   r3   ri  ri    s    Er=   ri  c                       e Zd ZdZy)_colSpanz>Inline node carrying a column-span value for flat-table cells.Nr7   r<   r=   r3   rk  rk    rF   r=   rk  r]   rawtextr   rb   inlinerr   re   c                     	 t        |      }|dk  rt        	 t        |      gg fS # t        $ r: |j                  j                  d||      }|j	                  |||      g|gfcY S w xY w)u<   Role handler for ``:cspan:`` — extra columns a cell spans.r   z-:cspan: requires a non-negative integer, got r   span)r   r1   reporterr2   problematicrk  	r]   rl  r   rb   rm  r   re   r   msgs	            r3   _flat_table_cspanrv        	CIq5  !r!!  C$$;D8D % 
 ##GWc:;cUBBC   ( A A+*A+c                     	 t        |      }|dk  rt        	 t        |      gg fS # t        $ r: |j                  j                  d||      }|j	                  |||      g|gfcY S w xY w)u9   Role handler for ``:rspan:`` — extra rows a cell spans.r   z-:rspan: requires a non-negative integer, got ro  rp  )r   r1   rr  r2   rs  ri  rt  s	            r3   _flat_table_rspanrz  5  rw  rx  c                   <   e Zd ZdZej
                  j                  j                  j                  ej
                  j                  j                  j                  ej
                  j                  j                  j                  ej
                  j                  j                  j                  ej
                  j                  j                  j                  ej
                  j                  j                  j                  dZdeej                  j                      fdZy)_FlatTableDirectiveax  Implementation of the ``flat-table`` directive.

    A flat-table is written as a two-level bullet list.  The outer items are
    rows; the inner items are cells.  Cells may carry ``:rspan:`` and
    ``:cspan:`` roles to span rows or columns.  Missing cells on the right
    side of a row are auto-extended (or filled with empty cells when
    ``:fill-cells:`` is given).
    )r]   r   header-rowsstub-columnswidths
fill-cellsr/   c                 R   | j                   st| j                  j                  j                  d| j                  z  t
        j                  j                  | j                  | j                        | j                        }|gS | j                         \  }}t
        j                  j                         }| j                  j                  | j                   | j                  |       t        |       }|j!                  |       |j#                         }|r|j%                  d|       |g|z   S )Nz.The "%s" directive is empty; content required.ro  r   )re   r   rr  r2   r]   r   rc   r   r   rb   
make_titleElementr`   rf   rg   _FlatTableBuilderparse_flat_table_nodebuild_table_nodeinsert)ri   r2   titlerm   rj   builder
table_nodes          r3   rn   z_FlatTableDirective.run_  s    ||&&//55@499L,,T__dooN[[ 6 E
 7N//+x~~%%'

d.A.A4H#D)%%d+--/
a'|h&&r=   N)r8   r9   r:   r;   r   r   r   r   r   r   r   positive_int_listr   rs   r	   rc   ru   rn   r<   r=   r3   r|  r|  L  s       $$//99!!%%00==''++66FF ((,,77GG""&&11CC&&**55::K'T(..--. 'r=   r|  c                      e Zd ZdZdeddfdZdej                  j                  fdZ	de
e   dej                  j                  fdZd	eddfd
Zdej                  j                   ddfdZddZdej                  j&                  dede
e   fdZdej                  j&                  deeee
ej                  j.                     f   fdZy)r  z@Converts a two-level bullet list into a docutils ``table`` node.	directiver/   Nc                 .    || _         g | _        d| _        y ry   )r  rowsmax_cols)ri   r  s     r3   __init__z_FlatTableBuilder.__init__w  s    "%'	r=   c                 b   | j                   j                  | j                        }t        |t              r|d   }| j                   j
                  j                  dd      }| j                   j
                  j                  dd      }t        j                  j                         }t        j                  j                  t        |            }||z  }|}|D ]=  }t        j                  j                  |      }|rd|j                  d<   |dz  }||z  }? |rKt        j                  j                         }	||	z  }| j                  d | D ]  }
|	| j!                  |
      z  }	 t        j                  j#                         }||z  }| j                  |d  D ]  }
|| j!                  |
      z  } |S )NrW   r~  r   r}  )cols)colwidthr(  )r  get_column_widthsr  r8  tupler   r   r   rc   tabletgroupr_   colspec
attributestheadr  _build_row_nodetbody)ri   
col_widthsstub_columnsheader_rowsr  r  remaining_stubsr  r  r  rowr  s               r3   r  z"_FlatTableBuilder.build_table_node|  s   ^^55dmmD
j%(#AJ~~--11.!Dnn,,00B$$&&&C
O&<&"Hnn,,h,?G-.""6*1$gF # NN((*EeOFyy+.--c22 / $$&%99[\*CT))#..E + r=   row_datac                     t         j                  j                         }|D ]R  }||\  }}}dg i}|r||d<   |r||d<   t        j                  j                  di |}|j	                  |       ||z  }T |S )Nr   morerowsmorecolsr<   )r   rc   r  entryr   )	ri   r  r  cellcspanrspancell_elementsattrsr  s	            r3   r  z!_FlatTableBuilder._build_row_node  s    nn  "D|*.'E5-%.OE$)j!$)j!NN((151ELL'5LC  
r=   ru  c                 6   | j                   j                  j                  j                  |t        j
                  j                  | j                   j                  | j                   j                        | j                   j                        }ddl	m
}  ||      )Nro  r   )SystemMessagePropagation)r  r   rr  r2   r   rc   r   r   rb   rich_rst._vendor.docutils.utilsr  )ri   ru  r2   r  s       r3   _raise_errorz_FlatTableBuilder._raise_error  su    ,,55;;NN(())4>>+D+D && < 
 	M&u--r=   rj   c                 d   t        |      dk7  s't        |d   t        j                  j                        s(| j                  d| j                  j                  z         t        |d         D ]2  \  }}| j                  ||      }| j                  j                  |       4 | j                          y )NrW   r   zUError parsing content block for the "%s" directive: exactly one bullet list expected.)r_   r8  r   rc   bullet_listr  r  r]   	enumerate_parse_row_itemr  r   _build_grid)ri   rj   row_numrow_itemr  s        r3   r  z'_FlatTableBuilder.parse_flat_table_node  s    t9>DGX^^5O5O!P46:nn6I6IJ
 "+47!3GX&&x9CIIS! "4 	r=   c           	      "   t               }g }t        | j                        D ]  \  }}d}g }|D ]  \  }}}	||f|v r|dz  }||f|v r|j                  ||||	f       t	        |dz         D ]9  }
t	        |dz         D ]&  }|
dkD  s|dkD  s|j                  ||
z   ||z   f       ( ; ||dz   z  } |j                  |        |D ]/  }|D ](  \  }}}}t        | j                  ||z   dz         | _        * 1 d| j                  j                  v }g | _        |D ]  }g }d}|D ]D  \  }}}}	||k  r|j                  d       |dz  }||k  r|j                  |||	f       ||dz   z  }F | j                  |z
  }|dkD  rw|s4|r|d   |d   \  }}}	||z   ||	f|d<   nY|j                  |dz
  dg f       nAt	        |      D ]3  }|j                  ddt        j                  j                         gf       5 | j                  j                  |        y)a  Assign column positions to cells and insert None placeholders for spanned slots.

        Phase 1: walk rows in order, tracking which (row, col) positions are
        already claimed by a spanning cell via an occupancy set.  Each cell
        lands in the first unoccupied column in its row.

        Phase 2: rebuild self.rows as flat lists (None for occupied slots,
        tuple for real cells) and pad the right edge with auto-span or
        fill-cells as requested.
        r   rW   r  N)r   r  r  r   r   r   maxr  r  r   r   rc   comment)ri   occupied
positionedrr  col	row_cellsr  r  re   drdc_rspan_content
fill_cells
col_cursormissingrc  s                     r3   r  z_FlatTableBuilder._build_grid  sS    &(
		*FAsC#%I),%ug#h(*1HC #h(*  #ueW!=>	*B#EAI.6R!V$LL!b&#();< / + uqy  *- i( + $I09,UFH #DMM3;? C 1: $ "T^^%;%;;
	#ICJ.7*UE7 3&JJt$!OJ !3& 

E5'23eai'
 /8 mmj0G{!s2w203B-ug#(7?E7"CB

GaKB#78"7^

Aq8>>+A+A+C*D#EF ,IIS!) $r=   r  r  c                    g }d}d}d }|D ]  }t        |t        j                  j                  t        j                  j                  f      rBt        |t        j                  j
                        rgt        |t        j                  j                        r|dz  }|}d} n |dk7  s|r/| j                  d| j                  j                  d|dz   d       |D ]+  }| j                  |      \  }	}
}|j                  |	|
|f       - |S )Nr   FrW   Tz%Error parsing content block for the "z5" directive: two-level bullet list expected, but row z- does not contain a second-level bullet list.)r8  r   rc   r  system_messagetargetr  r  r  r]   _parse_cell_itemr   )ri   r  r  r  child_nor2   	cell_listr;  	cell_itemr  r  r  s               r3   r  z!_FlatTableBuilder._parse_row_item  s    	E%(.."8"8(..:W:W!XYE8>>#8#89E8>>#=#=>A!	  q=E >>&&!5 #I*.*?*?	*J'E5-JJum45 # 
r=   r  c                    dx}}t        |      s||g fS t        |j                  t                    D ].  }|j	                  d      }|j
                  j                  |       0 t        |j                  t                    D ].  }|j	                  d      }|j
                  j                  |       0 ||t        |      fS )Nr   rq  )r_   listfindallrk  r   parentremoveri  )ri   r  r  r  elems        r3   r  z"_FlatTableBuilder._parse_cell_item  s     9~%##**845DHHV$EKKt$ 6 **845DHHV$EKKt$ 6 eT)_,,r=   r/   N)r8   r9   r:   r;   r|  r  r   rc   r  r  r	   r   r  r  strr  r  r  r  	list_itemr   r  r   ru   r  r<   r=   r3   r  r  t  s    J"5 $ 
(.."6"6 BS	 hnn6H6H  	. 	. 	.(..*@*@ T 6"p(@(@ 3 SWX[S\ >-!11-	sChnn1122	3-r=   r  Ffunction.c                 h     t        j                         dt        dt        dt        f fd       }|S )Nargskwargsr/   c                  L    t         5   | i |cd d d        S # 1 sw Y   y xY wr   )_sphinx_registration_lock)r  r  r  s     r3   wrapperz+_sphinx_registration_guard.<locals>.wrapper4  s    &T,V, '&&s   #)	functoolswrapsr   )r  r  s   ` r3   _sphinx_registration_guardr  3  s:    __X-s -c -c - - Nr=   c                     t         5  t        r
	 ddd       yt        j                  j                  j
                  j                  dt               t        j                  j                  j
                  j                  dt               t        j                  j                  j
                  j                  dt               t        j                  j                  j
                  j                  dt               dD ]:  } t        j                  j                  j
                  j                  | t               < t        j                  j                  j
                  j                  dt               t        j                  j                  j
                  j                  dt               d	D ]:  } t        j                  j                  j
                  j                  | t               < d
D ]:  } t        j                  j                  j
                  j                  | t               < t        j                  j                  j
                  j                  dt               t        j                  j                  j
                  j                  dt               t        j                  j                  j
                  j                  dt                t        j                  j                  j
                  j                  dt"               t        j                  j                  j
                  j                  dt$               t        j                  j                  j
                  j                  dt&               t        j                  j                  j
                  j                  dt(               t        j                  j                  j
                  j                  dt*               t        j                  j                  j
                  j                  dt,               t        j                  j                  j
                  j                  dt.               t        j                  j                  j
                  j                  dt0               t        j                  j                  j
                  j                  dt2               dD ]:  } t        j                  j                  j
                  j                  | t               < dD ]:  } t        j                  j                  j
                  j                  | t4               < dD ]:  } t        j                  j                  j
                  j                  | t6               < t        j                  j                  j
                  j                  dt8               ddlmc mc mc mc m} ddl mc mc mc mc m!c m"} |jG                  dtH               |jG                  dtJ               tM        |d      rd|j>                  d<   d|j>                  d<   daddd       y# 1 sw Y   yxY w) zQRegister Sphinx-specific directives so they render properly instead of as errors.Nversionaddedversionchangedr[  r?   )z
code-block
sourcecoder   math	highlight)indextabularcolumns)currentmodulezpy:currentmoduleonlycenteredhlisttoctreeliteralincluder  glossaryr@  rP   soft-deprecatedzimpl-detailinclude)r   role)/zpy:functionpy:classz	py:methodzpy:attributepy:datazpy:exceptionz	py:modulepy:propertyzpy:decoratorzpy:classmethodzpy:staticmethodpy:variablepy:type
py:typevarzpy:typealiasz	py:envvarz	py:optionzpy:coroutinefunctionzpy:coroutinemethodzpy:decoratorfunctionzpy:abstractmethodz	py:opcodezpy:describe
c:functionc:typec:structc:unionc:enumc:enumeratorc:memberc:varc:macrocpp:function	cpp:classcpp:type
cpp:membercpp:varcpp:enumcpp:enumeratorcpp:concept	cpp:aliasjs:functionjs:class	js:methodjs:attributejs:data	js:module)
automodule	autoclassautofunction
automethodautoattributeautoexceptionautodataautopropertyautodecoratorautoclassmethodautostaticmethodz
flat-tabler   r  r  rolesT)'r  _sphinx_directives_registeredr   r   r   r   register_directiverV   rw   r|   r   r   r   r   r   r   r   r   r   r  r-  r=  rC  rH  rK  r  rN  re  r|  +rich_rst._vendor.docutils.parsers.rst.rolesr#  r  2rich_rst._vendor.docutils.parsers.rst.languages.en	languagesenregister_canonical_rolerv  rz  hasattr)r]   _roles_ens      r3   _register_sphinx_directivesr(  <  sA    
#( 
#	" 	''::>K\]''::;KM^_''::<IZ[''::9FWX 9D  ++>>tEXY 9 	''::6>R''::;H[\/D  ++>>tEUV 0 :D  ++>>tE\] : 	''::6>R'':::GYZ''::7OT''::9FWX''::;KMef''::;KMef'':::GYZ''::;OQlm''::>Kab''::;LNfg''::=J^_''::9FWX &D  ++>>tEUV &
D$   ++>>tEWX%
(
D
   ++>>tEVW
 	''::<I\]DDDHHH&&w0AB&&w0AB3 !(CIIg!(CIIg(,%q 
#	"	"s   YX!YYc                  D   t         5  t        r
	 ddd       yddlm ddl} ddl} d&dt        dt        dt        dt        dt        d	t        t        t        t        f      d
t        t        t              dt        t        j                  j                     t        j                  j                     f   ffd}g d}|D ]  }j                   j"                  j$                  j'                  ||       t)        j                   j"                  j*                  j,                  d      sh|j                   j"                  j*                  j,                  j$                  |<    d&dt        dt        dt        dt        dt        d	t        t        t        t        f      d
t        t        t              dt        t        j                  j                     t        j                  j                     f   ffd}dD ]  }j                   j"                  j$                  j'                  ||       t)        j                   j"                  j*                  j,                  d      sh|j                   j"                  j*                  j,                  j$                  |<    d&dt        dt        dt        dt        dt        d	t        t        t        t        f      d
t        t        t              dt        t        j                  j                     t        j                  j                     f   ffd}j                   j"                  j$                  j'                  d|       t)        j                   j"                  j*                  j,                  d      r7dj                   j"                  j*                  j,                  j$                  d<   t/        j0                  dt.        j2                        d&dt        dt        dt        dt        dt        d	t        t        t        t        f      d
t        t        t              dt        t        j                  j                     t        j                  j                     f   ffd}j                   j"                  j$                  j'                  d|       t)        j                   j"                  j*                  j,                  d      r7dj                   j"                  j*                  j,                  j$                  d<   d&dt        dt        dt        dt        dt        d	t        t        t        t        f      d
t        t        t              dt        t        j                  j                     t        j                  j                     f   ffd}j                   j"                  j$                  j'                  d|       t)        j                   j"                  j*                  j,                  d      r7dj                   j"                  j*                  j,                  j$                  d<   t/        j0                  d      d&dt        dt        dt        dt        dt        d	t        t        t        t        f      d
t        t        t              dt        t        j                  j                     t        j                  j                     f   ffd}	dD ]  }j                   j"                  j$                  j'                  ||	       t)        j                   j"                  j*                  j,                  d      sh|j                   j"                  j*                  j,                  j$                  |<    d&dt        dt        dt        dt        dt        d	t        t        t        t        f      d
t        t        t              dt        t        j                  j                     t        j                  j                     f   ffd}
j                   j"                  j$                  j'                  d|
       t)        j                   j"                  j*                  j,                  d      r7dj                   j"                  j*                  j,                  j$                  d<   d&dt        dt        dt        dt        dt        d	t        t        t        t        f      d
t        t        t              dt        t        j                  j                     t        j                  j                     f   ffd}j                   j"                  j$                  j'                  d|       t)        j                   j"                  j*                  j,                  d      r7dj                   j"                  j*                  j,                  j$                  d<   	 	 d&dt        dt        dt        dt        dt        d	t        t        t        t        f      d
t        t        t              dt        t        j                  j                     t        j                  j                     f   ffd}j                   j"                  j$                  j'                  d |       t)        j                   j"                  j*                  j,                  d      r7d j                   j"                  j*                  j,                  j$                  d <   	 	 d&dt        dt        dt        dt        dt        d	t        t        t        t        f      d
t        t        t              dt        t        j                  j                     t        j                  j                     f   ffd!}j                   j"                  j$                  j'                  d"|       t)        j                   j"                  j*                  j,                  d      r7d"j                   j"                  j*                  j,                  j$                  d"<   	 	 d&dt        dt        dt        dt        dt        d	t        t        t        t        f      d
t        t        t              dt        t        j                  j                     t        j                  j                     f   ffd#}j                   j"                  j$                  j'                  d$|       t)        j                   j"                  j*                  j,                  d      r7d$j                   j"                  j*                  j,                  j$                  d$<   d%addd       y# 1 sw Y   yxY w)'u  Register common Sphinx roles to gracefully handle Sphinx-specific markup.

    Sphinx roles like :func:, :class:, :meth: are very common in Python
    docstrings but are not available in standard docutils.  This function
    registers them to render as inline code/literal text instead of errors.

    Thread safety: protected by ``_sphinx_registration_lock``, identical to
    :func:`_register_sphinx_directives`.  Per-process state only — each
    worker in a multi-process build registers independently, which is correct.
    Nr   r   r]   rl  r   rb   rm  r   re   r/   c                     |}d|v r9|j                  d      r(|j                  d      }|d| j                         }	|	r|	}j                  j	                  ||      }
|
gg fS )z@Generic Sphinx role handler that renders as inline literal text.<>N)endswithrfindr   rc   literalr]   rl  r   rb   rm  r   re   display_textbracket_pospotential_displayrj   r   s              r3   sphinx_rolez+_register_sphinx_roles.<locals>.sphinx_role  sg    Ld{t}}S1"jjo$(+$6$<$<$>!$#4L>>))'<@D62:r=   )Tfuncr  methmethodr   modrQ  attr	attributeobjobjectdataconstconstantexc	exceptionvarvariablerZ   zpy:funczpy:methr  zpy:modzpy:attrzpy:objr  zpy:constzpy:excenvvartokenoptiontermrefdocanynumrefdownload
mailheadermimetype	newsgroupmakevarregexpkbdguilabelmanpager  r  r  zpy:parameterr  zc:funcr  r  r  r  r  r  r   r  r  zc:exprzc:texprzcpp:funcr  r  r  r  r  r  r	  r
  zcpp:exprz	cpp:texprr  zjs:modr  zjs:funcr  r  zjs:attrr  r  zjs:methr  r  c                     |}d|v r9|j                  d      r(|j                  d      }|d | j                         }	|	r|	}j                  j	                  ||      }
|
gg fS )Nr+  r,  )r-  r.  r   rc   strongr0  s              r3   _bold_literal_rolez2_register_sphinx_roles.<locals>._bold_literal_role  sg    Ld{t}}S1"jjo$(+$6$<$<$>!$#4L>>((,?D62:r=   )commandprogramc                 F    j                   j                  ||      }|gg fS r   )rc   emphasis	r]   rl  r   rb   rm  r   re   rj   r   s	           r3   	_dfn_rolez)_register_sphinx_roles.<locals>._dfn_role  s%    >>**7D9D62:r=   dfnz	\((.*)\)$c                     j                  |      }|r3|d |j                          j                         }|j                  d      }	n|}d}	j                  j                  |||	      }
|
gg fS )NrW   r\   )rk   )searchr   r   grouprc   abbreviation)r]   rl  r   rb   rm  r   re   matched	abbr_textrk   rj   _abbr_rer   s              r3   
_abbr_rolez*_register_sphinx_roles.<locals>._abbr_role  so    ood+G !1'--/288:	%mmA. 	 >>..w	{.[D62:r=   abbrc                 j    |j                  dd      }j                  j                  ||      }|gg fS )Nz-->u   ▶)replacerc   r/  r\  s	           r3   _menuselection_rolez3_register_sphinx_roles.<locals>._menuselection_role  s5    <<x0D>>))'48D62:r=   menuselectionz\{([^}]*)\}c                 j    	j                  d|      }
j                  j                  ||      }|gg fS )Nz\1)r   rc   r/  )r]   rl  r   rb   rm  r   re   cleanrj   
_braces_rer   s            r3   
_samp_rolez*_register_sphinx_roles.<locals>._samp_role   s5    NN5$/E>>))'59D62:r=   )sampfilec                    |j                  dd      }|d   j                         }t        |      dkD  rd|d   z   nd}		 t        |      }
d|
dd|	 }d	| }j
                  j                  |||
      }|gg fS # t        $ r d}Y 5w xY w)N#rW   r   r\   zhttps://peps.python.org/pep-04d/zhttps://peps.python.org/zPEP refurir   r   r_   r   r1   rc   	reference)r]   rl  r   rb   rm  r   re   partspep_num_stranchorpep_numurldisplayrH  r   s                 r3   	_pep_rolez)_register_sphinx_roles.<locals>._pep_role+  s    JJsA&E(..*K),UacE!HnRF1k*4WSM6(K [M*G..**7GC*HC5"9	  101s    A< <B
	B
pepc                    |j                  dd      }|d   j                         }t        |      dkD  rd|d   z   nd}		 t        |      }
d|
 |	 }d| }j
                  j                  |||      }|gg fS # t        $ r d}Y 5w xY w)	Nrs  rW   r   r\   z)https://datatracker.ietf.org/doc/html/rfczhttps://datatracker.ietf.org/zRFC rv  rx  )r]   rl  r   rb   rm  r   re   rz  rfc_num_strr|  rfc_numr~  r  rH  r   s                 r3   	_rfc_rolez)_register_sphinx_roles.<locals>._rfc_role=  s    JJsA&E(..*K),UacE!HnRF6k*A'6(S [M*G..**7GC*HC5"9	  656s    A: :BBrfcc                     |j                         j                  d      }d| }d| }	j                  j                  ||	|      }
|
gg fS )NzCVE-z%https://www.cve.org/CVERecord?id=CVE-rv  )r   lstriprc   ry  )r]   rl  r   rb   rm  r   re   cve_idr~  r  rH  r   s              r3   	_cve_rolez)_register_sphinx_roles.<locals>._cve_roleO  sY     ZZ\((0F9&BCVHoG..**7GC*HC5"9r=   cvec                     |j                         }d| d}d| }	j                  j                  ||	|      }
|
gg fS )Nz'https://cwe.mitre.org/data/definitions/z.htmlzCWE-rv  r   rc   ry  )r]   rl  r   rb   rm  r   re   cwe_numr~  r  rH  r   s              r3   	_cwe_rolez)_register_sphinx_roles.<locals>._cwe_role_  sQ     jjlG;G9EJCWI&G..**7GC*HC5"9r=   cwec                 z    |j                         }d| d}|}	j                  j                  ||	|      }
|
gg fS )Nzhttps://pypi.org/project/ru  rv  r  )r]   rl  r   rb   rm  r   re   project_namer~  r  rH  r   s              r3   
_pypi_rolez*_register_sphinx_roles.<locals>._pypi_roleo  sJ      ::<L-l^1=C"G..**7GC*HC5"9r=   pypiTNN)r  _sphinx_roles_registeredrich_rst._vendorr   r   r!  r  r   r   r   r   r	   r   rc   ru   r  r   r   r  r$  r%  r"  r#  r   compileDOTALL)rich_rstr4  sphinx_rolesr  rW  
_role_namer]  rf  rj  ro  r  r  r  r  r  re  rn  r   s                  @@@r3   _register_sphinx_rolesr    s    
## 
#	" 	.:A
	c 
	C 
	s 
	C 
	RU 
	`himnqsvnviw`x 
	  KS  TX  Y\  T]  K^ 
	  jo  pt  u}  uC  uC  uH  uH  pI  KO  PX  P^  P^  Pm  Pm  Kn  pn  jo 
	!
F !D  &&>>t[Qx''++5588'B@D  $$..1177=	 !	S 	3 	c 	3 	Y\ 	goptuxz}u}p~g 	  RZ  [_  `c  [d  Re 	  qv  w{  |D  |J  |J  |O  |O  wP  RV  W_  We  We  Wt  Wt  Ru  wu  qv 	 1J  &&>>zK]^x''++5588'BFP  $$..1177
C 1	C 	# 	S 	# 	PS 	^fgkloqtltgu^v 	  IQ  RV  WZ  R[  I\ 	  hm  nr  s{  sA  sA  sF  sF  nG  IM  NV  N\  N\  Nk  Nk  Il  nl  hm 	 	""::5)L8##''1144g>=BH  **--33E: ::lBII6		S 		3 		c 		3 		QT 		_ghlmprumuhv_w 		  JR  SW  X[  S\  J] 		  in  os  t|  tB  tB  tG  tG  oH  JN  OW  O]  O]  Ol  Ol  Jm  om  in 		 	""::6:N8##''1144g>>DH  **--33F;	c 	C 	s 	C 	Z] 	hpquvy{~v~q  iA 	  S[  \`  ad  \e  Sf 	  rw  x|  }E  }K  }K  }P  }P  xQ  SW  X`  Xf  Xf  Xu  Xu  Sv  xv  rw 	
 	""::?L_`8##''1144g>GVH  **--33OD ZZ/
	S 	3 	c 	3 	QT 	_ghlmprumuhv_w 	  JR  SW  X[  S\  J] 	  in  os  t|  tB  tB  tG  tG  oH  JN  OW  O]  O]  Ol  Ol  Jm  om  in 	
 +J  &&>>z:Vx''++5588'BFP  $$..1177
C +	C 	# 	S 	# 	PS 	^fgkloqtltgu^v 	  IQ  RV  WZ  R[  I\ 	  hm  nr  s{  sA  sA  sF  sF  nG  IM  NV  N\  N\  Nk  Nk  Il  nl  hm 	 	""::5)L8##''1144g>=BH  **--33E:	C 	# 	S 	# 	PS 	^fgkloqtltgu^v 	  IQ  RV  WZ  R[  I\ 	  hm  nr  s{  sA  sA  sF  sF  nG  IM  NV  N\  N\  Nk  Nk  Il  nl  hm 	 	""::5)L8##''1144g>=BH  **--33E: 9=37	C 	# 	S 	# 	PS 	%d38n5	%d3i0	 tHNN$7$78$x~~?\?\:]]^	 	""::5)L8##''1144g>=BH  **--33E:
 9=37	C 	# 	S 	# 	PS 	%d38n5	%d3i0	 tHNN$7$78$x~~?\?\:]]^	 	""::5)L8##''1144g>=BH  **--33E:
 9=37	S 	3 	c 	3 	QT 	%d38n5	%d3i0	 tHNN$7$78$x~~?\?\:]]^	 	""::6:N8##''1144g>>DH  **--33F;#' e 
#	"	"s&   vDv+D6v"S>v!X,vvc                   >     e Zd ZdZ fdZdeddfdZdefdZ xZS )
MLStripperz3Utility class to strip out html for raw html sourcec                 n    t         |           | j                          d| _        t	               | _        y )NT)superr  resetconvert_charrefsr   r   )ri   	__class__s    r3   r  zMLStripper.__init__  s(    

 $J	r=   dr/   Nc                 :    | j                   j                  |       y r   )r   write)ri   r  s     r3   handle_datazMLStripper.handle_data  s    		r=   c                 6    | j                   j                         S r   )r   getvaluer   s    r3   get_datazMLStripper.get_data  s    yy!!##r=   )	r8   r9   r:   r;   r  r  r  r  __classcell__r  s   @r3   r  r    s*    =S T $# $r=   r  htmlc                     t               }	 |j                  |        |j                          |j	                         S # t        $ r | cY S w xY wr   )r  feedclose	Exceptionr  )r  ss     r3   
strip_tagsr    sF    A	t		 ::<  s   != A
Az\alphau   αz\betau   βz\gammau   γz\deltau   δz\epsilonu   εz\varepsilonz\zetau   ζz\etau   ηz\thetau   θz	\varthetau   ϑz\iotau   ιz\kappau   κz\lambdau   λz\muu   μz\nuu   νz\xiu   ξz\piu   πz\varpiu   ϖz\rhou   ρz\varrhou   ϱz\sigmau   σz	\varsigmau   ςz\tauu   τz\upsilonu   υz\phiu   φz\varphiz\chiu   χz\psiu   ψz\omegau   ωz\Gammau   Γz\Deltau   Δz\Thetau   Θz\Lambdau   Λz\Xiu   Ξz\Piu   Πz\Sigmau   Σz\Upsilonu   Υz\Phiu   Φz\Psiu   Ψz\Omegau   Ωz\times   ×z\div   ÷z\pm   ±z\mpu   ∓z\cdot   ·z\ldotsu   …z\cdotsu   ⋯z\vdotsu   ⋮z\ddotsu   ⋱z\lequ   ≤z\lez\gequ   ≥z\gez\nequ   ≠z\nez\approxu   ≈z\equivu   ≡z\simu   ∼z\simequ   ≃z\congu   ≅z\proptou   ∝z\subsetu   ⊂z\supsetu   ⊃z	\subsetequ   ⊆z	\supsetequ   ⊇z\inu   ∈z\notinu   ∉z\cupu   ∪z\capu   ∩z	\emptysetu   ∅z\varnothingz\neg   ¬z\wedgeu   ∧z\veeu   ∨z\oplusu   ⊕z\forallu   ∀z\existsu   ∃z\nexistsu   ∄z\tou   →z\rightarrowz
\leftarrowu   ←z\getsz\leftrightarrowu   ↔z\Rightarrowu   ⇒z
\Leftarrowu   ⇐z\Leftrightarrowu   ⇔z\uparrowu   ↑z
\downarrowu   ↓z\updownarrowu   ↕z\Uparrowu   ⇑z
\Downarrowu   ⇓z\mapstou   ↦z\inftyu   ∞z\partialu   ∂z\nablau   ∇z\sumu   ∑z\produ   ∏z\intu   ∫z\ointu   ∮z\hbaru   ℏz\ellu   ℓz\wpu   ℘u   ℜu   ℑu   ℵu   ∠u   ⊥u   ∥u   ′u   †u   ‡u   ⟨u   ⟩       )z\Rez\Imz\alephz\anglez\perpz	\parallelz\primez\daggerz\ddaggerz\langlez\ranglez\quadz\qquadz\ c                      t        | d          S ry   )r_   r3  s    r3   r5  r5    s    DG}r=   r6  c                    | }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd	|      }t        j                  d
d|      }|j                  dd      j                  dd      }t        D ]  \  }}|j                  ||      } |S )zConvert common LaTeX math notation to Unicode approximations.

    Handles the most common cases (Greek letters, operators, arrows, etc.)
    for improved readability in the terminal.  Unknown commands are left as-is.
    z	\\left\s*r\   z
\\right\s*z\\frac\{([^{}]*)\}\{([^{}]*)\}z(\1/\2)z\\sqrt\{([^{}]*)\}u   √(\1)z\^\{([^{}]*)\}z^\1z_\{([^{}]*)\}z_\1{r   )r   r   ri  _LATEX_TO_UNICODE_SORTED)r   resultlatexunis       r3   _convert_math_to_unicoder    s     F VVL"f-FVVM2v.F VV5z6JF VV):v>F VV%vv6F VV$ff5F ^^C$,,S"5F /
ss+ / Mr=   c                       e Zd ZU dZi Zeeeej                  j                     eeedef      eedef      f   f      ed<    e       Zee   ed<   ej'                  dd      Zeeeeeedf   f      ed<   ej'                  d	d
      Zeeeeeedf   f      ed<   eddeej                  j                     deedef      deedef      deedef      fd       Zedeej                  j                     ddfd       Zedeeej                  j                     eeedef      eedef      f   f   fd       Zdej                  j                  ddfdZdej                  j                  ddfdZ	 	 	 	 	 ddej                  j<                  dedeee f   dee!   dee!   dee   de"d   ddf fdZ#deej                  j                     deej                  j                  gef   fd Z$deej                  j                     deej                  j                  gef   fd!Z%d"ed#eeeeedf   f   defd$Z&d"edeee   e!f   fd%Z'dej                  j                  deee   ef   fd&Z(dej                  j                  defd'Z)d"ed(eddfd)Z*dej                  j                  defd*Z+dej                  j                  ddfd+Z,dd,Z-dd-Z.dd.Z/dd/Z0dd0Z1dd1Z2dd2Z3dd3Z4dd4Z5dd5Z6dd6Z7dd7Z8dd8Z9dd9Z:d"ed:e;ddfd;Z<dd<Z=d=e>ej                  j                     de>e   fd>Z?d?ej                  j                  de>e   fd@Z@dAedBedCedDedEe>ej                  j                     ddfdFZAdGed:e;dEe>ej                  j                     ddfdHZBdAedBed:e;dEe>ej                  j                     ddf
dIZCdJeDddfdKZEdLeDdMe>e   ddfdNZFdOedPedEe>ej                  j                     ddfdQZGddRZHddSZIddTZJddUZKddVZLddWZMddXZNddYZOddZZPdd[ZQdd\ZRdd]ZSdd^ZTdd_ZUdd`ZVddaZWddbZXddcZYdddZZddeZ[ddfZ\ddgZ]e^dhedeeef   fdi       Z_djej                  j                  de>e   fdkZadej                  j                  de>e   fdlZbddmednede;fdoZcdnedmedpedeDfdqZddmedpedeDfdrZedmedpedeDfdsZfdnedmedpedeDfdtZge^dpedeeef   fdu       Zhdvej                  j                  dee>eeeef      e>ej                  j                     f   fdwZidxe>eeeef      de>e   fdyZjddzZkdd{Zldd|Zmdd}Zndd~ZoddZpddZqddZrddZsddZtddZuddZvddZwddZxddej                  j                  dee   deDfdZzdej                  j                  dCeddfdZ{ddZ|ddZ}ddZ~ddZg dZe^de>e   de>e   fd       Zddej                  j                  d(eddfdZddZe^dededefd       Zddej                  j                  d(eddfdZddZddZddZddZddZdhededdfdZddZddZddZddZddZddZddZddZddZddZddZddZddZddZddZddZddej                  j<                  deddfdZddZd=e>ej                  j                     de>e   fdZddZddZddZddZddZddZddZddZddZddZddZddZddZddZddZddZddÄZddĄZe^de>e>e      de>e   dedAee   dedededdfd˄       Zdd̄Z xZS )r-   a  A visitor that produces rich renderables.

    .. note:: The ``_SUPERSCRIPT`` and ``_SUBSCRIPT`` translation tables are
       class-level constants so they are computed once rather than per-instance.

    Custom visitors for third-party node types can be registered via
    :meth:`register_visitor`.  Registered functions take ``(visitor, node)``
    as arguments and should follow the same conventions as the built-in
    ``visit_*`` / ``depart_*`` methods (e.g. raise
    ``docutils.nodes.SkipChildren`` to suppress child processing).
    ._custom_visitors_DISPATCH_CACHE_MISSuG   1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ=+-*/×÷u   ¹²³⁴⁵⁶⁷⁸⁹⁰ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻ⁼⁺⁻*/×÷N_SUPERSCRIPTu-   1234567890abcdefghijklmnopqrstuvwxyz=+-*/×÷ug   ₁₂₃₄₅₆₇₈₉₀abcdₑfgₕᵢⱼₖₗₘₙₒₚqᵣₛₜᵤᵥwₓyz₌₊₋*/×÷
_SUBSCRIPT
node_classvisit_fn	depart_fnr/   c                      |)|'dt         dt        f   dt         dt        f   f fd}|S d j                  vri  _        ||f j                  <   y)a  Register custom visit/depart functions for *node_class*.

        The registration is class-wide: it applies to every instance of this
        class (and subclasses that do not provide their own registry).

        Can be used in two ways:

        **Direct form** (original API)::

            RSTVisitor.register_visitor(MyNode, visit_fn=my_visit)

        **Decorator form** (when ``visit_fn`` and ``depart_fn`` are both
        ``None``, a single-argument call returns a decorator that registers
        the decorated function as the visit handler)::

            @RSTVisitor.register_visitor(MyNode)
            def visit_my_node(visitor, node):
                visitor.renderables.append(Text(node.astext()))
                raise docutils.nodes.SkipChildren()

        Parameters
        ----------
        node_class : type
            The docutils node class to handle.
        visit_fn : callable or None
            Called as ``visit_fn(visitor, node)`` when the node is entered.
            May raise ``docutils.nodes.SkipChildren`` to suppress child
            traversal.  Pass ``None`` to use a no-op visit.
        depart_fn : callable or None
            Called as ``depart_fn(visitor, node)`` when the node is exited.
            Pass ``None`` to use a no-op departure.

        Returns
        -------
        callable or None
            When used as a decorator (no ``visit_fn`` / ``depart_fn``
            provided), returns a decorator.  Otherwise returns ``None``.
        Nfn.r/   c                 .    j                  |        | S )N)r  )register_visitor)r  clsr  s    r3   
_decoratorz/RSTVisitor.register_visitor.<locals>._decorator?  s    $$Z"$=	r=   r  )r   r   __dict__r  )r  r  r  r  r  s   ``   r3   r  zRSTVisitor.register_visitor  sl    P 	 1xS1 hsCx6H  S\\1 $&C ,4i+@Z(r=   c                 Z    d| j                   v r| j                  j                  |d       yy)ah  Remove a previously registered custom visitor for *node_class*.

        If no registration exists for *node_class* the call is silently
        ignored.  Useful in test teardown to restore the original state.

        Parameters
        ----------
        node_class : type
            The docutils node class whose custom handlers should be removed.
        r  N)r  r  pop)r  r  s     r3   unregister_visitorzRSTVisitor.unregister_visitorK  s+     -  $$Z6 .r=   c                 ,    t        | j                        S )a  Return a snapshot of the current custom-visitor registry.

        Returns
        -------
        dict
            A ``{node_class: (visit_fn, depart_fn)}`` mapping.  The dict is
            a shallow copy; modifying it does not affect the registry.
        )rb  r  )r  s    r3   list_registered_visitorsz#RSTVisitor.list_registered_visitorsZ  s     C(())r=   rj   c                     | j                   j                  t        |            }||\  }}|	 || |      S y  | j                  t        |            |      S r   )r  r   rZ   _resolve_visit_handler)ri   rj   r  r  rc  s        r3   dispatch_visitzRSTVisitor.dispatch_visitf  s]    %%))$t*5KHa#d++6t**4:6t<<r=   c                     | j                   j                  t        |            }||\  }}|	 || |      S y  | j                  t        |            |      S r   )r  r   rZ   _resolve_depart_handler)ri   rj   r  rc  r  s        r3   dispatch_departurezRSTVisitor.dispatch_departureo  s]    %%))$t*5 LAy$ t,,7t++DJ7==r=   documentconsole
code_themeshow_line_numbersr&   r.   admonition_stylepanelcompactc                 ,   t         |   |       || _        || _        || _        || _        g | _        g | _        g | _        g | _	        || _
        t        |      | _        i | _        d | _        i | _        i | _        t#        j$                         | _        y r   )r  r  r  r  r  r  renderableserrorsfooter	citationsr&   r4   r.   refname_to_renderable_last_paragraph_text_visit_dispatch_cache_depart_dispatch_cache	threadingLock_dispatch_cache_lock)	ri   r  r  r  r  r&   r.   r  r  s	           r3   r  zRSTVisitor.__init__x  s     	" '3=1B=M&(#%#%&(+6,H,WGI" 59! mo"mo#$-NN$4!r=   	node_typec                    | j                   j                  || j                        }|| j                  ur|S | j                  5  | j                   j                  || j                        }|| j                  ur|cd d d        S t	        | d|j
                   | j                        }|| j                   |<   |cd d d        S # 1 sw Y   y xY w)Nvisit_)r  r   r  r  getattrr8   unknown_visitri   r  cachedhandlers       r3   r  z!RSTVisitor._resolve_visit_handler  s    ++//	4;T;TU222M&&//33It?X?XYFT666 '& dfY-?-?,@$A4CUCUVG4;D&&y1 '&&   6C4CC
c                    | j                   j                  || j                        }|| j                  ur|S | j                  5  | j                   j                  || j                        }|| j                  ur|cd d d        S t	        | d|j
                   | j                        }|| j                   |<   |cd d d        S # 1 sw Y   y xY w)Ndepart_)r  r   r  r  r  r8   unknown_departurer  s       r3   r  z"RSTVisitor._resolve_depart_handler  s    ,,00D<U<UV222M&&0044Y@Y@YZFT666 '& dgi.@.@-A$BDDZDZ[G5<D''	2 '&&r  r   r  c                    g }|D ]m  }|j                  t        |      |      }||j                  |       2t        |t              r|j                  t        |             ]|j                  |       o dj                  |      S )zKTranslate characters using `table` while preserving unmapped/deleted chars.r\   )r   ordr   r8  r   chrr   )ri   r   r  translated_charschmappeds         r3   _translate_with_fallbackz#RSTVisitor._translate_with_fallback  su    &(BYYs2w+F~ ''+FC( ''F4 ''/  ww'((r=   c                     	 t        |      }|j                  r|j                  d   nd }|dk(  s|| j                  dfS |dfS # t        $ r | j                  dfcY S w xY w)NFr   r   T)r&   r(   r.   aliases)ri   r   lexerguesseds       r3   _guess_lexer_namezRSTVisitor._guess_lexer_name  sr    	-%E ',mm%--"f%%u,,}  	-%%u,,	-s   A AAc                    t        |j                  d            dk\  r|d   d   n|j                  d      r|d   nd }||dfS | j                  r+| j                  |j	                               \  }}||rdfS dfS | j
                  dfS )Nr   r   rW   formatexplicitr	  default)r_   r   r&   r
  r1  r.   )ri   rj   r  guessed_lexerwas_guesseds        r3   _find_lexerzRSTVisitor._find_lexer  s    "%dhhy&9":a"?DOAX\X`X`aiXjd8npt 	 *$$)-)?)?)N&M; {)II	II!!9,,r=   c                     d}t        |dd       }|9t        |t        j                  j                        r|dz  }t        |dd       }|9|S )Nr   r  rW   )r  r8  r   rc   section)ri   rj   levelr  s       r3   _section_levelzRSTVisitor._section_level  sU    x. &(.."8"89
VXt4F   r=   r  c           
         ddt         j                  fddt         j                  fddddg}t        |t	        |      dz
        }||   \  }}}| j
                  j                  ||	      }|T| j                  j                  t        t        ||
      d             | j                  j                  t                      y | j                  j                  t        t        t        ||
      d      |||             y )Nzrestructuredtext.title.level.1boldzrestructuredtext.title.level.2)zrestructuredtext.title.level.3zbold underlineN)zrestructuredtext.title.level.4r  N)zrestructuredtext.title.level.5	underlineN)zrestructuredtext.title.level.6italicNrW   r  stylecenterr   r  border_style)r   DOUBLEROUNDEDminr_   r  	get_styler  r   r   r   r   r   )	ri   r   r  heading_levelsr  
style_namedefault_style	panel_boxr  s	            r3   _render_headingzRSTVisitor._render_heading  s    -vszzB-vs{{CF<A>
 E3~.23/=e/D,
M9&&z=&I##E$t5*A8$LM##GI.##E%T0G*RXain  ~C  %D  Er=   c                    t        d |j                  D        d      }d}|.|j                         j                  dd      j	                         }g }|j                  D ]I  }||u r|j                         j                  dd      j	                         }|s9|j                  |       K dj                  |      j	                         }|r	|r| d| S |r| dS |j                         j                  dd      j	                         S )z=Return labelled nodes (footnotes/citations) as `label: body`.c              3   j   K   | ]+  }t        |t        j                  j                        s(| - y wr   )r8  r   rc   r   r   r;  s     r3   r   z3RSTVisitor._format_labelled_node.<locals>.<genexpr>  s'     gmUz%QYQ_Q_QeQe?f5m   )33Nr\   r   r  : r   )nextr   r1  ri  r   r   r   )ri   rj   
label_noder   
body_partsr;  r   bodys           r3   _format_labelled_nodez RSTVisitor._format_labelled_node  s    gdmmgimn
!%%'//c:@@BE
]]E
"<<>))$4::<D!!$' # xx
#))+TWBtf%%WA;{{}$$T3/5577r=   c                    t        |j                        dk(  r2t        |j                  d   t        j                  j
                        ry |j                  j                  d      }| j                  j                  dd      }|r|j                  |      }t        |j                         j                  dd      |d	
      }| j                  rt        | j                  d   t              rbd|_        t        | j                  d         }|t        |      z   t        |j                        z   }| j                  d   j!                  |       n>d}t        |      t        |j                        z   }| j                  j#                  |       |s<|j                  j                  d      }|r| j                  d   ||f| j$                  |<   t        j                  j'                         )NrW   r   rw  zrestructuredtext.referencezblue underline on defaultr  r   r  r\   r  r   r  refname)r_   r   r8  r   rc   imager  r   r  r#  update_linkr   r1  ri  r  r   append_textr   r  SkipChildren)ri   rj   rw  r  
renderabler   r   r5  s           r3   visit_referencezRSTVisitor.visit_reference	  s   t}}"z$--2BHNNDXDX'Y$$X.&&'CMh&i%%f-E$++-//c:%RP

4+;+;B+? F JN((,-E #j/)C
,??CR ,,Z8Ej/C
$77C##J/oo)))4G7;7G7G7KUTW6X**73nn))++r=   c                 >   |j                  d      }|r^|d   D ]V  }	 | j                  |   \  }}}|j                  | j                  |      }|j                  |      }|j                  |||       X t        j                  j                         # t        $ r Y w xY w)Nrw  names)
r   r  KeyErrorget_style_at_offsetr  r7  stylizer   rc   r9  )ri   rj   urir]   r:  r   r   r  s           r3   visit_targetzRSTVisitor.visit_target%  s    hhx W-1-G-G-M*Js #66t||UK))#.""5%5 & nn))++   s   B	BBc                     t        |d      rht        |j                  t        j                  j
                        r9| j                  |j                         t        j                  j                         y y )Nr  )r%  r8  r  r   rc   r  visit_system_messager9  rz   s     r3   visit_paragraphzRSTVisitor.visit_paragraph2  sQ    4"z$++x~~?\?\']%%dkk2..--// (^"r=   c                 z   | j                   rt        | j                   d   t              r| j                   d   rt        t        |dd       t        j
                  j                        r| j                   d   j                  d       n| j                   d   j                  d       | j                   d   | _        y y y y )Nr  r  r   r   )	r  r8  r   r  r   rc   r  r   r  rz   s     r3   depart_paragraphzRSTVisitor.depart_paragraph7  s    
4+;+;B+? F#gdHd;X^^=U=UV$$R(//5$$R(//7,0,<,<R,@) $ !Gr=   c                     | j                  |      }| j                  |j                         |       t        j                  j                         r   )r  r(  r1  r   rc   r9  )ri   rj   r  s      r3   visit_titlezRSTVisitor.visit_title@  s;    ##D)T[[]E2nn))++r=   c                 Z   | j                   j                  dd      }| j                  j                  t	        t        |j                         d      t        j                  ||             | j                  j                  t                      t        j                  j                         )z2Render document subtitle with ROUNDED box styling.zrestructuredtext.subtitler  r  r  r  )r  r#  r  r   r   r   r1  r   r!  r   r   rc   r9  ri   rj   r  s      r3   visit_subtitlezRSTVisitor.visit_subtitleE  sw    &&'BF&SeDKKM8&D#++]bqv wx	*nn))++r=   c                    | j                   j                  dd      }| j                  j                  t	        t        |j                         d      t        j                  ||             t        j                  j                         )Nzrestructuredtext.rubricz
italic dimr  r  r  )r  r#  r  r   r   r   r1  r   r!  r   rc   r9  rK  s      r3   visit_rubriczRSTVisitor.visit_rubricL  sa    &&'@,&WeDKKM8&D#++]bqv wxnn))++r=   c                    | j                   j                  dd      }| j                  rft        | j                  d   t              rI| j                  d   j                  t	        |j                         j                  dd      |d             y | j                  j                  t	        |j                         j                  dd      d|	             y )
Nzrestructuredtext.textz4default on default not bold not italic not underliner  r  r   r  r4  r\   r   r  )	r  r#  r  r8  r   r8  r1  ri  r   rK  s      r3   
visit_TextzRSTVisitor.visit_TextQ  s    &&#J ' 
 
4+;+;B+? FR ,,T$++-2G2Gc2RZ_eh-ijT[[]%:%:4%E2UZ [\r=   c                 >    t         j                  j                         r   r   rc   r9  rz   s     r3   visit_commentzRSTVisitor.visit_comment[      nn))++r=   c                 >    t         j                  j                         r   rS  rz   s     r3   visit_substitution_definitionz(RSTVisitor.visit_substitution_definition^  rU  r=   c                      y r   r<   rz   s     r3   visit_compoundzRSTVisitor.visit_compounda      r=   c                      y r   r<   rz   s     r3   depart_compoundzRSTVisitor.depart_compoundd  rZ  r=   c                      y r   r<   rz   s     r3   visit_containerzRSTVisitor.visit_containerg  s    r=   c                      y r   r<   rz   s     r3   depart_containerzRSTVisitor.depart_containerk  rZ  r=   c                    |j                  dg       }|rd|d    nd}| j                  j                  |d      }|j                         j	                  dd      }| j                  ||       t        j                  j                         )	zGRender a generic inline span, applying any ``classes`` as a style name.r   zrestructuredtext.inline.r   zrestructuredtext.inlinenoner  r   r  )	r   r  r#  r1  ri  _append_inline_textr   rc   r9  )ri   rj   r   r%  r  r   s         r3   visit_inlinezRSTVisitor.visit_inlinen  s    ((9b)7>&wqzl3D] 	 &&z6&B{{}$$T3/  u-nn))++r=   r  c                     | j                   rHt        | j                   d   t              r+| j                   d   j                  t        ||d             y| j                   j	                  t        ||d             y)a  Append styled *text* to the last renderable if it is a :class:`Text`, otherwise create a new one.

        When merging into an existing Text, uses ``end=" "`` to add word
        separation; standalone Text gets ``end=""`` so the caller controls
        whitespace.
        r  r  r4  r\   N)r  r8  r   r8  r   )ri   r   r  s      r3   rc  zRSTVisitor._append_inline_texty  s`     
4+;+;B+? FR ,,T$e-MN##DU$CDr=   c           	          t        | j                  | j                  | j                  | j                  | j
                  | j                  | j                        S )zDCreate a fresh sub-visitor that shares this visitor's configuration.r  r  r  r&   r.   r  )r-   r  r  r  r  r&   r.   r  r   s    r3   _make_sub_visitorzRSTVisitor._make_sub_visitor  sH    MMLL"44((,,!22
 	
r=   r   c                 j    | j                         }|D ]  }|j                  |        |j                  S )zNRender admonition body children using a sub-visitor to preserve inline markup.rh  	walkaboutr  )ri   r   sub_visitorr;  s       r3   _render_admonition_bodyz"RSTVisitor._render_admonition_body  s2    ,,.EOOK( &&&r=   r;  c                 \    | j                         }|j                  |       |j                  S )a  Render a single child node using a sub-visitor to preserve inline markup.

        This is used for list items and other contexts where we want to preserve
        bold, italic, links, inline code, and other inline markup instead of
        stripping to plain text via astext().
        rj  )ri   r;  rl  s      r3   _render_child_inlinezRSTVisitor._render_child_inline  s*     ,,.$&&&r=   r  glyphr%  r&  body_childrenc                    | j                   j                  ||      }| j                  dk(  r| j                  ||||       y| j	                  |||       y)u  Render an admonition in either ``panel`` or ``compact`` style.

        ``title`` is the bare label (e.g. ``"Note"``) — used directly as the
        panel title in panel mode and as the inline prefix label (followed by
        ``": "``) in compact mode.
        r  r  )r  rp  r  rq  )panel_titler  rq  N)r  r#  r  _emit_compact_admonition_emit_panel_admonition)ri   r  rp  r%  r&  rq  r  s          r3   _emit_admonitionzRSTVisitor._emit_admonition  s_     &&z=&I  I-))U%_l)m''!+ ( r=   rs  c                    | j                  |      }| j                  j                  t        |rt	        | nd|||             y )Nr\   r  r  r  )rm  r  r   r   r   )ri   rs  r  rq  r1  s        r3   ru  z!RSTVisitor._emit_panel_admonition  s=    ++M:$%,Bk]bc	
r=   c                p    t        | | d|d      }| j                  |      }| j                  ||       y )Nr-  r\   r4  )r   rm  _prepend_styled_prefix)ri   r  rp  r  rq  prefixr1  s          r3   rt  z#RSTVisitor._emit_compact_admonition  s;    wb)B?++M:##FD1r=   tagc                 f   | j                   }|w| j                  rk| j                  d   |u rZ|j                          t        j                  |t        d      |d      }|j                  d       || j                  d<   || _         y|j                  d       | j                  j                  |       y)a  Inline ``tag`` onto the trailing paragraph, space-separated.

        Used by compact-mode version directives so that short tags like
        ``[Added in v0.47]`` share a line with the paragraph they follow,
        instead of being forced onto their own line by ``depart_paragraph``'s
        trailing ``"\n\n"``. Only merges when ``self.renderables[-1]`` is the
        ``Text`` most recently emitted by ``depart_paragraph`` in this
        visitor's scope (tracked via ``_last_paragraph_text``); otherwise
        falls back to emitting ``tag`` as its own paragraph. This guard
        prevents the tag from leaking onto a preceding admonition's prefix
        line or onto an admonition body paragraph appended via
        ``_prepend_styled_prefix``.
        Nr  r  r\   r   r   )r  r  rstripr   assembler   )ri   r|  prevmergeds       r3    _append_inline_to_prev_paragraphz+RSTVisitor._append_inline_to_prev_paragraph  s     (( 0 0T5E5Eb5IT5QKKM]]4cCR@FMM&!#)DR  )/D%JJv##C(r=   r{  r1  c                    |s-|j                  d       | j                  j                  |       y|d   }t        |t              r\t        j                  |||j
                        }| j                  j                  |       | j                  j                  |dd        y| j                  j                  |       | j                  j                  |       y)u  Append ``prefix`` followed by ``body`` to ``self.renderables``.

        When the first body renderable is a :class:`Text` (the common case —
        a paragraph), the prefix is merged into it via :meth:`Text.assemble`
        so the prefix and first paragraph share a wrapped line. Otherwise
        the prefix is emitted on its own line above the body. ``prefix`` is
        expected to have ``end=""`` so paragraph spacing is governed by the
        ``"\n\n"`` already baked into paragraph Texts by ``depart_paragraph``.
        r   Nr   r~  rW   )r   r  r8  r   r  r   r   )ri   r{  r1  firstr  s        r3   rz  z!RSTVisitor._prepend_styled_prefix  s     MM&!##F+QeT"]]65eii@F##F+##DH-##F+##D)r=   type_r[   c                    ddddddd}d| d	| d
| d
| d| d| d}d| d| d| d| d| d| d}dddd}|j                  |d      \  }}	| j                  j                  ||	      }
| j                  dk(  r[|j                  || d|       }| j	                  |      }| j
                  j                  t        |rt        | nd||
|
             y |j                  || d|       }|j                  |d      }| j	                  |      }|s&t        | d| d|
d      }| j                  |       y t        |      dk(  rt        |d   t              rx|d   j                         }|j                          d|j                  vrGt        j                   t        | d| d |
!      |t        d|
!      d"      }| j                  |       y t        | | d |
d      }| j#                  ||       y )#N)zrestructuredtext.versionadded
bold green)zrestructuredtext.versionchanged	bold cyan)zrestructuredtext.deprecatedbold yellow)z#restructuredtext.deprecated_removedbold red)restructuredtext.availability	bold blue) restructuredtext.soft_deprecatedbold bright_yellow)r  r  r[  r@  rP   r  zNew in version zChanged in version zDeprecated since version zAvailable since version zSoft Deprecated since version z
Added in vzChanged in vzDeprecated in vzAvailable in vzSoft Deprecated in v   ⚠    ✖ )r[  r@  r  r  r  r  r\   rx  []r4  rW   r   r   r-  r  r~  )r   r  r#  r  rm  r  r   r   r   r   r  r_   r8  copyr  plainr  rz  )ri   r  r[   rq  	style_mappanel_title_mapshort_title_map	glyph_mapr%  r&  r  rs  r1  short_titlerp  r|  inner	bracketedr{  s                      r3   _emit_version_directivez"RSTVisitor._emit_version_directive  sn   KNH"UJY
	 .gY7 3G9=5gY?$=gY"G6wi@!?yI
 )	2 ,WI6+G95$3G9"=,WI6!5gY?
 !"(%
	
 %.MM%9h$i!
M&&z=&I  G+)--eway5IJK//>D##deTl+Uafg %))%E7!G91EFeR(++M:%+a02FC11#6 t9>ja$7GLLNELLNU[[( MME7!K=35AE*		 55i@}B/u"E##FD1r=   c                 Z   |j                   r^t        |j                   d   t        j                  j                        r-|j                   d   j                         }|j                   dd  }nd}|j                   }| j                  |ddd|       t        j                  j                         )Nr   rW   
Admonitionr\   zrestructuredtext.admonition
bold whiter  rp  r%  r&  rq  )r   r8  r   rc   r  r1  rv  r9  )ri   rj   
user_titlerq  s       r3   visit_admonitionzRSTVisitor.visit_admonitionD  s    ==Za(8(..:N:NOq)002J MM!"-M%J MMM4&' 	 	
 nn))++r=   c                 ~    | j                  dddd|j                         t        j                  j	                         )N	Attentionr  zrestructuredtext.attentionzbold black on yellowr  rv  r   r   rc   r9  rz   s     r3   visit_attentionzRSTVisitor.visit_attentionU  s=    30-- 	 	
 nn))++r=   c                 ~    | j                  dddd|j                         t        j                  j	                         )NCautionr  zrestructuredtext.cautionredr  r  rz   s     r3   visit_cautionzRSTVisitor.visit_caution_  s=    1-- 	 	
 nn))++r=   c                 ~    | j                  dddd|j                         t        j                  j	                         )NDANGERr  zrestructuredtext.dangerzbold white on redr  r  rz   s     r3   visit_dangerzRSTVisitor.visit_dangeri  s=    0--- 	 	
 nn))++r=   c                 ~    | j                  dddd|j                         t        j                  j	                         )NERRORr  zrestructuredtext.errorr  r  r  rz   s     r3   visit_errorzRSTVisitor.visit_errors  s=    /$-- 	 	
 nn))++r=   c                 ~    | j                  dddd|j                         t        j                  j	                         )NHintr\   zrestructuredtext.hintyellowr  r  rz   s     r3   
visit_hintzRSTVisitor.visit_hint}  s=    ."-- 	 	
 nn))++r=   c                 ~    | j                  dddd|j                         t        j                  j	                         )N	IMPORTANTr\   zrestructuredtext.importantr  r  r  rz   s     r3   visit_importantzRSTVisitor.visit_important  s=    3%-- 	 	
 nn))++r=   c                 ~    | j                  dddd|j                         t        j                  j	                         )NNoter\   zrestructuredtext.noter  r  r  rz   s     r3   
visit_notezRSTVisitor.visit_note  s=    .&-- 	 	
 nn))++r=   c                 ~    | j                  dddd|j                         t        j                  j	                         )NTipr\   zrestructuredtext.tipr  r  r  rz   s     r3   	visit_tipzRSTVisitor.visit_tip  s=    -&-- 	 	
 nn))++r=   c                 ~    | j                  dddd|j                         t        j                  j	                         )NWarningr  zrestructuredtext.warningr  r  r  rz   s     r3   visit_warningzRSTVisitor.visit_warning  s=    1'-- 	 	
 nn))++r=   c                     |j                  dd      }|j                  dd      }| j                  |||j                         t        j                  j                         )NrZ   r  r[   r\   )r   r  r   r   rc   r9  )ri   rj   r  r[   s       r3   visit_versionmodifiedz RSTVisitor.visit_versionmodified  sK    0((9b)$$UGT]]Cnn))++r=   c                      y r   r<   rz   s     r3   depart_versionmodifiedz!RSTVisitor.depart_versionmodified  rZ  r=   c                 ~    | j                  dddd|j                         t        j                  j	                         )NzSee Alsor\   zrestructuredtext.seealsor  r  r  rz   s     r3   visit_seealsozRSTVisitor.visit_seealso  s=    1&-- 	 	
 nn))++r=   c                      y r   r<   rz   s     r3   depart_seealsozRSTVisitor.depart_seealso  rZ  r=   c                     |j                  dd      }|r| j                  d||j                         n | j                  dddd|j                         t        j
                  j                         )Nr[   r\   rP   Availabilityr  r  r  r   r  r   rv  r   rc   r9  ri   rj   r[   s      r3   visit_availabilityzRSTVisitor.visit_availability  sh    ((9b)(($--P !!$:)"mm "  nn))++r=   c                      y r   r<   rz   s     r3   depart_availabilityzRSTVisitor.depart_availability  rZ  r=   c                     |j                  dd      }|r| j                  d||j                         n | j                  dddd|j                         t        j
                  j                         )	Nr[   r\   r  zSoft Deprecatedr  r  r  r  r  r  s      r3   visit_soft_deprecatedz RSTVisitor.visit_soft_deprecated  sg    ((9b)(():GT]]S!!'=2"mm "  nn))++r=   c                      y r   r<   rz   s     r3   depart_soft_deprecatedz!RSTVisitor.depart_soft_deprecated  rZ  r=   c                 ~    | j                  dddd|j                         t        j                  j	                         )NzImplementation Detailr\   zrestructuredtext.impl_detailbold magentar  r  rz   s     r3   visit_impl_detailzRSTVisitor.visit_impl_detail  s=    )5(-- 	 	
 nn))++r=   c                      y r   r<   rz   s     r3   depart_impl_detailzRSTVisitor.depart_impl_detail  rZ  r=   c                     | j                   j                  dd      }|j                  dd      }| j                  j	                  t        t        ||      d             t        j                  j                         )Nzrestructuredtext.centeredr  r  r   r\   r  r  )
r  r#  r   r  r   r   r   r   rc   r9  ri   rj   r  r   s       r3   visit_centered_blockzRSTVisitor.visit_centered_block  sa    &&'BF&Sxx#d4u&=x HInn))++r=   c                      y r   r<   rz   s     r3   depart_centered_blockz RSTVisitor.depart_centered_block  rZ  r=   
field_namec                    | j                         }|j                         }|dv ry|dk(  rydD ]8  }|dz   }|j                  |      sd|t        |      d j                         fc S  |j                  d	      rd
|dd j                         fS dD ]8  }|dz   }|j                  |      sd|t        |      d j                         fc S  d|fS )zClassify a Python-domain field-list name.

        Returns a tuple ``(kind, arg)`` where ``kind`` is one of:
        ``param``, ``type``, ``returns``, ``rtype``, ``raises``, ``unknown``.
        )returnsr/   )r  r\   rtype)r  r\   )param	parameterargr   r  r  Nztype rZ      )raisesraiseexceptrA  r  unknown)r   lowerr   r_   )r  r]   loweredr{  rE  s        r3   _parse_py_field_namezRSTVisitor._parse_py_field_name  s     !**,++ g?FSLE!!%(SZ[ 1 7 7 999 @
 g&48>>+++@FSLE!!%(c%jk!2!8!8!::: A
 $r=   field_list_nodec                    i }g }d}d}g }g }|j                   D ];  }t        |j                         dk  r|j                   d   j                         j                         }	|j                   d   j                         j	                  dd      j                         }
| j                  |	      \  }}|dk(  r,|xs d}||vrddd	||<   |j                  |       |
||   d
<   |dk(  r,|xs d}||vrddd	||<   |j                  |       |
||   d<   |dk(  r|
}|dk(  r|
}|dk(  r|j                  |xs d|
f       )|j                  |	|
f       > |s|s|s|s|s| j                  |g      S | j                  j                  dd      }| j                  j                  dd      }| j                  j                  dd      }| j                  j                  dd      }g }|r|j                  t        d|             |D ]  }||   }t        d      }|j                  ||       |d   r'|j                  d       |j                  |d   |       |j                  |       |d
   si|j                  t        d|d
                  |j                  t                      |s|rf|j                  t        d|             |r
|r| d| }n|xs |}|j                  t        d| |             |j                  t                      |r|j                  t        d|             |D ]X  \  }}t        d      }|j                  ||       |r"|j                  d       |j                  |       |j                  |       Z |j                  t                      |r|j                  t        d|             |D ]X  \  }}t        d      }|j                  ||       |r"|j                  d       |j                  |       |j                  |       Z |j                  t                      |S ) z8Render a Sphinx-style Python field list as API sections.r\   r   r   rW   r   r  r  z	<unnamed>)rZ   descr  rZ   r  r  r  r   restructuredtext.py_desc.sectionr  r  #restructuredtext.py_desc.param_name#restructuredtext.py_desc.param_typecyanz restructuredtext.py_desc.returnsrb  
Parametersr  r  r-  r  ReturnsRaisesOther)r   r_   r1  r   ri  r  r   rm  r  r#  r   r   )ri   r  paramsparam_orderreturns_descreturns_typeraises_itemsunknown_itemsfieldraw_name	raw_valuekindr  
param_namesection_styleparam_name_styleparam_type_stylereturn_styler  r  r   returns_textexc_nameexc_descr7  r   s                             r3   _render_py_field_listz RSTVisitor._render_py_field_list	  s$   $--E5>>"Q&~~a(//1779Hq)002::4EKKMI11(;ID#w /K
V+24b)AF:&&&z2-6z"6* /K
V+24b)AF:&&&z2-6z"6*"((!##S%7K$CD$$h	%:;5 .8 |||}//0ABB../Q[a.b<<112Wag1h<<112Wag1h||--.PZ`-atLFG)
z*DzJ.>?=KK%KKf5EKF""4(=&&td5=/,B'CD * wy)<tI]CD".r,@+;|tb$7|LMwy)tHMBC&2"(DzH,<=KK%KK)""4( '3 wy)tG=AB+
UDzC'78KK%KK&""4( , wy)r=   c                    |j                  di       xs i }t        |j                  dd      xs d      j                         j                         }|sg S dddddd	d
d}d}g }|j	                         D ];  \  }}|j                  |      }	|	|	dk7  s |j                  |t        |	      f       = g }
|D ](  }||v s|
j                  |j                  dd             * |
r"|j                  ddj                  |
      f       |sg S | j                  j                  dd      }| j                  j                  dd      }| j                  j                  dd      }|dk(  rt        d|      g}|D ]X  \  }}t        d      }|j                  ||       |j                  d       |j                  ||       |j                  |       Z |j                  t                      |S t        ddd      }|D ]-  \  }}|j                  t        ||      t        ||             / t        d|      |t               gS )z9Render ``py:*`` directive options as structured metadata.r   r_  r\   Valuer   Module
Annotation	CanonicalPlatformSynopsis)r   rZ   rQ  rR  rX  rY  rZ  )rS  rT  rU  rV  rW  r[  rP  rO  r   r  Flagsz, r  r  r  z"restructuredtext.py_desc.meta_name#restructuredtext.py_desc.meta_valuerb  r=  Detailsr  r  r-  PropertyT
show_lines)r   r  r   r  itemsr   ri  r   r  r#  r   r   r   add_row)ri   rj   r   r_  	label_map
flag_orderr  r7  r   r   flagsr  meta_name_stylemeta_value_styler  property_nameproperty_valuer   r  s                      r3   _render_py_desc_optionsz"RSTVisitor._render_py_desc_options{	  s7   ((9b)/Rdhhy"-34::<BBDI &$""
	


 #//+JCKK$E Ub[UCJ/0 ,
 Cg~S[[c23  KK$))E"234I../Q[a.b,,001U_e0f<<112Wag1hf&*9M&J%KK15-~DzMAD!N2BC""4( 26 wy)j'd;-1)M>MM$}ODd>aqFrs .2 Ym4eWYGGr=   r_  r^  c                    |xs dj                         j                         }|xs dj                         j                         }|sd}d| d| }|dk(  r&|dv rd}n|dv rd	}n|d
v rd}n|dv rd}nx|dv rd}nqd}nn|dk(  r|dv rd}nb|dv rd}n[|dv rd}nT|dv rd	}nMd}nJ|dk(  r&|dv rd}n>|dv rd}n7|dv rd}n0|dv rd	}n)|dv rd}n"d}n|dk(  r|dv rd}n|dv rd}n|dv rd}nd}nd}| j                  j                  ||      S )z3Return panel style based on object type and domain.r]  r\   r<  restructuredtext.z_desc.>   r   rA  r  >   r7  rT  rU  abstractmethodcoroutinemethodr  >   r  	decoratorcoroutinefunctiondecoratorfunctionr  >   r=  rD  rF  propertyrC  r:  r  >   rZ   rQ  opcodetypevardescribe	typealiasr  r  c>   rZ   unionstruct>   macror  >   enum
enumerator>   rB  membercpp>   rZ   r   r0  r1  >   conceptr  >   aliasjs>   r   rQ  >   r7  r  >   r=  r:  r  )r   r  r  r#  )ri   r_  r^  normalized_domain
normalizedr%  r&  s          r3   _py_desc_panel_stylezRSTVisitor._py_desc_panel_style	  s   #^t224::<m**,224
!J():(;6*N
$33 ,mm +bb .`` -__ + ,#%88 ,44 .55 -00 + ,%'AA ,66 .55 -00 +y( + ,$&00 ,55 .44 - ,(M||%%j-%HHr=   	signaturec                    t        |      }|s|S t        h d      }t        h d      }|xs dj                         j                         }|xs dj                         j                         }| j                  j                  d| dd      }	| j                  j                  d| d	d
      }
| j                  j                  d| dd      }| j                  j                  d| dd      }| j                  j                  d| dd      }|dk(  r|n||z  }ddj                  t        d |D                    z  }t        j                  ||      D ]1  }|j                  |	|j                         |j                                3 t        j                  d|      D ]1  }|j                  ||j                         |j                                3 t        j                  d|      D ]1  }|j                  ||j                         |j                                3 t        j                  d|      D ]3  }|j                  ||j                  d      |j                  d             5 |dk(  rKt        j                  d|      }|1|j                  |
|j                  d      |j                  d             |S |dk(  rTd}t        j                  d|      D ]  }|} |1|j                  |
|j                  d      |j                  d             |S |dv r|t        j                  d|      }|b|j                  d      j                  d      d    }|j                  d      t!        |      z
  }|j                  |
||j                  d             |S |d!v rhd}t        j                  d"|      D ]  }|j                  d      }||vs|} |1|j                  |
|j                  d      |j                  d             |S )#z<Apply custom syntax highlighting to C/C++ domain signatures.>   r   autocharr3  longvoid_Boolr>  floatshortr0  doubleexterninlinesignedstaticr1  _Atomictypedef_Complexregisterrestrictunsignedvolatile
_Imaginary>,   r   r?  boolr@  r3  rA  rB  r   r>  rW  rD  rE  r0  usingrF  exportfriendrH  publicrI  rJ  r1  char8_tr7  mutablenullptrprivatevirtualwchar_tchar16_tchar32_tdecltyper  noexceptoverridetemplatetypenamerP  rQ  	consteval	constexpr	constinit	namespace	protectedr/  r\   r$  z_desc.signature.typebright_cyanr  z_desc.signature.namer  z_desc.signature.namespacemagentaz_desc.signature.operatorr  z_desc.signature.numbergreen
\b(?:%s)\b|c              3   F   K   | ]  }t        j                  |        y wr   r   escaper   keywords     r3   r   z8RSTVisitor._highlight_c_cpp_signature.<locals>.<genexpr>
  s     9e\dQX"))G:L\d   !\b\d+(?:\.\d+)?\bz::|->|=z\b([A-Za-z_][A-Za-z0-9_]*)::rW   r8  z \b([A-Za-z_][A-Za-z0-9_]*)\b\s*=Nr  z#(~?[A-Za-z_][A-Za-z0-9_]*)\s*(?=\()>   r3  rZ   r   r0  r1  r7  z9\b([A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*)\bz::r  >   rB  r5  r4  z\b([A-Za-z_][A-Za-z0-9_]*)\b)r   	frozensetr   r  r  r#  r   r.  r   finditerr@  r   r   r`  ra  r   r_   )ri   r^  r_  r=  rendered
c_keywordscpp_keywordsr:  normalized_objtype
type_style
name_stylenamespace_styleoperator_stylenumber_stylekeywordskeyword_patternmatchalias_match
name_match
head_matchleaf
leaf_startrightmost_identifierrE  s                           r3   _highlight_c_cpp_signaturez%RSTVisitor._highlight_c_cpp_signature	  s   	?O  
 
 ! "
  $]s11399;%m224::<\\++.?@Q?RRf,gq~+
\\++.?@Q?RRf,gqw+x
,,003DEVDWWp1q  |E0  F//2CDUCVVn0o  zG/  H||--0ABSATTj.ku|-}!2c!9:
\@Y'#((69e\d9e3e*ff[[)<EZ		D = [[!5yAE\5;;=%))+F B [[Y7E^U[[]EIIKH 8 [[!@)LE_ekk!neiilK M ())$GSK&  [->->q-A;??STCUV0 /  :-J %KYW"
 X%  Z-=-=a-@*..QRBST    #ZZ#_ajkJ%!''*006r:'^^A.T:
  Z9JK   #BB#' %DiPA(+0( Q $/  -A-G-G-JL`LdLdefLghr=   c                 l   t        |      }|s|S t        h d      }|xs dj                         j                         }| j                  j                  dd      }| j                  j                  dd      }| j                  j                  dd	      }| j                  j                  d
d      }	| j                  j                  dd      }
ddj                  t        d |D                    z  }t        j                  ||      D ]1  }|j                  ||j                         |j                                3 t        j                  d|      D ]1  }|j                  |
|j                         |j                                3 t        j                  d|      D ]1  }|j                  |	|j                         |j                                3 |dv rTd}t        j                  d|      D ]  }|} |1|j                  ||j                  d      |j                  d             |S |dk(  rKt        j                  d|      }|1|j                  ||j                  d      |j                  d             |S |dk(  rt        j                  d|      D ]3  }|j                  ||j                  d      |j                  d             5 t        j                  d|      }|1|j                  ||j                  d      |j                  d             |S |dk(  rKt        j                  d|      }|1|j                  ||j                  d      |j                  d             |S |dk(  rIt        j                  d|      }|1|j                  ||j                  d      |j                  d             |S )zAApply custom syntax highlighting to JavaScript-domain signatures.>'   doifinforletnewtryrB  caseelsenullthistruerB  withrS  awaitbreakcatchr   r>  falser  throwwhileyielddeleterU  importr/   switchtypeofr  extendsfinallycontinuedebuggerr  
instanceofr\   z*restructuredtext.js_desc.signature.keywordrj  r  z'restructuredtext.js_desc.signature.namer  z,restructuredtext.js_desc.signature.namespacerk  z+restructuredtext.js_desc.signature.operatorr  z)restructuredtext.js_desc.signature.numberrl  rm  rn  c              3   F   K   | ]  }t        j                  |        y wr   rp  rr  s     r3   r   z5RSTVisitor._highlight_js_signature.<locals>.<genexpr>L
  s     9h\gQX"))G:L\grt  ru  z=>|=|\.>   r7  r  Nz#([A-Za-z_$][A-Za-z0-9_$]*)\s*(?=\()rW   r   z\b([A-Za-z_$][A-Za-z0-9_$]*)\brQ  z\b([A-Za-z_$][A-Za-z0-9_$]*)\.z\b([A-Za-z_$][A-Za-z0-9_$]*)\b$r:  z([A-Za-z_$][A-Za-z0-9_$]*)\s*$r=  )r   rv  r   r  r  r#  r   r.  r   rw  r@  r   r   r`  )ri   r_  r=  rx  js_keywordsr{  keyword_styler}  r~  r  r  r  r  r  class_match
leaf_matchattribute_match
data_matchs                     r3   _highlight_js_signaturez"RSTVisitor._highlight_js_signature7
  sZ   	?O !
  &m224::<../[er.s\\++,U_e+f
,,001_ir0s//0]gt/u||--.Ycj-k'#((69h\g9h3h*ii[[)<E]EKKM599;G = [[!5yAE\5;;=%))+F B [[Y7E^U[[]EIIKH 8 !77J%KYW"
 X%  Z-=-=a-@*..QRBST( '  7*))$EyQK&  [->->q-A;??STCUV    8+%F	R  %++a.%))A,O S#EyQJ%  Z-=-=a-@*..QRBST   ;. ii(I9UO*  _-B-B1-EGZGZ[\G]^   6)#DiPJ%  Z-=-=a-@*..QRBSTr=   c                 	   t        |      }|s|S | j                  j                  dd      }| j                  j                  dd      }| j                  j                  dd      }| j                  j                  dd	      }| j                  j                  d
d      }| j                  j                  dd      }	|dv rRd}
t        j                  d|      D ]  }|}
 |
1|j                  ||
j                  d      |
j                  d             t        j                  d|      D ]3  }|j                  ||j                  d      |j                  d             5 t        j                  d|      D ]1  }|j                  ||j                         |j                                3 t        j                  d|      D ]!  }|j                         }t        |      }||k  r1||   j                         r|dz  }||k  r||   j                         rd}|}||k  r4||   }|dv r|dz  }n|dv r|dkD  r|dz  }nn|dk(  r|dv rn|dz  }||k  r4|}|}||k  r1||   j                         r|dz  }||k  r||   j                         r||kD  r7||dz
     j                         r!|dz  }||kD  r||dz
     j                         r!||kD  s|j                  |||       $ t        j                  d|      D ].  }|j                         }t        |      }||k  r1||   j                         r|dz  }||k  r||   j                         r||k\  s||   dv rbd}|}||k  r4||   }|dv r|dz  }n|dv r|dkD  r|dz  }nn|dk(  r|dv rn|dz  }||k  r4|}|}||k  r1||   j                         r|dz  }||k  r||   j                         r||kD  r7||dz
     j                         r!|dz  }||kD  r||dz
     j                         r!||kD  s|j                  |||       1 t        j                  d|      D ]1  }|j                  ||j                         |j                                3 t        j                  d|      D ]1  }|j                  |	|j                         |j                                3 |S )z=Apply custom syntax highlighting to Python-domain signatures.z/restructuredtext.py_desc.signature.self_and_clsbright_magentar  z(restructuredtext.py_desc.signature.arrowr  z'restructuredtext.py_desc.signature.typer  z'restructuredtext.py_desc.signature.namer  z'restructuredtext.py_desc.signature.boolrk  z&restructuredtext.py_desc.signature.intrl  >	   r7  r  r'  rT  rU  r%  r&  r(  r)  Nz!([A-Za-z_][A-Za-z0-9_]*)\s*(?=\()rW   z\b(self|cls)\bz->r   z([{z)]}z,)=z:\s*z,)z\b(?:True|False)\bz\b\d+\b)
r   r  r#  r   rw  r@  r   r   r_   isspace)ri   r_  r=  rx  self_and_cls_stylearrow_styler|  r}  
bool_style	int_styler  r  arrow_matchisignature_lengthdepthjr  
type_starttype_endcolon_matchs                        r3   _highlight_py_signaturez"RSTVisitor._highlight_py_signatureq
  s   	?O!\\334eo3  All,,-Wan,o\\++,U_e+f
\\++,U_e+f
\\++,U_h+i
LL**+S]d*e	 
 

 J %I9U"
 V%  Z-=-=a-@*..QRBST[[!2I>E/Q1N ? [[	2E[%++-E 3
 ;;ui8K!A"9~&&9Q<+?+?+AQ &&9Q<+?+?+A EA&&q\;QJE5[qy
 A:"+Q && JHx'Ij,A,I,I,Ka
 x'Ij,A,I,I,KZ'Ihl,C,K,K,MA Z'Ihl,C,K,K,M*$  ZB? 9F ;;w	:K!A"9~&&9Q<+?+?+AQ &&9Q<+?+?+A $$	!(<EA&&q\;QJE5[qy
A:"+Q && JHx'Ij,A,I,I,Ka
 x'Ij,A,I,I,KZ'Ihl,C,K,K,MA Z'Ihl,C,K,K,M*$  ZB? ;B [[!6	BEZ		D C [[Y7EYuyy{C 8 r=   c                    | j                   j                  dd      }t        d| d|      }|xs dj                         j	                         }|dv r%|j                  | j                  |||	             |S |d
k(  r$|j                  | j                  ||             |S |j                  | j                  ||             |S )z?Render a styled panel title for Python/C/C++/JS domain objects.z%restructuredtext.py_desc.title_prefixr  r  r  z] r  r]  >   r/  r6  r^  r_  r=  r9  )r_  r=  )	r  r#  r   r   r  r8  r  r  r  )ri   r^  r_  r=  prefix_styler  r:  s          r3   _render_py_desc_titlez RSTVisitor._render_py_desc_title
  s    ||--.U_e-fq	_L9#^t224::<,d==VU\hq=rs
 	 $&d::7V_:`a  d::7V_:`ar=   c                     | j                         }d|v r&|j                  d      \  }}}|j                         }n|}d}|j                         }|r|j                  dd      d   nd}|xs d}||fS )z=Split ``name[: type]`` style signatures into name/type parts.r   r\   .rW   r  z<attribute>)r   ra  rsplit)	r=  cleaned	name_partrc  	type_partparsed_typenormalized_name	leaf_nameparsed_names	            r3   _split_py_attribute_signaturez(RSTVisitor._split_py_attribute_signature
  s     //#'>&-&7&7&<#Iq)#//+KIK#//+ ;JO**3226r	0=K''r=   
class_nodec                    g }g }h d}|j                   D ]e  }t        |t              r@|j                  dd      j	                         |v r|j                  di       xs i }| j                  |j                  dd            \  }}|j                  d      }	|	dv r|}	|	t        |	      j                         nd}
|
rg }|j                   D ]i  }t        |t        j                  j                        r(|j                         j                  dd	      j                         }|sY|j                  |       k |j                  ||
d	j                  |      j                         f       U|j                  |       h ||fS )
zHCollect typed ``py:attribute`` style children under a class description.>   r=  r*  rC  r:  r_  r\   r   r`  rZ   )Nr\   r   r  )r   r8  rE   r   r  r  r  r   r   rc   
field_listr1  ri  r   r   )ri   r  r  remaining_childrenattribute_typesr;  child_options	attr_namesig_typeraw_type	attr_typedescription_parts
grandchildpieces                 r3   _collect_typed_class_attributesz*RSTVisitor._collect_typed_class_attributes
  sc   13
8:G((E%)eii	2.F.L.L.NRa.a %		)R 8 >B&*&H&HSXZ\I]&^#	8(,,V4z)'H5=5ICM//1r	(*%&+nn
 &j(..2K2KL$ * 1 1 3 ; ;D# F L L N -44U; '5 %%y)SXXFW=X=^=^=`&ab%%e,) ), ---r=   r  c                 R   | j                   j                  dd      }| j                   j                  dd      }| j                   j                  dd      }| j                   j                  dd      }t        d	|
      g}|D ]  \  }}}	t        ||
      }
|
j                  d       |
j                  ||
       t        d      }|j	                  |
       |j                  |       |	sh|j                  t        d|	 |
              |j                  t                      |S )z2Render typed class attributes as an indented list.r  r  r  r  r  r  r  rb  
Attributesr  r-  r  r  )r  r#  r   r   r8  r   )ri   r  r  r}  r|  value_styler  r  r  attr_description	attr_textr   s               r3    _render_py_class_attribute_tablez+RSTVisitor._render_py_class_attribute_table  s   ../Q[a.b\\++,Q[a+b
\\++,Q[a+b
ll,,-R\b,c"&|="I!J6:2Iy"2Yj9IT"Yj9:DY't$""4$/?.@(A#UV 7; 	79%r=   c                 $   |j                  dd      }|j                  dd      }|j                  dd      }| j                  ||      }| j                  |||      }g }|dk(  r;|d	v r7| j                  |      \  }}	|r6|j	                  | j                  |             nt        |j                        }	|j	                  | j                  |             |	D ]h  }
t        |
t        j                  j                        r!|j	                  | j                  |
             H|j	                  | j                  |
g             j | j                  j!                  t#        |rt%        | nd|||
             t        j                  j'                         )Nr^  r]  r_  r<  r`  r\   )r^  r  >   r   rA  rx  )r   r<  r  r  r   r  r  r   r"  r8  r   rc   r  r  rm  r  r   r   r   r9  )ri   rj   r^  r_  r`  r  r  r1  typed_attributesrq  r;  s              r3   visit_py_desczRSTVisitor.visit_py_desc0  s^   (D)((9h/hhub!))'&)A**&'UX*Y T>g)??.2.R.RSW.X+mDAABRST /MD0067"E%!:!:;D66u=>D88%AB	 #
 	$%,BeE3	
 nn))++r=   c                      y r   r<   rz   s     r3   depart_py_desczRSTVisitor.depart_py_descL  rZ  r=   c           	         | j                   j                  dd      }|j                  dd      }t        |j                  dg             }|j                  dd      }|j                  d	d
      }|j                  dd
      }|j                  dd      }| j                   j                  dd      }	|r|j	                          g }
g }|D ]G  }|s|j                  d      rLd|v rH|d |j                  d       j                         }||j                  d      dz   d j                         }n|}|}|j                  d      }|dkD  r||k\  r|rH|t        |      k\  r%|j                  dg|dz   t        |      z
  z         n|d |dz    }||xx   dz  cc<   |r4|dk(  s||k  r*dj                  d |d |dz    D              }d|z  | dz   }n%g d}d|z  |t        |t        |      dz
           z   }|
j                  t        ||z   |	             J | j                  j                  t!        |
rt#        |
 nd|||             t$        j&                  j)                         )Nzrestructuredtext.toctreer  r  r   r   r   r   r   r   Fr   r   #restructuredtext.bullet_list_markerr  r,  r+  rW   r  ru  r  c              3   2   K   | ]  }t        |        y wr   )r  )r   r   s     r3   r   z0RSTVisitor.visit_toctree_stub.<locals>.<genexpr>x  s     'U@TuE
@T   r  z. u    • u    ∘ u    ▪ r  r\   rx  )r  r#  r   r  reverser-  r.  r   countr_   r   r   r"  r   r   r  r   r   r   rc   r9  )ri   rj   r  r   r   r   r   r   r   marker_styler  countersr  r  docnamer  number_labelmarkermarkerss                      r3   visit_toctree_stubzRSTVisitor.visit_toctree_stubO  s`   &&'A;&W((9j1txx	2./88J*88J688$6>*a0||--.S]j-kOO E~~c"se| 1S!1288:C 01 4R8>>@
 MM#&E!| 1CM)OOQC519s8}+D$EF'
3H1$^q%8EN<R"xx'U%RS)@T'UU<.(;;5E3w<!;K0L(MMtFW$4LIJ? B 	%%"GE3	
 nn))++r=   c                      y r   r<   rz   s     r3   depart_toctree_stubzRSTVisitor.depart_toctree_stub  rZ  r=   c           
      6   | j                   j                  dd      }|j                  dd      }|j                  dd       }||j                  d      xs | j                  }|j                  d| j                        }| j
                  j                  t        t        ||| j                  |	      ||t        j                  
             n0| j
                  j                  t        t        |      d|             t        j                  j                         )Nzrestructuredtext.literalincludegrey58r  r   z<unknown file>re   r   r}   themeline_numbers)r  r  r   r  r  r  )r  r#  r   r.   r  r  r   r   r   r  r   SQUAREr   r   rc   r9  )ri   rj   r  r   re   r   r}   s          r3   visit_literalinclude_stubz$RSTVisitor.visit_literalinclude_stub  s    &&'HRZ&[88J(89((9d+ xx
+At/A/AHhhy$*@*@AG##7HDOORYZ"!&

	 ##d8n,<5Q nn))++r=   c                      y r   r<   rz   s     r3   depart_literalinclude_stubz%RSTVisitor.depart_literalinclude_stub  rZ  r=   c                    | j                   j                  dd      }| j                  |j                        }| j                  j                  t        |rt        | ndd||             t        j                  j                         )Nzrestructuredtext.glossaryr  r  r\   Glossaryrx  )r  r#  rm  r   r  r   r   r   r   rc   r9  )ri   rj   r  r1  s       r3   visit_glossary_blockzRSTVisitor.visit_glossary_block  sp    &&'BF&S++DMM:$%,Bj\ab	
 nn))++r=   c                      y r   r<   rz   s     r3   depart_glossary_blockz RSTVisitor.depart_glossary_block  rZ  r=   c                    |j                  dd      xs d}g }|j                  D ]  }t        |t        j                  j
                        s(|j                  D ]t  }| j                  |j                        }|s|j                  t        d             ;t        |      dk(  r|j                  |d          ^|j                  t        |        v  |st        j                  j                         t        ddd	      }t        |      D ]  }|j                  d        t        dt        |      |      D ]Y  }	t        ||	|	|z          }
t        |
      |k  r)|
j                  t        d             t        |
      |k  r) |j                   |
  [ | j"                  j                  |       t        j                  j                         )
z8Render an hlist node as a borderless multi-column table.r   r   r\   rW   r   FN)r   rW   )show_headerr   padding)r   r   r8  r   rc   r  rm  r   r   r_   r   r9  r   r   
add_columnr  r  r  )ri   rj   r   r  r;  r4  item_renderableshlist_tablerc  	row_startr  s              r3   visit_hlist_blockzRSTVisitor.visit_hlist_block  s|   ((9a(-A ]]E%!;!;<!NND'+'C'CDMM'R$+T"X.-.!3%5a%89U,<%=> + # ..--//4HwA""2&   q#e*g6IuYy7':;<Cc(W$

48$ c(W$K%	 7 	,nn))++r=   c                      y r   r<   rz   s     r3   depart_hlist_blockzRSTVisitor.depart_hlist_block  rZ  r=   c                     | j                   j                  dd      }| j                  |j                         | j                        }| j                  ||       t        j                  j                         )Nzrestructuredtext.subscriptrb  r  )	r  r#  r  r1  r  rc  r   rc   r9  ri   rj   r  
translateds       r3   visit_subscriptzRSTVisitor.visit_subscript  s[    &&'CV&T224;;=$//R
  U3nn))++r=   c                     | j                   j                  dd      }| j                  |j                         | j                        }| j                  ||       t        j                  j                         )Nzrestructuredtext.superscriptrb  r  )	r  r#  r  r1  r  rc  r   rc   r9  r  s       r3   visit_superscriptzRSTVisitor.visit_superscript  s]    &&'Ev&V224;;=$BSBST
  U3nn))++r=   c                     | j                   j                  dd      }| j                  |j                         j	                  dd      |       t
        j                  j                         )Nzrestructuredtext.emphasisr  r  r   r  r  r#  rc  r1  ri  r   rc   r9  rK  s      r3   visit_emphasiszRSTVisitor.visit_emphasis  sR    &&'BH&U  !6!6tS!A5Inn))++r=   c                     | j                   j                  dd      }| j                  |j                         j	                  dd      |       t
        j                  j                         )Nzrestructuredtext.strongr  r  r   r  r  rK  s      r3   visit_strongzRSTVisitor.visit_strong  sR    &&'@&&Q  !6!6tS!A5Inn))++r=   link_overridec                    d\  }}d|j                   v r,|j                   j                  d      d   j                         }d|j                   v r,|j                   j                  d      d   j                         }|xs) |j                  d|xs d      xs |j                  d      }t	        d      t	        |j                  d	|xs d      t        |d
            z   S )Nr  z:target:r  z:alt:r  ImagerA  u   🌆 altz#6088ff)linkcolorr  )	rawsourcer   r   r   r   r   )ri   rj   r  r   r  r!  s         r3   _make_image_textzRSTVisitor._make_image_text  s     V'^^))*5b9??AFdnn$..&&w/399;CX63DW EXRWG}tHHUCN7+T3 
 
 	
r=   c                    | j                   j                  |d      }|j                  dd      }|j                         j	                  dd      }|r| d| d}| j                  ||       t        j                  j                         )	Nr  r  rk   r\   r   r   (r?  )	r  r#  r   r1  ri  rc  r   rc   r9  )ri   rj   r%  r  rk   r   s         r3   _render_inline_with_explanationz*RSTVisitor._render_inline_with_explanation  s{    &&z;&Ghh}b1{{}$$T3/V2k]!,D  u-nn))++r=   c                 (    | j                  |d       y )Nzrestructuredtext.abbreviationr'  rz   s     r3   visit_abbreviationzRSTVisitor.visit_abbreviation  s    ,,T3RSr=   c                 (    | j                  |d       y )Nzrestructuredtext.acronymr)  rz   s     r3   visit_acronymzRSTVisitor.visit_acronym  s    ,,T3MNr=   c                     | j                   j                  | j                  |             t        j                  j                         r   )r  r   r$  r   rc   r9  rz   s     r3   visit_imagezRSTVisitor.visit_image
  s4     5 5d ;<nn))++r=   c                 >   t        d |j                  D        d       }t        d |j                  D        d       }||t        d |j                  D        d       }t        d |j                  D        d       }t        d |j                  D        d       }|)||j                  d      nd }| j                  ||      }nt	        d      }||j                         nd }| |j                         j                  d	d
      nd }	| j                  j                  dd      }
| j                  j                  dd      }|	t        |t	        |	|            n|}| j                  j                  t        |||
d             t        j                  j                         )Nc              3   j   K   | ]+  }t        |t        j                  j                        s(| - y wr   )r8  r   rc   ry  r   r/  s     r3   r   z*RSTVisitor.visit_figure.<locals>.<genexpr>  s$     ]MqZ8>>C[C[5\Mr,  c              3   j   K   | ]+  }t        |t        j                  j                        s(| - y wr   r8  r   rc   r6  r1  s     r3   r   z*RSTVisitor.visit_figure.<locals>.<genexpr>  s$     [mz!X^^EYEY7Z1mr,  c              3   j   K   | ]+  }t        |t        j                  j                        s(| - y wr   r3  r1  s     r3   r   z*RSTVisitor.visit_figure.<locals>.<genexpr>  s&     c*;Qz!X^^MaMa?bq*;r,  c              3   j   K   | ]+  }t        |t        j                  j                        s(| - y wr   )r8  r   rc   r   r1  s     r3   r   z*RSTVisitor.visit_figure.<locals>.<genexpr>  s$     _1Ax~~G]G]9^Qr,  c              3   j   K   | ]+  }t        |t        j                  j                        s(| - y wr   )r8  r   rc   legendr1  s     r3   r   z*RSTVisitor.visit_figure.<locals>.<genexpr>  s$     ]}!
1hnnF[F[8\A}r,  rw  )r  u
   🌆 Imager   r  zrestructuredtext.figure_borderbluer  zrestructuredtext.figure_legenddimr  F)r  r  expand)r.  r   r   r$  r   r1  ri  r  r#  r   r  r   r   r   rc   r9  )ri   rj   ref_node
image_nodecaption_nodelegend_noder  
image_textr   legend_textr  legend_stylebody_renderables                r3   visit_figurezRSTVisitor.visit_figure  s   ]DMM]_cd[dmm[]ab
("6c(*;*;ceijJ__aef]t}}]_cd!6>6JHLL2PTM..z.WJl+J+7+C,%%'ALAXk((*224=^b||--.NX^-_||--.NX]-^ & *d;lCD 	 	oWS_hm nonn))++r=   r  r  c                    g }d}h d}|t        |       k  r| |   }t        |t              r|j                  j	                         |v rp|dz   t        |       k  r_t        | |dz      t              rIt               }|j                  |       |j                  | |dz             |j                  |       |dz  }|j                  |       |dz  }|t        |       k  r|S )az  Merge marker-only bullet Text nodes with their following Text node.

        List rendering emits the marker and item body as separate Text
        renderables. In contexts that prefix each renderable line-by-line
        (e.g. block quotes), that separation can visually split bullets from
        their text. This helper keeps marker and first text fragment together.
        r   >      •   ∘   ▪rW   r   )r_   r8  r   r  r   r8  r   )r  r  r  bullet_markerscurrentcombineds         r3   _merge_bullet_markers_with_textz*RSTVisitor._merge_bullet_markers_with_text-  s     .#k""!!nG7D)MM'')^;EC,,{1q51486$$W-$$[Q%78h'QMM'"FA! #k""$ r=   c           	      $   | j                   j                  dd      }| j                   j                  dd      }d|z  }| j                  t        |t	        | j                        dz
           }|j
                  D ]  }d}|j
                  D ]  }	t        |	t        j                  j                        r| j                  |	|dz          >t        |	t        j                  j                        r| j                  |	|dz          xt        |	t        j                  j                        rA|r,| j                  j                  t!        ||z   d	|
             d}	 | j#                  |	       | j'                  |	      }
|r|
rYt        |
d   t               rFt!        ||z   d	|
      }|j)                  |
d          ||
d<   | j                  j+                  |
       nE| j                  j                  t!        ||z   d	|
             | j                  j+                  |
       d}|
st        |
d   t               r|
d   j-                  |       | j                  j+                  |
         y# t        j                  j$                  $ r Y w xY w)z[Recursively render a bullet list with support for unlimited nesting and any child elements.r  r  r  z!restructuredtext.bullet_list_textrb  r  rW   Tr\   rP  Fr   N)r  r#  _BULLET_LIST_MARKERSr"  r_   r   r8  r   rc   r  _render_bullet_listenumerated_list_render_enumerated_listr   r  r   r   visit_literal_blockr9  ro  r8  r   r@  )ri   rj   r  r  
text_styleindentr  r  first_contentr;  child_renderablesrJ  s               r3   rN  zRSTVisitor._render_bullet_listM  s6   ||--.S]j-k\\++,OY_+`
**3uc$:S:S6TWX6X+YZI M"++eX^^%?%?@,,UEAI>x~~'E'EF00	Bx~~'C'CD$((//Vf_"T`0ab(-007
 )-(A(A%(H%$ -<Ma<PRV1W'+FVO<'XH$001B11EF3;-a0 ,,334EF ,,33D&bXd4ef ,,334EF(- -)*;A*>E 1! 4 < <Z H ,,334EFI , ' $>>66 s   I..JJc                     | j                  |d       | j                  j                  t                      t        j
                  j                         Nr   )r  )rN  r  r   r   r   rc   r9  rz   s     r3   visit_bullet_listzRSTVisitor.visit_bullet_list{  s>      Q /	*nn))++r=   enumtyper  c                    ddl m} | dk(  rt        t        d      |z   dz
        S | dk(  rt        t        d      |z   dz
        S | dk(  rt	         ||            j                         S | d	k(  rt	         ||            S t	        |      S )
z<Convert an integer *i* to the appropriate enumeration label.r   )RomanNumeral
loweralphaarW   
upperalphaA
lowerroman
upperroman)/rich_rst._vendor.docutils.utils._roman_numeralsr[  r  r   r  r  )rY  r  r[  s      r3   _make_enum_markerzRSTVisitor._make_enum_marker  s     	Q|#s3x!|a'((%s3x!|a'((%|A'--//%|A''q6Mr=   c           	         | j                   j                  dd      }| j                   j                  dd      }d|z  }|j                  dd      }|j                  d	d
      }|j                  dd      }|j                  dd      }	t        |j                        D ]  \  }
}|	|
z   }| d| | j                  ||       | }d}|j                  D ]x  }t        |t        j                  j                        r| j                  ||dz          >t        |t        j                  j                        r| j                  ||dz          xt        |t        j                  j                        r>|r)| j                  j                  t!        |d|             d}	 | j#                  |       | j'                  |      }|rF| j                  j                  t!        |d|             | j                  j)                  |       d}3|s7t        |d   t               r|d   j+                  |       | j                  j)                  |       {  y# t        j                  j$                  $ r Y w xY w)z`Recursively render an enumerated list with support for unlimited nesting and any child elements.z'restructuredtext.enumerated_list_markerr  r  z restructuredtext.enumerated_textrb  r  rY  arabicr{  r\   suffixr  r   rW   r  TrP  Fr   N)r  r#  r   r  r   rc  r8  r   rc   r  rN  rO  rP  r   r  r   r   rQ  r9  ro  r   r@  )ri   rj   r  r  rR  rS  rY  r{  rf  r   idxr  r  r  rT  r;  rU  s                    r3   rP  z"RSTVisitor._render_enumerated_list  s    ||--.Wan-o\\++,NX^+_
88J1(B'(C(!$'6NCAxq)?)?!)L(MfXVF M"++eX^^%?%?@,,UEAI>x~~'E'EF00	Bx~~'C'CD$((//VL0YZ(-007
 )-(A(A%(H%$((//VL0YZ((//0AB(- -)*;A*>E 1! 4 < <Z H ,,334EF3 ,	 7 $>>66 s   II32I3c                     | j                  |d       | j                  j                  t                      t        j
                  j                         rW  )rP  r  r   r   r   rc   r9  rz   s     r3   visit_enumerated_listz RSTVisitor.visit_enumerated_list  s>    $$T$3	*nn))++r=   c                     | j                   j                  dd      }| j                  |j                         j	                  dd      |       t
        j                  j                         )Nz!restructuredtext.inline_codeblockzgrey78 on grey7r  r   r  r  rK  s      r3   visit_literalzRSTVisitor.visit_literal  sS    &&'JTe&f  !6!6tS!A5Inn))++r=   c                     | j                   j                  dd      }| j                  |j                         j	                  dd      |       t
        j                  j                         )Nz restructuredtext.title_referencer  r  r   r  r  rK  s      r3   visit_title_referencez RSTVisitor.visit_title_reference  sS    &&'IS[&\  !6!6tS!A5Inn))++r=   c                 l   | j                   j                  dd      }| j                  rat        | j                  d   t              rD| j                  d   j                          | j                  d   j                  t	        d             | j                  |      \  }}|dk(  r|n| d| d}|j                  d	      }|r| d
| }t        |j                  d            }t        |j                  dd            }|xs |xs | j                  }	t        |j                  dd            }
| j                  j                  t        t        |j                         || j                   |	|
|j                  d            |t"        j$                  |             t&        j(                  j+                         )N%restructuredtext.literal_block_borderr  r  r  r   r  r&  r?  r]   u    — r   r}   Fr   rW   )r  r  r   r   r  r   r  )r  r#  r  r8  r   r  r8  r  r   rS  r  r   r   r   r   r1  r  r   r  r   rc   r9  )ri   rj   r  r  lexer_sourcer  r]   has_highlightexplicit_linenosshow_linenosr   s              r3   rQ  zRSTVisitor.visit_literal_block  s   &&'NX`&a
4+;+;B+? FR '')R ,,T$Z8"..t4|%3E7"\NRS9T xxgU4&)E TXX&789E :;'R=RD<R<R,23
KKM//!-)$(HH->$? #JJ	
 nn))++r=   c                    | j                   j                  t        t        |j	                               d|j
                  j                  dd       d|j
                  j                  dd       d|j
                  j                  dd       d|j
                  j                  d	d       d
	dddddddj                  |j
                  j                  d      d                   |j	                         j                         t        fddD              }|s|j                  D ]  }t        |t        j                  j                        s(|j	                         j                  dd      }|sK| j                  rGt        | j                  d   t              r*| j                  d   j!                  t        |d             | j                  j                  t        |d              t        j                  j#                         )NzSystem Message: rZ   ?ru  r  r&  r   z, line r   z);rb  r  r  r  r  r  )NINFOWARNINGr  SEVEREDEBUGr  c              3   &   K   | ]  }|v  
 y wr   r<   )r   rs  message_texts     r3   r   z2RSTVisitor.visit_system_message.<locals>.<genexpr>  s     gDfW4Dfs   )r  overliner  r   r  r  r~  r\   )r  r   r   r   r1  r  r   r  rJ  r   r8  r   rc   r   ri  r  r8  r9  )ri   rj   is_title_errorr;  snippetr|  s        @r3   rD  zRSTVisitor.visit_system_message  s   T[[]#()<)<VS)I(J!DOOL_L_`gilLmKnnpqu  rA  rA  rE  rE  FN  PS  rT  qU  U\  ]a  ]l  ]l  ]p  ]p  qw  y|  ]}  \~  ~@  A$*KMdn  {I  T`  a  e  eOO''/	
 {{}**,gDfggeX^^%A%AB#lln44T3?G++
4;K;KB;OQU0V ,,R0<<T's=ST ,,33Db4IJ ' nn))++r=   field_valuec                 L   | j                   j                  dd      }| j                   j                  dd      }| j                  rt        | j                  d   t              rp| j                  d   }|j
                  d   j                  dk(  rE|j
                  d	   j                  d
k(  r)|j                  t        ||      t        ||             yt	        dd
d      }|j                  t        ||      t        ||             | j                  j                  |       y)z>Add a row to the shared field table, creating it if necessary.zrestructuredtext.field_namer  r  zrestructuredtext.field_valuerb  r  r   z
Field NamerW   zField Valuer  NTr  )
r  r#  r  r8  r   r   headerr  r   r   )ri   r  r  field_name_stylefield_value_stylepossible_tabler  s          r3   _add_to_field_tablezRSTVisitor._add_to_field_table
  s    <<112OY_1` LL223Q[a2b
4+;+;B+? G!--b1N&&q)00L@~G]G]^_G`GgGgkxGx&&tJ>N'OQUVaizQ{|lMdCd:-=>[Xi@jk&r=   c                     | j                  |j                  d   j                         |j                  d   j                                t        j                  j                         )Nr   rW   )r  r   r1  r   rc   r9  rz   s     r3   visit_fieldzRSTVisitor.visit_field  sI      q!1!8!8!:DMM!<L<S<S<UVnn))++r=   c                      y r   r<   rz   s     r3   visit_docinfozRSTVisitor.visit_docinfo  rZ  r=   c                 ~    | j                  d|j                                t        j                  j	                         NAuthorr  r1  r   rc   r9  rz   s     r3   visit_authorzRSTVisitor.visit_author  +      4;;=9nn))++r=   c                     |j                   D ]"  }| j                  d|j                                $ t        j                  j                         r  )r   r  r1  r   rc   r9  )ri   rj   authors      r3   visit_authorszRSTVisitor.visit_authors"  s9    mmF$$Xv}}? $nn))++r=   c                 ~    | j                  d|j                                t        j                  j	                         )NOrganizationr  rz   s     r3   visit_organizationzRSTVisitor.visit_organization'  s+      ?nn))++r=   c                 ~    | j                  d|j                                t        j                  j	                         )NAddressr  rz   s     r3   visit_addresszRSTVisitor.visit_address+  +      DKKM:nn))++r=   c                 ~    | j                  d|j                                t        j                  j	                         )NContactr  rz   s     r3   visit_contactzRSTVisitor.visit_contact/  r  r=   c                 ~    | j                  d|j                                t        j                  j	                         )NVersionr  rz   s     r3   visit_versionzRSTVisitor.visit_version3  r  r=   c                 ~    | j                  d|j                                t        j                  j	                         )NRevisionr  rz   s     r3   visit_revisionzRSTVisitor.visit_revision7  s+      T[[];nn))++r=   c                 ~    | j                  d|j                                t        j                  j	                         )NStatusr  rz   s     r3   visit_statuszRSTVisitor.visit_status;  r  r=   c                 ~    | j                  d|j                                t        j                  j	                         )NDater  rz   s     r3   
visit_datezRSTVisitor.visit_date?  s+      7nn))++r=   c                 ~    | j                  d|j                                t        j                  j	                         )N	Copyrightr  rz   s     r3   visit_copyrightzRSTVisitor.visit_copyrightC  s+      dkkm<nn))++r=   c           
         | j                   j                  dd      }| j                   j                  dd      }| j                   j                  dd      }|j                  D ]5  }|j                  }|st        |      dk(  r|d d \  }}}	t	        |j                         |d	      t	        d
d      z   t	        |j                         |      z   }
| j                  j                  |
       | j                  j                  t	        dd             | j                  t        |	d      r|	j                  ng       }| j                  j                  |       | j                  j                  t	        dd             t        |      dk\  r|d   }|d   }t        |      dkD  r,|d   }t	        |j                         |d	      t	        d
d      z   t	        |j                         |      z   }
| j                  j                  |
       |dd  D ]  }t        |t        j                  j                        r8| j                  j                  t	        d
|j                         z   |             `t        |t        j                  j                        r| j                  j                  t	        dd             | j                  |j                        }| j                  j                  |       | j                  j                  t	        dd             t        |t        j                  j                         rx| j                  j                  t	        dd             | j                  j                  | j#                  |             | j                  j                  t	        dd             t        |t        j                  j$                        r	 | j'                  |       t        |t        j                  j*                        r	 | j-                  |       t        |t        j                  j.                        r	 | j1                  |       Lt        |t        j                  j2                        r	 | j5                  |       t        |t        j                  j6                        s	 | j9                  |        q| j                  j                  t	        |j                         |      t	        dd      z   t	        |j                         j;                  dd      |      z   t	        dd      z          |d   }| j                  j                  t	        |j                         |      t	        dd      z          8 t        j                  j)                         # t        j                  j(                  $ r Y w xY w# t        j                  j(                  $ r Y w xY w# t        j                  j(                  $ r Y w xY w# t        j                  j(                  $ r Y 3w xY w# t        j                  j(                  $ r Y Ww xY w)Nzrestructuredtext.term_stylerb  r  z!restructuredtext.classifier_styler  z"restructuredtext.definitions_style   r\   r4  z : r~  r  
    r   r   r   r   r  rW   r  z
      )r  r#  r   r_   r   r1  r  r   rm  r%  r   r8  r   rc   
classifier
definitionrd   ro  r  rX  r9  rO  ri  r   rQ  r/  rk  block_quotevisit_block_quoteri  )ri   rj   
term_styleclassifier_styledefinitions_styler;  child_childrenrG  r  definitionsr  def_renderablesr  first_classifierr  s                  r3   visit_definition_listz RSTVisitor.visit_definition_listG  s;   \\++,ISY+Z
<<112U_e1f LL223Wag2h]]E"^^N!>"a'0>r0B-j+jbA5b)*:,,.6FGH 
   ''/  ''X2(>? #'">">,3K,LK((RT#   ''8  ''Tr(:;^$)%a( ,B/
~&* (6a'8$T[[]*"Eu"-./668@PQR 
 $$++F3,QR0%b(..*C*CD ,,33 $URYY[%8@P Q (HNN,E,EF ,,33Dr4JK.2.J.J2;;.WO ,,33OD ,,33D24FG'HNN,D,DE ,,33Dr4JK ,,33D4M4Mb4QR ,,33D24FG'HNN,F,FG% $ 6 6r : (HNN,J,JK% $ : :2 > (HNN,H,HI% $ 8 8 < (HNN,B,BC% $ 2 22 6 (HNN,F,FG% $ 6 6r :I 1V $$++T[[]*=xR01z002::4EM^_` zr23 &a(  ''T[[]*(MPTUY_aPb(bcs #t nn))++G $,>>#>#> % $%
 $,>>#>#> % $%
 $,>>#>#> % $%
 $,>>#>#> % $%
 $,>>#>#> % $%sZ   V;WXX'?Y;WWX ?X X$#X$'YYY,+Y,c                    | j                   j                  dd      }| j                   j                  dd      }| j                   j                  dd      }| j                   j                  dd      }|j                  D ]  }|j                  \  }}t        d      }	|j                  D ]  }
	 |
j                  \  }}|	t        |j                         |
      |rt        |j                         |
      n	t               z   t        |j                        dkD  rt        |j                  |
      n	t               z   z  }	 |r,|	t        d      z  }	|	t        |j                         |
      z  }	| j                  j                  |	t        d      z           t        j                  j                         # t        $ r |
j                  d	   d }}Y w xY w)Nzrestructuredtext.option_stringrb  r  z restructuredtext.option_argumentz,restructuredtext.option_child_text_separatorz#restructuredtext.option_descriptionr\   r~  r   r  rW   r  r   )r  r#  r   r   r1   r1  r_   child_text_separatorr  r   r   rc   r9  )ri   rj   option_string_styleoption_argument_style!option_child_text_separator_styleoption_description_styleoption_list_itemoption_groupdescriptionoption_textrF  option_stringoption_arguments                r3   visit_option_listzRSTVisitor.visit_option_list  s   "ll445U_e4f $ 6 67Yci 6 j,0LL,B,B:F -C -
) $(<<#9#9:_io#9#p  $(8(A(A%L+2,K&//N5;__2M? --/7JKVetO224<QRkokqs |4459 \>>Fgh!V 0 tH~-tK$6$6$8@XYY##K$t*$<=+ !., nn))++ " N5;__Q5G?MNs   0F77GGc           
      B   | j                   j                  dd      }| j                  j                  t	        t        |j                         d| j                  | j                        |t        j                  d             t        j                  j                         )Nro  r  r  pyconr  zdoctest blockrp  )r  r#  r  r   r   r   r1  r  r  r   r  r   rc   r9  rK  s      r3   visit_doctest_blockzRSTVisitor.visit_doctest_block  sz    &&'NX`&at{{}gT__SWSiSij"JJ%		
 nn))++r=   c                    | j                   j                  dd      }| j                   j                  dd      }| j                   j                  dd      }t        |j                        }|r,t	        |d   t
        j                  j                        r|d   nd }|r|d d n|}t        |      D ]  \  }}	|rF| j                  j                  t                      | j                  j                  t                      | j                  |	      }
| j                  |
      }
|
rt	        |
d	   t              r|
d	   }|j                          |j!                  |d	t#        |             t        d
|      }|j%                  |       | j                  j                  |       |
dd  D ]g  }t	        |t              r:t        d
|      }|j%                  |       | j                  j                  |       M| j                  j                  |       i a| j                  j                  t        d
|             | j                  j'                  |
        |r[| j                  j                  t                      | j                  j                  t        d|j)                         z   |             n#| j                  j                  t                      t
        j                  j+                         )Nz restructuredtext.blockquote_textwhiter  z.restructuredtext.blockquote_attribution_markerr  z,restructuredtext.blockquote_attribution_textgrey89r  r   u   ▌ r  rW   u     — )r  r#  r  r   r8  r   rc   attributionr  r  r   r   ro  rK  r   r  r@  r_   r8  r   r1  r9  )ri   rj   rR  r  author_styler   r  
paragraphsr  rd   para_renderablesr  rJ  r  
combined_rs                  r3   r  zRSTVisitor.visit_block_quote  sp   \\++,NX_+`
||--<FV . 
 ||--.\fn-o&&.:hrlHNNLfLf3ghrlmq&1Xcr]x
 )* 5E9  ''	2  ''	2  $88C#CCDTUJ/?/BD$I(+ j!SZ8l;$$U+  ''1 *!"-A!!T*%)&%E
"..q1((//
;((//2 .   ''V<(HI  ''(89= !6@ ##GI.##[;#5#5#77|L ##GI.nn))++r=   rS  c                 X   d|z  }|j                   D ]  }t        |t        j                  j                        r| j                  ||dz          =t        |t        j                  j                        sb| j                  j                  t        ||j                         z                 y)zDRecursively render a line_block node, preserving nested indentation.r  rW   N)r   r8  r   rc   
line_block_render_line_blockr   r  r   r   r1  )ri   rj   rS  r{  r;  s        r3   r  zRSTVisitor._render_line_block  sy    &]]E%!:!:;''vz:E8>>#6#67  ''Velln-D(EF	 #r=   c                 `    | j                  |       t        j                  j                         r   )r  r   rc   r9  rz   s     r3   visit_line_blockzRSTVisitor.visit_line_block  s#    %nn))++r=   c                 X    g }|D ]"  }|j                  | j                  |             $ |S )zRender a list of body nodes into renderables, returning the collected list.

        Uses a sub-visitor for each child so that inline markup (bold, italic,
        links, inline code, etc.) is preserved throughout.
        )r   ro  )ri   r   r  r;  s       r3   _collect_body_renderablesz$RSTVisitor._collect_body_renderables  s/     EMM$33E:; r=   c                     | j                   j                  dd      }t        |j                        }d}d}|r<t	        |d   t
        j                  j                        r|d   j                         }d}| j                  ||d        }|r/| j                  j                  t        t        | |||             n(| j                  j                  t        d|||             t
        j                  j                         )Nzrestructuredtext.topicr  r  r\   r   rW   rx  )r  r#  r  r   r8  r   rc   r  r1  r  r  r   r   r   r9  )ri   rj   r  r   r  
body_startbody_renderabless          r3   visit_topiczRSTVisitor.visit_topic  s    &&'?&U&

8A;0D0DEQK&&(EJ99(:;:OP##e-.e5W\] ##E"EUZ$[\nn))++r=   c                    t        |j                        }d}|}|r?t        |d   t        j                  j
                        r|d   j                         }|dd  }d}|r?t        |d   t        j                  j                        r|d   j                         }|dd  }| j                  |      }|rt        | nd}| j                  j                  t        |||d             t        j                  j                         )Nr\   r   rW   F)r  subtitler:  )r  r   r8  r   rc   r  r1  r  r  r   r  r   r   r9  )ri   rj   r   r  rq  r  r  re   s           r3   visit_sidebarzRSTVisitor.visit_sidebar1  s    & Za(8(..:N:NO!!$++-E)!"-MZa(8(..:Q:QR$Q'..0H)!"-M  99-H.>%)*BgUXV[ \]nn))++r=   c                     | j                   j                  dd      }| j                  j                  t	        |             y )Nzrestructuredtext.hrr  r  r  )r  r#  r  r   r   rK  s      r3   visit_transitionzRSTVisitor.visit_transitionG  s5    &&'<h&O5 12r=   c                    | j                   j                  dd      }| j                  rat        | j                  d   t              rD| j                  d   j                          | j                  d   j                  t	        d             t        |j                               }| j                  j                  t        t	        |      |t        j                  d             t        j                  j                         )Nro  r  r  r  r   r  rp  )r  r#  r  r8  r   r  r8  r  r1  r   r   r   r  r   rc   r9  ri   rj   r  	converteds       r3   visit_math_blockzRSTVisitor.visit_math_blockK  s    &&'NX`&a
4+;+;B+? FR '')R ,,T$Z8,T[[];	Y"JJ		
 nn))++r=   c                     | j                   j                  dd      }t        |j                         j	                  dd            }| j                  ||       t        j                  j                         )z>Render inline math with Unicode approximations where possible.zrestructuredtext.mathr  r  r   r  )	r  r#  r  r1  ri  rc  r   rc   r9  r  s       r3   
visit_mathzRSTVisitor.visit_math[  s\    &&'>&Q,T[[]-B-B4-MN	  E2nn))++r=   c                     | j                   j                  t        | j                  |      d             t        j
                  j                         Nleft)r  r   r   r2  r   rc   r9  rz   s     r3   visit_citationzRSTVisitor.visit_citationb  s9    eD$>$>t$DfMNnn))++r=   c                    | j                   j                  dd      }| j                  ryt        | j                  d   t              r\| j                  d   j                  |j                         j                  dd      |       t        j                  j                         | j                  j                  t	        |j                         j                  dd      |d	             t        j                  j                         )
Nz#restructuredtext.citation_referencegrey74r  r  r   r  r  r\   r4  )r  r#  r  r8  r   r   r1  ri  r   rc   r9  rK  s      r3   visit_citation_referencez#RSTVisitor.visit_citation_referencef  s    &&'LV^&_
4+;+;B+? FR ''(=(=dC(HPU'V..--//T[[]%:%:4%EUXZ [\nn))++r=   c           	         | j                   j                  dd      }| j                  j                  dt	        t        |j                         d      dt        j                  |             t        j                  j                         )Nzrestructuredtext.captionr  r  r   r  r   )r  r   r  )r  r#  r  r  r   r   r1  r   r   r   rc   r9  rK  s      r3   visit_headerzRSTVisitor.visit_headern  se    &&'A6&R5t{{}h)Gy^a^h^hpu#vwnn))++r=   c                     | j                   j                  t        |j                         d             t        j
                  j                         )Nr  r  r   r   r1  r   rc   r9  rz   s     r3   visit_footerzRSTVisitor.visit_footers  s4    59:nn))++r=   c                    | j                   j                  dd      }d}d|j                         j                  |d       d}| j                  r[t        | j                  d   t              r>| j                  d   j                  ||	       t        j                  j                         | j                  j                  t        ||d
             t        j                  j                         )Nz#restructuredtext.footnote_referencer  r  r   r  r  r  r  r  r\   r4  r  r#  r1  ri  r  r8  r   r   r   rc   r9  )ri   rj   r  newliner   s        r3   visit_footnote_referencez#RSTVisitor.visit_footnote_referencew  s    &&'LV^&_4;;=((#67q9
4+;+;B+? FR ''E':..--//TB ?@nn))++r=   c                    | j                   j                  dd      }|j                         j                  dd      }| j                  r[t        | j                  d   t              r>| j                  d   j                  ||       t        j                  j                         | j                  j                  t        ||d	             t        j                  j                         )
Nz'restructuredtext.substitution_referencerb  r  r   r  r  r  r\   r4  r  r  s       r3   visit_substitution_referencez'RSTVisitor.visit_substitution_reference  s    &&'PZ`&a{{}$$T3/
4+;+;B+? FR ''E':..--//TB ?@nn))++r=   c                     | j                   j                  t        | j                  |      d             t        j
                  j                         r  )r  r   r   r2  r   rc   r9  rz   s     r3   visit_footnotezRSTVisitor.visit_footnote  s9    5!;!;D!A6JKnn))++r=   c                     | j                   j                  t        |j                         d             t        j
                  j                         r  r  rz   s     r3   visit_generatedzRSTVisitor.visit_generated  s4    578nn))++r=   c                 >    t         j                  j                         r   rS  rz   s     r3   visit_pendingzRSTVisitor.visit_pending  rU  r=   c                 >    t         j                  j                         r   r   rc   SkipNoderz   s     r3   visit__colSpanzRSTVisitor.visit__colSpan      nn%%''r=   c                 >    t         j                  j                         r   r  rz   s     r3   visit__rowSpanzRSTVisitor.visit__rowSpan  r  r=   c           	      4   | j                   j                  dd      }|j                         j                  dd      }|rq| j                  r>t        | j                  d   t              r!| j                  d   j                  ||       n'| j                  j                  t        ||d	             | j                  j                  t        t        |j                         d
| j                        dd             t        j                  j                         )Nzrestructuredtext.problematicrb  r  r   r  r  r  r\   r4  r   )r  r  z#System Message: Problematic Elementr  r  )r  r#  r1  ri  r  r8  r   r   r  r   r   r  r   rc   r9  )ri   rj   problematic_styleproblematic_texts       r3   visit_problematiczRSTVisitor.visit_problematic  s     LL223Q[a2b;;=00s;Jt/?/?/CT$J  $++,<DU+V  ''-=EV\^(_`t{{}EI;'	
 nn))++r=   c           
         | j                   j                  dd      }| j                  |      \  }}|j                         }|dk(  rdnd|z   }|dk(  rt	        |      }d }| j
                  j                  t        t        ||| j                  | j                        |t        j                  |             t        j                  j                         )	Nro  r  r  r  zstripped raw htmlzraw r  rp  )r  r#  r  r1  r  r  r   r   r   r  r  r   r  r   rc   r9  )ri   rj   r  r  rc  r   r  s          r3   	visit_rawzRSTVisitor.visit_raw  s    &&'NX`&a##D)q{{}(-$Ve^F?d#DEtU$//H^H^_"JJ		
 nn))++r=   gridr  r  header_style
cell_styler   c                     !"#$%&'()*+,-./ t               .t              -g }d\   !d\  d\  d\  d\  #"i /dt        dt        dt        t        t        t        f      f /fd	'd
t        dt        dt        f .fd*dt        dt        dt        f'fd$dt        dt        ffd&dt        dt        dt        f'fd%dt
        t           dt
        t           fd+dt        dt        f&fd)i ,dt        dt        dt
        t           f)+, fd(dt        t           dt        t           dt        f !"#%&'*-fd}dt        dt        f$( -fd}	dt        dt        dt        f"#$&'() -f
d}
dt        dt        f$' -fd}|r].rt         |dd      j                        nt              d-z  z   dz   }|j                  t        |j                  |      d             t        .      D ]  }|dkD  r|dz
  nd} ||      } |||      }|rt        "#fd |j                  D              s|j                  |       |rUt         |	|            D ]  }|j                   |
||               |j                   |.dz
  d             t!        | S )!aD  Build a Rich Group that renders a table with proper cspan/rspan merging.

        *grid[r][c]* is either ``(renderable, cspan, rspan)`` for a real cell or
        ``None`` for a placeholder occupied by a span from another cell.
        *col_widths[c]* is the inner character width of column *c* (excluding borders).
        )u   ┏   ━   ┳u   ┓)u   ┡r  u   ╇u   ┩)   ├   ─u   ┼   ┤)u   └r  u   ┴u   ┘)u   ┃u   │r  r/  r/   c                    | |f}j                  |d      }||v r|S t        | dd      D ]W  }t        |dd      D ]E  }
|   |   }||\  }}}	|| cxk  r	||	z   k  s#n &||cxk  r	||z   k  s5n 8||f|<   ||fc c S  Y d|<   y)zBReturn (origin_row, origin_col) for the real cell covering (r, c).Nr  )r   r   )r  r/  r7  r  rrccr  rc  csprspr  origin_caches             r3   _originz+RSTVisitor._spanning_table.<locals>._origin  s    a&C!%%c40F!SL%8Ar2&2r*B8B<D| "&KAsCQ*"s(*rQ/B"s(/B-/HS) "Bx + ' !%Lr=   	row_abovec                     | dk  s| dz   	k\  ryt        | dd      D ]T  }t        |dd      D ]B  }|   |   }||\  }}}||cxk  r	||z   k  s#n &|| cxk  r	||z   k  s5n 8| ||z   k  c c S  V y)z?True if a cell covering (row_above, c) extends to the next row.r   rW   Fr  )r   )
r  r/  r  r  r  rc  r  r  r  nrowss
           r3   _rspan_continuesz4RSTVisitor._spanning_table.<locals>._rspan_continues  s    1}	A 6Ir2.2r*B8B<D| "&KAsCQ*"s(*rY/J"s(/J(2833 + / r=   c                 P    |dk(  ry | |dz
        } | |      }|duxr ||k(  S )zJTrue if column c is a cspan continuation of the cell to its left in row r.r   FrW   Nr<   )r  r/  left_originhere_originr  s       r3   _cspan_continuesz4RSTVisitor._spanning_table.<locals>._cspan_continues
  s=    Av!!QU+K!!Q-Kd*I{k/IIr=   c                     | k  S r   r<   )r  r  s    r3   
_is_headerz.RSTVisitor._spanning_table.<locals>._is_header  s    {?"r=   c                 0     | |       | |dz         k7  S )zGTrue iff row *r* has a vertical separator between column *c* and *c+1*.rW   r<   )r  r/  r  s     r3   _has_vborderz0RSTVisitor._spanning_table.<locals>._has_vborder  s    1a=GAq1u$555r=   line_segmentsc                 P   t               g}| D ]  }|j                  s|j                  s|j                  j                  d      }t	        |      D ]Q  \  }}|r|d   j                  ||j                         |t        |      dz
  k  s9|j                  t                      S  |S )Nr   r  rW   )r   controlr   r   r  r   r  r_   )r+  r   segrz  r  r   s         r3   _segments_to_linesz6RSTVisitor._spanning_table.<locals>._segments_to_lines  s    !%E$;;chht,#,U#3KE4b	((syy9s5zA~-TV,	 $4	 % Lr=   c                      |       rS S r   r<   )r  r(  r  r  s    r3   
_row_stylez.RSTVisitor._spanning_table.<locals>._row_style&  s    #-a=<@j@r=   c                    | |f}|v r|   S |    |   }|g |<   g S |\  }}}t        |||z   dz          d|z  z   } |       }|dk  rt        d      g|<   |   S j                  j                  ||      }	|rt	        ||      n||n
t        d      }
j                  |
|	ddd	      }g }|D ]  }|j                   |              |st        d
|z  |      g}g }|D ]`  }t        |j                        }||kD  r|j                  |dd       n||k  r|j                  d
||z
  z  |       |j                  |       b ||<   |S )zARender cell content into styled lines sized to its spanned width.NrW   r  r   r\   width	max_widthTF)r   r  padr   r  r  crop)overflowr6  )sumr   r   r   r#   render_linesr   r"   r  truncater   )r  r/  r7  r  re   r  rc  availr  r   render_targetrendered_linesr   rx  r;  r   current_widthr1  r/  cell_render_cacher  r  r  s                    r3   _render_cell_linesz6RSTVisitor._spanning_table.<locals>._render_cell_lines+  s   a&C''(--71:D|)+!#&	"OGS!
1QWq[12QW<EqMEz*.r(!#&(--oo,,5E,JG6;F7E2WM`'fjkmfnM$11 2 N !#E*/9: +cEk78%'J ( 4 5(MM%&eMD"U*KKu}'< =UKK!!$'  &0c"r=   abovebelowc                    | du }|du }| duxr |duxr | ,dz
  k(  xr |,k(  }| duxr |duxr  (|       xr  (|      }|r"!#$f\  }}}}	n1|rf\  }}}}	n#|r f\  }}}}	n|rd\  }}}}	nf\  }}}}	| |s	 *| d      nd}
|r&n%}|
r|s|s|}n|}t        -      D ]  }| |s	 *| |      nd}|r|d+|   dz   z  z  }n||+|   dz   z  z  }|-dz
  k  s;|}| |s *| |dz         nd}|r5|r3| duxr#  )| |      duxr  )| |       )| |dz         k(  }||rdn|z  }|s|r|r
||rdnd	z  }||rd
ndz  }| duxr | xr	  '| |      }|duxr	  '||      }|r|r|r|z  }|r|dz  }|z  }|r||s|rdnz  }|r |r|#z  }|r|dz  }|r|dz  }|dz  }||z  } | |s *| -dz
        nd}|r|s|s||z  }t        |      S ||	z  }t        |      S )zEHorizontal rule between rows *above* and *below* (None = table edge).NrW   )   ┣r     ╋   ┫r   Fr  r   rE  rG  r  r  rF  u   ┻u   ┯r  u   ┬)r   r   ).rB  rC  is_topis_botis_head_sepis_inner_header_sepLHMRrc0V_sepr  r/  rclrcrrcsame_originhas_uphas_dnrcNBHBLBMBRMHMLMMMRSHSLSMSRTHTLTMTRVBVHr*  r(  r  r"  r  r  ncolss.                        r3   _sepz(RSTVisitor._spanning_table.<locals>._sepZ  s    d]Fd]FT! )%)[1_,) [(	  T! &%&u%& u%	   R^
1aR^
1aR^
1a$7
1aR^
1a 160A&"5!,V[C-B2E6&5\383DV%eQ/Y^
1 122Ajma/00Auqy=C=B=NW]+E1q59chCs!- K 'q 1 =K 'q 1WUAE5J J $ KSU:.#58A#58A!&d!2!\6z!\lSXZ[F\!&d!2!M|E17M!f* !R!4 !U
 !R#;:MTVVA#% !R!, !U
!4 !U
 !U
FAa "d 9>8IRX"5%!)4^cC6&U
 7N Q7Nr=   c           	          d}d}|	k  rO | |      r|dz  }|    |   }||dz  }$|\  }}}t        |t         | |                  }|d|z   z  }|	k  rO|S )zCPhysical line count for a logical row after rendering cell content.rW   r   )r  r_   )
r  heightr/  r  rc  r  r&  rA  r  rk  s
         r3   _row_heightz/RSTVisitor._spanning_table.<locals>._row_height  s    FAe)#Aq)FAAwqz<FA 	3VS);Aq)A%BCQW e) Mr=   line_noc                   
  |       }|rn} |       }t        |      }d}|k  r | |      r|dz  }|    |   }||\  }}	}
t        |||	z   dz          d|	z  z   } | |      }|t        |      k  r||   nt        d|z  |      }|j                  d|       |j	                  |       |j                  d|       ||	z   dz
  k  r|j                  |       |d|	z   z  }n | |      }||d   |k(  r|}|dz   k  r, | |dz         |k(  r|dz  }|dz   k  r | |dz         |k(  r||z
  }	t        ||dz          d|	z  z   }|j                  d|dz   z  |       |dz
  k  r|j                  |       |dz   }nF|j                  d|   dz   z  |       |dz
  k  r | |dz         s|j                  |       |dz  }|k  r|j                  |       |S )z.One physical content line for logical row *r*.r   rW   r  r  r  r   )r   r9  r_   r   r8  )r  rp  is_hdrVr  r   r/  r  re   r  rc  r<  rx  r  originspan_endri  rj  r&  r(  r  rA  r1  r  r  rk  s                   r3   r  z,RSTVisitor._spanning_table.<locals>._content  sD   ]F"AqME7DAe)#Aq)FAAwqz#&*OGS!
1QWq[ 9:QWDE1!Q7H183x=1HHW-dSVY^S^fkNlEKK5K1$$U+KK5K13w*ASLA
 %Q]F)fQi1n#$&lU2wq(Q,7OSY7Y$MH 'lU2wq(Q,7OSY7Y&l #JqA$> ?!c' IC519$5UC#eai/ KKN$qLC:a=1+<$=UKuqy=1A!QU1K KKNQK e)L KKNKr=   c                 n    d}|k  r- | |      r|dz  }|    |   y | |      y|dz  }|k  r-y)z8True when a row is fully covered by rowspans from above.r   rW   FTr<   )r  r/  r&  r  r  rk  s     r3   _is_placeholder_rowz7RSTVisitor._spanning_table.<locals>._is_placeholder_row  s\    Ae)#Aq)FA71:) 1a=( Q e) r=   Nr   r  rW   r  r  c              3   0   K   | ]  }|d   v   yw)r  Nr<   )r   r  ri  rj  s     r3   r   z-RSTVisitor._spanning_table.<locals>.<genexpr>  s!     *W"21RD+=s   )r_   r   r   r   rS  r	   r    r   r   r"   r  r9  r   r  r   allr   )0r  r  r  r  r  r  r  r   rl  ro  r  rw  totalr  rB  is_placeholdersep_linerp  rY  rZ  r[  r\  r]  r^  r_  r`  ra  rb  rc  rd  re  rf  rg  rh  ri  rj  r&  r*  r(  r  rA  r1  r"  r/  r@  rk  r!  r  s0   ``` ```           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@r3   _spanning_tablezRSTVisitor._spanning_table  s     D	J 4BB3BB3BB3BBB JL	s 	s 	xc3h'@ 	(	 	 	 		J 	J 	J 	J	## 	#$ 	#	6C 	6C 	6D 	6	d7m 	T
 		A# 	A# 	A @B+	# +	# +	$t* +	 +	^Z	 Z	hsm Z	 Z	 Z	 Z	 Z	|	3 	3 	 	".	 .	c .	d .	 .	`	3 	4 	 	  5:HT$]001ZSTW\S\A\_`A`ELLell51BCuAUAEE03NE1~H"s*W*W'WX& Q0Xa12 1  	T%!)T*+e}r=   c                    /01234  j                   j                  dd      } j                   j                  dd      1d }d }|j                  D ]x  }t        |t        j
                  j                  t        j
                  j                  f      r|j                         }Rt        |t        j
                  j                        sw|}z |t        j
                  j                         t        d |j                  D              3d }d }|j                  D ]P  }t        |t        j
                  j                        r|}*t        |t        j
                  j                        sO|}R |t        j
                  j                         3dk(  rm|6|j                  r*t        d |j                  d   j                  D              3n5|j                  r)t        d	 |j                  d   j                  D              3d
t        j
                  j                  dt        f1 fd/dt        j
                  j                  dt         dt"        t$        t           t&        t(        t(        f   f   f/13fd}dt        j
                  j                  dt*        fd}	 |	|      xs |d uxr  |	|      }
|
r&|rt-        |j                        nd}g }i }g }|r$|j                  D ]  }|j/                  |df        |j                  D ]  }|j/                  |df        |D ]  \  }}d g3z  }d}t1        |j                        }|3k  r||v r||xx   dz  cc<   ||   dk  r||= |dz  }'t3        |d       }||dz  };|j5                  dd      }|j5                  dd      } /|      }|||f||<   |dkD  rt7        |||z   dz         D ]  }|||<   	 |d|z   z  }|3k  r|j/                  |        g 4dt        dt$        t8           f4 fd0dt        dt(        f0fd}dt        dt(        f0fd}dg3z  2dg3z  }|D ]T  }t;        |      D ]D  \  }}|	|\  }}}|dk(  st=        2|    ||            2|<   t=        ||    ||            ||<   F V |D ]_  }t;        |      D ]O  \  }}|	|\  }}}|dkD  st        2|||z   dz          d|z  z   } ||      } | |kD  s=2||z   xx   | |z
  z  cc<   Q a t=        d j                   j>                  j@                        }!dt$        t(           dt(        fd}" |"2      |!z
  }#dt$        t(           dt(        dt(        f2fd }$ |$||#      }#|#dkD  r |$dg3z  |#      }# jB                  j/                   jE                  |2|||1 j                                t        j
                  j                         |d uxr t+        |j                        }%tG        |%||d!      }&||j                  r|j                  d   }'d}(|'j                  D ]~  }|j5                  dd      })|&jI                  |j                         jK                  d"d#      jM                         1$       t7        |)      D ]  }|&jI                  d%1$        |(d|)z   z  }( |(3k  rB|&jI                  d%1$       |(dz  }(|(3k  rn#t7        3      D ]  }|&jI                  d%1$        i }*|j                  D ]  }|*jO                         D +ch c]  \  }}+|+dkD  s| },}}+ |||,      \  }-}.tQ        |,      D ]  }|*|xx   dz  cc<   |*|   dk  s|*|=  |*jS                  |.        |&jT                  |-    jB                  j/                  |&       t        j
                  j                         c c}+}w )&Nzrestructuredtext.table_headerr  r  zrestructuredtext.table_cellrb  c              3   j   K   | ]+  }t        |t        j                  j                        s(d  - yw)rW   N)r8  r   rc   r  r1  s     r3   r   z)RSTVisitor.visit_table.<locals>.<genexpr>.  s$     [/QZ8>>CYCY5Zq/r,  r   c              3   F   K   | ]  }d |j                  dd      z     ywrW   r  r   Nr   r   es     r3   r   z)RSTVisitor.visit_table.<locals>.<genexpr>?  #     \A[Aq155Q#77A[rt  c              3   F   K   | ]  }d |j                  dd      z     ywr  r  r  s     r3   r   z)RSTVisitor.visit_table.<locals>.<genexpr>A  r  rt  r  r/   c                    j                         }| j                  D ]  }|j                  |        |j                  }|st	        d      S t        d | j                  D              }|r<j                  |      }|D cg c]  }t        |t              r| }}|st	        d      S j                  j                  t        | j                  j                  j                  dd      dd      }g }|D ]  }t	        j                  |D 	cg c]'  }	|	j                  r|	j                   |	j"                  f) c}	 }
|
j%                          |
j&                  j)                         sq|j+                  |
        |st	        d      S t-        |      dk(  r|d	   S t        | S t/        |      D ]}  \  }}t        |t              s|j%                          t-        |j&                        t-        |j&                  j1                               z
  }|sc||d
 }|j2                  |_        |||<    t-        |      dk(  r|d	   S t        | S c c}w c c}	w )zFRender an entry node with a sub-visitor to preserve inline RST markup.r\   r  c              3      K   | ]B  }t        |t        j                  j                  t        j                  j                  f       D y wr   )r8  r   rc   r  rO  r+  s     r3   r   zHRSTVisitor.visit_table.<locals>._render_entry_content.<locals>.<genexpr>K  s8      +E 58>>#=#=x~~?]?]"^_+s   AA
   r3  Fr   r6  r   rW   r   N)rh  r   rk  r  r   rJ  rK  r8  r   r  r:  r   r   r   r  r-  r   r  r  r  r   r   r_   r  r  r   )r  rl  r;  r  has_listr  r>  compact_linesr   r.  	line_textr  leadingtrimmedr  ri   s                 r3   _render_entry_contentz5RSTVisitor.visit_table.<locals>._render_entry_contentC  s+   002K, (%11KBj11 "^^ H  #BB;O*5T+QZ7=Sq+T"*55!%!:!:;' LL0077dd7S#	 "; " -/*D $;?S4Cs{{388SYY/4S!I $$& ,,.%,,Y7 + %*55}%*(++m,, "+.1a&HHJ!!''lS1A-BBG"#GH+&'ee)0A / ;1$"1~%+&&K U Ts   III
$I
r  occupied_colsc                 $   g }i }d}t        | j                        }|k  r||v r"|j                  t        d             |dz  }+t	        |d      }|"|j                  t        d             |dz  }[|j                  dd      }|j                  dd      }|j                   |             |dkD  rt        ||dz   |z         D ]  }	|||	<   	 t        |      D ]  }
|j                  t        d               |d|z   z  }|k  r||fS )an  Build cell renderables for one body row.

            Accounts for columns already occupied by rowspans from earlier rows
            and for cells that span multiple columns (morecols).  Returns a tuple
            of (cells, new_rowspans) where new_rowspans maps col_idx to the
            morerows value for any spanning cells introduced by this row.
            r   r\   r  rW   Nr  r  )iterr   r   r   r.  r   r   )r  r  cellsnew_rowspanscol_idx
entry_iterr  r  r  span_colrc  r  r  num_colss              r3   _build_row_cellsz0RSTVisitor.visit_table.<locals>._build_row_cellsz  s-    ELGcll+JH$m+LLb
!;<qLGZ.= LLb
!;<qLG 99Z3 99Z3259: a<$)'7Q;3I$J19X. %K xALLb
!;< ) 1x<'; H$> ,&&r=   r  c                     | j                   D ]:  }|j                   D ])  }|j                  dd      s|j                  dd      s(  y < y)Nr  r   r  TF)r   r   )r  r  r  s      r3   
_any_spansz*RSTVisitor.visit_table.<locals>._any_spans  sC    ''AuuZ+quuZ/C# & ( r=   TFrW   r  r  r:  c                 F   | g S D ]  \  }}|| u s|c S  j                   j                  | j                   j                  j                  dd      dd      }g }|D ]+  }dj	                  d |D              }|j                  |       - j                  | |f       |S )Nr  r3  Fr  r\   c              3   N   K   | ]  }|j                   r|j                    y wr   )r-  r   )r   r.  s     r3   r   zHRSTVisitor.visit_table.<locals>._rendered_plain_lines.<locals>.<genexpr>  s     #PCKKCHHs   %%)r  r:  r   r   r   r   )	r:  cached_renderablecached_linesr   plain_linesr   r  rendered_plain_lines_cacheri   s	          r3   _rendered_plain_linesz5RSTVisitor.visit_table.<locals>._rendered_plain_lines  s    %I7Q3%|(J6++ 8R 11 LL0077dd7S#	 2  *,!DGG#P#PPE&&u- " +11:{2KL""r=   c                 <     |       }t        d |D        d      S )Nc              3   2   K   | ]  }t        |        y wr   r!   )r   r   s     r3   r   z;RSTVisitor.visit_table.<locals>._plain_w.<locals>.<genexpr>  s     =utHTNur  r   r  )r  )r:  r   r  s     r3   _plain_wz(RSTVisitor.visit_table.<locals>._plain_w  s     -j9=u=qIIr=   c                      |       }d}|D ],  }|j                         D ]  }t        |t        |            } . t        d|      S )NrW      )r   r  r"   r"  )r:  r   widestr   rE  r  s        r3   _min_token_wz,RSTVisitor.visit_table.<locals>._min_token_w  sJ    -j9!D!%!$VXe_!= ". " 2v&r=   r  r  c                 <    t        |       dt        |       z  z   dz   S )Nr  rW   )r9  r_   )r  s    r3   _table_widthz,RSTVisitor.visit_table.<locals>._table_width  s    6{QV_4q88r=   floors	remainingc                 v   |dkD  rt        
      D cg c]  \  }}|| |   kD  s| }}}|s	 |S |j                  
fdd       t        d|t        |      z        }d}|D ]>  }|dk  r n7
|   | |   z
  }t	        |||      }	|	dk  r(
|xx   |	z  cc<   ||	z  }||	z  }@ |dk(  r	 |S |dkD  r|S c c}}w )Nr   c                     |    S r   r<   )r  r  s    r3   r5  zBRSTVisitor.visit_table.<locals>._shrink_to_floor.<locals>.<lambda>$  s	    Ar=   T)r7  r  rW   )r  r:  r  r_   r"  )r  r  r  w	reducibleper_col_cutchangedrg  max_cutcutr  s             r3   _shrink_to_floorz0RSTVisitor.visit_table.<locals>._shrink_to_floor  s    !m/8/D V/Dtq!FSTI/DI V$  !  NN'>NM"%ac)n)D"EKG($>!",S/F3K"?!';	B!8$"33.!S(	3  ) !|  '  !m& ! % !Ws
   B5B5)r	  r  r  r  r   r  r  r\   )+r  r#  r   r8  r   rc   r  r   r1  r  r9  r9  r  r  ru   r   r   r   r	   r   r   rS  r_   r   r  r.  r   r   r  r  r  r   r5  r  r}  r   r  ri  r   r  r  r   r  )5ri   rj   r  r  r  r;  r  r  r  r  	has_spansnum_header_rowsr  rspan_activeall_rowsr  row_noderc  grid_rowr  r  r  mcmrre   span_cr  r  col_min_widthsr/  r  	availableneededmax_total_widthr  r8  r  
has_header
rich_table
header_rowr  r  rowspan_remainingremr  r  r  r  r  r  r  r  r  s5   `                                              @@@@@@r3   visit_tablezRSTVisitor.visit_table  s   ||--.MW]-^\\++,ISY+Z
 ]]E%(.."6"68N8N!OPE8>>#8#89	 # >..--// [&//[[ __E%!5!56E8>>#7#78	 % =..--// q= U^^\PQARA[A[\\\PQARA[A[\\5	')<)< 5	' 5	'n,	'(.."5"5 ,	'c ,	'eTXY\T]_cdgildl_mTmNn ,	'^	 3 3 	 	 u%R%t*;*Q
5@Q	5:c%..1O$&D+-L?AH >>COOS$K0 *~~e- &  (!'+fx&7!("3"34
Hnl*$S)Q.)',1 ,S 1q  T2E}q :q1B:q1B3E:G%,b"$5HSMAv&+CrA&>F35L0 '?1r6MC% Hn& H%/  (: GI&## #$s) #&JS JS J' ' ' xJS8^N (2GAt| &*OGRQw(+JqM8G;L(M
1,/q0A<PWCX,Yq)  3 ! !(2GAt| &*OGRAv$'
1QVaZ(@$AAF$J	!)'!2!I-&q2v.&92DD.  3 ! "!T\\%9%9%C%CDO9T#Y 93 9 $J//AH!c !s !s !2 (AH!|+QC(NHE##$$*o<LL ..--// $&?4+?
"%	

 *JG#,, 99Z3%%elln&<&<T3&G&M&M&OWa%bxA))"J)? )1x<' - H$%%b
%;1 H$ 8_%%b
%; % -/>>C,=,C,C,EQ,ESq,EHQ"23"AE<H~!#&!+&$S)Q.)#. & $$\2J& " 	
+nn))++ Rs   ^?(^?r  )monokaiFTpythonr  r  )r/   r-   )r]  r   )r   )r8   r9   r:   r;   r  r   r   r   r   rc   ru   r   r   r   r   __annotations__r<  r  r  	maketransr  r   r   r  rT  r  r  r  r  r  r  r   r   rS  r
   r  r  r  r  r
  r  r  r(  r2  r;  rB  rE  rG  rI  rL  rN  rQ  rT  rW  rY  r\  r^  r`  rd  r   rc  rh  r	   rm  ro  rv  ru  rt  r   r  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rU  r  r  r  r"  r<  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r6  r$  r'  r*  r,  r.  rC  rM  rK  r  rN  rX  rc  rO  rP  ri  rk  rm  rQ  rD  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r}  r  r  r  s   @r3   r-   r-     s   
* FHhtD)<)<$=uXhWZ\_W_N`Eackltuxz}u}l~cE  @A  %A   B  C  H-3X(6*5?B}}Q 	D@L(4U3T>%: :;<  >A]]7  :c>Jc5c4#889:  3$x~~/B/B*C 3xX`adfiaiXjOk 3  @H  IQ  RU  WZ  RZ  I[  @\ 3  hp  qy  z}  B  zB  qC  hD 3 3j 7D1D1D,E 7$ 7 7 	*d8>>3F3F.GxX`adfiaiXjOkmuv~  @C  EH  @H  wI  nJ  PJ  JK  /K  *L 	* 	*=8>>#6#6 =4 =>x~~':': >t > /8,1&*'/8?!5..))!5 !5 #{*+	!5
 $D>!5 d^!5  }!5 ""45!5 
!5FX^^5H5H0I hX`XfXfXkXkWlnqWqNr hnn6I6I1J xYaYgYgYlYlXmorXrOs )S )c5cSWCX>X9Y )^a )c eHSM44G.H 	- 3 3 	-hsmS>P8Q 	-8>>#6#6 3 EC E E E$8(..*=*= 8# 8,,HNN$7$7 ,D ,8,0
A,
,,
],,	,
E 
EE 
Ed 
E

'X^^5H5H0I 'dSVi '	'(..*=*= 	'$s) 	'  	
   HNN//0 
2
S 
 
W[\d\j\j\o\oWp 
uy 
2 2S 2 2_cdldrdrdwdw_x 2  ~B 2
)D )T )6*T *c *t *.I2S I23 I2tT\TbTbTgTgOh I2mq I2V,",,,,,,,,,,,, ,,,  sCx  :\X^^5N5N \SWX[S\ \|8HHNN,?,? 8HDI 8Ht7IC 7I 7I 7IrG Gs Gs GW[ GR8s 8s 8t 8tls ls lt l\C # # RV  ( (sCx ( (".(..:M:M .RWX\]bcfhkmpcp]qXrtx  zB  zH  zH  zM  zM  uN  YN  SO .<T%S#:N5O TXY\T] (,84,l,4, ,D,,,
,


X^^%9%9 

(SV- 

cg 

,HNN4G4G ,UX ,]a ,TO,,: 7T#Y 49  >,G(B(B ,G3 ,GW[ ,G\,
 C C C  &GHNN,J,J &GSV &G_c &GP,
,
,
&,P,8'c ' ' ',,,
,,,,,,,,^,@,>
,2,hGx~~'@'@ G# GVZ G,	$x~~7J7J2K 	PTUXPY 	,&,,3, ,,,,
,,,,,,((,&,. S49oSIS S }	S
 S S S 
S Sn
M,r=   r-   c                      e Zd ZdZ	 	 	 	 	 	 	 	 ddedeeeef      dee   dee   dee   dee   d	ee   d
ee   de	d   ddfdZ
ddddee   dedefdZ	 ddddee   dee   defdZ	 ddddee   dedefdZdededefdZy) r,   a  A reStructuredText renderable for rich.

    Parameters
    ----------
    markup : str
        A string containing reStructuredText markup.
    code_theme : Optional[Union[str, SyntaxTheme]]
        Pygments theme for code blocks. Defaults to "monokai".
    show_line_numbers : Optional[bool]
        Whether to display line numbers for syntax-highlighted code blocks.
    show_errors : Optional[bool]
        Whether to show system_messages aka errors and warnings.
    guess_lexer : Optional[bool]
        Whether to guess lexers for code blocks without specified language.
    default_lexer : Optional[str]
        Which lexer to use if no lexer is guessed or found. Defaults to "python"
    sphinx_compat : Optional[bool]
        Enable compatibility with Sphinx roles (func, meth, class, etc.) commonly used in
        Python docstrings. When enabled, these roles render as inline code instead of errors.
        Defaults to True for better compatibility with Python documentation.
    filename : Optional[str]
        A file name to use for error messages, useful for debugging purposes. Defaults to "<rst-document>"
    admonition_style : str
        How admonition directives (``note``, ``warning``, ``versionadded``, etc.) render.
        ``"panel"`` (default) emits a bordered Rich :class:`~rich.panel.Panel` per directive.
        ``"compact"`` collapses each directive to a styled inline title prefix, making the
        output suitable for narrow contexts such as CLI ``--help`` panels.
    Fmarkupr  r  show_errorsr&   r.   sphinx_compatr   r  r  r/   Nc
                     |	dvrt        d|	      || _        || _        || _        || _        || _        t        |      | _        || _        || _	        |	| _
        y )Nr  z3admonition_style must be 'panel' or 'compact', got )r1   r  r  r  r  r&   r4   r.   r  r   r  )
ri   r  r  r  r  r&   r.   r  r   r  s
             r3   r  zRestructuredText.__init__  sr     #77EFVEYZ  "=G1B+6+6,H,W-:'/=Mr=   )force_terminalr4  r  c                h    t        |xs d|d      }|j                  |        |j                         S )a  Render the RST markup to a plain string.

        This is a convenience wrapper around the full rich rendering pipeline.
        All options passed to the constructor (code theme, show_errors, etc.)
        are respected.

        Parameters
        ----------
        width : int, optional
            Output width in columns.  Defaults to 80 when not specified.
        force_terminal : bool, optional
            When ``True`` the console is created with ``force_terminal=True``,
            which enables ANSI styles in the exported text.  Defaults to
            ``False`` so that the plain-text output is style-free by default.

        Returns
        -------
        str
            The rendered markup as a plain string.
        P   Tr4  r  record)r   printexport_text)ri   r4  r  r  s       r3   render_to_stringz!RestructuredText.render_to_string  s8    * +2)

 	d""$$r=   r  r  c                |    t        |xs ddd      }|j                  |        |j                  |xs t              S )a  Render the RST markup to an HTML string.

        Parameters
        ----------
        width : int, optional
            Output width in columns.  Defaults to 80.
        theme : rich.terminal_theme.TerminalTheme, optional
            The colour theme to use for the HTML export.  Defaults to
            ``DEFAULT_TERMINAL_THEME`` from :mod:`rich.terminal_theme`.

        Returns
        -------
        str
            A self-contained HTML document.
        r  Tr  r  )r   r  export_htmlr%   )ri   r4  r  r  s       r3   render_to_htmlzRestructuredText.render_to_html  s<    * DNd"")H2H"IIr=   r\   r  r  c                l    t        |xs ddd      }|j                  |        |j                  |      S )an  Render the RST markup to an SVG string.

        Parameters
        ----------
        width : int, optional
            Output width in columns.  Defaults to 80.
        title : str, optional
            Title shown in the SVG image header.  Defaults to an empty string.

        Returns
        -------
        str
            An SVG document as a string.
        r  Tr  r  )r   r  
export_svg)ri   r4  r  r  s       r3   render_to_svgzRestructuredText.render_to_svg  s6    ( DNd!!!..r=   r  r   c           	   #     K   | j                   rt                t                t        j                  j                  | j                  | j                  ddd      }t        ||| j                  | j                  | j                  | j                  | j                        }|j                  |       |j                  rt!        |j                  d   t"              r\|j                  d   j%                          d|j                  d   _        |j                  d   rna|j                  j)                          n9t!        |j                  d   t*              r|j                  j)                          nn|j                  r|j                  D ]  }t!        |t"              rr|j,                  }|j/                  d      rU|j%                  d      }|t1        |      d  }|j3                         }	|	j%                          ||	j&                  z   |	_        |	}|j5                  ||      E d {     | j6                  r7|j8                  r+|j8                  D ]  }
|j5                  |
|      E d {     |j;                  dd	      }|j;                  d
d	      }|j<                  rE|j5                  t?        tA        |j<                   dtB        jD                  ||            E d {    |j;                  dd	      }|j;                  dd	      }|jF                  rF|j5                  t?        tA        |jF                   dtB        jD                  ||            E d {    y y 7 :7 7 7 w)NE   )report_level
halt_level)source_pathsettings_overridesrg  r  r   zrestructuredtext.citationrb  r  z restructuredtext.citation_borderr  citation)r  r   r  r  zrestructuredtext.footerzrestructuredtext.footer_borderFooter)$r  r  r(  r   corepublish_doctreer  r   r-   r  r  r&   r.   r  rk  r  r8  r   r  r   r  r   r  r-  r_   r  renderr  r  r#  r  r   r   r   r  r  )ri   r  r   r  visitorr:  r  strippedtrailingfixedr2   citation_stylecitation_border_styler  r  s                  r3   __rich_console__z!RestructuredText.__rich_console__  s    "$')
 ==00KK02"E 1 
 "44((,,!22
 	7# !!'--b148##B'..0.2##B'+&&r*''++-G//3W=##'') !! "--J *d+"((>>$'$||D1H$S]^4H&OO-ELLN (599 4EI!&J~~j':::# .$  ">>%999 ( !**+FPV*W ' 1 12T^f 1 g~~eW../zszz`u  ~L  M   !!";V!L(()IS[(\>>~~eW^^,H#**[gotu    ; :
sR   E9M%<B&M%"M#AM%%M&A8M%M!A6M%M#M%M%!M%#M%)r  FFFr  Tr   r  r   )r8   r9   r:   r;   r  r   r   r   rS  r
   r  r   r  r$   r  r  r   r   r   r  r<   r=   r3   r,   r,   m  sy   @ 9B,1&+&+'/(,"28?NN U3#345N $D>	N
 d^N d^N  }N  ~N 3-N ""45N 
N4%V[ %hsm %t %`c %>  $J *.	J}J &	J
 
J6  $/ 	/}/ 	/
 
/0J J. J\ Jr=   r,   r  r  )r;   ior   r   html.parserr   r  r  r   r  typingr   r   r   r   r	   r
   r   r   r   r   r  r   rich_rst._vendor.docutils.corer  "rich_rst._vendor.docutils.frontendrich_rst._vendor.docutils.iorich_rst._vendor.docutils.nodes%rich_rst._vendor.docutils.parsers.rst0rich_rst._vendor.docutils.parsers.rst.directives7rich_rst._vendor.docutils.parsers.rst.directives.tablesr  richr   
rich.alignr   rich.consoler   r   r   r   r   rich.jupyterr   
rich.panelr   
rich.styler   rich.syntaxr   r   	rich.textr   
rich.tabler   	rich.ruler   rich.segmentr    
rich.cellsr"   rich.styledr#   rich.terminal_themer$   r%   pygments.lexersr&   r'   pygments.utilr(   importlib.metadata	importlib__all__
__author__metadatar[   __package__r8   __version__r  r4   rc   GeneralBodyr  r6   r  r?   rB   rE   rH   rJ   rL   rN   rP   rR   rT   r   r   	DirectiverV   rw   r|   r   r   r   r   r   r   r   r   r   r   r   r  r  r-  r=  rC  rH  rK  rN  re  ri  rk  ru   r  rv  rz  r   tablesr|  r  r  r  r  r  r(  r  r  r  r  _LATEX_TO_UNICODEr  r.  r  r  r  SparseNodeVisitorr-   r,   r)   reSTr*   r+   r<   r=   r3   <module>r     s     "  	 	  ] ] ] & % ) # & , 7 > &    N N %   +        E : ' 
[3
  (()@A (3- 	hnn,,hnn.A.A8>>CYCY 	
	hnn'')?)? 	
	X^^++X^^-@-@(..BXBX 	
	hnn$$hnn&9&98>>;Q;Q 	
	8>>))8>>+>+>@V@V 	
	(..00(..2E2Ex~~G]G] 	
	X^^++X^^-@-@(..BXBX 	
	(..(((..*=*=x~~?U?U 	
	8>>))8>>+>+>@V@V 	
	hnn,,hnn.A.A8>>CYCY 	
	(..(((..*=*=x~~?U?U 	((,,66 8((,,66 $^(**..88 ^B&X%%))33 &R(**..88  
x''++55 

h..22<< 
"X%%))33 " 
8))--77 
8h&&**44 &Bhsm B B$((,,66 $NEx//33== EPx//33== *E((,,66 EP))--77 4("2"2"6"6"@"@ "X--11;; ,x//33== ,8++//99  $))--77 $N((,,66 B	x~~%%x~~'='= 	
	x~~%%x~~'='= 	 )-#'"
"" " 	"
 " d38n%" d3i " 4##$d8>>+H+H&IIJ": )-#'"
"" " 	"
 " d38n%" d3i " 4##$d8>>+H+H&IIJ".%'(**..99@@FF %'Pt- t-n !& 
 +INN, #s(); c@R \-~ ! _(D$ $S S ,t,t,%.,6?, , &t, .6t, >Ed, t	, "4	, *24	, :CD	,
 ,
 d,
 %+D,
 39$, D, T, $+D, 3=d, t, "4, *1$, 9DT, T, t, &-d, 5<T, t, t, , '0, 8B4, D, $, !*4, 2=d, T, D, #,T, t, d, %+D, 39%,  d!,  u!,  '0!," u#,"  #,& U',& E',& $+E',& 4:5',( U),( E),( $.u),( 7@),* U+,* u+,* '/+,* 8B5+,. /,. "5/,. +7/,. @LU/,0 E1,0 e1,0 &-e1,0 6=e1,2 %3,2 (3,6 T7,6 e7,6 &-e7,6 6?7,8 9,8 "59,8 +6u9,< E=,< "5=,< +8=,< AI%=,> ?,>  .u?,> 7DU?,@ A,@  +EA,@ 4A%A,B UC,B (C,B 1>uC,D E,H uI,H "5I,H +4UI,J UK,J eK,J &-eK,J 6>uK,L eM,L eM,L &,UM,L =B5%u%e5vcW, ^ !
""$*DE 
3 3 Fv-,11 v-,r[P| Pf 4D C Cd C 0r=   