U
    /e                     @  sp   d Z ddlmZ ddlZeeZddlZddlZ	ddl
mZ ddlmZ ddlmZ dZdd	d
Zdd ZdS )aG   Generate an inline visual representations of a pandas Dataframe.

This directive will embed the output of ``df.head().to_html()`` into the HTML
output.

For example:

.. code-block:: rest

    :bokeh-dataframe:`bokeh.sampledata.sprint.sprint`

Will generate the output:

    :bokeh-dataframe:`bokeh.sampledata.sprint.sprint`

    )annotationsN)nodes)SphinxError   )PARALLEL_SAFE)bokeh_dataframesetupc                 C  s   | dd\}}zt|}	W n( tk
rF   td| d| Y nX t|	|d}
|
dkrvtd| d| d| t|
tjst|dt	j
d	|
  d
d}|gg fS )ai  Generate an inline visual representation of a single color palette.

    If the HTML representation of the dataframe can not be created, 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

    .r   z"Unable to generate HTML table for z: couldn't import module Nz: no Dataframe z in module z is not a pandas Dataframe html)format)rsplit	importlibimport_moduleImportErrorr   getattr
isinstancepdZ	DataFramer   rawheadZto_html)nameZrawtexttextlinenoZinlineroptionscontentmodule_nameZdf_namemoduleZdfnode r   C/tmp/pip-unpacked-wheel-f5fndrjf/bokeh/sphinxext/bokeh_dataframe.pyr   B   s    r   c                 C  s   |  dt tS )z+ Required Sphinx extension setup function. zbokeh-dataframe)Zadd_roler   r   )Zappr   r   r   r   _   s    r   )NN)__doc__
__future__r   logging	getLogger__name__logr   Zpandasr   Zdocutilsr   Zsphinx.errorsr   r
   r   __all__r   r   r   r   r   r   <module>   s   

