Ë
    šÓ^jÎ]  ã                   ó.  — U d Z ddlZddlZddlZddlZddlmZmZmZ ddl	m
Z
mZmZ g d¢Zg d¢ZdZdZd	Zd
ZdZdddddœZ ee«      Zee   ed<   h d£Zh d£Zdedefd„Zdee   defd„Zded   fd„Z deded   fd„Z!dee   dededefd„Z"dee   de#eef   fd „Z$dee   d!ed"ede#eef   fd#„Z%dee   d!ed"ed$ed%edefd&„Z&dee   d'ed(edefd)„Z'dee   d%ed*ede#ee   ef   fd+„Z(dee   d%ed*ede#ee   ef   fd,„Z)d-e
dee   fd.„Z*d/e+ddfd0„Z,y)1aÌ  Helpers for annotating function docstrings with deprecation information.

This module owns all logic that reads or modifies a callable's ``__doc__``
attribute during deprecation decoration.  It supports both Google-style
(``Args:`` / ``Arguments:``), NumPy-style (``Parameters`` + underline),
and Sphinx-style (``:param ...:``) docstrings, plus MkDocs/Markdown output.

Key Components:
    - String constants (``TEMPLATE_DOC_*``) for reusable message fragments.
    - Style normalizer: :func:`normalize_docstring_style`, :func:`_auto_detect_style`
    - Section-aware insertion helpers: :func:`find_docstring_insertion_index`,
      :func:`is_numpy_underline`
    - Per-argument note builder: :func:`_build_arg_deprecation_note`
    - Google-style section helpers: :func:`_find_google_args_section`,
      :func:`_get_google_arg_indents`, :func:`_find_google_arg_line`
    - Shared continuation-line helper: :func:`_find_entry_end`
    - Annotators: :func:`_annotate_google_style_arg`,
      :func:`_annotate_sphinx_style_arg`
    - Notice builder: :func:`_build_general_notice_lines`
    - Orchestrator: :func:`_update_docstring_with_deprecation`

Copyright (C) 2020-2026 Jiri Borovec <6035284+Borda@users.noreply.github.com>

é    N)ÚLiteralÚOptionalÚcast)ÚDeprecationConfigÚ
TargetModeÚ_has_deprecation_meta)z!.. deprecated:: %(deprecated_in)sz   %(remove_text)sz   %(target_text)s)z-!!! warning "Deprecated in %(deprecated_in)s"z    %(remove_text)sz    %(target_text)su3   Deprecated since v%(deprecated_in)s â€” %(reason)s.u   Deprecated â€” %(reason)s.z# Will be removed in v%(remove_in)s.zno longer usedzuse `%(new_arg)s` insteadÚautoÚrstÚmkdocs)r	   r
   r   ÚmarkdownÚSUPPORTED_DOCSTRING_STYLES>
   úargs:únotes:úwarns:úraises:úyields:úreturns:ú	examples:ú
arguments:úattributes:úparameters:>
   úother parametersÚnotesÚwarnsÚraisesÚyieldsÚmethodsÚreturnsÚexamplesÚ
attributesÚ
parametersÚlineÚreturnc                 óf   — | j                  «       }t        |«      dk\  xr t        d„ |D «       «      S )zAReturn ``True`` when the line is a NumPy-style section underline.é   c              3   ó&   K  — | ]	  }|d k(  –— Œ y­w)ú-N© )Ú.0Úchars     úe/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/deprecate/docstring/inject.pyú	<genexpr>z%is_numpy_underline.<locals>.<genexpr>X   s   è ø€ Ò%G°d d¨c¥kÑ%Gùs   ‚)ÚstripÚlenÚall)r"   Ústrippeds     r+   Úis_numpy_underliner1   U   s,   € à�z‰z‹|€HÜˆx‹=˜AÑÒG¤#Ñ%G¸hÔ%GÓ"GÐGó    Úlinesc                 ó&  — t        | «      D ]y  \  }}|j                  «       j                  «       t        v r|c S |dz   t	        | «      k  sŒ@|j                  «       j                  «       t
        v sŒet        | |dz      «      sŒw|c S  t	        | «      S )z>Find insertion index before first Google/NumPy section header.é   )Ú	enumerater-   ÚlowerÚGOOGLE_DOCSTRING_SECTIONSr.   ÚNUMPY_DOCSTRING_SECTIONSr1   )r3   Úidxr"   s      r+   Úfind_docstring_insertion_indexr;   [   s€   € ä˜uÓ%ò ‰	ˆˆTØ�:‰:‹<×ÑÓÔ#<Ñ<ØŠJà�!‰G”c˜%“jÓ Ø—
