Ë
    šÓ^j  ã                  óæ   — U d Z ddlmZ ddlZddlmZ  ej                  e«      ZdZ	de
d<   	 ddlmZ dd	lmZ d
Zer	 ddlmZ d
Z	e	r G d„ de«      Zdd„Zy# e$ r dZY Œ&w xY w# e$ r dZ	Y Œ(w xY w)u  Sphinx autodoc extension: expose runtime-modified docstrings for _DeprecatedProxy.

.. note::
    **Beta feature** â€” the public API of this module (documenter class, priority
    value) may change in a minor release while it stabilises.

``@deprecated_class(update_docstring=True)`` writes the deprecation notice into
the proxy's ``__doc__`` at decoration time.  Sphinx's autodoc sees the proxy as
a non-class instance and renders it as ``"alias of <target>"`` without showing
the docstring.

This extension bridges the gap by registering a custom :class:`ClassDocumenter`
that:

1. Recognises :class:`~deprecate.proxy._DeprecatedProxy` objects via
   :meth:`can_document_member`.
2. Swaps the proxy for the underlying (wrapped) class so that Sphinx can
   introspect members and build the correct signature.
3. Returns the proxy's ``__doc__`` (which already contains the injected
   ``.. deprecated::`` block) from :meth:`get_doc`, so the notice appears in
   the rendered output.

Usage in ``conf.py``::

    extensions = [
        'sphinx.ext.autodoc',
        ...
        'deprecate.docstring.sphinx_ext',
    ]

Requirements:
    ``sphinx`` with ``sphinx.ext.autodoc`` is required.  Importing this module
    without Sphinx installed is safe â€” the custom documenter is simply not
    registered.


é    )ÚannotationsN)ÚAnyFÚboolÚ_PROXY_AVAILABLE)ÚClassDocumenter)Úprepare_docstringT)Ú_DeprecatedProxyc                  ó~   ‡ — e Zd ZdZdZej                  dz   Ze	 	 	 	 	 	 	 	 	 	 dˆ fd„«       Zdd	ˆ fd„Z	d
ˆ fd„Z
ˆ xZS )Ú_DeprecatedProxyClassDocumentera¾  ClassDocumenter subclass that handles pyDeprecate ``_DeprecatedProxy`` objects.

            Registered with a priority one step above the standard
            :class:`~sphinx.ext.autodoc.ClassDocumenter` so that it is selected
            whenever ``autoclass::`` is used on a :class:`~deprecate.proxy._DeprecatedProxy`
            instance, while all ordinary classes continue to be handled by the
            built-in documenter.

            Úclassé   c                óL   •— t        |t        «      xs t        ‰| �  ||||«      S )zEReturn ``True`` for proxies and for all types the base class accepts.)Ú
isinstancer	   ÚsuperÚcan_document_member)ÚclsÚmemberÚ
membernameÚisattrÚparentÚ	__class__s        €úi/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/deprecate/docstring/sphinx_ext.pyr   z3_DeprecatedProxyClassDocumenter.can_document_memberQ   s0   ø€ ô " &Ô*:Ó;ò ¼u¹wÑ?ZØ˜J¨°ó@ð ó    c                óî   •— t         ‰| �  |¬«      }t        | dd«      }|rTt        |t        «      rDt        |dd«      xs d| _        t        |d«      r|j                  j                  | _	        d| _
        |S )u“  Import the object and, when it is a proxy, swap it for the wrapped class.

                The proxy's ``__doc__`` (which contains the injected deprecation notice) is saved in ``self._proxy_doc``
                before the swap so that :meth:`get_doc` can return it verbatim.

                ``doc_as_attr`` is reset to ``False`` after the swap because the base
                :class:`~sphinx.ext.autodoc.ClassDocumenter` computes it using ``self.object.__name__``.  On a
                :class:`~deprecate.proxy._DeprecatedProxy` that attribute is forwarded to the *target* class (via
                ``__getattr__``), which makes Sphinx believe the object is an alias for that target and adds an ``alias
                of â€¦`` paragraph.  After the swap ``self.object`` is the real class whose ``__name__`` matches the
                documented path, so ``doc_as_attr`` should be ``False``.

                )Ú
raiseerrorÚobjectNÚ__doc__Ú Ú_cfgF)r   Úimport_objectÚgetattrr   r	   Ú
_proxy_docÚhasattrr   Úobjr   Údoc_as_attr)Úselfr   Úresultr$   r   s       €r   r    z-_DeprecatedProxyClassDocumenter.import_object^   ss   ø€ ô ™Ñ.¸*Ð.ÓE�ô # 4¨°4Ó8�Ùœj¨Ô.>Ô?ä+2°3¸	À2Ó+FÒ+LÈ"�D”Oô ˜s FÔ+Ø&)§h¡h§l¡l˜œð
 (-�DÔ$Ø�r   c                óV   •— t        | dd«      }|rt        |«      gS t        ‰| �  «       S )z?Return the proxy docstring so the deprecated block is rendered.r"   r   )r!   r   r   Úget_doc)r&   Ú	proxy_docr   s     €r   r)   z'_DeprecatedProxyClassDocumenter.get_doc~   s/   ø€ ä!(¨¨|¸RÓ!@�	ÙÜ-¨iÓ8Ð9Ð9Ü‘w‘Ó(Ð(r   )
r   r   r   Ústrr   r   r   r   Úreturnr   )F)r   r   r,   r   )r,   zlist[list[str]] | None)Ú__name__Ú
__module__Ú__qualname__r   Úobjtyper   ÚpriorityÚclassmethodr   r    r)   Ú__classcell__)r   s   @r   r   r   C   sq   ø„ ñð ˆGØ&×/Ñ/°!Ñ3ˆHàð
àð
ð  ð
ð ð	
ð
 ð
ð ô
ó ð
ö÷@)ñ )r   r   c                ó¬   — t         r/t        r)| j                  d«       | j                  t        d¬«       nt         rt
        j                  d«       dddœS )zºRegister the ``_DeprecatedProxy`` documenter with Sphinx.

    Args:
        app: The Sphinx application instance.

    Returns:
        Extension metadata dict consumed by Sphinx.

    zsphinx.ext.autodocT)Úoverrideu…   deprecate.docstring.sphinx_ext: _DeprecatedProxy unavailable â€” extension loaded but _DeprecatedProxyClassDocumenter not registered.z0.1)ÚversionÚparallel_read_safe)Ú_SPHINX_AVAILABLEr   Úsetup_extensionÚadd_autodocumenterr   Ú_loggerÚwarning)Úapps    r   Úsetupr>   †   sQ   € õ Õ-Ø×ÑÐ0Ô1ð 	×ÑÔ>ÈÐÕNÝ	Ü�‰ðSô	
ð °DÑ9Ð9r   )r=   r   r,   zdict[str, Any])r   Ú
__future__r   ÚloggingÚtypingr   Ú	getLoggerr-   r;   r   Ú__annotations__Úsphinx.ext.autodocr   Úsphinx.util.docstringsr   r8   ÚImportErrorÚdeprecate.proxyr	   r   r>   © r   r   ú<module>rI      sž   ðò$õL #ã Ý à
ˆ'×
Ñ
˜HÓ
%€àÐ �$Ó ðÝ2Ý8àÐñ
 ð!Ý4àÐñ ô@	)¨oô @	)ôF:øðc ò ØÒðûð ò !Ø Òð!ús"   ®A ¿A& ÁA#Á"A#Á&A0Á/A0