File: //usr/lib/python3/dist-packages/twisted/python/__pycache__/_pydoctor.cpython-310.pyc
o
�bO � @ s� d Z ddlZddlmZ ddlmZmZmZ ddlm Z G dd� de �Z
dd � ZG d
d� dej�Z
dd
� Zdd� ZG dd� dej�ZG dd� dej�ZdS )z�
Support for a few things specific to documenting Twisted using pydoctor.
FIXME: https://github.com/twisted/pydoctor/issues/106
This documentation does not link to pydoctor API as there is no public API yet.
� N)�Optional)�
astbuilder�model�
zopeinterface)�SphinxInventoryc s e Zd ZdZ� fdd�Z� ZS )�TwistedSphinxInventoryz�
Custom SphinxInventory to work around broken external references to
Sphinx.
All exceptions should be reported upstream and a comment should be created
with a link to the upstream report.
c sp t � �|�}|dur|S |�d�r6| j�dd�\}}|du r dS |dkr'd}nd}|du r/dS |� d|� �S dS )a
Resolve the full URL for a cross reference.
@param name: Value of the cross reference.
@type name: L{str}
@return: A full URL for the I{name} reference or L{None} if no link was
found.
@rtype: L{str} or L{None}
Nzzope.interface.z$zope.interface.interfaces.IInterface)NNz&zope.interface.adapter.AdapterRegistryzadapter.html�/)�super�getLink�
startswith�_links�get)�self�name�result�baseURL�_�relativeLink�� __class__� �:/usr/lib/python3/dist-packages/twisted/python/_pydoctor.pyr
s
�zTwistedSphinxInventory.getLink)�__name__�
__module__�__qualname__�__doc__r
�
__classcell__r r r r r s r c C sX |D ]'}t |tj�r)t�|j| �}|dv r)z
t| | j|�| _W q t y( Y qw qdS )z�
With a list of decorators, and the object it is running on, set the
C{_deprecated_info} flag if any of the decorators are a Twisted deprecation
decorator.
)z#twisted.python.deprecate.deprecatedz+twisted.python.deprecate.deprecatedPropertyN)
�
isinstance�ast�Callr �
node2fullname�func�deprecatedToUsefulTextr �_deprecated_info�AttributeError)r �
decorators�a�fnr r r �
getDeprecatedL s ���r( c s( e Zd Z� fdd�Z� fdd�Z� ZS )�TwistedModuleVisitorc sF t � �|� z
| jjj|j }W n
ty Y dS w t||j� dS )z<
Called when a class definition is visited.
N) r �visit_ClassDef�builder�current�contentsr �KeyErrorr( �raw_decorators)r �node�clsr r r r* c s �z#TwistedModuleVisitor.visit_ClassDefc sP t � �|� z
| jjj|j }W n
ty Y dS w |jr&t||j� dS dS )z?
Called when a function definition is visited.
N) r �visit_FunctionDefr+ r, r- r r. r% r( )r r0 r! r r r r2 p s ��z&TwistedModuleVisitor.visit_FunctionDef)r r r r* r2 r r r r r r) b s
r) c C st ddl m} | jd j}t| jd dt| jd dd��}t|t�s'|dks'J �|||gdd � | jd
d� D ��R � S )z3
Change an AST C{Version()} to a real one.
r )�Version� �n�sN�NEXTc s s � | ]}|r|j V qd S �N)r5 )�.0�xr r r � <genexpr>� s � z(versionToUsefulObject.<locals>.<genexpr>� )�incrementalr3 �argsr6 �getattrr �int)�versionr3 �package�majorr r r �versionToUsefulObject s
&rD c C s� ddl m} t|jd �}t|j�dkr3|jd r3t|jd tj�r,| �|jd j �}n|jd j
}nd}|jD ]}|jdkrC|j
j
}q8||||d�d S )z6
Change a C{@deprecated} to a display string.
r )�_getDeprecationWarningStringr4 N�replacement)rF �.)�twisted.python.deprecaterE rD r>