403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.109
Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64
User : SERVERWEB ( 0)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  C:/cygwin64/lib/python3.9/site-packages/sphinx/ext/napoleon/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : C:/cygwin64/lib/python3.9/site-packages/sphinx/ext/napoleon/__pycache__/docstring.cpython-39.pyc
a

�ab���@s�dZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZddlmZmZdd	lmZdd
lmZddlmZe�e�Z e�!d�Z"e�!d
�Z#e�!d�Z$e�!d�Z%e�!d�Z&e�!d�Z'e�!d�Z(e�!d�Z)e�!d�Z*e�!d�Z+e�!d�Z,dZ-ife.e	e.e.fe.d�dd�Z/Gdd�d�Z0e
e.e
e.d�dd�Z1e.e
e.d �d!d"�Z2d+e.e.e.d#�d$d%�Z3dife.e.e4e.d&�d'd(�Z5Gd)d*�d*e0�Z6dS),z�
    sphinx.ext.napoleon.docstring
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


    Classes for docstring parsing and formatting.


    :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�partial)�Any�Callable�Dict�List�Tuple�Type�Union)�Sphinx��Config)�modify_iter)�_�__)�logging)�stringify_annotation)�get_type_hintsz
\.\. \S+::z^(\s|\w)+:\s*$z(.+?)\(\s*(.*[^\s]+)\s*\)z^[=\-`:\'"~^_*+#<>]{2,}\s*$z(?<!:):(?!:)z>((?::(?:[a-zA-Z0-9]+[\-_+:.])*[a-zA-Z0-9]+:`.+?`)|(?:``.+?``))z5(?:(?::(?:[a-zA-Z0-9]+[\-_+:.])*[a-zA-Z0-9]+:)?`.+?`)z^(\*|\+|\-)(\s+\S|\s*$)zP^(?P<paren>\()?(\d+|#|[ivxlcdm]+|[IVXLCDM]+|[a-zA-Z])(?(paren)\)|\.)(\s+\S|\s*$)z_(,\sor\s|\sor\s|\sof\s|:\s|\sto\s|,\sand\s|\sand\s|,\s|[{]|[}]|"(?:\\"|[^"])*"|'(?:\\'|[^'])*')z^default[^_0-9A-Za-z].*$)�None�True�False�Ellipsis)�_type�translations�returncCs(||vr||S|dkrdSd|S|S)z0Convert type specification to reference in reST.rz:obj:`None`�:class:`%s`�)rrrr�A/usr/lib/python3.9/site-packages/sphinx/ext/napoleon/docstring.py�_convert_type_spec9src
@seZdZdZe�dej�Zd�ee	e
e	feee	e	e
e
dd�dd�Ze	d�d	d
�Ze
e	d�dd�Zd�ee
e	d�dd�Ze
e	d�dd�Ze
e	d�dd�Zd�eeee	e	e
e	fd�dd�Zd�eeee
ee	e	e
e	fd�dd�Zee	e
e	fd�dd�Zd�ee
ee	e	e
e	fd�d d!�Ze
e	d�d"d#�Ze	d�d$d%�Ze
e	d�d&d'�Ze
e	d�d(d)�Zd�e
e	ee
e	d*�d+d,�Ze	e	d-�d.d/�Z e
e	e
e	d0�d1d2�Z!e	e
e	e
e	d3�d4d5�Z"d�e	e
e	e	e
e	d6�d7d8�Z#d�e
ee	e	e
e	fe	e	e
e	d;�d<d=�Z$e	e	e
e	e
e	d>�d?d@�Z%e	e
ee	e	e
e	fe
e	dA�dBdC�Z&d�eedE�dFdG�Z'e	edH�dIdJ�Z(e
e	edK�dLdM�Z)e
e	edK�dNdO�Z*d�e
e	ee
e	dQ�dRdS�Z+d�e	eedT�dUdV�Z,e
e	edK�dWdX�Z-ed�dYdZ�Z.ed�d[d\�Z/dd�d]d^�Z0dd�d_d`�Z1e	e	e
e	da�dbdc�Z2e
e	d�ddde�Z3e	e
e	df�dgdh�Z4e	e
e	df�didj�Z5e	e
e	df�dkdl�Z6e	e
e	df�dmdn�Z7e	e
e	df�dodp�Z8e	e
e	df�dqdr�Z9e	ee
e	ds�dtdu�Z:e	e
e	df�dvdw�Z;e	e
e	df�dxdy�Z<e	e
e	df�dzd{�Z=e	e
e	df�d|d}�Z>e	e
e	df�d~d�Z?e	e
e	df�d�d��Z@e	e
e	df�d�d��ZAe	e
e	df�d�d��ZBe	e
e	df�d�d��ZCe	e
e	df�d�d��ZDe	e
e	df�d�d��ZEe	e
e	df�d�d��ZFe	ee	e	e	fdH�d�d��ZGe	eHe	d��d�d��ZIe
e	e
e	dK�d�d��ZJe	e	d��d�d��ZKdS)��GoogleDocstringaVConvert Google style docstrings to reStructuredText.

    Parameters
    ----------
    docstring : :obj:`str` or :obj:`list` of :obj:`str`
        The docstring to parse, given either as a string or split into
        individual lines.
    config: :obj:`sphinx.ext.napoleon.Config` or :obj:`sphinx.config.Config`
        The configuration settings to use. If not given, defaults to the
        config object on `app`; or if `app` is not given defaults to the
        a new :class:`sphinx.ext.napoleon.Config` object.


    Other Parameters
    ----------------
    app : :class:`sphinx.application.Sphinx`, optional
        Application object representing the Sphinx process.
    what : :obj:`str`, optional
        A string specifying the type of the object to which the docstring
        belongs. Valid values: "module", "class", "exception", "function",
        "method", "attribute".
    name : :obj:`str`, optional
        The fully qualified name of the object.
    obj : module, class, exception, function, method, or attribute
        The object to which the docstring belongs.
    options : :class:`sphinx.ext.autodoc.Options`, optional
        The options given to the directive: an object with attributes
        inherited_members, undoc_members, show_inheritance and noindex that
        are True if the flag option of same name was given to the auto
        directive.


    Example
    -------
    >>> from sphinx.ext.napoleon import Config
    >>> config = Config(napoleon_use_param=True, napoleon_use_rtype=True)
    >>> docstring = '''One line summary.
    ...
    ... Extended description.
    ...
    ... Args:
    ...   arg1(int): Description of `arg1`
    ...   arg2(str): Description of `arg2`
    ... Returns:
    ...   str: Description of return value.
    ... '''
    >>> print(GoogleDocstring(docstring, config))
    One line summary.
    <BLANKLINE>
    Extended description.
    <BLANKLINE>
    :param arg1: Description of `arg1`
    :type arg1: int
    :param arg2: Description of `arg2`
    :type arg2: str
    <BLANKLINE>
    :returns: Description of return value.
    :rtype: str
    <BLANKLINE>

    zX^\s*((?::(?P<role>\S+):)?`(?P<name>~?[a-zA-Z0-9_.-]+)`| (?P<name2>~?[a-zA-Z0-9_.-]+))\s*N���	docstring�config�app�what�name�obj�optionsrc
