U
    /e|                     @  s   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	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dlmZ dZG dd deZdd ZdS )a   Thoroughly document Bokeh property attributes.

The ``bokeh-prop`` directive generates documentation for Bokeh model properties,
including cross links to the relevant property types. Additionally, any
per-attribute help strings are also displayed.

This directive takes the name *(class.attr)* of a Bokeh property as its
argument and the module as an option:

.. code-block:: rest

    .. bokeh-prop:: Bar.thing
        :module: bokeh.sphinxext.sample

Examples
--------

For the following definition of ``bokeh.sphinxext.sample.Bar``:

.. code-block:: python

    class Bar(Model):
        ''' This is a Bar model. '''
        thing = List(Int, help="doc for thing")

the above usage yields the output:

    .. bokeh-prop:: Bar.thing
        :module: bokeh.sphinxext.sample


The ``bokeh-prop`` direction may be used explicitly, but it can also be used
in conjunction with the :ref:`bokeh.sphinxext.bokeh_autodoc` extension.

    )annotationsN)	unchanged)SphinxError)	type_link)BokehDeprecationWarning   )PARALLEL_SAFE)BokehDirective)PROP_DETAIL)BokehPropDirectivesetupc                   @  s*   e Zd ZdZdZdZeedZdd ZdS )r   Tr      )moduletypec           
   
   C  s<  | j d }|d\}}| jd }zt|}W n( tk
rX   td| d| Y nX t||d }|d krtd| d| d| t	  tj
d	td
 | }W 5 Q R X z||}W n. tk
r   td| d| d| Y nX tj|| jd t||t|j|jd kr dn
t|jd}	| |	dS )Nr   .r   z&Could not generate reference docs for z: could not import module z&Unable to generate reference docs for z: no model z in module ignore)categoryz: no property z
 on model  )namer   defaultZ	type_infodocz<bokeh-prop>)	argumentsrsplitoptions	importlibimport_moduleImportErrorr   getattrwarningscatch_warningsfilterwarningsr   lookupAttributeErrorr
   renderreprZinstance_defaultr   property__doc__textwrapdedentparse)
selfZ	full_nameZ
model_nameZ	prop_namemodule_namer   modelZ	model_objZ
descriptorZrst_text r-   >/tmp/pip-unpacked-wheel-f5fndrjf/bokeh/sphinxext/bokeh_prop.pyrunc   s2    


 zBokehPropDirective.runN)	__name__
__module____qualname__Zhas_contentZrequired_argumentsZoptional_argumentsr   Zoption_specr/   r-   r-   r-   r.   r   \   s
   
r   c                 C  s   |  ddt tS )z+ Required Sphinx extension setup function. pyz
bokeh-prop)Zadd_directive_to_domainr   r   )Zappr-   r-   r.   r      s    r   )r&   
__future__r   logging	getLoggerr0   logr   r'   r   Zdocutils.parsers.rst.directivesr   Zsphinx.errorsr   Zbokeh.core.property._sphinxr   Zbokeh.util.warningsr   r   r   Zbokeh_directiver	   Z	templatesr
   __all__r   r   r-   r-   r-   r.   <module>   s    '
-