ó
mÜJ]c           @` sÄ   d  Z  d d l m Z m Z m Z m Z d d l Z e j 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 d e f d „  ƒ  YZ d „  Z d S(   u    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.

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t	   unchanged(   t   SphinxErrori   (   t   BokehDirective(   t   PROP_DETAILu   BokehPropDirectiveu   setupt   BokehPropDirectivec           B` s0   e  Z e Z d  Z d  Z i e d 6Z d „  Z RS(   i   u   modulec      
   C` sn  |  j  d j d ƒ \ } } y t j |  j d ƒ } Wn5 t k
 rm t d |  j  d |  j d f ƒ ‚ n Xt | | d  ƒ } | d  k r¶ t d |  j  d | |  j d f ƒ ‚ n  | ƒ  } y t | j	 | ƒ } Wn1 t
 k
 rt d |  j  d | | f ƒ ‚ n Xt j d | d |  j d d	 | j j ƒ  d
 | j d  k rId n t j | j ƒ ƒ } |  j | d ƒ S(   Ni    u   .u   moduleuD   Could not generate reference docs for %r: could not import module %ru=   Unable to generate reference docs for %s, no model '%s' in %su@   Unable to generate reference docs for %s, no property '%s' in %st   namet   modulet	   type_infot   docu    u   <bokeh-prop>(   t	   argumentst   rsplitt	   importlibt   import_modulet   optionst   ImportErrorR   t   getattrt   Nonet	   __class__t   AttributeErrorR   t   rendert   propertyt   _sphinx_typet   __doc__t   textwrapt   dedentt   _parse(   t   selft
   model_namet	   prop_nameR
   t   modelt	   model_objt
   descriptort   rst_text(    (    s9   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_prop.pyt   run^   s&    (*	$	*(	   t   __name__t
   __module__t   Truet   has_contentt   required_argumentst   optional_argumentsR   t   option_specR%   (    (    (    s9   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_prop.pyR   U   s   
c         C` s   |  j  d d t ƒ d S(   u+    Required Sphinx extension setup function. u   pyu
   bokeh-propN(   t   add_directive_to_domainR   (   t   app(    (    s9   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_prop.pyt   setup{   s    (   u   BokehPropDirectiveu   setup(   R   t
   __future__R    R   R   R   t   loggingt	   getLoggerR&   t   logR   R   t   docutils.parsers.rst.directivesR   t   sphinx.errorsR   t   bokeh_directiveR   t	   templatesR   t   __all__R   R/   (    (    (    s9   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_prop.pyt   <module>)   s   " &