#Cs�||_||_|js4ddlm}|jr,|jjn|�|_|sjt�|�rHd}n"t�|�rXd}nt|�rfd}nd}||_	||_
||_||_t
|t�r�|��}	n|}	t|	dd�d	�|_g|_d
|_d|_t|d�s�g|_t|d��s�|j|jt|jd
�|jt|jd�t|jd�t|jd�|j|jt|jd�t|jd�|j|j|jt|jd�|j|j|j|j |j |j!|j!|j"|j"|j#|j$t|jd�t|jd�t|jd�t|jd�|j%|j%|j&|j&d�"|_'|�(�|�)�dS)Nrr�class�module�function�objectcSs|��S�N)�rstrip)�srrr�<lambda>��z*GoogleDocstring.__init__.<locals>.<lambda>)�modifierF�_directive_sections�	_sections�	attention�caution�danger�error�hint�	important�note�tip�todo�warning)"�argsZ	argumentsr4Z
attributesr5r6r7�example�examplesr8r9zkeyword argszkeyword arguments�methodsr:Znoteszother parameters�
parametersZreceiveZreceivesr�returns�raiseZraisesZ
referenceszsee alsor;r<r=�warnings�warnZwarns�yieldZyields)*�_configZ_appZsphinx.ext.napoleonrr"�inspectZisclassZismodule�callable�_what�_name�_obj�_opt�
isinstance�str�
splitlinesr
�
_line_iter�
_parsed_lines�_is_in_section�_section_indent�hasattrr2�_parse_parameters_sectionr�_parse_admonition�_parse_attributes_section�_parse_examples_section� _parse_keyword_arguments_section�_parse_methods_section�_parse_notes_section�_parse_other_parameters_section�_parse_receives_section�_parse_returns_section�_parse_raises_section�_parse_references_section�_parse_see_also_section�_parse_warns_section�_parse_yields_sectionr3�_load_custom_sections�_parse)
�selfr!r"r#r$r%r&r'r�linesrrr�__init__�s�















�%zGoogleDocstring.__init__�rcCsd�|���S)z�Return the parsed docstring in reStructuredText format.

        Returns
        -------
        unicode
            Unicode version of the docstring.

        �
)�joinri�rhrrr�__str__�s	zGoogleDocstring.__str__cCs|jS)z�Return the parsed lines of the docstring in reStructuredText format.

        Returns
        -------
        list(str)
            The lines of the docstring in a list.

        )rSrnrrrri�s	zGoogleDocstring.lines�)�indentrcCsFg}|j��}|��sB|r&|�||�rB|�t|j��|j��}q|Sr,)rR�peek�_is_section_break�_is_indented�append�next)rhrqri�linerrr�_consume_indented_block�s
