
    -Ph	                        d Z ddlmZ ddlmZ ddlmZ ddlZddlm	Z	 erddlm
Z
 ddlmZ dd	lmZ dd
lmZmZ  G d dej                  Z G d de	          ZddZddZdS )a  Provides the ``ifconfig`` directive.

The ``ifconfig`` directive enables writing documentation
that is included depending on configuration variables.

Usage::

    .. ifconfig:: releaselevel in ('alpha', 'beta', 'rc')

       This stuff is only included in the built docs for unstable versions.

The argument for ``ifconfig`` is a plain Python expression, evaluated in the
namespace of the project configuration (that is, all variables from
``conf.py`` are available.)
    )annotations)TYPE_CHECKING)nodesN)SphinxDirective)ClassVar)Node)Sphinx)ExtensionMetadata
OptionSpecc                      e Zd ZdS )ifconfigN)__name__
__module____qualname__     S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/ext/ifconfig.pyr   r   #   s        Dr   r   c                  6    e Zd ZU dZdZdZdZi Zded<   d
dZ	d	S )IfConfigT   r   zClassVar[OptionSpec]option_specreturn
list[Node]c                    t                      }| j        j        |_        |                     |           | j        d         |d<   ||                     d          z  }|gS )Nr   exprT)allow_section_headings)r   statedocumentset_source_info	argumentsparse_content_to_nodes)selfnodes     r   runzIfConfig.run.   s]    zz
+T"""~a(V++4+HHHvr   N)r   r   )
r   r   r   has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacer   __annotations__r$   r   r   r   r   r   '   sR         K $(*K****     r   r   appr	   doctreenodes.documentdocnamestrr   Nonec                x   d | j         D             }|                    | j         j                                                   | j        j        |d<   t          |                    t                              D ]}	 t          |d         |          }|s|
                    g            1|
                    |j                   L# t          $ rh}ddlm} d                     ||j        |                    }|j                            d| |          }	|
                    |	           Y d }~d }~ww xY wd S )	Nc                (    i | ]}|j         |j        S r   )namevalue).0confvals     r   
<dictcomp>z*process_ifconfig_nodes.<locals>.<dictcomp>8   s    	@	@	@'',	@	@	@r   builderr   r   )format_exception_only z,Exception occurred in ifconfig expression: 
)	base_node)configupdate__dict__copyr7   r2   listfindallr   evalreplace_selfchildren	Exception	tracebackr8   join	__class__reportererror)
r*   r+   r-   nsr#   reserrr8   msgnewnodes
             r   process_ifconfig_nodesrO   7   sk   	@	@SZ	@	@	@BIIcj!&&(()))K$ByMW__X..// 1 1	1tF|R((C  1!!"%%%%!!$-0000  	' 	' 	'777777''//sCCDDC&,,EEEQU -  G g&&&&&&&&	'1 1s   <C
D7AD22D7r
   c                    |                      t                     |                     dt                     |                     dt
                     t          j        ddS )Nr   zdoctree-resolvedT)versionparallel_read_safe)add_noder   add_directiver   connectrO   sphinx__display_version__)r*   s    r   setuprX   N   sX    LLj(+++KK"$:;;;-"  r   )r*   r	   r+   r,   r-   r.   r   r/   )r*   r	   r   r
   )__doc__
__future__r   typingr   docutilsr   rV   sphinx.util.docutilsr   r   docutils.nodesr   sphinx.applicationr	   sphinx.util.typingr
   r   Elementr   r   rO   rX   r   r   r   <module>rb      sA     # " " " " "                    0 0 0 0 0 0 A######))))))@@@@@@@@	 	 	 	 	u} 	 	 	        1 1 1 1.     r   