ó
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 e j d d ƒ Z d S(   uë   Thoroughly document Bokeh enumerations

The ``bokeh-enum`` directive generates useful documentation for enumerations,
including all the allowable values. If the number of values is large, the full
list is put in a collapsible code block.

This directive takes the name of a Bokeh enum variable as the argument and the
module name as an option. An optional description may be added as content:

.. code-block:: rest

    .. bokeh-enum:: baz
        :module: bokeh.sphinxext.sample

        Specify a baz style

Examples
--------

The directive above will generate the following output:

    .. bokeh-enum:: baz
        :module: bokeh.sphinxext.sample

        Specify a baz style

Although ``bokeh-enum`` may be used explicitly, it is more often convenient in
conjunction with the :ref:`bokeh.sphinxext.bokeh_autodoc` extension. Together,
the same output above will be generated directly from the following code:

.. code-block:: python

    #: Specify a baz style
    baz = enumeration("a", "b", "c")

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t	   unchanged(   t   SphinxErrori   (   t   BokehDirective(   t   ENUM_DETAILu   BokehEnumDirectiveu   setupt   BokehEnumDirectivec           B` s4   e  Z e Z d  Z i e d 6d „  d 6Z d „  Z RS(   i   u   modulec         C` s   t  S(   N(   t   True(   t   x(    (    s9   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_enum.pyt   <lambda>[   t    u   noindexc         C` s  |  j  d } y t j |  j d ƒ } Wn5 t k
 r^ t d |  j  d |  j d f ƒ ‚ n Xt | | d  ƒ } t | ƒ } t	 | ƒ d k r· | d  d | d } t
 j | ƒ } n | } d  } t j d | d	 |  j d d
 |  j j d t ƒ d |  j d | d | ƒ } |  j | d ƒ S(   Ni    u   moduleuD   Could not generate reference docs for %r: could not import module %ri´   i(   u    .... iØÿÿÿt   namet   modulet   noindexu   noindext   contentt	   shortreprt   fullrepru   <bokeh-enum>(   t	   argumentst	   importlibt   import_modulet   optionst   ImportErrorR   t   getattrt   Nonet   reprt   lent   _wrappert   wrapR   t   rendert   gett   FalseR   t   _parse(   t   selfR   R   t   enumR   R   t   rst_text(    (    s9   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_enum.pyt   run^   s(    (			(   t   __name__t
   __module__R	   t   has_contentt   required_argumentsR   t   option_specR%   (    (    (    s9   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_enum.pyR   U   s   c         C` s   |  j  d d t ƒ d S(   u+    Required Sphinx extension setup function. u   pyu
   bokeh-enumN(   t   add_directive_to_domainR   (   t   app(    (    s9   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_enum.pyt   setup{   s    t   subsequent_indentu       (   u   BokehEnumDirectiveu   setup(   t   __doc__t
   __future__R    R   R   R   t   loggingt	   getLoggerR&   t   logR   t   textwrapt   docutils.parsers.rst.directivesR   t   sphinx.errorsR   t   bokeh_directiveR   t	   templatesR   t   __all__R   R-   t   TextWrapperR   (    (    (    s9   lib/python2.7/site-packages/bokeh/sphinxext/bokeh_enum.pyt   <module>*   s   " &	