B
    Bc                 @   s   d dl 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
d
dddddddddddddddddddddddddddd d!Zd"d# ZdS )$    Nz'^[~\.]?[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*$z(\s*[\[\]\(\)\{\}]\s*|,\s+)z
[\]\)\}]\wz	(``.+?``)z(:\w+:`.+?(?<!\\)`)z(`.+?`)z(\s+or\s+|\s+\|\s+|,\s+|\s+)z[](){}z:data:`python:None`z):ref:`bool <python:bltin-boolean-values>`z:data:`python:True`z:data:`python:False`z:class:`python:list`z:class:`python:tuple`z:class:`python:str`z:class:`python:dict`z:class:`python:float`z:class:`python:int`z:func:`python:callable`z:term:`python:iterable`z:term:`python:sequence`z(:func:`python:contextlib.contextmanager`z%:func:`python:collections.namedtuple`z:term:`python:generator`znumpy.ndarrayz:term:`numpy:array_like`z$:ref:`scalar <numpy:arrays.scalars>`znumpy.random.RandomStatez:data:`numpy.inf`z:data:`numpy.nan`z:mod:`numpy`)NoneboolZbooleanTrueFalselisttuplestrstringdictfloatintcallableiterableZsequencecontextmanager
namedtuple	generatorZarrayZndarrayz
np.ndarrayz
array-likeZ
array_likeZscalarZRandomStateznp.random.RandomStateznp.infznp.nanZnumpyc                s  }d}t tr8 dkr*d}t }ntd |  krT |  |  }}|} n|  }}t|r||kr||krd| d| dS |rd| dS |S  fd	d
}d| kr|| tS d| kr|| tS d| kr|| t	S t
dd | D rt| r| S || tS || tS )a  Parse and apply appropriate sphinx role(s) to `param_type`.

    The :obj: role is the default.

    Parameters
    ----------
    param_type : str
        text
    xref_aliases : dict
        Mapping used to resolve common abbreviations and aliases
        to fully qualified names that can be cross-referenced.
    xref_ignore : set or "all"
        A set containing words not to cross-reference. Instead of a set, the
        string 'all' can be given to ignore all unrecognized terms.
        Unrecognized terms include those that are not in `xref_aliases` and
        are not already wrapped in a reST role.

    Returns
    -------
    out : str
        Text with fully-qualified names and terms that may be wrapped in a
        ``:obj:`` role.
    TallFz(xref_ignore must be a set or 'all', got z:obj:`z <z>``c       	         s   g }| | }t|}|dkrx|t|D ]p\}}||rF|| q(t| }|r|d dkr||d k r||d  d }|dkr|d7 }|| q(W d|S | S )z
        Split string using the regex pattern,
        apply main function to the parts that do not match the pattern,
        combine the results
           r   r   z([{\ )splitlen	enumeratematchappend	make_xrefjoin)	spatternresultstokensnitokZresZ	next_char)xref_aliasesxref_ignore ,lib/python3.7/site-packages/numpydoc/xref.py_split_and_apply_re   s    


z&make_xref.<locals>._split_and_apply_rez``z:`c             s   s   | ]}|t kV  qd S )N)CONTAINER_CHARS).0cr(   r(   r)   	<genexpr>   s    zmake_xref.<locals>.<genexpr>)
isinstancer   lowerset	TypeErrorQUALIFIED_NAME_REr   DOUBLE_QUOTE_SPLIT_REROLE_SPLIT_RESINGLE_QUOTE_SPLIT_REanyCONTAINER_SPLIT_REJECT_REsearchCONTAINER_SPLIT_RETEXT_SPLIT_RE)Z
param_typer&   r'   Z
ignore_setZwrap_unknownlinktitler*   r(   )r&   r'   r)   r   a   s:    
$



r   )recompiler3   r:   r8   r4   r5   r6   r;   r1   r+   ZDEFAULT_LINKSr   r(   r(   r(   r)   <module>   sZ   