
    -e-                        d Z ddlmZ ddlZ ej        e          ZddlmZ ddl	m
Z
 ddlmZ ddlmZ d	Zdd
Zd Zi Z ede           dS )a   Generate an inline visual representations of a single color palette.

The ``:bokeh-palette:`` role can be used with by providing any of the
following:

* a palette name from ``bokeh.palettes``, e.g. ``Spectral9``

* a palette function from ``bokeh.palettes`` called with argument, e.g. ``viridis(12)``

* An explicit list of colors: ``['#000000', '#333333', '#666666', '#999999', '#cccccc', '#ffffff']``

The following usage of the the directive:

.. code-block:: rest

    * by name: :bokeh-palette:`Spectral9`

    * by function: :bokeh-palette:`viridis(12)`

    * by list: :bokeh-palette:`['#000000', '#333333', '#666666', '#999999', '#cccccc', '#ffffff']`

Generates the output:

    * by name: :bokeh-palette:`Spectral9`

    * by function: :bokeh-palette:`viridis(12)`

    * by list: :bokeh-palette:`['#000000', '#333333', '#666666', '#999999', '#cccccc', '#ffffff']`

Palette swatches are 20 pixels in height. For palettes short than 20 colors,
the default width for the swatches is 20 pixels. If larger palettes are given,
the width of the HTML spans is progressively reduced, down to a minimum of one
pixel. For instance displaying the full Viridis palette with the expression

.. code-block:: rest

    :bokeh-palette:`viridis(256)`

Will generate the output:

    :bokeh-palette:`viridis(256)`

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

    )annotationsN)nodes)SphinxError   )PARALLEL_SAFE)PALETTE_DETAIL)bokeh_palettesetupc                ^   	 t          d| t                     n'# t          $ r}t          d|d|           d}~ww xY wt                              dd          }t          |t          t          f          rt          d |D                       st          d|d|           t          |          d	k     rd
n@t          |          dk     rdn+t          |          dk     rdnt          |          dk     rdnd}	t          j        ||	          }
t          j        d|
d          }|gg fS )a  Generate an inline visual representations of a single color palette.

    This function evaluates the expression ``f"palette = {text}"``, in the
    context of a ``globals`` namespace that has previously imported all of
    |bokeh.plotting|. The resulting value for ``palette`` is used to
    construct a sequence of HTML ``<span>`` elements for each color.

    If evaluating the palette expression fails or does not produce a list or
    tuple of all strings, then a SphinxError is raised to terminate the build.

    For details on the arguments to this function, consult the Docutils docs:

    http://docutils.sourceforge.net/docs/howto/rst-roles.html#define-the-role-function

    z
palette = z#cannot evaluate palette expression z
, reason: Npalettec              3  @   K   | ]}t          |t                    V  d S )N)
isinstancestr).0xs     =lib/python3.11/site-packages/bokeh/sphinxext/bokeh_palette.py	<genexpr>z bokeh_palette.<locals>.<genexpr>r   s,      2Q2Q!:a3E3E2Q2Q2Q2Q2Q2Q    zpalette expression z! generated invalid or no output:           
   @            r   )r   width html)format)exec_globals	Exceptionr   getr   listtuplealllenr   renderr   raw)namerawtexttextlinenoinlineroptionscontentepwr   nodes               r   r	   r	   ]   s\    W $  (++++ W W WUUURSUUVVVWY%%Aa$'' ^s2Q2Qq2Q2Q2Q/Q/Q ^\\\YZ\\]]]!ffrkkSVVb[[rr3q66B;;aaQTUVQWQWZ]Q]Q]AAcdA !444D9Rf---D62:s    
?:?c                F    |                      dt                     t          S )z+ Required Sphinx extension setup function. zbokeh-palette)add_roler	   r   )apps    r   r
   r
   z   s    LL-000r   zfrom bokeh.palettes import *)NN)__doc__
__future__r   logging	getLogger__name__logdocutilsr   sphinx.errorsr   r   r   	templatesr   __all__r	   r
   r"   r!    r   r   <module>rD      s   - -d # " " " " " g!!       % % % % % %       % % % % % %   :    #X . . . . .r   