U
    /e                     @  s   d Z ddlmZ ddlZeeZddlmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ d
ZG dd dejejZG dd de
Zdd ZdS )a   Generate visual representations of palettes in Bokeh palette groups.

The ``bokeh.palettes`` modules expose attributes such as ``mpl``, ``brewer``,
and ``d3`` that provide groups of palettes. The ``bokeh-palette-group``
directive accepts the name of one of these groups, and generates a visual
matrix of colors for every palette in the group.

As an example, the following usage of the the directive:

.. code-block:: rest

    .. bokeh-palette-group:: mpl

Generates the output:

    .. bokeh-palette-group:: mpl

.. note::
   This extension assumes both Bootstrap and JQuery are present (which is the
   case for the Bokeh documentation theme). If using this theme outside the
   Bokeh documentation, be sure to include those resources by hand.

    )annotationsN)nodes)	Directive)SphinxError   )PARALLEL_SAFE)PALETTE_GROUP_DETAIL)bokeh_palette_groupBokehPaletteGroupDirectivesetupc                   @  s"   e Zd Zedd ZejdfZdS )r	   c           	      C  s   | j d tt|d d }t|ts<|d }td| t|}|D ]:}|| }dd t|D }tj	|||d}| j | qH| j d t
jd S )Nz.<div class="container-fluid"><div class="row">groupzinvalid palette group name c                 S  s   g | ]}|d k r|qS )    ).0xr   r   G/tmp/pip-unpacked-wheel-f5fndrjf/bokeh/sphinxext/bokeh_palette_group.py
<listcomp>X   s      z2bokeh_palette_group.visit_html.<locals>.<listcomp>)namenumberspalettesz</div></div>)bodyappendgetattrbp
isinstancedictr   sortedr   renderr   ZSkipNode)	Zvisitornoder   Z
group_namenamesr   r   r   htmlr   r   r   
visit_htmlM   s    
zbokeh_palette_group.visit_htmlN)__name__
__module____qualname__staticmethodr!   __func__r    r   r   r   r   r	   K   s   
r	   c                   @  s   e Zd ZdZdZdd ZdS )r
   Fr   c                 C  s   t  }| jd |d< |gS )Nr   r   )r	   	arguments)selfr   r   r   r   runf   s    zBokehPaletteGroupDirective.runN)r"   r#   r$   Zhas_contentZrequired_argumentsr)   r   r   r   r   r
   a   s   r
   c                 C  s    | j ttjd | dt tS )z+ Required Sphinx extension setup function. )r    zbokeh-palette-group)add_noder	   r    Zadd_directiver
   r   )Zappr   r   r   r   l   s    r   )__doc__
__future__r   logging	getLoggerr"   logZdocutilsr   Zdocutils.parsers.rstr   Zsphinx.errorsr   Zbokeh.palettesr   r    r   Z	templatesr   __all__ZGeneralElementr	   r
   r   r   r   r   r   <module>   s   
