Ë
    šÓ^j�  ã                  ón   — d Z ddlmZ ddlZddlZ	 ddlZ G d„ dej                  «      Zy# e$ r Y yw xY w)u­  Griffe extension: expose runtime-modified docstrings to mkdocstrings.

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

``@deprecated(update_docstring=True)`` writes the deprecation notice into
``fn.__doc__`` at decoration time.  Griffe â€” the engine used by mkdocstrings â€”
reads docstrings from the source AST, so it never sees that runtime change.

This extension bridges the gap: after Griffe has visited a module it imports
the module at runtime and replaces every AST docstring whose callable carries
a ``__deprecated__`` attribute (set by pyDeprecate) with the live ``__doc__``.

Usage in ``mkdocs.yml``::

    plugins:
      - mkdocstrings:
          handlers:
            python:
              options:
                extensions:
                  - deprecate.docstring.griffe_ext:RuntimeDocstrings

Requirements:
    ``griffe`` is a dependency of ``mkdocstrings[python]`` and will always be
    present in an MkDocs environment that uses mkdocstrings.  Importing this
    module without ``griffe`` installed is safe â€” ``RuntimeDocstrings`` simply
    will not be defined.

é    )ÚannotationsNc                  óD   — e Zd ZdZdd„Zedd„«       Zd	d„Zed
d„«       Zy)ÚRuntimeDocstringszCUpdate Griffe docstrings to reflect decorator-modified ``__doc__``.c               óÌ   — | j                  |«      }|€y|j                  j                  «       D ]3  \  }}t        |t        j
                  «      sŒ!| j                  |||«       Œ5 y)a!  Run after a module is fully loaded by Griffe.

            For each function or method in *mod* that carries a ``__deprecated__`` attribute (set by pyDeprecate),
            replace the Griffe docstring with the runtime value so that mkdocstrings renders the injected notice.

            N)Ú_import_moduleÚmembersÚitemsÚ
isinstanceÚgriffeÚObjectÚ_update_obj)ÚselfÚmodÚloaderÚkwargsÚruntime_modÚnameÚobjs          úi/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/deprecate/docstring/griffe_ext.pyÚ	on_modulezRuntimeDocstrings.on_module/   s]   € ð ×-Ñ-¨cÓ2ˆKØÐ"Øà Ÿ[™[×.Ñ.Ó0ò =‘	��cÜ˜c¤6§=¡=Õ1Ø×$Ñ$ S¨+°tÕ<ñ=ó    c                ó  — 	 t        j                  | j                  «      S # t        t        f$ r Y nw xY wt        | dd«      }|€yddl}|j                  |«      }t        | j                  j                  d«      «      dz
  }|j                  dk(  r|dz  }t        |j                  |   «      }|t        j                  v}|r t        j                  j                  d|«       	 t        j                  | j                  «      |r t        j                  j                  |«       S S # t        t        f$ r% Y |r t        j                  j                  |«       yyw xY w# |r t        j                  j                  |«       w w xY w)ut  Import *mod* at runtime, adding its package root to sys.path if needed.

            griffe loads modules via its own search_paths which are not on sys.path, so a plain
            ``importlib.import_module(mod.name)`` will fail for modules that live outside the installed packages (e.g. a
            local ``demo.py``). We derive the package root from ``mod.filepath`` â€” walking up one level per dotted name
            component so that both single-file modules (``demo``) and package sub-modules (``pkg.submod``) resolve
            correctly â€” and temporarily add it to sys.path so the import can succeed.

            ÚfilepathNr   ú.é   z__init__.py)Ú	importlibÚimport_moduler   ÚImportErrorÚModuleNotFoundErrorÚgetattrÚpathlibÚPathÚlenÚsplitÚstrÚparentsÚsysÚpathÚinsertÚremove)r   r   r!   ÚpÚdepthÚ
source_dirÚaddeds          r   r   z RuntimeDocstrings._import_module>   sE  € ðÜ ×.Ñ.¨s¯x©xÓ8Ð8øÜÔ!4Ð5ò Ùðúô ˜s J°Ó5ˆHØÐØãð —‘˜XÓ&ˆAÜ˜Ÿ™Ÿ™ sÓ+Ó,¨qÑ0ˆEØ�v‰v˜Ò&Ø˜‘
�Ü˜QŸY™Y uÑ-Ó.ˆJØ¤c§h¡hÐ.ˆEÙÜ—‘—‘  :Ô.ð0Ü ×.Ñ.¨s¯x©xÓ8ñ Ü—H‘H—O‘O JÕ/ð øô  Ô!4Ð5ò ØáÜ—H‘H—O‘O JÕ/ð ðûñ Ü—H‘H—O‘O JÕ/ð ús0   ‚! ¡3²3Ã#D$ Ä$EÄ3E ÅEÅE Å$E?c                óx  — t        ||d «      }|€y t        |t        j                  «      r| j	                  ||«       y t        |t        j
                  «      rc| j	                  ||«       |j                  j                  «       D ]3  \  }}t        |t        j                  «      sŒ!| j                  |||«       Œ5 y y )N)
r    r
   r   ÚFunctionÚ_replace_docstringÚClassr   r	   r   r   )r   r   Úparentr   Úruntime_objÚmember_nameÚmembers          r   r   zRuntimeDocstrings._update_objo   s�   € Ü! &¨$°Ó5ˆKØÐ"Øä˜#œvŸ™Ô/Ø×'Ñ'¨¨[Õ9Ü˜C¤§¡Ô.Ø×'Ñ'¨¨[Ô9Ø+.¯;©;×+<Ñ+<Ó+>ò KÑ'�K Ü! &¬&¯-©-Õ8Ø×(Ñ(¨°¸kÕJñKð /r   c                óÈ   — t        |dd«      syt        |dd«      }|sy| j                  €y|| j                  _        | j                  j                  j	                  dd«       y)zDOverwrite the Griffe docstring when the runtime ``__doc__`` differs.Ú__deprecated__NÚ__doc__Úparsed)r    Ú	docstringÚvalueÚ__dict__Úpop)Ú
griffe_objr4   Úruntime_docs      r   r1   z$RuntimeDocstrings._replace_docstring|   sc   € ô ˜;Ð(8¸$Ô?ØÜ! +¨y¸$Ó?ˆKÙØØ×#Ñ#Ð+ØØ)4ˆJ× Ñ Ô&ð
 × Ñ ×)Ñ)×-Ñ-¨h¸Õ=r   N)r   úgriffe.Moduler   zgriffe.GriffeLoaderr   ÚobjectÚreturnÚNone)r   rA   rC   rB   )r   úgriffe.Objectr3   rB   r   r%   rC   rD   )r?   rE   r4   rB   rC   rD   )	Ú__name__Ú
__module__Ú__qualname__r9   r   Ústaticmethodr   r   r1   © r   r   r   r   ,   s9   „ ÙQó	=ð 
ò.	0ó 
ð.	0ó`	Kð 
ò	>ó 
ñ	>r   r   )	r9   Ú
__future__r   r   r'   r   Ú	Extensionr   r   rJ   r   r   ú<module>rM      sG   ðñõ@ #ã Û 
ðe>Ûô
_>˜F×,Ñ,õ _>øð	 ò 	Ùð	ús   ’, ¬4³4