ó
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 m Z d d
 l m Z d Z d e f d „  ƒ  YZ d „  Z d S(   u   Thoroughly document Bokeh options classes.

The ``bokeh-options`` directive will automatically document all the properties
of a Bokeh Options class under a heading of "Keyword Args".

This directive takes the name of a Bokeh Options subclass as the argument, and
its module as an option:

.. code-block:: rest

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

Examples
--------

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

.. code-block:: python

    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

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t	   unchanged(   t   SphinxErrori   (   t   Optionsi   (   t   BokehDirectivet	   py_sig_re(   t   OPTIONS_DETAILu   BokehOptionsDirectiveu   setupt   BokehOptionsDirectivec           B` s0   e  Z e Z d  Z d  Z i e d 6Z d „  Z RS(   i   u   modulec         C` sÎ  d j  |  j ƒ } t j | ƒ } | d  k r@ t d | ƒ ‚ n  | j ƒ  \ } } } } |  j d } y t j	 | ƒ } Wn' t
 k
 r¡ t d | | f ƒ ‚ n Xt | | d  ƒ }	 |	 d  k rÜ t d | | | f ƒ ‚ n  t |	 t ƒ st d | | f ƒ ‚ n  |	 i  ƒ }
 g  } x“ t |
 j ƒ  ƒ D] } t |
 j | ƒ } | j t d | d | j j ƒ  d	 t | j |
 ƒ ƒ d
 | j d  k rŒd n t j | j j ƒ  ƒ ƒ ƒ q)Wt j d | ƒ } |  j | d ƒ S(   Nu    u/   Unable to parse signature for bokeh-options: %ru   moduleuE   Unable to generate reference docs for %s, couldn't import module '%s'u?   Unable to generate reference docs for %s, no options '%s' in %suS   Unable to generate reference docs for %s, options '%s' is not a subclass of Optionst   namet   typet   defaultt   docu    t   optsu   <bokeh-options>(   t   joint	   argumentsR   t   matcht   NoneR   t   groupst   optionst	   importlibt   import_modulet   ImportErrort   getattrt
   issubclassR   t   sortedt
   propertiest	   __class__t   appendt   dictt   propertyt   _sphinx_typet   reprt   instance_defaultt   __doc__t   textwrapt   dedentt   rstripR	   t   rendert   _parse(   t   selft   sigt   mt   name_prefixt   options_namet   arglistt   retannt   module_namet   moduleR   t   options_objR   t	   prop_namet
   descriptort   rst_text(    (    s<   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_options.pyt   run\   s4    5(	   t   __name__t
   __module__t   Truet   has_contentt   required_argumentst   optional_argumentsR   t   option_specR7   (    (    (    s<   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_options.pyR
   S   s   
c         C` s   |  j  d d t ƒ d S(   u+    Required Sphinx extension setup function. u   pyu   bokeh-optionsN(   t   add_directive_to_domainR
   (   t   app(    (    s<   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_options.pyt   setup‚   s    (   u   BokehOptionsDirectiveu   setup(   R$   t
   __future__R    R   R   R   t   loggingt	   getLoggerR8   t   logR   R%   t   docutils.parsers.rst.directivesR   t   sphinx.errorsR   t   util.optionsR   t   bokeh_directiveR   R   t	   templatesR	   t   __all__R
   RA   (    (    (    s<   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_options.pyt   <module>&   s   " /