
    -Ph"                        d dl mZ d dlmZ d dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d d	lmZ d d
lmZ ddlmZ ddlmZmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z'm(Z(m)Z)m*Z* ddl+m,Z, deddfdZ-edefd            Z.defdZ/dedefdZ0dej1        fdZ2dej1        fdZ3dej4        ddfd Z5 G d! d"e(          Z6 G d# d$e          Z7dS )%    )contextmanager)partialN)Path)nodes)
directives)version_info)Sphinx)BuildEnvironment)SphinxTransform   )compiled)findall	read_text)setup_article_info)setup_badges_and_buttons)setup_cards)setup_dropdown)setup_grids)setup_icons)PassthroughTextElementSdDirectivecreate_componentsetup_custom_directives)
setup_tabsappreturnc           	         |                      dt                     |                      dt                     |                     t          j        dt          t          f           |                     t          t          t          ft          t          ft          t          ft          t          ft          t          f           t          |           5 }|                     dt          d           |                     t                     t          |            t!          |            t#          |            t%          |            t'          |            t)          |            t+          |            ddd           n# 1 swxY w Y   |                     d	i d
           |                      dt/          t0          |                     dS )zSet up the sphinx extension.zbuilder-initedzenv-updatedT)overridehtml)r   latextextmantexinfodiv)r   Nsd_custom_directivesenvzconfig-inited)directive_map)connectupdate_css_jsupdate_css_linksadd_noder   	containervisit_containerdepart_containerr   visit_depart_nullcapture_directivesadd_directiveDivadd_transformAddFirstTitleCssr   r   r   r   r   r   r   add_config_valuer   r   )r   r'   s     W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx_design/extension.pysetup_extensionr7      s   KK -000KK/000 LL$o?O-P     LL!23 "34!23 12"$56     
C	 	  	 M%t444*+++ %%%CCsC33	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  /U;;;KK!8VVV    s   B!E==FFc              #   P   K   i | j         fd}|| _         V  | _         dS )z<Capture the directives that are registered by the extension.c                 &    || <    | |fi | d S )N )name	directivekwargsr1   r'   s      r6   _add_directivez*capture_directives.<locals>._add_directiveF   s-    'ddI0000000    N)r1   )r   r>   r1   r'   s     @@r6   r0   r0   @   sY       M%M1 1 1 1 1 1 'C
%Cr?   c                    d| j         _        t          | j                  dz                                  }|                                }|                    d           | j        j        	                    t          |                     |dz  }|                     |j                   |                                s*t          t          d          }|                    |           t          t          d          }t           dk     rEt#          j        |                    d	          d
                                          }|d| dz  }n|dz  }|                     |j                   |                                rdS |rd| j         _        |                    d          D ]}|                                 |                    |d	           dS )z$Copy the CSS to the build directory.F_sphinx_design_staticT)exist_okzdesign-tabs.jsz
