3
6Ad]‘  ã               @   s„   d dl Z d dlmZ G dd„ deƒZejdƒG dd„ deƒƒZejddd	�d
d„ ƒZdd„ Zeƒ Z	dd„ Z
ejddd	�dd„ ƒZdS )é    N)Úcbookc               @   s4   e Zd ZdZdd„ Zdd„ Zdd„ Ze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	   ú/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/matplotlib-3.1.1-py3.6-linux-x86_64.egg/matplotlib/docstring.pyÚ__init__!   s    zSubstitution.__init__c             C   s   |j r| j | j;  _ |S )N)Ú__doc__r   )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   Úupdate)r   r   r   r	   r	   r
   r   +   s    zSubstitution.updatec             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.
        )r   )Úclsr   Úresultr	   r	   r
   Úfrom_params1   s    zSubstitution.from_paramsN)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r   Úclassmethodr   r	   r	   r	   r
   r      s
   r   z3.1c               @   s"   e Zd ZdZddd„Zdd„ ZdS )	ÚAppenderaf  
    A function decorator that will append an addendum to the docstring
    of the target function.

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

    Usage: construct a docstring.Appender with a string to be joined to
    the original docstring. An optional 'join' parameter may be supplied
    which will be used to join the docstring and addendum. e.g.

    add_copyright = Appender("Copyright (c) 2009", join='
')

    @add_copyright
    def my_dog(has='fleas'):
        "This docstring will have a copyright below"
        pass
    Ú c             C   s   || _ || _d S )N)ÚaddendumÚjoin)r   r   r   r	   r	   r
   r   R   s    zAppender.__init__c             C   s$   |j | jg}|j o| jj|ƒ|_ |S )N)r   r   r   )r   r   Zdocitemsr	   r	   r
   r   V   s    zAppender.__call__N)r   )r   r   r   r   r   r   r	   r	   r	   r
   r   >   s   
r   zinspect.getdoc())Úalternativec             C   s   | j otj| j ƒ| _ | S )zDedent a docstring (if present))r   r   Údedent)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 )N)r   )Útarget)Úsourcer	   r
   Údo_copye   s    zcopy.<locals>.do_copyr	   )r   r   r	   )r   r
   Úcopyc   s    r    c             C   s   t j| ƒ| _t| ƒS )z@Dedent *func*'s docstring, then interpolate it with ``interpd``.)ÚinspectÚgetdocr   Úinterpd)r   r	   r	   r
   Údedent_interpdq   s    r$   z#docstring.copy() and cbook.dedent()c                s   ‡ fdd„S )zOA decorator that will copy the docstring from the source and
    then dedent itc                s   t tˆ ƒ| ƒƒS )N)r   r    )r   )r   r	   r
   Ú<lambda>   s    zcopy_dedent.<locals>.<lambda>r	   )r   r	   )r   r
   Úcopy_dedentw   s    r&   )r!   Ú
matplotlibr   Úobjectr   Ú
deprecatedr   r   r    r#   r$   r&   r	   r	   r	   r
   Ú<module>   s   8