
    KiR+                        d Z dZddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZ  G d d	e      Z G d
 de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d  d!e      Z G d" d#e      Zy$)%zb
Directives for additional body elements.

See `docutils.parsers.rst.directives` for API details.
reStructuredText    )nodes)	Directive)
directives)normalize_options)Lexer
LexerErrorNumberLinesc                       e Zd ZdZdZej                  ej                  dZdZ	dZ
	 ej                  ej                  ej                  ej                  ej                   ej"                  fZ	 d Zy)BasePseudoSectionz!Base class for Topic and Sidebar.TclassnameNc                    t        | j                  j                  t        j                  t        j
                  t        j                  f      sHt        | j                  j                  | j                        r| j                  d| j                  z        | j                          | j                  r| j                  d   }| j                  j                  || j                        \  }}t        j                  |dg| g}d| j                   v r| j                  j                  | j                   d   | j                        \  }}|j#                  t        j$                  | j                   d   dg|        |j'                  |       ng }g }dj)                  | j*                        } | j,                  |g||z    }|dxx   | j                   j/                  dg       z  cc<   | j                  j1                  | j                        \  |_        |_        | j7                  |       |r1| j                  j9                  | j*                  | j:                  |       |gS )NzBThe "%s" directive may not be used within topics or body elements.r    subtitle
classesr   )
isinstancestate_machinenoder   Rootsectionsidebarinvalid_parentserrorr   assert_has_content	argumentsstateinline_textlinenotitleoptionsappendr   extendjoincontent
node_classgetget_source_and_linesourcelineadd_namenested_parsecontent_offset)self
title_text	textnodesmessagestitlesmore_messagestextr   s           p/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/docutils/parsers/rst/directives/body.pyrunzBasePseudoSection.run*   s   4--22!JJu}}EG4--22D4H4HI** 8:>))D E E!>>*J"&**"8"8&0$++#?Ixkk*b=9=>FT\\)+/::+A+ALL,dkk,;(	=ennT\\*-Er 9.79 :.FHyy&tt:v'8:Y4<<++GR88((<<T[[I		dJJ##DLL$2E2EtLv    )__name__
__module____qualname____doc__final_argument_whitespacer   class_option	unchangedoption_spechas_contentr(   r   SubStructuralBibliographic
DecorativeBodyParttopicr   r8    r9   r7   r   r      so    + $&33%//1KKJ<**E,?,?''UZZNOr9   r   c                   (    e Zd ZdZej
                  Zy)Topic   N)r:   r;   r<   required_argumentsr   rH   r(   rI   r9   r7   rK   rK   K   s    Jr9   rK   c                   d    e Zd ZdZej
                  Zej                  de	j                  iz  Zd Zy)SidebarrL   r   c                    t        | j                  j                  t        j                        r| j                  d| j                  z        d| j                  v r| j                  s| j                  d      t        j                  |       S )Nz<The "%s" directive may not be used within a sidebar element.r   z6The "subtitle" option may not be used without a title.)r   r   r   r   r   r   r   r#   r   r   r8   )r0   s    r7   r8   zSidebar.runX   sy    d((--u}}=** 026))< = =%dnn** 0 1 1 !$$T**r9   N)r:   r;   r<   optional_argumentsr   r   r(   r   rA   r   unchanged_requiredr8   rI   r9   r7   rO   rO   Q   s8    J#// *"?"?3A AK+r9   rO   c                   L    e Zd ZdZej
                  ej                  dZdZd Z	y)	LineBlockzLegacy directive for line blocks.

    Use is deprecated in favour of the line block syntax,
    cf. `parsers.rst.states.Body.line_block()`.
    r   Tc                 L   | j                          t        j                  | j                  j	                  dg             }| j
                  j                  | j                        \  |_        |_	        | j                  |       |g}t        | j                        D ]  \  }}| j                  j                  |j                         | j                  | j                   z         \  }}t        j                  |dg| }|j                  |_        |j                  |z   |_	        |j                         r*t#        |      t#        |j%                               z
  |_        ||z  }|j)                  |       | xj                   dz  c_         | j                  j+                  |       |S )Nr   r   r   rL   )r   r   