�
�z'GoogleDocstring._consume_indented_blockcCs6g}|j��r2|j��r2|��s2|�t|j��q|Sr,)rR�has_nextrr�_is_section_headerrurv�rhrirrr�_consume_contiguous�s
��z#GoogleDocstring._consume_contiguouscCs<g}|j��}|j��r8|s8|�t|j��|j��}q|Sr,)rRrrryrurv�rhrirwrrr�_consume_empty�s
zGoogleDocstring._consume_emptyTF��
parse_type�prefer_typerc
Cs�t|j�}|�|�\}}}|d|}}}	|rTt�|�}
|
rT|
�d���}|
�d�}|�|�}|rp|sp||}}|r�|jj	r�t
||jjp�i�}|�|�d}|	g|�
|�|��}|�||j���}|||fS)Nrrp�)rvrR�_partition_field_on_colon�_google_typed_arg_regex�match�group�strip�_escape_args_and_kwargsrH�napoleon_preprocess_typesr�napoleon_type_aliases�_get_indent�_dedentrx�	__class__ri)
rhr�r�rw�before�colon�afterrLr�_descr�rq�_descsrrr�_consume_fields"




zGoogleDocstring._consume_field)r�r��multiplerc	Csv|��g}|��sr|�||�\}}}|rT|rT|�d�D]}|�|��||f�q8q|s`|s`|r|�|||f�q|S)N�,)r~rsr��splitrur�)	rhr�r�r��fieldsrLrr�r%rrr�_consume_fieldsszGoogleDocstring._consume_fieldscCsbt|j�}|�|�\}}}|r"|s4||}}||7}|g|�|���}|�||j���}||fSr,)rvrRr�r��_consume_to_endr�rHri)rhrwrr�r�r�rrr�_consume_inline_attribute*s

z)GoogleDocstring._consume_inline_attribute��preprocess_typesrc	Cs�|�|���}|r�|�|d�\}}}dd|}}}|rb|rR|g|dd�}n|dd�}|}|r�|r�|jjr�t||jjp�i�}|�||j���}|||fgSgSdS)Nrrrp)	r��_consume_to_next_sectionr�rHr�rr�r�ri)	rhr�rir�r�r�rLrr�rrr�_consume_returns_section4s �z(GoogleDocstring._consume_returns_sectioncCs|�|���}|Sr,)r�r�r{rrr�_consume_usage_sectionLsz&GoogleDocstring._consume_usage_sectioncCs*t|j�}|�d�}|��|jvr&|}|S)N�:)rvrRr��lowerr3)rh�sectionZstripped_sectionrrr�_consume_section_headerPs


z'GoogleDocstring._consume_section_headercCs$g}|j��r |�t|j��q|Sr,)rRryrurvr{rrrr�Ws
zGoogleDocstring._consume_to_endcCs2|��g}|��s&|�t|j��q||��Sr,)r~rsrurvrRr{rrrr�]s
z(GoogleDocstring._consume_to_next_section)ri�fullrcs2|rdd�|D�S|�|���fdd�|D�SdS)NcSsg|]}|���qSr)�lstrip��.0rwrrr�
<listcomp>fr0z+GoogleDocstring._dedent.<locals>.<listcomp>csg|]}|�d��qSr,rr���
min_indentrrr�ir0)�_get_min_indent)rhrir�rr�rr�ds
zGoogleDocstring._dedent�r%rcCsp|�d�r(t|jdd�r(|dd�d}|dd�dkrHd|dd�S|dd	�d
krhd|d	d�S|SdS)NrZstrip_signature_backslashF���z\_r�z**z\*\*rp�*z\*)�endswith�getattrrH�rhr%rrrr�ksz'GoogleDocstring._escape_args_and_kwargs)�descrcCsx|�|�rdg|}n^|d�d�rt|dd�}|�|d�}|�|�}||kr\dg|}nd|dg|�|d�}|S)Nrr�::rp�)�_is_listr�r��_get_initial_indent�_indent)rhr�Z
desc_blockrqZblock_indentrrr�_fix_field_descvs

zGoogleDocstring._fix_field_desc)�
admonitionrircCsj|�|�}t|�dkr.d||d��fdgS|rZ|�|�|�d�}d|dg|dgSd|dgSdS)Nrpz
.. %s:: %srr�z.. %s::)�_strip_empty�lenr�r�r�)rhr�rirrr�_format_admonition�s
z"GoogleDocstring._format_admonition)�prefixri�paddingrcCsv|rl|durdt|�}g}t|�D]B\}}|dkrH|�||���q$|r\|�||�q$|�d�q$|S|gSdS)N� rr)r��	enumeraterur-)rhr�rir�Zresult_lines�irwrrr�
_format_block�szGoogleDocstring._format_block�param�type)r��
field_role�	type_rolerc	Cs�g}|D]p\}}}|�|�}t|�rN|�|�}d||f}|�|�||��n|�d||f�|r|�d|||f�q|dgS)Nz:%s %s: z:%s %s:z
:%s %s: %sr)r��anyr��extendr�ru)	rhr�r�r�rirLrr��fieldrrr�_format_docutils_params�s

