o
    ]i                     @   s   d Z ddlZddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZmZ ddlmZmZ ejd	ejf Zes:J d
ejejddedejeje
  dededef
ddZdS )z.Utility functions for working with docstrings.    N)ChainMap)	Signature)chain   )DocstringMetaDocstringParamDocstringReturnsDocstringStyleRenderingStyle)composeparse. )excludestylerendering_styleothersr   r   r   returnc                    s    dt dt f fdd}|S )aq  A function decorator that parses the docstrings from `others`,
    programmatically combines them with the parsed docstring of the decorated
    function, and replaces the docstring of the decorated function with the
    composed result. Only parameters that are part of the decorated functions
    signature are included in the combined docstring. When multiple sources for
    a parameter or docstring metadata exists then the decorator will first
    default to the wrapped function's value (when available) and otherwise use
    the rightmost definition from ``others``.

    The following example illustrates its usage:

    >>> def fun1(a, b, c, d):
    ...    '''short_description: fun1
    ...
    ...    :param a: fun1
    ...    :param b: fun1
    ...    :return: fun1
    ...    '''
    >>> def fun2(b, c, d, e):
    ...    '''short_description: fun2
    ...
    ...    long_description: fun2
    ...
    ...    :param b: fun2
    ...    :param c: fun2
    ...    :param e: fun2
    ...    '''
    >>> @combine_docstrings(fun1, fun2)
    >>> def decorated(a, b, c, d, e, f):
    ...     '''
    ...     :param e: decorated
    ...     :param f: decorated
    ...     '''
    >>> print(decorated.__doc__)
    short_description: fun2
    <BLANKLINE>
    long_description: fun2
    <BLANKLINE>
    :param a: fun1
    :param b: fun1
    :param c: fun2
    :param e: fun2
    :param f: decorated
    :returns: fun1
    >>> @combine_docstrings(fun1, fun2, exclude=[DocstringReturns])
    >>> def decorated(a, b, c, d, e, f): pass
    >>> print(decorated.__doc__)
    short_description: fun2
    <BLANKLINE>
    long_description: fun2
    <BLANKLINE>
    :param a: fun1
    :param b: fun1
    :param c: fun2
    :param e: fun2

    :param others: callables from which to parse docstrings.
    :param exclude: an iterable of ``DocstringMeta`` subclasses to exclude when
        combining docstrings.
    :param style: style composed docstring. The default will infer the style
        from the decorated function.
    :param rendering_style: The rendering style used to compose a docstring.
    :return: the decorated function with a modified docstring.
    funcr   c           	         s(  t | }t| jp
d}dd D |g }ttdd |D   t|D ]}|js+q%|j|_|j|_ t|D ]}|j	s>q8|j	|_	|j
|_
 i }|D ])}i }|jD ]}t|}|v r]qR||g | qR| D ]\}}|||< qkqK fdd|jD |t< tt|  |_t|d| _| S )N c                 S   s   g | ]	}t |jp	d qS )r   )r   __doc__).0otherr   r   Z/var/www/html/stock_analysis/be/venv/lib/python3.10/site-packages/docstring_parser/util.py
<listcomp>a   s    z7combine_docstrings.<locals>.wrapper.<locals>.<listcomp>c                 s   s     | ]}d d |j D V  qdS )c                 S   s   i | ]}|j |qS r   )arg_name)r   paramr   r   r   
<dictcomp>e   s    zAcombine_docstrings.<locals>.wrapper.<locals>.<genexpr>.<dictcomp>Nparams)r   docr   r   r   	<genexpr>d   s
    
z6combine_docstrings.<locals>.wrapper.<locals>.<genexpr>c                    s   g | ]
}| v r | qS r   r   )r   namer   r   r   r      s
    )r   r   )r   from_callabler   r   dictr   reversedshort_descriptionblank_after_short_descriptionlong_descriptionblank_after_long_descriptionmetatype
setdefaultappenditems
parametersr   listr   valuesr   )	r   sigcomb_docdocsr   combinedmetasr)   	meta_typer   r   r   r   r   r   wrapper]   sV   
	



z#combine_docstrings.<locals>.wrapper)_Func)r   r   r   r   r8   r   r7   r   combine_docstrings   s   G4r:   )r   typingTcollectionsr   inspectr   	itertoolsr   commonr   r   r   r	   r
   parserr   r   CallableAnyr9   AUTOCOMPACTIterableTyper:   r   r   r   r   <module>   s.    