‘
“×"Ñ"Ó$Ô(@Ò@Ü" 5¨¨q©¡>Õ2àŠJðô ˆu‹:Ðr2   ©r
   r   c                  ó  — t         j                  j                  dd«      j                  «       } | dv ry| dk(  rydt        j
                  v ryt        j                  r$dt        j                  d   j                  «       v ryy)uo  Detect documentation engine from environment or process name.

    Resolution order:

    1. ``DEPRECATE_DOCSTRING_STYLE`` env var â€” explicit override, takes highest priority.
    2. ``sys.modules`` â€” ``mkdocs`` imported â†’ MkDocs build in progress.
    3. ``sys.argv[0]`` full path â€” ``mkdocs`` anywhere in the path string.
    4. Default â†’ ``"rst"``.

    ÚDEPRECATE_DOCSTRING_STYLEÚ )r   r   r   r
   r   )ÚosÚenvironÚgetr7   ÚsysÚmodulesÚargv)Ú	env_styles    r+   Ú_auto_detect_stylerG   i   sm   € ô —
‘
—‘Ð:¸BÓ?×EÑEÓG€IØÐ*Ñ*ØØ�EÒØà”3—;‘;ÑØÜ
‡x‚x�H¤§¡¨¡× 1Ñ 1Ó 3Ñ3ØØr2   Údocstring_stylec                 ó,  — t        | t        «      st        d| ›dt        t        «      ›d�«      ‚t
        j                  | j                  «       «      }|€t        d| ›dt        t        «      ›d�«      ‚|dk(  r
t        «       S t        t        d   |«      S )z/Validate and normalize docstring style aliases.z Invalid `docstring_style` value z. Supported styles are: ú.r	   r<   )Ú
isinstanceÚstrÚ
ValueErrorÚsortedr   ÚDOCSTRING_STYLE_ALIASESrB   r7   rG   r   r   )rH   Únormalized_styles     r+   Únormalize_docstring_stylerQ   �   s®   € ä�o¤sÔ+ÜØ.ØÐ!Ð!9¼&ÔA[Ó:\Ð9_Ð_`ðbó
ð 	
ô /×2Ñ2°?×3HÑ3HÓ3JÓKÐØÐÜØ.ØÐ!Ð!9¼&ÔA[Ó:\Ð9_Ð_`ðbó
ð 	
ð ˜6Ò!Ü!Ó#Ð#Ü”˜Ñ(Ð*:Ó;Ð;r2   Únew_argÚdeprecated_inÚ	remove_inc                 óx   — | rt         d| iz  nt        }|rt        nt        }|||dœz  }|r|t        d|iz  z  }|S )uë  Build an inline deprecation note string for a single deprecated argument.

    Args:
        new_arg: Replacement argument name, or ``None`` when the argument is simply removed.
        deprecated_in: Version string when the argument was deprecated (e.g. ``"1.8"``).
        remove_in: Version string when the argument will be removed (e.g. ``"1.9"``).

    Returns:
        A one-line deprecation note suitable for embedding in a docstring.

    Example:
        >>> _build_arg_deprecation_note(None, "1.8", "1.9")
        'Deprecated since v1.8 â€” no longer used. Will be removed in v1.9.'
        >>> _build_arg_deprecation_note("new_arg", "1.8", "1.9")
        'Deprecated since v1.8 â€” use `new_arg` instead. Will be removed in v1.9.'

    rR   )rS   ÚreasonrT   )ÚTEMPLATE_DOC_ARG_REASON_RENAMEDÚTEMPLATE_DOC_ARG_REASON_REMOVEDÚ!TEMPLATE_DOC_ARG_DEPRECATED_SINCEÚTEMPLATE_DOC_ARG_DEPRECATEDÚTEMPLATE_DOC_ARG_REMOVE)rR   rS   rT   rV   ÚtemplateÚnotes         r+   Ú_build_arg_deprecation_noter^   “   sR   € ñ$ HOÔ,°	¸7Ð/CÒCÔTs€FÙ4AÕ0ÔGb€HØ¨ÀÑHÑH€DÙØÔ'¨;¸	Ð*BÑBÑBˆØ€Kr2   c                 óÈ   — t        j                  d«      }t        | «      D ]?  \  }}|j                  |«      sŒ|t	        |«      t	        |j                  «       «      z
  fc S  y)uL  Return ``(section_start, section_indent)`` for a Google-style ``Args:`` header.

    Scans *lines* for an ``Args:`` or ``Arguments:`` header and returns its line
    index and leading indentation.  Returns ``(-1, 0)`` when not found.

    The match is intentionally strict: a line qualifies only when it consists
    of optional leading spaces followed by exactly ``Args:`` or ``Arguments:``
    with nothing else on the line (no trailing text).  This avoids accidental
    matches inside prose paragraphs.

    See `Google Python Style Guide â€” Functions and Methods
    <https://google.github.io/styleguide/pyguide.html#383-functions-and-methods>`_
    for the ``Args:`` section specification.

    Args:
        lines: Docstring already split into individual lines.

    Returns:
        A 2-tuple ``(section_start, section_indent)``.

    z^\s*(Args|Arguments):\s*$)éÿÿÿÿr   )ÚreÚcompiler6   Úmatchr.   Úlstrip)r3   Ú_section_reÚir"   s       r+   Ú_find_google_args_sectionrg   ­   s]   € ô, —*‘*Ð9Ó:€KÜ˜UÓ#ò 5‰ˆˆ4Ø×Ñ˜TÕ"Ø”c˜$“i¤# d§k¡k£mÓ"4Ñ4Ð4Ò4ð5ð r2   Úsection_startÚsection_indentc                 óÈ  — d}t        |dz   t        | «      «      D ]I  }| |   j                  «       sŒt        | |   «      t        | |   j                  «       «      z
  }||kD  r|} n |dk(  ry|dz   }t        |dz   t        | «      «      D ]S  }| |   }|j                  «       sŒt        |«      t        |j                  «       «      z
  }||k  r ||fS ||kD  sŒN|} ||fS  ||fS )a›  Return ``(arg_indent, continuation_indent)`` for a Google-style Args section.

    *arg_indent* is the column at which individual argument entries begin.
    *continuation_indent* is the column used for continuation lines within an
    argument entry (defaults to ``arg_indent + 4`` when not detectable).
    Returns ``(-1, -1)`` when the section has no non-empty child lines.

    Args:
        lines: Docstring already split into individual lines.
        section_start: Line index of the ``Args:`` / ``Arguments:`` header.
        section_indent: Leading indentation of that header line.

    Returns:
        A 2-tuple ``(arg_indent, continuation_indent)``.

    r`   r5   )r`   r`   é   ©Úranger.   r-   rd   )r3   rh   ri   Ú
arg_indentrf   Úcurrent_indentÚcontinuation_indentr"   s           r+   Ú_get_google_arg_indentsrq   Ê   s  € ð" €JÜ�= 1Ñ$¤c¨%£jÓ1ò ˆØ�‰8�>‰>ÕÜ   q¡›]¬S°°q±·±Ó1BÓ-CÑCˆNØ Ò.Ø+�
Ùðð �RÒØà$ q™.ÐÜ�= 1Ñ$¤c¨%£jÓ1ò 	ˆØ�Q‰xˆØ�z‰zŒ|ØÜ˜T›¤S¨¯©«Ó%7Ñ7ˆØ˜^Ò+Øð
 Ð*Ð*Ð*ð	 ˜JÓ&Ø"0ÐØàÐ*Ð*Ð*ð	ð Ð*Ð*Ð*r2   rn   Úarg_namec                 ód  — t        |dz   t        | «      «      D ]•  }| |   }|j                  «       sŒt        |«      t        |j                  «       «      z
  }||k  r y||k(  sŒK||d }t        |«      t        |«      kD  xr |t        |«         dv }	||k(  s|j	                  |«      sŒ�|	sŒ“|c S  y)a'  Return the line index of *arg_name* inside a Google-style Args section.

    Returns ``-1`` when *arg_name* is not found within the section.

    Args:
        lines: Docstring already split into individual lines.
        section_start: Line index of the ``Args:`` / ``Arguments:`` header.
        section_indent: Leading indentation of that header line.
        arg_indent: Leading indentation of argument entry lines.
        arg_name: Name of the argument to locate.

    Returns:
        Line index of the matching argument entry, or ``-1``.

    r5   Nz :(,r`   )rm   r.   r-   rd   Ú
