File: //opt/alt/python311/lib/python3.11/site-packages/deprecated/__pycache__/sphinx.cpython-311.pyc
�
$�;f( � �n � d Z ddlZddlZddlZddlmZ ddlmZ G d� de� � Zdd �Z dd
�Z
dd�ZdS )
a-
Sphinx directive integration
============================
We usually need to document the life-cycle of functions and classes:
when they are created, modified or deprecated.
To do that, `Sphinx <http://www.sphinx-doc.org>`_ has a set
of `Paragraph-level markups <http://www.sphinx-doc.org/en/stable/markup/para.html>`_:
- ``versionadded``: to document the version of the project which added the described feature to the library,
- ``versionchanged``: to document changes of a feature,
- ``deprecated``: to document a deprecated feature.
The purpose of this module is to defined decorators which adds this Sphinx directives
to the docstring of your function and classes.
Of course, the ``@deprecated`` decorator will emit a deprecation warning
when the function/method is called or the class is constructed.
� N)�ClassicAdapter)�
deprecatedc �B � � e Zd ZdZdddedf� fd� Z� fd�Z� fd�Z� xZS )�
SphinxAdaptera
Sphinx adapter -- *for advanced usage only*
This adapter override the :class:`~deprecated.classic.ClassicAdapter`
in order to add the Sphinx directives to the end of the function/class docstring.
Such a directive is a `Paragraph-level markup <http://www.sphinx-doc.org/en/stable/markup/para.html>`_
- The directive can be one of "versionadded", "versionchanged" or "deprecated".
- The version number is added if provided.
- The reason message is obviously added in the directive block if not empty.
� N�F c � �� |st d� � �|| _ || _ t t | � � � ||||�� � dS )a�
Construct a wrapper adapter.
:type directive: str
:param directive:
Sphinx directive: can be one of "versionadded", "versionchanged" or "deprecated".
:type reason: str
:param reason:
Reason message which documents the deprecation in your library (can be omitted).
:type version: str
:param version:
Version of your project which deprecates this feature.
If you follow the `Semantic Versioning <https://semver.org/>`_,
the version number has the format "MAJOR.MINOR.PATCH".
:type action: str
:param action:
A warning filter used to activate or not the deprecation warning.
Can be one of "error", "ignore", "always", "default", "module", or "once".
If ``None`` or empty, the the global filtering mechanism is used.
See: `The Warnings Filter`_ in the Python documentation.
:type category: type
:param category:
The warning category to use for the deprecation warning.
By default, the category class is :class:`~DeprecationWarning`,
you can inherit this class to define your own deprecation warning category.
:type line_length: int
:param line_length:
Max line length of the directive text. If non nul, a long text is wrapped in several lines.
z3'version' argument is required in Sphinx directives)�reason�version�action�categoryN)�
ValueError� directive�line_length�superr �__init__)�selfr r
r r r
r � __class__s ��D/opt/alt/python311/lib/python3.11/site-packages/deprecated/sphinx.pyr zSphinxAdapter.__init__, s\ �� �V � T��R�S�S�S�"���&���
�m�T�"�"�+�+�6�7�SY�dl�+�m�m�m�m�m� c � �� | j rdnd}|� | j | j �� � g}| j dk r
| j dz
nd}t j | j � � � � � }|� � � D ]W}|r>|� t j
||dd�� � � � � � � �B|� d� � �X|j pd}|� d �
� � pdg}t |� � dk r/t j d� |dd� � � � � nd}|d
|z }|r&t j dd|t j �� � dz }nd}|d� d� |D � � � � z
}||_ | j dv r|S t% t&