sd_tabs.jszstyle.min.css)   r   utf8)usedforsecurityzsphinx-design.z.min.csszsphinx-design.min.cssNz*.css)encoding)r&   sphinx_design_css_changedr   outdirabsoluteexistsmkdirconfightml_static_pathappendstradd_js_filer;   r   static_module
write_textsphinx_versionhashlibmd5encode	hexdigestadd_css_fileglobunlink)r   static_pathstatic_existedjs_pathcontenthashcss_pathpaths           r6   r)   r)   O   s    ).CG%
##&==GGIIK ''))Nt$$$J&&s;'7'7888,,GOOGL!!!>> $M<887###77G{7>>&115IIISSUU!@$!@!@!@@ !88X]###  1,0)  ))  &11111r?   r&   c                 `    |j         r&t          |j                                                  S dS )zUIf CSS has changed, all files must be re-written, to include the correct stylesheets.N)rG   listall_docskeys)r   r&   s     r6   r*   r*   r   s3    
$ )CL%%''((() )r?   nodec                     d}i }|                     dd          rd}d|v r|d         |d<   | j                             | j        |dfd|i|           d S )Nzdocutils containeris_divFdocutilsstyler$   CLASS)getbodyrN   starttag)selfrf   classesattrss       r6   r-   r-   x   st    "GExx%   $ggI]T]4GGgGGGHHHHHr?   c                 :    | j                             d           d S )Nz</div>
)rm   rN   ro   rf   s     r6   r.   r.      s    IZ     r?   c                     dS )zvisit/depart passthroughNr:   rs   s     r6   r/   r/      s      r?   c                   ^    e Zd ZdZdZdZej        ej        dZdZ	de
ej                 fdZdS )r2   zSame as the ``container`` directive,
    but does not add the ``container`` class in HTML outputs,
    which can interfere with Bootstrap CSS.
    r   T)rj   r;   r   c                    	 | j         r t          j        | j         d                   }ng }n?# t          $ r2}|                     d| j         d| j         d          d          |d }~ww xY wt          dd                    | j                  |          }d| j	        v r| j	        d         |d<   | 
                    |           |                     |           | j        r&| j                            | j        | j        |           |gS )	Nr   z#Invalid class attribute value for "z" directive: "z".r$   
)rawtextrp   rj   )	argumentsr   class_option
ValueErrorerrorr;   r   joinr^   optionsset_source_infoadd_namestatenested_parsecontent_offset)ro   rp   excrf   s       r6   run_with_defaultszDiv.run_with_defaults   s!   	~ $1$.2CDD 	 	 	**ddiddt~^_O`ddd 	  tyy/F/FPWXXXdl"" L1DMT"""d< 	MJ##DL$2EtLLLvs   ), 
A(-A##A(N)__name__
__module____qualname____doc__optional_argumentsfinal_argument_whitespacer   	unchangedoption_spechas_contentrc   r   Noder   r:   r?   r6   r2   r2      sf         
  $&0*:NOOKK4
#3      r?   r2   c                       e Zd ZdZdZd ZdS )r4   z/Add a CSS class to to the first sections title.i  c                    d} t          | j                  t          j                  D ]C} t          |          t          j                  D ]}|                                dk    rd} n |sd S  t          | j                  t          j                  D ]p}t          |j        d         t          j	                  rGd|j        d         v r'|j        d         d         
                    d           ndg|j        d         d<    d S d S )NFsd_hide_titleTr   rp   z	sd-d-none)r   documentr   docinfo
field_nameastextsection
isinstancechildrentitlerN   )ro   hider   r;   r   s        r6   applyzAddFirstTitleCss.apply   s"   -wt}--em<< 	 	G((()9::  ;;==O33DE 4  	F-wt}--em<< 	 	G'*1-u{;; C 0 333$Q'	299+FFFF6A]G$Q'	2EE	 	r?   N)r   r   r   r   default_priorityr   r:   r?   r6   r4   r4      s/        99    r?   r4   )8
contextlibr   	functoolsr   rT   pathlibr   ri   r   docutils.parsers.rstr   sphinxr   rS   sphinx.applicationr	   sphinx.environmentr
   sphinx.transformsr    r   rQ   _compatr   r   article_infor   badges_buttonsr   cardsr   dropdownr   gridsr   iconsr   sharedr   r   r   r   tabsr   r7   r0   r)   r*   r   r-   r.   Elementr/   r2   r4   r:   r?   r6   <module>r      s   % % % % % %                    + + + + + + 1 1 1 1 1 1 % % % % % % / / / / / / - - - - - - ' ' ' ' ' ' ' ' ' ' ' ' ' ' , , , , , , 4 4 4 4 4 4       $ $ $ $ $ $                              D    D &F & & & & 2v  2  2  2  2F)& )'7 ) ) ) )I
 I I I I! ! ! ! !#%- #D # # # #    +   >         r?   