startswith)
r3   rh   ri   rn   rr   rf   r"   ro   ÚrestÚhas_arg_boundarys
             r+   Ú_find_google_arg_linerw   õ   s¾   € ô$ �= 1Ñ$¤c¨%£jÓ1ò ˆØ�Q‰xˆØ�z‰zŒ|ØÜ˜T›¤S¨¯©«Ó%7Ñ7ˆØ˜^Ò+Øð ð ˜ZÓ'Ø˜
˜Ð$ˆDÜ" 4›y¬3¨x«=Ñ8ÒZ¸TÄ#ÀhÃ-Ñ=PÐTZÐ=ZÐØ�xÒ D§O¡O°HÕ$=ÒBRØ’ðð r2   Ú	entry_idxÚentry_indentc                 óÎ   — |}t        |dz   t        | «      «      D ]G  }| |   }|j                  «       s |S t        |«      t        |j                  «       «      z
  |k  r |S |}ŒI |S )aö  Return the index of the last continuation line for a docstring entry.

    Scans forward from *entry_idx + 1* and stops at the first blank line or
    the first line whose indentation is ``<= entry_indent``.

    Note:
        A blank line within a multi-paragraph argument description is treated
        as the entry boundary.  Only the content up to that blank line receives
        the deprecation note; subsequent paragraphs are considered outside the
        entry.

    Args:
        lines: Docstring already split into individual lines.
        entry_idx: Line index of the entry's opening line.
        entry_indent: Leading indentation of that opening line.

    Returns:
        Index of the last line belonging to the entry (>= *entry_idx*).

    r5   rl   )r3   rx   ry   Úend_idxrf   r"   s         r+   Ú_find_entry_endr|     sw   € ð* €GÜ�9˜q‘=¤# e£*Ó-ò ˆØ�Q‰xˆØ�z‰zŒ|Øð €Nô ˆt‹9”s˜4Ÿ;™;›=Ó)Ñ)¨\Ò9Øà€Nð ‰ðð €Nr2   r]   c                 ó,  ‡— t        | «      \  }}|dk(  r| dfS t        | ||«      \  }}|dk(  r| dfS t        | ||||«      }|dk(  r| dfS t        | ||«      }t	        ˆfd„| ||dz    D «       «      r| dfS d|z  ‰z   }	| d|dz    |	gz   | |dz   d z   }
