a
    ضaw                     @   sT   d dl Z G dd dZdd ZG dd deZG dd	 d	eZd
d Ze  ZZdS )    Nc                   @   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   d/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/matplotlib/docstring.py__init__   s    zSubstitution.__init__c                 C   s   |j rt|j | j |_ |S N)__doc__inspectcleandocr   )r   funcr   r   r	   __call__$   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   update)r   r   r   r   r   r	   r   )   s    zSubstitution.updateN)__name__
__module____qualname__r   r
   r   r   r   r   r   r	   r      s   r   c                 c   s&   | V  |   D ]}t|E d H  qd S r   )__subclasses___recursive_subclasses)clssubclsr   r   r	   r   0   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||W Y d }~n
d }~0 0 | |||S )Nz:kwdocr   )Artistkwdocc                    s   g | ]}|j  kr|qS r   )r   ).0r   namer   r	   
<listcomp>=   s   
z2_ArtistKwdocLoader.__missing__.<locals>.<listcomp>)	endswithKeyErrorlenZmatplotlib.artistr   r   r   
ValueError
setdefault)r   keyr   r   r   er   r   r	   __missing__7   s    
 z_ArtistKwdocLoader.__missing__N)r   r   r   r'   r   r   r   r	   r   6   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
   P   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   S   s    
z&_ArtistPropertiesSubstitution.__call__)r   r   r   r   r
   r   __classcell__r   r   r.   r	   r(   D   s   r(   c                    s    fdd}|S )z;Copy a docstring from another source function (if present).c                    s    j r j | _ | S r   )r   )targetsourcer   r	   do_copy\   s    zcopy.<locals>.do_copyr   )r3   r4   r   r2   r	   copyZ   s    r5   )	r   r   r   dictr   r(   r5   Zdedent_interpdZinterpdr   r   r   r	   <module>   s   ,