B
    @\@                 @   s   d Z ddlmZmZmZ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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 useful type information
for the property attribute, including cross links to the relevant
property types. Additionally, any per-attribute docstrings are
also displayed.

This directive takes the path to an attribute on a Bokeh
model class as an argument::

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

Examples
--------

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

    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

    )absolute_importdivisionprint_functionunicode_literalsN)	unchanged)SphinxError   )BokehDirective)PROP_DETAIL)BokehPropDirectivesetupc               @   s(   e Zd ZdZdZdZdeiZdd ZdS )r   Tr      modulec             C   s  | j d d\}}yt| jd }W n0 tk
rX   td| j d | jd f Y nX t||d }|d krtd| j d || jd f | }yt|j|}W n, t	k
r   td| j d ||f Y nX t
j|| jd |j |jd krdn
t|jd}| |d	S )
Nr   .r   zDCould not generate reference docs for %r: could not import module %rz=Unable to generate reference docs for %s, no model '%s' in %sz@Unable to generate reference docs for %s, no property '%s' in %s )namer   Z	type_infodocz<bokeh-prop>)Z	argumentsrsplit	importlibimport_moduleZoptionsImportErrorr   getattr	__class__AttributeErrorr
   ZrenderpropertyZ_sphinx_type__doc__textwrapdedent_parse)selfZ
model_nameZ	prop_namer   ZmodelZ	model_objZ
descriptorZrst_text r    9lib/python3.7/site-packages/bokeh/sphinxext/bokeh_prop.pyrunX   s&    "zBokehPropDirective.runN)	__name__
__module____qualname__Zhas_contentZrequired_argumentsZoptional_argumentsr   Zoption_specr"   r    r    r    r!   r   N   s
   r   c             C   s   |  ddt d S )Npyz
bokeh-prop)Zadd_directive_to_domainr   )Zappr    r    r!   r   u   s    r   )r   Z
__future__r   r   r   r   ZloggingZ	getLoggerr#   logr   r   Zdocutils.parsers.rst.directivesr   Zsphinx.errorsr   Zbokeh_directiver	   Z	templatesr
   __all__r   r   r    r    r    r!   <module>"   s   
'