|
dfS )ut  Find *arg_name* in a Google-style ``Args:`` section and insert *note* below it.

    Supports both ``Args:`` and ``Arguments:`` section headers.  Returns the
    original list unchanged when no matching section or argument entry is found.

    Args:
        lines: Docstring already split into individual lines.
        arg_name: Name of the deprecated argument to locate.
        note: Text to insert as a continuation line under the matched entry.

    Returns:
        A 2-tuple ``(new_lines, found)`` where *found* is ``True`` when the
        argument was located and the note was successfully inserted.

    The note is inserted as a continuation line directly after the matched entry:

    .. code-block:: text

    Args:
            lr (float): Learning rate.
            old_cfg (object): Old config.
                Deprecated â€” use cfg instead.  # <-- inserted here

    r`   Fc              3   ó&   •K  — | ]  }‰|v –— Œ
 y ­w©Nr(   ©r)   Úlnr]   s     €r+   r,   z-_annotate_google_style_arg.<locals>.<genexpr>]  s   øè ø€ Ò
B˜"ˆ4�2Œ:Ñ
Bùó   ƒr5   Tú N)rg   rq   rw   r|   Úany)r3   rr   r]   rh   ri   rn   rp   Úarg_line_idxr{   Ú	note_lineÚ	new_liness     `        r+   Ú_annotate_google_style_argrˆ   6  sä   ø€ ô2 %>¸eÓ$DÑ!€M�>Ø˜ÒØ�eˆ|Ðä&=¸eÀ]ÐTbÓ&cÑ#€JÐ#Ø�RÒØ�eˆ|Ðä(¨°¸~ÈzÐ[cÓd€LØ�rÒØ�eˆ|Ðä˜e \°:Ó>€Gä
Ó
B  l°W¸q±[Ð AÔ
BÔBØ�dˆ{ÐØÐ)Ñ)¨DÑ0€IØ�m˜ !™Ð$¨	 {Ñ2°U¸7ÀQ¹;¸=Ð5IÑI€IØ�dˆ?Ðr2   c                 ó   ‡— t        j                  dt        j                  |«      z   dz   «      }d}d}t        | «      D ]6  \  }}|j	                  |«      }|sŒ|}t        |j                  d«      «      } n |dk(  r| dfS t        | ||«      }	t        ˆfd„| ||	dz    D «       «      r| dfS d	|d
z   z  ‰z   }
| d|	dz    |
gz   | |	dz   d z   }|dfS )ue  Find ``:param arg_name:`` in a Sphinx-style docstring and insert *note* below it.

    Supports both ``:param arg_name:`` and ``:param SomeType arg_name:`` forms.
    Returns the original list unchanged when no matching ``:param`` field is found.

    Args:
        lines: Docstring already split into individual lines.
        arg_name: Name of the deprecated argument to locate.
        note: Text to insert as a continuation line under the matched field.

    Returns:
        A 2-tuple ``(new_lines, found)`` where *found* is ``True`` when the
        parameter was located and the note was successfully inserted.

    The note is inserted as a continuation line directly after the matched field::

        :param lr: Learning rate.
        :param old_cfg: Old config.
            Deprecated â€” use cfg instead.  # <-- inserted here
        :returns: Result.

    z^(\s*):param\s+(?:\S+\s+)?z\s*:r`   r   r5   Fc              3   ó&   •K  — | ]  }‰|v –— Œ
 y ­wr   r(   r€   s     €r+   r,   z-_annotate_sphinx_style_arg.<locals>.<genexpr>‹  s   øè ø€ Ò
D˜"ˆ4�2Œ:Ñ
Dùr‚   Trƒ   rk   N)	ra   rb   Úescaper6   rc   r.   Úgroupr|   r„   )r3   rr   r]   ÚpatternÚparam_line_idxÚparam_indentrf   r"   Úmr{   r†   r‡   s     `         r+   Ú_annotate_sphinx_style_argr‘   d  sý   ø€ ô. �j‰jÐ6¼¿¹À8Ó9LÑLÈwÑVÓW€Gà€NØ€LÜ˜UÓ#ò ‰ˆˆ4Ø�M‰M˜$ÓˆÚØˆNÜ˜qŸw™w q›z›?ˆLÙðð ˜ÒØ�eˆ|Ðä˜e ^°\ÓB€Gä
Ó
D  n°wÀ±{Ð CÔ
DÔDØ�dˆ{ÐØ�| aÑ'Ñ(¨4Ñ/€IØ�m˜ !™Ð$¨	 {Ñ2°U¸7ÀQ¹;¸=Ð5IÑI€IØ�dˆ?Ðr2   Údep_infoc                 ój  — | j                   rd| j                   › d�nd}d}d}t        | j                  «      ra| j                  j                  › d| j                  j                  › �}t        j                  | j                  «      rdnd}d|› d|› d�}d	|› d�}t        | j                  «      }|d
k(  r	t        }|}nt        }|}g }	|D ]h  }
|
j                  «       j                  d«      r|sŒ%|
j                  «       j                  d«      r|sŒG|	j                  |
| j                  ||dœz  «       Œj |	S )a  Render the general deprecation notice lines for the given style.

    Selects the RST (``.. deprecated::``) or MkDocs (``!!! warning``) template
    based on ``dep_info.docstring_style``, substitutes ``deprecated_in``,
    ``remove_in``, and the target reference, and omits template lines whose
    placeholder resolves to an empty string.

    Args:
        dep_info: Frozen deprecation metadata attached to the decorated callable.

    Returns:
        A list of rendered notice lines (without leading body indentation).

    zWill be removed in rJ   r?   ÚclassÚfunczUse :z:`z
` instead.zUse `r   z%(remove_text)sz%(target_text)s)rS   Úremove_textÚtarget_text)rT   ÚcallableÚtargetÚ
__module__Ú__name__ÚinspectÚisclassrQ   rH   ÚTEMPLATE_DOC_DEPRECATED_MKDOCSÚTEMPLATE_DOC_DEPRECATED_RSTr-   ÚendswithÚappendrS   )r’   r–   Útarget_text_rstÚtarget_text_mkdocsÚfull_target_nameÚref_typerH   r\   r—   Úresultr"   s              r+   Ú_build_general_notice_linesr§   ’  s?  € ð BJ×ASÒASÐ'¨×(:Ñ(:Ð';¸1Ñ=ÐY[€KØ€OØÐÜ�—‘Ô Ø&Ÿo™o×8Ñ8Ð9¸¸8¿?¹?×;SÑ;SÐ:TÐUÐÜ%Ÿo™o¨h¯o©oÔ>‘7ÀFˆØ! ( ¨2Ð.>Ð-?¸zÐJˆØ$Ð%5Ð$6°jÐAÐä/°×0HÑ0HÓI€OØ˜(Ò"Ü1ˆØ(‰ä.ˆØ%ˆà€FØò 
ˆØ�:‰:‹<× Ñ Ð!2Ô3¹KØØ�:‰:‹<× Ñ Ð!2Ô3¹KØØ�‰Ø X×%;Ñ%;ÈKÐhsÑtÑtõ	
ð
ð €Mr2   Ú
wrapped_fnc                 óò  ‡— t        | d«      r| j                  syt        | «      sy| j                  j                  «       }| j                  }|j
                  r´d}|j
                  j                  «       D ]M  \  }}t        ||j                  |j                  «      }t        |||«      \  }}|st        |||«      \  }}|rŒLd}ŒO |rF|j                  t        j                  u r*t        j                   dj#                  |«      «      | _        yt%        |«      }dt&        t(           dt&        t(           dt*        fd	„}	 |	||«      ryt-        d
„ |dd D «       d«      Š|j
                  r�|r9|d   j/                  «       s&|j1                  «        |r|d   j/                  «       sŒ&|j3                  d«       |j5                  ˆfd„|D «       «       t        j                   dj#                  |«      «      | _        y|D �
cg c]  }
‰|
z   ‘Œ	 }}
t7        |«      }|d| }||d }|r$|d   j/                  «       r|j3                  d«       |j5                  |«       |rr|r9|d   j/                  «       s&|j1                  «        |r|d   j/                  «       sŒ&|r$|d   j/                  «       r|j3                  d«       |j5                  |«       t        j                   dj#                  |«      «      | _        yc c}
w )uÈ  Annotate a function's docstring with deprecation information.

    Two paths are taken depending on whether ``args_mapping`` is set:

    - **Inline arg path** (``args_mapping`` present): each deprecated argument is
      located in the ``Args:`` / ``Arguments:`` (Google style) or ``:param``
      (Sphinx style) section and a one-line deprecation note is inserted directly
      beneath it.  When ``target`` is ``True`` (self-deprecation) and all deprecated
      args are found, the function returns early and no general notice block is
      added.  When ``target`` is a callable or ``None``, the general block is
      always added after the inline annotations because the function itself is
      deprecated.
    - **General notice path** (no ``args_mapping``, or at least one arg was not
      found in the docstring): a deprecation notice is inserted before the first
      Google/NumPy section header (e.g. ``Args:``, ``Parameters``) when detected,
      otherwise appended at the end of the docstring.  The notice format depends
      on ``docstring_style``: Sphinx ``.. deprecated::`` directive (default
      ``"rst"``) or MkDocs/Markdown admonition (``"mkdocs"``/``"markdown"``).

    Args:
        wrapped_fn: Function whose docstring should be updated. Must have
            ``__deprecated__`` attribute set with deprecation metadata.

    Returns:
        None. Modifies the function's ``__doc__`` attribute in-place.

    Metadata Used:
        The function's ``__deprecated__`` attribute should be a
        :class:`~deprecate._types.DeprecationConfig` instance with:
        - deprecated_in: Version when deprecated
        - remove_in: Version when will be removed
        - target: Replacement callable (optional)
        - args_mapping: Mapping of old â†’ new argument names (optional)

    Example:
        General notice path â€” no ``args_mapping``:

        >>> def new_func(): pass
        >>> def old_func():
        ...     '''Original docstring.'''
        ...     pass
        >>> old_func.__deprecated__ = DeprecationConfig(
        ...     deprecated_in='1.0',
        ...     remove_in='2.0',
        ...     target=new_func,
        ... )
        >>> _update_docstring_with_deprecation(old_func)
        >>> print(old_func.__doc__) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
        Original docstring.
        <BLANKLINE>
        .. deprecated:: 1.0
           Will be removed in 2.0.
           Use :func:`...new_func` instead.

        Inline arg path â€” self-deprecation (``target=True``) with all args found:

        >>> def fn_with_args(x: int, old_arg: str = "") -> str:
        ...     '''Do something.
        ...
        ...     Args:
        ...         x: The main input.
        ...         old_arg: The old argument.
        ...     '''
        ...     return str(x)
        >>> fn_with_args.__deprecated__ = DeprecationConfig(
        ...     deprecated_in='1.0',
        ...     remove_in='2.0',
        ...     target=TargetMode.ARGS_REMAP,
        ...     args_mapping={'old_arg': None},
        ... )
        >>> _update_docstring_with_deprecation(fn_with_args)
        >>> 'Deprecated since v1.0' in fn_with_args.__doc__
        True
        >>> '.. deprecated::' in fn_with_args.__doc__
        False

    Note:
        Does nothing if the function has no docstring or no ``__deprecated__`` attribute.
        To preserve Google/NumPy parsing, the general notice is inserted before the
        first section header (e.g. ``Args:`` or ``Parameters``) when detected.

    Ú__doc__NTFú
Ú	doc_linesÚblock_linesr#   c           	      ó  ‡ ‡‡— ‰syt        ‰ «      t        ‰«      z
  }|dk  ry‰d   j                  «       }t        |dz   «      D ]C  Š‰ ‰   j                  «       |k7  rŒt        ˆˆ ˆfd„t        t        ‰«      «      D «       «      sŒC y y)z®Return True if ``block_lines`` appears as a contiguous block in ``doc_lines``.

        Lines are compared using ``.strip()`` to ignore leading/trailing whitespace.

        Fr   r5   c              3   ór   •K  — | ].  }‰‰|z      j                  «       ‰|   j                  «       k(  –— Œ0 y ­wr   )r-   )r)   Úoffsetr­   r¬   Ústarts     €€€r+   r,   zU_update_docstring_with_deprecation.<locals>._has_deprecation_block.<locals>.<genexpr>8  s;   øè ø€ ò ØU[�	˜% &™.Ñ)×/Ñ/Ó1°[ÀÑ5H×5NÑ5NÓ5PÕPñùs   ƒ47T)r.   r-   rm   r/   )r¬   r­   Ú	max_startÚfirstr±   s   ``  @r+   Ú_has_deprecation_blockzB_update_docstring_with_deprecation.<locals>._has_deprecation_block)  s–   ú€ ñ ØÜ˜	“N¤S¨Ó%5Ñ5ˆ	Ø�qŠ=ØØ˜A‘×$Ñ$Ó&ˆÜ˜9 q™=Ó)ò 	ˆEØ˜Ñ×%Ñ%Ó'¨5Ò0ØÜõ Ü_dÔehÐitÓeuÓ_vôõ ñ ð	ð r2   c              3   óŽ   K  — | ]=  }|j                  «       sŒ|d t        |«      t        |j                  «       «      z
   –— Œ? y ­wr   )r-   r.   rd   )r)   r"   s     r+   r,   z5_update_docstring_with_deprecation.<locals>.<genexpr>B  s4   è ø€ ÒV°DÈÏÉÍˆÐ.”�D“	œC §¡£Ó.Ñ.Ô	/ÑVùs
   ‚A˜-Ar5   r?   r`   c              3   ó(   •K  — | ]	  }‰|z   –— Œ y ­wr   r(   )r)   r�   Úbody_indents     €r+   r,   z5_update_docstring_with_deprecation.<locals>.<genexpr>J  s   øè ø€ ÒB¨"�[ 2Õ%ÑBùs   ƒr   )Úhasattrrª   r   Ú
