o
    ì6WjŒ  ã                   @   sÚ   d Z ddlZddlZddlmZmZmZmZ ddl	m
Z
 ddlmZmZmZmZ ejeejeejeejeiZejfdeje dedefd	d
„Zejfdejdedefdd„Zejejdfdededededef
dd„ZdS )zThe main parsing routine.é    N)ÚepydocÚgoogleÚnumpydocÚrest)Úadd_attribute_docstrings)Ú	DocstringÚDocstringStyleÚ
ParseErrorÚRenderingStyleÚtextÚstyleÚreturnc                 C   sŽ   |t jkrt|  | ¡S d}g }t ¡ D ]#}z| | ¡}W n ty1 } z|}W Y d}~qd}~ww | |¡ q|s<|‚t|dd„ dd�d S )z§Parse the docstring into its components.

    :param text: docstring text to parse
    :param style: docstring style
    :returns: parsed docstring representation
    Nc                 S   s
   t | jƒS )N)ÚlenÚmeta)Úd© r   úf/home/esfera/Documents/content_generation/venv/lib/python3.10/site-packages/docstring_parser/parser.pyÚ<lambda>0   s   
 zparse.<locals>.<lambda>T)ÚkeyÚreverser   )r   ÚAUTOÚ
_STYLE_MAPÚparseÚvaluesr	   ÚappendÚsorted)r   r   ÚexcÚretsÚmoduleÚretÚexr   r   r   r      s   
	€ÿr   Úobjc                 C   s0   t | j|d�}t | ¡st | ¡rt| |ƒ |S )aQ  Parse the object's docstring(s) into its components.

    The object can be anything that has a ``__doc__`` attribute. In contrast to
    the ``parse`` function, ``parse_from_object`` is able to parse attribute
    docstrings which are defined in the source code instead of ``__doc__``.

    Currently only attribute docstrings defined at class and module levels are
    supported. Attribute docstrings defined in ``__init__`` methods are not
    supported.

    When given a class, only the attribute docstrings of that class are parsed,
    not its inherited classes. This is a design decision. Separate calls to
    this function should be performed to get attribute docstrings of parent
    classes.

    :param obj: object from which to parse the docstring(s)
    :param style: docstring style
    :returns: parsed docstring representation
    )r   )r   Ú__doc__ÚinspectÚisclassÚismoduler   )r!   r   Ú	docstringr   r   r   Úparse_from_object3   s   
r'   z    r&   Úrendering_styleÚindentc                 C   s(   t |tjkr	| jn| }|j| ||d�S )a  Render a parsed docstring into docstring text.

    :param docstring: parsed docstring representation
    :param style: docstring style to render
    :param indent: the characters used as indentation in the docstring string
    :returns: docstring text
    )r(   r)   )r   r   r   r   Úcompose)r&   r   r(   r)   r   r   r   r   r*   R   s   ÿÿr*   )r"   r#   ÚtypingÚTÚdocstring_parserr   r   r   r   Údocstring_parser.attrdocr   Údocstring_parser.commonr   r   r	   r
   ÚRESTÚGOOGLEÚNUMPYDOCÚEPYDOCr   r   ÚOptionalÚstrr   ÚAnyr'   ÚCOMPACTr*   r   r   r   r   Ú<module>   sR    ü	ÿÿÿ
þþÿþ
ý!üÿþýüû