
    -e                         d Z ddlmZ ddlZ ej        e          ZddlmZ ddl	Z	ddl
mZmZ ddlmZ ddlmZ dd	lmZ d
ZdZddZddZddZddZddZddZd ZddZdS )ag   Simplify linking to Bokeh Github resources.

This module provides roles that can be used to easily reference information from
various sources in the Bokeh project structure:

``:bokeh-commit:`` : link to a specific commit

``:bokeh-issue:`` : link to an issue

``:bokeh-minpy:`` : provide the minimum supported Python version

``:bokeh-pull:`` : link to a pull request

``:bokeh-requires:`` : list the install requires from pyproject.toml

``:bokeh-tree:`` : (versioned) link to a source tree URL

Examples
--------

The following code:

.. code-block:: rest

    The repo history shows that :bokeh-commit:`bf19bcb` was made in
    in :bokeh-pull:`1698`, which closed :bokeh-issue:`1694`. This included
    updating all of the files in the :bokeh-tree:`examples` subdirectory.

yields the output:

The repo history shows that :bokeh-commit:`bf19bcb` was made in
in :bokeh-pull:`1698`,which closed :bokeh-issue:`1694`. This included
updating all of the files in the :bokeh-tree:`examples` subdirectory.

To enable this extension, add `"bokeh.sphinxext.bokeh_roles"` to the
extensions list in your Sphinx configuration module.

    )annotationsN)join)nodesutils)set_classes   )PARALLEL_SAFE)	_REPO_TOP)bokeh_commitbokeh_issuebokeh_minpy
bokeh_pullbokeh_requires
bokeh_treesetupzhttps://github.com/bokeh/bokehc           	     b    |j         j        j        j        }t	          ||ddd||          }|gg fS )Link to a Bokeh Github issue.

    Returns 2 part tuple containing list of nodes to insert into the
    document and a list of system messages.  Both are allowed to be
    empty.

    commitzcommit )documentsettingsenvapp_make_gh_link_node)	namerawtexttextlinenoinlineroptionscontentr   nodes	            ;lib/python3.11/site-packages/bokeh/sphinxext/bokeh_roles.pyr   r   `   s;     

#
'
+Cc7Hi4QXYYD62:    c           
     R   |j         j        j        j        }	 t	          |          }|dk    rt
          nM# t
          $ r@ |j                            d|d|          }	|                    |||	          }
|
g|	gfcY S w xY wt          ||dddt          |          |          }|gg fS )r   r   zAGithub issue number must be a number greater than or equal to 1;  is invalid.lineissue#issuesr   r   r   r   int
ValueErrorreportererrorproblematicr   strr   r   r   r   r   r   r    r   	issue_nummsgprbr!   s               r"   r   r   m   s     

#
'
+CII	>>    $$%}im%}%}%}  EK$  L  L!!'7C88use| c7GS(C	NNT[\\D62:   5 AA?>A?c                    t          j        t          t          d                    }t	          j        |d         d                             d                    }|gg fS )zProvide the minimum supported Python version from pyproject.toml.

    Returns 2 part tuple containing list of nodes to insert into the
    document and a list of system messages.  Both are allowed to be
    empty.

    pyproject.tomlprojectzrequires-pythonz>=)tomlloadr   r
   r   Textlstrip)	r   r   r   r   r   r   r    	pyprojectr!   s	            r"   r   r      sR     	$y*:;;<<I:i	*+<=DDTJJKKD62:r#   c           
     R   |j         j        j        j        }	 t	          |          }|dk    rt
          nM# t
          $ r@ |j                            d|d|          }	|                    |||	          }
|
g|	gfcY S w xY wt          ||dddt          |          |          }|gg fS )r   r   zHGithub pull request number must be a number greater than or equal to 1; r%   r&   pullzpull request r+   r2   s               r"   r   r      s     

#
'
+CII	>>    $$  &Ept  &E  &E  &E  LR$  S  S!!'7C88use| c7FOVSQZ^^]deeD62:r6   c                    t          j        t          t          d                    }t	          j                    }|d         d         D ],}	|t	          j        dt	          j        |	                    z  }-|gg fS )zProvide the list of required package dependencies for Bokeh.

    Returns 2 part tuple containing list of nodes to insert into the
    document and a list of system messages.  Both are allowed to be
    empty.

    r8   r9   dependencies )r:   r;   r   r
   r   bullet_list	list_itemr<   )
r   r   r   r   r   r   r    r>   r!   deps
             r"   r   r      sq     	$y*:;;<<ID#N3 5 5EJsOO44462:r#   c                    |j         j        j        j        }|j        j        d         }d|v rd}t
           d| d| }	|pi }t          |           t          j        ||fd|	i|}
|
gg fS )a  Link to a URL in the Bokeh GitHub tree, pointing to appropriate tags
    for releases, or to main otherwise.

    The link text is simply the URL path supplied, so typical usage might
    look like:

    .. code-block:: none

        All of the examples are located in the :bokeh-tree:`examples`
        subdirectory of your Bokeh checkout.

    Returns 2 part tuple containing list of nodes to insert into the
    document and a list of system messages.  Both are allowed to be
    empty.

    version-mainz/tree//refuri)	r   r   r   r   configBOKEH_GHr   r   	reference)r   r   r   r   r   r   r    r   tagurlr!   s              r"   r   r      s    " 

#
'
+C
'.
#C
czz
)
)S
)
)4
)
)CmG?7D@@@@@D62:r#   c                T   |                      dt                     |                      dt                     |                      dt                     |                      dt                     |                      dt
                     |                      dt                     t          S )z+ Required Sphinx extension setup function. zbokeh-commitzbokeh-issuezbokeh-minpyz
bokeh-pullzbokeh-requiresz
bokeh-tree)add_roler   r   r   r   r   r   r	   )r   s    r"   r   r      s    LL...LL,,,LL,,,LLz***LL!>222LLz***r#   c                    t            d| d| }|pi }t          |           t          j        || t	          j        |           fd|i|}|S )a  Return a link to a Bokeh Github resource.

    Args:
        app (Sphinx app) : current app
        rawtext (str) : text being replaced with link node.
        role (str) : role name
        kind (str) : resource type (issue, pull, etc.)
        api_type (str) : type for api link
        id : (str) : id of the resource to link to
        options (dict) : options dictionary passed to role function

    rK   rL   )rN   r   r   rO   r   unescape)	r   r   rolekindapi_typeidr   rQ   r!   s	            r"   r   r      so     
'
'
'
'2
'
'CmG?7t$AU^B-?-?$A$AYY#YQXYYDKr#   )NN)N)__doc__
__future__r   logging	getLogger__name__logos.pathr   r:   docutilsr   r   docutils.parsers.rst.rolesr   rC   r	   utilr
   __all__rN   r   r   r   r   r   r   r   r    r#   r"   <module>rf      sa  % %T # " " " " " g!!        ! ! ! ! ! ! ! ! 2 2 2 2 2 2             ,
 
 
 
   *
 
 
 
   *      <	 	 	      r#   