splitlinesÚ__deprecated__Úargs_mappingÚitemsr^   rS   rT   rˆ   r‘   r™   r   Ú
ARGS_REMAPrœ   ÚcleandocÚjoinr§   ÚlistrL   ÚboolÚnextr-   Úpopr¡   Úextendr;   )r¨   r3   r’   Úall_args_foundrr   rR   r]   ÚfoundÚdeprecation_linesr´   r�   Ú
insert_idxÚprefixÚsuffixr·   s                 @r+   Ú"_update_docstring_with_deprecationrË   ¾  s¤  ø€ ôf �:˜yÔ)°×1CÒ1CØÜ  Ô,ØØ×Ñ×)Ñ)Ó+€EØ×(Ñ(€Hà×ÒØˆØ!)×!6Ñ!6×!<Ñ!<Ó!>ò 	'ÑˆH�gÜ.¨w¸×8NÑ8NÐPX×PbÑPbÓcˆDÜ5°e¸XÀtÓL‰LˆE�5ÙÜ9¸%ÀÈ4ÓP‘��uÚØ!&‘ð	'ñ ˜hŸo™o´×1FÑ1FÑFÜ!(×!1Ñ!1°$·)±)¸EÓ2BÓ!CˆJÔØä3°HÓ=Ðð¬$¬s©)ð Ä$ÄsÁ)ð ÔPTó ñ, ˜eÐ%6Ô7ØÜÙV¸EÀ!À"¸IÔVØ
ó€Kð ×Òá˜E "™IŸO™OÔ-Ø�I‰IŒKñ ˜E "™IŸO™OÕ-à�‰�RÔØ�‰ÓBÐ0AÔBÔBÜ$×-Ñ-¨d¯i©i¸Ó.>Ó?ˆ
Õð 9JÖJ°"˜[¨2Ó-ÐJÐÐJÜ3°EÓ:ˆ
Ø�{˜
Ð#ˆØ�z�{Ð#ˆÙ�f˜R‘j×&Ñ&Ô(Ø�M‰M˜"ÔØ�‰Ð'Ô(ÙÙ ¨¡×!1Ñ!1Ô!3Ø—
‘
”ñ  ¨¡×!1Ñ!1Õ!3á˜& ™)Ÿ/™/Ô+Ø—‘˜bÔ!Ø�M‰M˜&Ô!Ü$×-Ñ-¨d¯i©i¸Ó.?Ó@ˆ
Õùò Ks   Ç<K4)-rª   rœ   r@   ra   rC   Útypingr   r   r   Údeprecate._typesr   r   r   rŸ   rž   rY   rZ   r[   rX   rW   rO   Ú	frozensetr   rL   Ú__annotations__r8   r9   rÁ   r1   rÀ   Úintr;   rG   rQ   r^   Útuplerg   rq   rw   r|   rˆ   r‘   r§   ÚobjectrË   r(   r2   r+   ú<module>rÓ      s\  ðòó2 Û 	Û 	Û 
ß *Ñ *ç QÑ QòÐ ò"Ð ð %]Ð !à=Ð à?Ð à"2Ð à"=Ð à#)°%À8ÐYaÑbÐ Ù-6Ð7NÓ-OÐ ˜I c™NÓ OòÐ òÐ ðH˜Sð H Tó Hð¨$¨s©)ð ¸ó ð˜G OÑ4ó ð0<¨sð <°w¸Ñ7Oó <ð$¨°#©ð Àsð ÐWZð Ð_bó ð4 T¨#¡Yð °5¸¸c¸±?ó ð:(+ 4¨¡9ð (+¸Sð (+ÐRUð (+ÐZ_Ð`cÐehÐ`hÑZió (+ðVØ�‰9ðØ%(ðØ:=ðØKNðØZ]ðàóðB˜4 ™9ð °ð ÀCð ÈCó ð@+ d¨3¡ið +¸3ð +Àcð +ÈeÐTXÐY\ÑT]Ð_cÐTcÑNdó +ð\+ d¨3¡ið +¸3ð +Àcð +ÈeÐTXÐY\ÑT]Ð_cÐTcÑNdó +ð\)Ð*;ð )ÀÀSÁ	ó )ðX]A°6ð ]A¸dô ]Ar2   