line_blockr#   r)   r   r*   r!   r+   r,   r-   	enumerater'   r   r    stripr/   lenlstripindentr%   nest_line_block_lines)r0   block	node_listi	line_text
text_nodesr3   r,   s           r7   r8   zLineBlock.runn   sR   !  )9)9'2)FG))==dkkJ		eG	%dll3 
	%LAy#'::#9#9!4;;1D1D#D$F J::i9j9D,,DK

QDI !)ns93C3C3E/FFTMEX&1$
	% 	

((/r9   N)
r:   r;   r<   r=   r   r?   r@   rA   rB   r8   rI   r9   r7   rT   rT   c   s,     '33%//1KKr9   rT   c                   H    e Zd Zej                  ej
                  dZdZd Zy)ParsedLiteralr   Tc                 ^   t        | j                        }| j                          dj                  | j                        }| j
                  j                  || j                        \  }}t        j                  |dg|i |}| j                  dz   |_        | j                  |       |g|z   S )Nr   r   rL   )r   r#   r   r&   r'   r   r    r!   r   literal_blockr/   r,   r-   )r0   r#   r6   rb   r3   r   s         r7   r8   zParsedLiteral.run   s    #DLL1!yy&#zz55dDKKH
H""4DjDGD''!+	dv  r9   N	r:   r;   r<   r   r?   r@   rA   rB   r8   rI   r9   r7   rd   rd      s%    &33%//1KK!r9   rd   c                   f    e Zd ZdZdZej                  ej                  ej                  dZdZ	d Z
y)	CodeBlockzParse and mark up content of a code block.

    Configuration setting: syntax_highlight
       Highlight Code content with Pygments?
       Possible values: ('long', 'short', 'none')

    rL   )r   r   number-linesTc                 b   | j                          | j                  r| j                  d   }nd}t        | j                        }dg}|r|j	                  |       d|v r|j                  |d          	 t        dj                  | j                        || j                  j                  j                  j                        }d|v r8	 t!        |d   xs d	      }|t'        | j                        z   }t)        |||      }t+        j,                  dj                  | j                        |      }| j/                  |       d|v r|d   |j0                  d<   |D ];  \  }}	|r|t+        j2                  |	|	|      z  }$|t+        j4                  |	      z  }= |gS # t        $ rp}| j                  j                  j                  j                  dkD  r't        dj                  | j                        |d      }n| j                  |      Y d }~Jd }~ww xY w# t"        $ r | j%                  d
      w xY w)Nr   r   coder   r      nonerj   rL   z+:number-lines: with non-integer start valuerV   r+   )r   r   r   r#   r$   r%   r   r&   r'   r   documentsettingssyntax_highlightr	   report_levelwarningint
ValueErrorr   rZ   r
   r   rf   r-   
attributesinlineText)
r0   languager#   r   tokensr   	startlineendliner   values
             r7   r8   zCodeBlock.run   s   !>>~~a(HH#DLL1(NN8$NN79-.	*499T\\2H::..77HHJF W$P 7 <1=	  #dll"33G G<F""499T\\#:GLdw(/(9DOOH%$ 	*NGUUE7CC 

5))	* v=  	*zz""++881<tyy6&Ill5)) 	*  Pjj!NOOPs&   3AF H 	H A%HHH.N)r:   r;   r<   r=   rQ   r   r?   r@   rA   rB   r8   rI   r9   r7   ri   ri      s=     &33%//#-#7#7K K/r9   ri   c                   H    e Zd Zej                  ej
                  dZdZd Zy)	MathBlockr   Tc                    t        | j                        }| j                          dj                  | j                        j                  d      }g }|D ]z  }|st        j                  | j                  |fi |}| j                  j                  | j                        \  |_        |_        | j                  |       |j                  |       | |S )Nr   z

)r   r#   r   r&   r'   splitr   
math_block
block_textr   r*   r!   r+   r,   r-   r$   )r0   r#   r'   _nodesr^   r   s         r7   r8   zMathBlock.run   s    #DLL1!))DLL)//7 	 E##DOOUFgFD,,@@MT[YMM$MM$	  r9   Nrg   rI   r9   r7   r   r      s'    &33%//K
 Kr9   r   c                   P    e Zd ZdZdZdZej                  ej                  dZ	d Z
