o
    t€#g`  ã                   @   s`   d dl Z ddlmZ dd„ ZG dd„ dƒZG dd	„ d	eƒZG d
d„ deƒZdd„ Zeƒ  Z	Z
dS )é    Né   )Ú_apic                    ó   ‡ fd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
   ˆ | _ | S ©N)Ú
_kwarg_doc)Úfunc©Útext© úz/var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/matplotlib/_docstring.pyÚ	decorator   s   zkwarg_doc.<locals>.decoratorr
   )r	   r   r
   r   r   Ú	kwarg_doc   s   r   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	Ú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                 O   s   |r|rt dƒ‚|p|| _d S )Nz+Only positional or keyword args are allowed)Ú	TypeErrorÚparams©ÚselfÚargsÚkwargsr
   r
   r   Ú__init__=   s   zSubstitution.__init__c                 C   s   |j rt |j ¡| j |_ |S r   )Ú__doc__ÚinspectÚcleandocr   )r   r   r
   r
   r   Ú__call__B   s   zSubstitution.__call__c                 O   s   | j j|i |¤Ž dS )zW
        Update ``self.params`` (which must be a dict) with the supplied args.
        N)r   Úupdater   r
   r
   r   r   G   s   zSubstitution.updateN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r
   r
   r
   r   r   "   s
    r   c                   @   s   e Zd Zdd„ ZdS )Ú_ArtistKwdocLoaderc              
      s†   |  d¡s	t|ƒ‚|d tdƒ … ‰ ddlm}m} z‡ fdd„t |¡D ƒ\}W n ty: } zt|ƒ|‚d }~ww |  	|||ƒ¡S )Nz:kwdocr   )ÚArtistÚkwdocc                    s   g | ]	}|j ˆ kr|‘qS r
   )r   )Ú.0Úcls©Únamer
   r   Ú
<listcomp>U   s    
ÿz2_ArtistKwdocLoader.__missing__.<locals>.<listcomp>)
ÚendswithÚKeyErrorÚlenÚmatplotlib.artistr   r    r   Úrecursive_subclassesÚ
ValueErrorÚ
setdefault)r   Úkeyr   r    r"   Úer
   r#   r   Ú__missing__O   s   

€ÿz_ArtistKwdocLoader.__missing__N)r   r   r   r/   r
   r
   r
   r   r   N   s    r   c                       s(   e Zd ZdZdd„ Z‡ fdd„Z‡  ZS )Ú_ArtistPropertiesSubstitutionaÜ  
    A `.Substitution` with two additional features:

    - 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.
    - 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).
    c                 C   s   t ƒ | _d S r   )r   r   )r   r
   r
   r   r   h   s   z&_ArtistPropertiesSubstitution.__init__c                    s0   t ƒ  |¡ t|tƒr|jtjkr| |jƒ |S r   )Úsuperr   Ú
isinstanceÚtyper   Úobject)r   Úobj©Ú	__class__r
   r   r   k   s   
z&_ArtistPropertiesSubstitution.__call__)r   r   r   r   r   r   Ú__classcell__r
   r
   r6   r   r0   \   s    r0   c                    r   )z;Copy a docstring from another source function (if present).c                    s   ˆ j rˆ j | _ | S r   )r   )Útarget©Úsourcer
   r   Údo_copyt   s   zcopy.<locals>.do_copyr
   )r;   r<   r
   r:   r   Úcopyr   s   r=   )r   Ú r   r   r   Údictr   r0   r=   Údedent_interpdÚinterpdr
   r
   r
   r   Ú<module>   s    ,