z'GoogleDocstring._format_docutils_params)rLrr�rcCs�|�|�}t|�}|rdnd}|r\|rNd|vr>d|||f}qZd|||f}q�d||f}n,|r�d|vrvd||f}q�d||f}nd}|r�|�|�}|d	r�||d	g|d
d�S|g|Sn|gSdS)Nz -- r�`z
**%s** (%s)%sz**%s** (*%s*)%sz**%s**%sz%s%sz*%s*%srrp)r�r�r�)rhrLrr�Zhas_desc�	separatorr�rrr�
_format_field�s(

zGoogleDocstring._format_field)�
field_typer�rc
Cs�d|��}dt|�}t|�dk}g}|D]f\}}}|�|||�}	|r||rd|�|�|d|	��q�|�|�|d|	��q,|�|�|d|	��q,|r�|dr�|�d�|S)Nz:%s:r�rpz * r�r)r�r�r�r�r�ru)
rhr�r�r��multirirLrr�r�rrr�_format_fields�s
zGoogleDocstring._format_fieldsr)�
peek_aheadrcCsP|j�|d�|}||jjkrL|r.|�|�S|d7}|j�|d�|}qdS)Nrpr)rRrr�sentinelr�)rhr�rwrrr�_get_current_indent�s
z#GoogleDocstring._get_current_indent)rwrcCs*t|�D]\}}|��s|Sqt|�Sr,)r��isspacer�)rhrwr�r.rrrr��s
zGoogleDocstring._get_indent)rircCs |D]}|r|�|�SqdS�Nr�r�r}rrrr��sz#GoogleDocstring._get_initial_indentcCs>d}|D],}|r|�|�}|dur(|}q||kr|}q|p<dSr�r�)rhrir�rwrqrrrr��s
zGoogleDocstring._get_min_indentr�)ri�nrcs�fdd�|D�S)Ncsg|]}d�|�qS)r�rr��r�rrr��r0z+GoogleDocstring._indent.<locals>.<listcomp>r)rhrir�rr�rr��szGoogleDocstring._indent)rwrqrcCs2t|�D]$\}}||krdS|��sdSqdS)NTF)r�r�)rhrwrqr�r.rrrrtszGoogleDocstring._is_indentedcCs�|sdSt�|d�rdSt�|d�r,dSt|�dksF|d�d�rJdS|�|d�}|}|dd�D]}|rh|�|�}q�qh||kS)NFrTr�r�rp)�_bullet_list_regexr��_enumerated_list_regexr�r�r�)rhrirqZnext_indentrwrrrr�	s
zGoogleDocstring._is_listcCsz|j����}t�|�}|rJ|�d�|jvrJ|�|�}|jdd�}||kS|j	rvt
�|�rv|j	D]}|�|�r`dSq`dS)Nr�rp)r�TF)rRrrr��_google_section_regexr�r�r3r�r�r2�_directive_regex�
startswith)rhr�r�Z
header_indentZsection_indent�directive_sectionrrrrzs




z"GoogleDocstring._is_section_headercCs8|j��}|j��p6|��p6|jo6|o6|�||j�Sr,�rRrrryrzrTrtrU)rhrwrrrrs(s
���z!GoogleDocstring._is_section_breakcCs�|jjdur�|jjD]�}t|t�r4|j|j|��<q|ddkrV|j|j|d��<q|ddkrx|j|j|d��<q|j�	|d��|j�|j|d��<qdS)NrpZparams_stylerZ
returns_style)
rHZnapoleon_custom_sectionsrOrP�_parse_custom_generic_sectionr3r��"_parse_custom_params_style_section�#_parse_custom_returns_style_section�get)rh�entryrrrrf0s
����z%GoogleDocstring._load_custom_sectionscCs�|��|_|jrN|jdvrNg}z|��}Wnty<Yn0|j�|�dS|j��r�|�	�r�zT|�
�}d|_|��|_
t�|�r�|g|��}n|j|��|�}Wd|_d|_
q�d|_d|_
0n |js�|��|��}n|��}|j�|�qNdS)N)Z	attribute�data�propertyTFr)r~rSrLrK�_parse_attribute_docstring�
StopIterationr�rRryrzr�rTr�rUr�r�r�r3r�r|)rh�resr�rirrrrgFs4



�
zGoogleDocstring._parse)r�r�rcCs|��}|�||�Sr,)r�r�)rhr�r�rirrrrXhsz!GoogleDocstring._parse_admonitioncCs4|��\}}|�dd|�}|r0|�dd|g�|S)Nr�	:type: %s)r�r�r�)rhrr�rirrrr�ms
z*GoogleDocstring._parse_attribute_docstring�r�rcCsg}|��D]�\}}}|s$|�|�}|jjrl|�||j�}d|}|�|�||��|r�|�d||f�q|�d|�|j	r�d|j	vr�|�d�|�d�|�
dd|�}|�|�|d��|r�|�d�|�|�d|gd��|�d�q|jj�r|�d�|S)	Nz
:ivar %s: z:vartype %s: %sz.. attribute:: �noindex�   :noindex:rr�r�)r��_lookup_annotationrHZnapoleon_use_ivar�
_qualify_namerMr�r�rurNr�r�)rhr�rirLrr�r�r�rrrrYts.





z)GoogleDocstring._parse_attributes_sectioncCs6td�td�d�}|jj}|�|��|�}|�||�S)NZExampleZExamples)r?r@)rrHZ$napoleon_use_admonition_for_examplesr�r��_parse_generic_section)rhr��labels�use_admonitionZlabelrrrrZ�s�z'GoogleDocstring._parse_examples_sectioncCs|�|d�S)NF)r��rhr�rrrr��sz-GoogleDocstring._parse_custom_generic_sectioncCs|�||���Sr,)r�r�r�rrrr��sz2GoogleDocstring._parse_custom_params_style_sectioncCs|jdd�}|�||�S)NT�r�)r�r��rhr�r�rrrr��sz3GoogleDocstring._parse_custom_returns_style_sectioncCs6ddg}ddg}|��}|�|d�}|||dgS)Nz.. rubric:: Usage:rz.. code-block:: pythonr�)r�r�)rhr��header�blockrirrr�_parse_usage_section�s
z$GoogleDocstring._parse_usage_section)r�r�rcCs\|�|���}|�|�}|r2d|}|�|d�}nd|}|rP|dg|dgS|dgSdS)Nz.. admonition:: %sr�z.. rubric:: %sr)r�r�r�r�)rhr�r�rir�rrrr��s
z&GoogleDocstring._parse_generic_sectioncCs4|��}|jjr |j|ddd�S|�td�|�SdS)N�keywordZkwtype)r�r�zKeyword Arguments)r�rHZnapoleon_use_keywordr�r�rr�rrrr[�s�z0GoogleDocstring._parse_keyword_arguments_sectioncCsng}|jdd�D]X\}}}|�d|�|jrBd|jvrB|�d�|r^|�dg|�|d��|�d�q|S)NF)r�z.. method:: %sr�r�rr�)r�rurNr�r�)rhr�rirLrr�rrrr\�s
z&GoogleDocstring._parse_methods_sectioncCs|jj}|�td�|�S)NZNotes)rHZ!napoleon_use_admonition_for_notesr�r�rhr�r�rrrr]�sz$GoogleDocstring._parse_notes_sectioncCs:|jjr|jdd�}|�|�S|��}|�td�|�SdS)NT�r�zOther Parameters�rHZnapoleon_use_paramr�r�r�rr�rrrr^�s

z/GoogleDocstring._parse_other_parameters_sectioncCs:|jjr|jdd�}|�|�S|��}|�td�|�SdS)NTr�Z
Parametersr�r�rrrrW�s

z)GoogleDocstring._parse_parameters_sectionc
Cs�|jddd�}g}|D]�\}}}|j�|�}|rF|�d�rF|�d�}n$t�|�rj|�d�}||dd�}|rvd|nd	}|�|�}t|�r�dd
�|�nd	}	|�	d||	f�q|r�|�	d	�|S)NFT)r�r�r%r�rpr�r�rz
    z:raises%s:%s)
r��	_name_rgxr�r��_xref_regex�findr�r�rmru)
rhr�r�rirLrr��m�posr�rrrra�s 



z%GoogleDocstring._parse_raises_sectioncCs:|jjr|jdd�}|�|�S|��}|�td�|�SdS)NTr�ZReceivesr�r�rrrr_�s

z'GoogleDocstring._parse_receives_sectioncCs|jj}|�td�|�S)NZ
References)rHZ&napoleon_use_admonition_for_referencesr�rr�rrrrb�sz)GoogleDocstring._parse_references_sectionc
Cs�|��}t|�dk}|rdn|jj}g}|D]�\}}}|rJ|�|d|�}	n|�|||�}	|r�|rt|�|�d|	��q�|�|�d|	��q,t|	�r�|�|�d|	��|r,|r,|�d|dg�q,|r�|dr�|�d�|S)	NrpFrz          * z:returns: * z
:returns: z
:rtype: %sr�)	r�r�rHZnapoleon_use_rtyper�r�r�r�ru)
rhr�r�r�Z	use_rtyperirLrr�r�rrrr`s&
z&GoogleDocstring._parse_returns_sectioncCs|�d|�S�N�seealso)rXr�rrrrcsz'GoogleDocstring._parse_see_also_sectioncCs|�td�|���S)NZWarns)r�rr�r�rrrrdsz$GoogleDocstring._parse_warns_sectioncCs|jdd�}|�td�|�S)NTr�ZYields)r�r�rr�rrrre!sz%GoogleDocstring._parse_yields_sectionc	Cs�g}g}d}d}tt�|��D]�\}}|r6|�|�qt�|�}|ddkr�|r�d}||��|���}|�|d|����|�||��d��q|�|�qd�|��	�|d�|��	�fS)NrFr�rT)
r��_xref_or_code_regexr�ru�_single_colon_regex�search�start�endrmr�)	rhrwZbefore_colonZafter_colonr�Zfound_colonr��sourcerrrrr�%s$
�z)GoogleDocstring._partition_field_on_colon)�	attr_name�klassrcCsV|rRd|vrR|�d�r"|dd�}z
|j}WntyD|j}Yn0d||fS|S)N�.�~rpz~%s.%s)r��__qualname__�AttributeError�__name__)rhrr�qrrrr�;s