y)RubricrL   r   Tr   c                     t        | j                        }| j                  d   }| j                  j	                  || j
                        \  }}t        j                  |dg|i |}| j                  |       |g|z   S )Nr   r   )	r   r#   r   r   r    r!   r   rubricr-   )r0   r#   rubric_textr2   r3   r   s         r7   r8   z
Rubric.run   sp    #DLL1nnQ'"jj44[$++N	8k2E	EWEfx(""r9   N)r:   r;   r<   rM   rQ   r>   r   r?   r@   rA   r8   rI   r9   r7   r   r      s2     $&33%//1K#r9   r   c                       e Zd ZdZg Zd Zy)
BlockQuoteTc                     | j                          | j                  j                  | j                  | j                        }|D ]4  }t        |t        j                        s|dxx   | j                  z  cc<   6 |S )Nr   )r   r   block_quoter'   r/   r   r   r   )r0   elementselements      r7   r8   zBlockQuote.run  sh    !::))$,,8K8KL 	3G'5#4#45	"dll2"	3 r9   N)r:   r;   r<   rB   r   r8   rI   r9   r7   r   r     s    KGr9   r   c                       e Zd ZdgZy)EpigraphepigraphNr:   r;   r<   r   rI   r9   r7   r   r     s	    lGr9   r   c                       e Zd ZdgZy)
Highlights
highlightsNr   rI   r9   r7   r   r     	    nGr9   r   c                       e Zd ZdgZy)	PullQuotez
pull-quoteNr   rI   r9   r7   r   r     r   r9   r   c                   H    e Zd Zej                  ej
                  dZdZd Zy)Compoundr   Tc                    | j                          dj                  | j                        }t        j                  |      }|dxx   | j
                  j                  dg       z  cc<   | j                  j                  | j                        \  |_
        |_        | j                  |       | j                  j                  | j                  | j                  |       |gS )Nr   r   r   )r   r&   r'   r   compoundr#   r)   r   r*   r!   r+   r,   r-   r   r.   r/   )r0   r6   r   s      r7   r8   zCompound.run$  s    !yy&~~d#Y4<<++GR88((<<T[[I		d

d.A.A4Hvr9   Nrg   rI   r9   r7   r   r     s%    &33%//1KK	r9   r   c                   :    e Zd ZdZdZdej                  iZdZd Z	y)	ContainerrL   Tr   c                 t   | j                          dj                  | j                        }	 | j                  r#t	        j
                  | j                  d         }ng }t        j                  |      }|d   j                  |       | j                  j                  | j                        \  |_        |_        | j#                  |       | j$                  j'                  | j                  | j(                  |       |gS # t        $ r0 | j                  d| j                  d| j                  d   d      w xY w)Nr   r   z#Invalid class attribute value for "z" directive: "z".r   )r   r&   r'   r   r   r?   ru   r   r   r   	containerr%   r   r*   r!   r+   r,   r-   r   r.   r/   )r0   r6   r   r   s       r7   r8   zContainer.run7  s    !yy&	2~~$11$..2CD
 t$Yw'((<<T[[I		d

d.A.A4Hv  	2**99dnnQ/12 2	2s   1C> >9D7N)
r:   r;   r<   rQ   r>   r   r@   rA   rB   r8   rI   r9   r7   r   r   0  s(     $://0KKr9   r   N)r=   __docformat__docutilsr   docutils.parsers.rstr   r   docutils.parsers.rst.rolesr   docutils.utils.code_analyzerr   r	   r
   r   rK   rO   rT   rd   ri   r   r   r   r   r   r   r   r   rI   r9   r7   <module>r      s   
 #  * + 8 G G3	 3l + +$	 B!I !">	 >B	 4#Y #" z 
 

 
y $	 r9   