U
    \	a+	                     @   s8   d dl Z d dlmZ G dd dZdd Ze ZeZdS )    N)_apic                   @   sB   e Zd ZdZdd Zdd Zdd Zeej	dd	d
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kwargs r
   8/tmp/pip-unpacked-wheel-wjyw_3jo/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|| dS )zW
        Update ``self.params`` (which must be a dict) with the supplied args.
        N)r   updater   r
   r
   r   r   +   s    zSubstitution.updatez3.3zassign to the params attribute)alternativec                 C   s   |  }||_ |S )a@  
        In the case where the params is a mutable sequence (list or
        dictionary) and it may change before this class is called, one may
        explicitly use a reference to the params rather than using *args or
        **kwargs which will copy the values and not reference them.

        :meta private:
        )r   )clsr   resultr
   r
   r   from_params1   s    zSubstitution.from_paramsN)__name__
__module____qualname__r   r   r   r   classmethodr   
deprecatedr   r
   r
   r
   r   r      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_copyC   s    zcopy.<locals>.do_copyr
   )r   r    r
   r   r   copyA   s    r!   )r   Z
matplotlibr   r   r!   ZinterpdZdedent_interpdr
   r
   r
   r   <module>   s
   ;