
    zYHhS                     p    d dl Z ddlmZ d Z G d d      Z G d de      Z G d	 d
      Zd Z e       Z	y)    N   )_apic                       fd}|S )a  
    Decorator for defining the kwdoc documentation of artist properties.

    This decorator can be applied to artist property setter methods.
    The given text is stored in a private attribute ``_kwarg_doc`` on
    the method.  It is used to overwrite auto-generated documentation
    in the *kwdoc list* for artists. The kwdoc list is used to document
    ``**kwargs`` when they are properties of an artist. See e.g. the
    ``**kwargs`` section in `.Axes.text`.

    The text should contain the supported types, as well as the default
    value if applicable, e.g.:

        @_docstring.kwarg_doc("bool, default: :rc:`text.usetex`")
        def set_usetex(self, usetex):

    See Also
    --------
    matplotlib.artist.kwdoc

    c                     | _         | S N)
_kwarg_doc)functexts    N/var/www/html/planif/env/lib/python3.12/site-packages/matplotlib/_docstring.py	decoratorzkwarg_doc.<locals>.decorator   s         )r
   r   s   ` r   	kwarg_docr      s    , r   c                       e Zd ZdZd Zd Zy)SubstitutionaG  
    A decorator that performs %-substitution on an object's docstring.

    This decorator should be robust even if ``obj.__doc__`` is None (for
    example, if -OO was passed to the interpreter).

    Usage: construct a docstring.Substitution with a sequence or dictionary
    suitable for performing substitution; then decorate a suitable function
    with the constructed object, e.g.::

        sub_author_name = Substitution(author='Jason')

        @sub_author_name
        def some_function(x):
            "%(author)s wrote this function"

        # note that some_function.__doc__ is now "Jason wrote this function"

    One can also use positional arguments::

        sub_first_last_names = Substitution('Edgar Allen', 'Poe')

        @sub_first_last_names
        def some_function(x):
            "%s %s wrote the Raven"
    c                 8    |r|rt        d      |xs || _        y )Nz+Only positional or keyword args are allowed)	TypeErrorparams)selfargskwargss      r   __init__zSubstitution.__init__=   s    FIJJnfr   c                     |j                   r1t        j                  |j                         | j                  z  |_         |S r   )__doc__inspectcleandocr   )r   r	   s     r   __call__zSubstitution.__call__B   s-    <<"++DLL9DKKGDLr   N)__name__
__module____qualname__r   r   r   r   r   r   r   r   "   s    4%
r   r   c                       e Zd Zd Zy)_ArtistKwdocLoaderc                    |j                  d      st        |      |d t        d        ddlm}m} 	 fdt        j                  |      D        \  }| j                  | ||            S # t        $ r}t        |      |d }~ww xY w)Nz:kwdocr   )Artistkwdocc              3   @   K   | ]  }|j                   k(  r|  y wr   )r   ).0clsnames     r   	<genexpr>z1_ArtistKwdocLoader.__missing__.<locals>.<genexpr>O   s$      -C||t+  -s   )
endswithKeyErrorlenmatplotlib.artistr$   r%   r   recursive_subclasses
ValueError
setdefault)r   keyr$   r%   r(   er)   s         @r   __missing__z_ArtistKwdocLoader.__missing__I   s    ||H%3-?S]N#3	'-4#<#<V#D -DC sE#J//  	'3-Q&	's    A. .	B7BBN)r   r   r    r4   r   r   r   r"   r"   H   s    
0r   r"   c                   "    e Zd ZdZd Zd Zd Zy)_ArtistPropertiesSubstitutionaQ  
    A class to substitute formatted placeholders in docstrings.

    This is realized in a single instance ``_docstring.interpd``.

    Use `~._ArtistPropertiesSubstition.register` to define placeholders and
    their substitution, e.g. ``_docstring.interpd.register(name="some value")``.

    Use this as a decorator to apply the substitution::

        @_docstring.interpd
        def some_func():
            '''Replace %(name)s.'''

    Decorating a class triggers substitution both on the class docstring and
    on the class' ``__init__`` docstring (which is a commonly required
    pattern for Artist subclasses).

    Substitutions of the form ``%(classname:kwdoc)s`` (ending with the
    literal ":kwdoc" suffix) trigger lookup of an Artist subclass with the
    given *classname*, and are substituted with the `.kwdoc` of that class.
    c                 "    t               | _        y r   )r"   r   )r   s    r   r   z&_ArtistPropertiesSubstitution.__init__n   s    (*r   c                 <     | j                   j                  di | y)z
        Register substitutions.

        ``_docstring.interpd.register(name="some value")`` makes "name" available
        as a named parameter that will be replaced by "some value".
        Nr   )r   update)r   r   s     r   registerz&_ArtistPropertiesSubstitution.registerq   s     	$V$r   c                     |j                   r1t        j                  |j                         | j                  z  |_         t	        |t
              r/|j                  t        j                  k7  r | |j                         |S r   )r   r   r   r   
isinstancetyper   object)r   objs     r   r   z&_ArtistPropertiesSubstitution.__call__z   sR    ;;!**3;;7$++ECKc4 S\\V__%D
r   N)r   r   r    r   r   r:   r   r   r   r   r6   r6   V   s    .+%r   r6   c                       fd}|S )z;Copy a docstring from another source function (if present).c                 B    j                   rj                   | _         | S r   )r   )targetsources    r   do_copyzcopy.<locals>.do_copy   s    >>#^^FNr   r   )rC   rD   s   ` r   copyrE      s     Nr   )
r    r   r   r   dictr"   r6   rE   interpdr   r   r   <module>rI      sA     8# #L0 0) )X (
)r   