zGoogleDocstring._qualify_namecCs�|r�d}t|�D]\}}|r|}q&q|dkr2g}d}ttt|���D]}||}|rF|}q`qF|dksx|dt|�kr�|||d�}|S)Nr�rrp)r��reversed�ranger�)rhrirr�rwr	rrrr�Fs"zGoogleDocstring._strip_empty)rLrcCst|jjrp|jdvrp|jrpt|d�sXt|jdi�}|�t|jdi�pDi�t|jd|�|_||jvrpt	|j|�SdS)N)r)r(�	exception�_annotationsZautodoc_type_aliasesr�r)
rHZnapoleon_attr_annotationsrKrMrVr��updaterrr)rhrL�localnsrrrr�Ys
��
z"GoogleDocstring._lookup_annotation)NNrrNN)rp)TF)TFF)F)F)N)r�r�)r)r�)rp)Lr�
__module__r�__doc__�re�compile�Xr�r	rPr�SphinxConfigr
rrjrori�intrxr|r~�boolrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rtr�rzrsrfrgrXr�rYrZr�r�r�r�r�r[r\r]r^rWrar_rbr`rcrdrer�rr�r�r�rrrrrFs�>���L	���

�

���	"	

			r)�tokensrcs2t�|�}d��fdd���fdd�}t||��S)N�Zoptional�defaultc3s�d}d}z|��}Wnty*Yq�Yn0|dkr:|}q|��sDq|�vrj|�|�|dur�|�|�q�|dur||Vd}|dkr�|d7}n|dkr�|d8}|V|dkrq�qdS)Nr�, �{rp�})�popleft�
IndexErrorr��
appendleft)r!Zopen_bracesZprevious_token�token)�keywordsrr�
takewhile_setms4



z,_recombine_set_tokens.<locals>.takewhile_setc3sTz|��}Wnty"YqPYn0|dkrH|�d�d��|��Vq|VqdS)Nr%r)r'r(r)rm)r!r*)r,rr�combine_set�s

z*_recombine_set_tokens.<locals>.combine_set)�collections�deque�list)r!Ztoken_queuer-r)r+r,r�_recombine_set_tokensis

$
r1)�specrcs(dd��t�fdd�t�|�D��}|S)NcSs6t�|�r,|dd�}|dd�}|d|gS|gSdS)N��r�)�_default_regexr�)�itemr#�otherrrr�postprocess�s


z(_tokenize_type_spec.<locals>.postprocessc3s$|]}�|�D]}|r|VqqdSr,r)r�Z	raw_tokenr6�r8rr�	<genexpr>�s�z&_tokenize_type_spec.<locals>.<genexpr>)r0�_token_regexr�)r2r!rr9r�_tokenize_type_spec�s
�r<)r*�locationrcCs>dd�}|�d�s|�d�r$d}�n||�sh|�d�r@|�d�sh|�d�rT|�d�sh|�d�rn|�d�rnd	}n�|�d�r�tjtd
�||d�d	}n�|�d�r�tjtd�||d�d	}n�|�d�s�|�d�r�tjtd
�||d�d	}nV|�d�s�|�d��rtjtd�||d�d	}n&|dv�r$d}nt�|��r6d}nd}|S)NcSs*zt|�Wnty YdS0dSdS)NFT)�complex�
ValueError)r*rrr�
is_numeric�s
z_token_type.<locals>.is_numericr��	delimiterr%r&�"�'�literalz-invalid value set (missing closing brace): %s�r=z-invalid value set (missing opening brace): %sz4malformed string literal (missing closing quote): %sz4malformed string literal (missing opening quote): %sr"�control�	referencer&)r�r��loggerr=rr�r�)r*r=r@�type_rrr�_token_type�sh	�������
�
���
rJ)rr=rrcspdd��t|�}t|�}�fdd�|D�}dd���fdd�dd�d	d�d
d�d��d��fd
d�|D��}|S)NcSsP|�||�}|tvr"|dkr"d}n|dkr6|dkr6d}t�|�durL||}|S)Nr�	:obj:`%s`z...z:obj:`%s <Ellipsis>`)r��_SINGLETONSr�r�)r&rZdefault_translation�translationrrr�convert_obj�sz-_convert_numpy_type_spec.<locals>.convert_objcsg|]}|t|��f�qSr)rJ)r�r*rErrr�s�z,_convert_numpy_type_spec.<locals>.<listcomp>cSsd|S)Nz``%s``r��xrrrr/	r0z*_convert_numpy_type_spec.<locals>.<lambda>cs�|�d�S)NrrrO)rNrrrr/
r0cSsd|S)Nz*%s*rrOrrrr/r0cSs|Sr,rrOrrrr/r0cSs|Sr,rrOrrrr/
r0)rDr&rFrArGrc3s |]\}}��|�|�VqdSr,)r�)r�r*rI)�
convertersrrr:r0z+_convert_numpy_type_spec.<locals>.<genexpr>)r<r1rm)rr=rr!Zcombined_tokens�typesZ	convertedr)rNrQr=rr�_convert_numpy_type_spec�s
��rSc
seZdZdZd!eeeefeeeee	e	dd��fdd�
Z
ed�dd	�Zeed
��fdd�Zd"e
e
eeeeefd�dd�Zd#e
eeeeeefd�dd�Zed�dd�Ze
d�dd�Ze
d�dd�Zeeed�dd�Zeeeed�dd �Z�ZS)$�NumpyDocstringa�
Convert NumPy style docstrings to reStructuredText.

    Parameters
    ----------
    docstring : :obj:`str` or :obj:`list` of :obj:`str`
        The docstring to parse, given either as a string or split into
        individual lines.
    config: :obj:`sphinx.ext.napoleon.Config` or :obj:`sphinx.config.Config`
        The configuration settings to use. If not given, defaults to the
        config object on `app`; or if `app` is not given defaults to the
        a new :class:`sphinx.ext.napoleon.Config` object.


    Other Parameters
    ----------------
    app : :class:`sphinx.application.Sphinx`, optional
        Application object representing the Sphinx process.
    what : :obj:`str`, optional
        A string specifying the type of the object to which the docstring
        belongs. Valid values: "module", "class", "exception", "function",
        "method", "attribute".
    name : :obj:`str`, optional
        The fully qualified name of the object.
    obj : module, class, exception, function, method, or attribute
        The object to which the docstring belongs.
    options : :class:`sphinx.ext.autodoc.Options`, optional
        The options given to the directive: an object with attributes
        inherited_members, undoc_members, show_inheritance and noindex that
        are True if the flag option of same name was given to the auto
        directive.


    Example
    -------
    >>> from sphinx.ext.napoleon import Config
    >>> config = Config(napoleon_use_param=True, napoleon_use_rtype=True)
    >>> docstring = '''One line summary.
    ...
    ... Extended description.
    ...
    ... Parameters
    ... ----------
    ... arg1 : int
    ...     Description of `arg1`
    ... arg2 : str
    ...     Description of `arg2`
    ... Returns
    ... -------
    ... str
    ...     Description of return value.
    ... '''
    >>> print(NumpyDocstring(docstring, config))
    One line summary.
    <BLANKLINE>
    Extended description.
    <BLANKLINE>
    :param arg1: Description of `arg1`
    :type arg1: int
    :param arg2: Description of `arg2`
    :type arg2: str
    <BLANKLINE>
    :returns: Description of return value.
    :rtype: str
    <BLANKLINE>

    Methods
    -------
    __str__()
        Return the parsed docstring in reStructuredText format.

        Returns
        -------
        str
            UTF-8 encoded version of the docstring.

    __unicode__()
        Return the parsed docstring in reStructuredText format.

        Returns
        -------
        unicode
            Unicode version of the docstring.

    lines()
        Return the parsed lines of the docstring in reStructuredText format.

        Returns
        -------
        list(str)
            The lines of the docstring in a list.

    Nrr c	s$dg|_t��|||||||�dS)Nz
