
    h                         S r SSKJrJr  SSKJr  SSKrSSKJr   " S S\R                  \R                  5      r
S rS	 rSS
 jrSS jrS rg)a-  
Custom roles for the Matplotlib documentation.

.. warning::

    These roles are considered semi-public. They are only intended to be used in
    the Matplotlib documentation.

However, it can happen that downstream packages end up pulling these roles into
their documentation, which will result in documentation build errors. The following
describes the exact mechanism and how to fix the errors.

There are two ways, Matplotlib docstrings can end up in downstream documentation.
You have to subclass a Matplotlib class and either use the ``:inherited-members:``
option in your autodoc configuration, or you have to override a method without
specifying a new docstring; the new method will inherit the original docstring and
still render in your autodoc. If the docstring contains one of the custom sphinx
roles, you'll see one of the following error messages:

.. code-block:: none

    Unknown interpreted text role "mpltype".
    Unknown interpreted text role "rc".

To fix this, you can add this module as extension to your sphinx :file:`conf.py`::

    extensions = [
        'matplotlib.sphinxext.roles',
        # Other extensions.
    ]

.. warning::

    Direct use of these roles in other packages is not officially supported. We
    reserve the right to modify or remove these roles without prior notification.
    )urlsplit
urlunsplit)nodesN)rcParamsDefaultc                       \ rS rSrSrS rSrg)_QueryReference.   z
Wraps a reference or pending reference to add a query string.

The query string is generated from the attributes added to this node.

Also equivalent to a `~docutils.nodes.literal` node.
c                 N    SR                  S U R                  5        5       5      $ )z+Generate query string from node attributes.&c              3   4   #    U  H  u  pU S U 3v   M     g7f)=N ).0namevalues      L/var/www/html/env/lib/python3.13/site-packages/matplotlib/sphinxext/roles.py	<genexpr>2_QueryReference.to_query_string.<locals>.<genexpr>9   s     L^kd4&%)^s   )joinattlist)selfs    r   to_query_string_QueryReference.to_query_string7   s    xxLT\\^LLL    r   N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes__r   r   r   r   r   .   s    Mr   r   c                     UR                  5       nUR                  [        R                  5       H,  n[	        US   5      R                  US9n[        U5      US'   M.     U R                  U5        g)zw
Resolve *node* into query strings on its ``reference`` children.

Then act as if this is a `~docutils.nodes.literal`.
refuri)queryN)r   findallr   	referencer   _replacer   visit_literal)r   noder#   refnodeuris        r   _visit_query_reference_noder+   <   sd       "E<<0wx()222?&sO 1 	tr   c                 &    U R                  U5        g)z0
Act as if this is a `~docutils.nodes.literal`.
N)depart_literal)r   r(   s     r   _depart_query_reference_noder.   J   s     	r   c           
      P   SU S3nSnUR                  Xw SU S3SU5      u  p[        XS9nX-  nU/nU[        ;   ag  US:w  aa  UR                  [        R
                  " S	5      [        R                  " S
[        [        U   5      5      [        R
                  " S5      /5        X4$ )z
Sphinx role ``:rc:`` to highlight and link ``rcParams`` entries.

Usage: Give the desired ``rcParams`` key as parameter.

:code:`:rc:`figure.dpi`` will render as: :rc:`figure.dpi`
z
rcParams["z"]zmatplotlibrc-sample <>ref)	highlightbackendz (default:  ))interpretedr   r   extendr   Textliteralrepr)r   rawtexttextlinenoinlineroptionscontenttitletarget	ref_nodesmessagesqr	node_lists                r   _rcparam_rolerH   Q   s     b!E"F!--ewb5J.3V=I 
	1BOBI 49#4JJ}%MM"d?4#89:JJsO 	 r   c                 v    UnSS0nXx;  a  [        SU< 35      eUR                  Xw SX    S3SU5      u  pX4$ )aa  
Sphinx role ``:mpltype:`` for custom matplotlib types.

In Matplotlib, there are a number of type-like concepts that do not have a
direct type representation; example: color. This role allows to properly
highlight them in the docs and link to their definition.

Currently supported values:

- :code:`:mpltype:`color`` will render as: :mpltype:`color`

color
colors_defzUnknown mpltype: r0   r1   r2   )
ValueErrorr7   )r   r<   r=   r>   r?   r@   rA   mpltypetype_to_link_targetrG   rE   s              r   _mpltype_rolerO   p   sg     G ),WK899!--9B2;<A>vOIr   c                     U R                  S[        5        U R                  S[        5        U R                  [        [
        [        4[
        [        4[
        [        4S9  [        R                  SSS.$ )NrcrM   )htmllatexr=   T)versionparallel_read_safeparallel_write_safe)	add_rolerH   rO   add_noder   r+   r.   
matplotlib__version__)apps    r   setupr\      si    LL}%LLM*LL)+GH*,HI)+GH	   "--"&tE Er   )NN)r   urllib.parser   r   docutilsr   rY   r   InlineTextElementr   r+   r.   rH   rO   r\   r   r   r   <module>ra      sM   #J .   &MellE$5$5 M>2
Er   