
    G8c                     p    d dl Z ddlmZ  G d d      Z G d de      Z G d d	e      Zd
 Z e       xZZ	y)    N   )_apic                   "    e Zd 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      7/usr/lib/python3/dist-packages/matplotlib/_docstring.py__init__zSubstitution.__init__!   s    FIJJnf    c                     |j                   r1t        j                  |j                         | j                  z  |_         |S N)__doc__inspectcleandocr	   )r   funcs     r   __call__zSubstitution.__call__&   s-    <<"++DLL9DKKGDLr   c                 <     | j                   j                  |i | y)zW
        Update ``self.params`` (which must be a dict) with the supplied args.
        N)r	   updater
   s      r   r   zSubstitution.update+   s     	D+F+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                 F   |j                  d      st        |      |d t        d        }ddlm}m} 	 t        j                  |      D cg c]  }|j                  |k(  r| c}\  }| j                  | ||            S c c}w # t        $ r}t        |      |d }~ww xY w)Nz:kwdocr   )Artistkwdoc)endswithKeyErrorlenmatplotlib.artistr!   r"   r   recursive_subclassesr   
ValueError
setdefault)r   keynamer!   r"   clses          r   __missing__z_ArtistKwdocLoader.__missing__3   s    ||H%3-?S]N#3	'#'#<#<V#D -C||t+  -DC sE#J//	- 	'3-Q&	's)   B B$B B 	B BB N)r   r   r   r.   r   r   r   r   r   2   s    
0r   r   c                   (     e Zd ZdZd Z fdZ x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                 "    t               | _        y r   )r   r	   )r   s    r   r   z&_ArtistPropertiesSubstitution.__init__L   s    (*r   c                     t         |   |       t        |t              r/|j                  t
        j                  k7  r | |j                         |S r   )superr   
isinstancetyper   object)r   obj	__class__s     r   r   z&_ArtistPropertiesSubstitution.__call__O   s:    c4 S\\V__%D
r   )r   r   r   r   r   r   __classcell__)r8   s   @r   r0   r0   @   s    	+ r   r0   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_copyX   s    >>#^^FNr   r   )r=   r>   s   ` r   copyr?   V   s     Nr   )
r    r   r   dictr   r0   r?   dedent_interpdinterpdr   r   r   <module>rD      sB     ), ),X0 0L , 9: :r   