.. index::)r2�superrj)rhr!r"r#r$r%r&r'�r�rrrjrszNumpyDocstring.__init__rkcCsnz|jdurt�|j�nd}Wnty4d}Yn0|j}|durP|durPdS|dur\d}d�|d|g�S)Nrr�zdocstring of %s)rMrIZgetfile�	TypeErrorrLrm)rh�filepathr%rrr�
_get_locationxs
zNumpyDocstring._get_locationr�cs:t�j�d|vr.d��fdd�|�d�D��S�|�SdS)Nr$c3s|]}�|�VqdSr,r)r�r���funcrrr:�r0z9NumpyDocstring._escape_args_and_kwargs.<locals>.<genexpr>)rUr�rmr�r�rVrZrr��sz&NumpyDocstring._escape_args_and_kwargsTFrc	Cs�t|j�}|r |�|�\}}}n
|d}}|��|��}}|�|�}|rX|sX|�|�}|rj|sj||}}|jjr�t||�	�|jj
p�id�}|�|�d}|�|�
|��}|�||j���}|||fS)Nr)r=rrp)rvrRr�r�r�r�rHr�rSrYr�r�r�rxr�ri)	rhr�r�rwrLrrrqr�rrrr��s(





�zNumpyDocstring._consume_fieldr�cCs|jdd�S)NT)r�)r�)rhr�rrrr��sz'NumpyDocstring._consume_returns_sectioncCs"t|j�}t�|�st|j�|Sr,)rvrRr�r�r�rrrr��s


