L i dZddlZddlmZddlmZddlmZddl m Z m Z m Z m Z mZddlmZmZej$d ej&fZe sJd e j*ej,d d ed ej.ej0e de dedef dZy)z.Utility functions for working with docstrings.N)ChainMap) Signature)chain) DocstringMetaDocstringParamDocstringReturnsDocstringStyleRenderingStyle)composeparse.)excludestylerendering_styleothersrrrreturnc8dtdtffd }|S)aqA 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 long_description: fun2 :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 long_description: fun2 :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. funcrctj|}t|jxsd} Dcgc]}t|jxsdc}|gz}t t d|D}t |D]2}|js|j|_|j|_nt |D]2}|js|j|_ |j|_ ni}|D]c}i}|jD]3} t| } | vr|j| gj| 5|jD] \} } | || < e|j D cgc] } | |vs|| c} |t"<t%t'|j)|_ t+||_|Scc}wcc} w)Nc3pK|])}|jDcic]}|j|c}+ycc}ww)N)paramsarg_name).0docparams [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/docstring_parser/util.py z6combine_docstrings..wrapper..ds39< CuU^^U*CCs 61 6)rr)r from_callabler __doc__dictrreversedshort_descriptionblank_after_short_descriptionlong_descriptionblank_after_long_descriptionmetatype setdefaultappenditems parametersrlistrvaluesr )rsigcomb_docotherdocsrrcombinedmetasr( meta_typenamerrrrs rwrapperz#combine_docstrings..wrapper]s%%d++,8>?uemm)r*?8*L #  D> C((),)>)>H &11  2  D> C''(+(<(rIs4 # 3: 24*//&4&<&< { { ZZ}- .{ {$ {  {r;