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mZ dd
lmZ dZG dd deZdd ZdS )a   Thoroughly document Bokeh options classes.

The ``bokeh-options`` directive will automatically document
all the properties) of a Bokeh Options class.


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

    .. bokeh-options:: Opts
        :module: bokeh.sphinxext.sample

Examples
--------

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

    class Opts(Options):
        ''' This is an Options class '''

        host = String(default="localhost", help="a host to connect to")
        port = Int(default="5890", help="a port to connect to")


the above usage yields the output:

    .. bokeh-options:: Opts
        :module: bokeh.sphinxext.sample

    )absolute_importdivisionprint_functionunicode_literalsN)	unchanged)SphinxError   )Options   )BokehDirective	py_sig_re)OPTIONS_DETAIL)BokehOptionsDirectivesetupc               @   s(   e Zd ZdZdZdZdeiZdd ZdS )r   Tr
   r   modulec             C   s@  d | j}t|}|d kr*td| | \}}}}| jd }yt|}W n$ t	k
rv   td||f Y nX t
||d }	|	d krtd|||f t|	tstd||f |	i }
g }xbt|
 D ]R}t
|
j|}|t||j t||
|jd krdnt|j d qW tj|d	}| |d
S )N z/Unable to parse signature for bokeh-options: %rr   zEUnable to generate reference docs for %s, couldn't import module '%s'z?Unable to generate reference docs for %s, no options '%s' in %szSUnable to generate reference docs for %s, options '%s' is not a subclass of Options )nametypedefaultdoc)optsz<bokeh-options>)joinZ	argumentsr   matchr   groupsoptions	importlibimport_moduleImportErrorgetattr
issubclassr	   sortedZ
properties	__class__appenddictpropertyZ_sphinx_typereprZinstance_default__doc__textwrapdedentrstripr   Zrender_parse)selfZsigmZname_prefixZoptions_nameZarglistZretannZmodule_namer   r   Zoptions_objr   Z	prop_nameZ
descriptorZrst_text r.   <lib/python3.7/site-packages/bokeh/sphinxext/bokeh_options.pyrun[   s4    


*zBokehOptionsDirective.runN)	__name__
__module____qualname__Zhas_contentZrequired_argumentsZoptional_argumentsr   Zoption_specr0   r.   r.   r.   r/   r   Q   s
   r   c             C   s   |  ddt d S )Npyzbokeh-options)Zadd_directive_to_domainr   )Zappr.   r.   r/   r      s    r   )r'   Z
__future__r   r   r   r   ZloggingZ	getLoggerr1   logr   r(   Zdocutils.parsers.rst.directivesr   Zsphinx.errorsr   Zutil.optionsr	   Zbokeh_directiver   r   Z	templatesr   __all__r   r   r.   r.   r.   r/   <module>$   s   
0