File: //usr/lib/python3/dist-packages/sphinx/ext/napoleon/__pycache__/docstring.cpython-310.pyc
o
�$�a]� � @ s� d Z ddlZddlZddlZddlmZ ddlmZmZm Z m
Z
mZmZm
Z
ddlmZ ddlmZ ddlmZ ddlmZmZ dd lmZ dd
lmZ ddlmZ e�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-i fde.de e.e.f de.fdd�Z/G dd� d�Z0de
e. de
e. fd d!�Z1d"e.de
e. fd#d$�Z2d-d%e.d&e.de.fd'd(�Z3di fde.d&e.de4de.fd)d*�Z5G d+d,� d,e0�Z6dS ).z�
sphinx.ext.napoleon.docstring
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Classes for docstring parsing and formatting.
:copyright: Copyright 2007-2021 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�returnc C s$ | |v r|| S | dkrdS d| S )z0Convert type specification to reference in reST.r z:obj:`None`�:class:`%s`� )r r r r �?/usr/lib/python3/dist-packages/sphinx/ext/napoleon/docstring.py�_convert_type_spec9 s
r c @ s� e Zd ZdZe�dej�Z d�dee e
e f dedede d e d
e
de
ddfd
d�Zde fdd�Zde
e fdd�Zd�dede
e fdd�Zde
e fdd�Zde
e fdd�Zd�dededee e e
e f fdd �Z d�deded!ede
ee e e
e f fd"d#�Zdee e
e f fd$d%�Zd�d&ede
ee e e
e f fd'd(�Zde
e fd)d*�Zde fd+d,�Zde
e fd-d.�Zde
e fd/d0�Zd�d1e
e d2ede
e fd3d4�Zd e de fd5d6�Z d7e
e de
e fd8d9�Z!d:e d1e
e de
e fd;d<�Z"d�d=e d1e
e d>e de
e fd?d@�Z# Bd�dCe
ee e e
e f dDe dEe de
e fdFdG�Z$dHe dIe dJe
e de
e fdKdL�Z%dMe dCe
ee e e
e f de
e fdNdO�Z&d�dQedefdRdS�Z'dTe defdUdV�Z(d1e
e defdWdX�Z)d1e
e defdYdZ�Z*d�d1e
e d\ede
e fd]d^�Z+d�dTe dedefd_d`�Z,d1e
e defdadb�Z-defdcdd�Z.defdedf�Z/d�dgdh�Z0d�didj�Z1d:e dke de
e fdldm�Z2de
e fdndo�Z3dke de
e fdpdq�Z4dke de
e fdrds�Z5dke de
e fdtdu�Z6dke de
e fdvdw�Z7dke de
e fdxdy�Z8dke de
e fdzd{�Z9dke d|ede
e fd}d~�Z:dke de
e fdd��Z;dke de
e fd�d��Z<dke de
e fd�d��Z=dke de
e fd�d��Z>dke de
e fd�d��Z?dke de
e fd�d��Z@dke de
e fd�d��ZAdke de
e fd�d��ZBdke de
e fd�d��ZCdke de
e fd�d��ZDdke de
e fd�d��ZEdke de
e fd�d��ZFdTe dee e e f fd�d��ZGd�e d�eHde fd�d��ZId1e
e de
e fd�d��ZJdHe de fd�d��ZKdS )��GoogleDocstringaV Convert 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�optionsr c
C sJ || _ || _| j sddlm} | jr| jjn|� | _ |s5t�|�r$d}nt�|�r,d}n t|�r3d}nd}|| _ || _
|| _|| _t
|t�rK|�� } n|} t| dd� d �| _g | _d
| _d| _t| d�sgg | _t| d��si d
| j�d| j�dt| jd��d| j�dt| jd��dt| jd��dt| jd��d| j�d| j�dt| jd��dt| jd��d| j�d| j�d| j�dt| jd��d| j�d| j�i d| j�d| j �d | j �d!| j!�d"| j!�d#| j"�d$| j"�d%| j#�d&| j$�d't| jd'��d(t| jd(��d)t| jd)��d*t| jd)��d+| j%�d,| j%�d-| j&�d.| j&��| _'| �(� | �)� d S )/Nr r �class�module�function�objectc S s | � � S �N)�rstrip)�sr r r �<lambda>� � z*GoogleDocstring.__init__.<locals>.<lambda>)�modifierF�_directive_sections� _sections�args� arguments� attention�
attributes�caution�danger�error�example�examples�hint� importantzkeyword argszkeyword arguments�methods�note�noteszother parameters�
parameters�receive�receivesr �returns�raise�raises�
referenceszsee also�tip�todo�warning�warnings�warn�warns�yield�yields)*�_config�_app�sphinx.ext.napoleonr r! �inspect�isclass�ismodule�callable�_what�_name�_obj�_opt�
isinstance�str�
splitlinesr
�
_line_iter�
_parsed_lines�_is_in_section�_section_indent�hasattrr1 �_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_sectionr2 �_load_custom_sections�_parse)
�selfr r! r"