
    O&i	                         d Z ddlmZmZmZ 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  G d
 dej                  Z G d de          Zdedej        deddfdZdedeeef         f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.)
    )AnyDictList)nodes)NodeN)Sphinx)SphinxDirective)nested_parse_with_titles)
OptionSpecc                       e Zd ZdS )ifconfigN)__name__
__module____qualname__     `/home/geonatureadmin/si_en_reseau/tutos/venv/lib/python3.11/site-packages/sphinx/ext/ifconfig.pyr   r      s        Dr   r   c                   F    e Zd ZU dZdZdZdZi Zee	d<   de
e         fdZdS )IfConfigT   r   option_specreturnc                     t                      }| j        j        |_        |                     |           | j        d         |d<   t          | j        | j        |           |gS )Nr   expr)r   statedocumentset_source_info	argumentsr
   content)selfnodes     r   runzIfConfig.run)   sX    zz
+T"""~a(V T\4@@@vr   N)r   r   r   has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacer   r   __annotations__r   r   r"   r   r   r   r   r   !   s\         K $ K   T$Z      r   r   appdoctreedocnamer   c                 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|z  |          }	|
                    |	           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>3   s    	@	@	@'',	@	@	@r   builderr   r   )format_exception_only z.Exception occurred in ifconfig expression: 
%s)	base_node)configupdate__dict__copyr2   r-   listfindallr   evalreplace_selfchildren	Exception	tracebackr3   join	__class__reportererror)
r(   r)   r*   nsr!   reserrr3   msgnewnodes
             r   process_ifconfig_nodesrJ   2   sp   	@	@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&,, .I-0.1<@ - B BG g&&&&&&&&	'1 1s   <C
D7AD22D7c                     |                      t                     |                     dt                     |                     dt
                     t          j        ddS )Nr   zdoctree-resolvedT)versionparallel_read_safe)add_noder   add_directiver   connectrJ   sphinx__display_version__)r(   s    r   setuprS   H   sQ    LLj(+++KK"$:;;;1NNNr   )__doc__typingr   r   r   docutilsr   docutils.nodesr   rQ   sphinx.applicationr   sphinx.util.docutilsr	   sphinx.util.nodesr
   sphinx.util.typingr   Elementr   r   r   strrJ   rS   r   r   r   <module>r^      si     # " " " " " " " " "              % % % % % % 0 0 0 0 0 0 6 6 6 6 6 6 ) ) ) ) ) )	 	 	 	 	u} 	 	 	       "1 1 1# 1RV 1 1 1 1,Ov O$sCx. O O O O O Or   