z&NumpyDocstring._consume_section_headercCsN|j�d�\}}|j��pL|��pLddg||gkpL|joL|oL|�||j�S)Nr�rr�)rhZline1Zline2rrrrs�s����z NumpyDocstring._is_section_breakcCsj|j�d�\}}|��}||jvr:t|t�r:tt�|��S|j	rft
�|�rf|j	D]}|�|�rPdSqPdS)Nr�TF)rRrrr�r3rOrPr �_numpy_section_regexr�r2r�r�)rhr�Z	underliner�rrrrz�s


z!NumpyDocstring._is_section_headerr�cCs8|��}z|�|�WSty2|�d|�YS0dSr)r�� _parse_numpydoc_see_also_sectionr?r�)rhr�rirrrrc�s
z&NumpyDocstring._parse_see_also_section)�contentrcsg�ttttfd��fdd��tttdd���fdd�}�fdd	��d}g}|D]�}|��sbqT�j�|�}|r�||��d����d
�r�|||�|d|���||��d�}}|�d
d�d��g}|ds�g}qT|�d
��s8|||�d}d|v�r(|�d�D]}|���r
||g��q
n|���rN|}qT|durT|�	|���qT|||���sdgS�fdd��D��g}d}	�D]�\}
}}|�r�d||
f}
nd|
}
|�s�|	�r�|dg7}||
g7}n|dd|
7<|�r|��
d
�|�g�7}d}	nd}	�q�|dg7}��d|�S)a
        Derived from the NumpyDoc implementation of _parse_see_also.

        See Also
        --------
        func_name : Descriptive text
            continued text
        another_func_name : Descriptive text
        func_name1, func_name2, :meth:`func_name`, func_name3

        )�textrcsP�j�|�}|r@|��}|ddur0|ddfS|d|dfStd|��dS)zMatch ':role:`name`' or 'name'rpNr�r�z%s is not a item name)r�r��groupsr?)r_r�grnrr�parse_item_name�szHNumpyDocstring._parse_numpydoc_see_also_section.<locals>.parse_item_nameN)r%�restrcs6|sdS�|�\}}��|t|�|f�|dd�=dSr,)rur0)r%rc�role)�itemsrbrr�	push_item�s
zBNumpyDocstring._parse_numpydoc_see_also_section.<locals>.push_itemcsn�jj}|dus|s|||fS|�||�}�j�|�}|sD|||fS|��}|d}|dpb|d}|||fS)Nrdr%Zname2)rHr�r�r�r��	groupdict)r[�descriptionrdrZ
translatedr�r`�new_funcrnrr�	translate�s

zBNumpyDocstring._parse_numpydoc_see_also_section.<locals>.translater�rprr�r�csg|]\}}}�|||��qSrr)r�r[rhrd)rjrrr� s�zCNumpyDocstring._parse_numpydoc_see_also_section.<locals>.<listcomp>Tz:%s:`%s`rKrr�z, %sFr)
rPrrr�r�r�r	r�r�rur�rmr�)rhr^rfZcurrent_funcrcrwrr[riZ
last_had_descr%r�rd�linkr)rerbrhrjrr]�sb
"





�

z/NumpyDocstring._parse_numpydoc_see_also_section)NNrrNN)TF)F)rrrrr	rPrrr
rrjrYr�r rr�r�r�rsrzrcr]�
__classcell__rrrVrrTs*\����	rT)N)7rr.rIr�	functoolsr�typingrrrrrrr	Zsphinx.applicationr
Z
sphinx.configrrZsphinx.ext.napoleon.iteratorsr
Z
sphinx.localerrZsphinx.utilrZsphinx.util.inspectrZsphinx.util.typingrZ	getLoggerrrHrr�r�r�r\rrr�r�r�r;r5rLrPrrr1r<rJ�dictrSrTrrrr�<module>s`$





��
���
)8;$

Youez - 2016 - github.com/yon3zu
LinuXploit