ó
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
 m Z d d l m Z d d l m Z d d l m Z d d	 l m Z m Z d Z d e j e j f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d „  Z d „  Z d S(   u
   Display code blocks in collapsible sections when outputting to HTML.

This directive takes a heading to use for the collapsible code block:

.. code-block:: rest

    .. collapsible-code-block:: python
        :heading: Some Code

        from __future__ import print_function

        print("Hello, Bokeh!")

This directive is identical to the standard ``code-block`` directive
that Sphinx supplies, with the addition of one new option:

heading (string):
    A heading to put for the collapsible block. Clicking the heading
    expands or collapses the block.



Examples
--------

The inline example code above produces the following output:

.. collapsible-code-block:: python
    :heading: Some Code

    from __future__ import print_function

    print("Hello, Bokeh!")

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   basename(   t   nodes(   t	   unchanged(   t	   CodeBlocki   (   t   CCB_PROLOGUEt   CCB_EPILOGUEu   collapsible_code_blocku   CollapsibleCodeBlocku"   html_depart_collapsible_code_blocku!   html_visit_collapsible_code_blocku   setupt   collapsible_code_blockc           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sE   lib/python2.7/site-packages/bokeh/sphinxext/collapsible_code_block.pyR
   W   s   t   CollapsibleCodeBlockc           B` s*   e  Z e j Z e j d  e ƒ d „  Z RS(   t   headingc         C` sá   |  j  j j j } |  j j j d } t | ƒ } d | | j d ƒ f } | j d d ƒ } t	 j
 d d d | g ƒ} t ƒ  } | | d <|  j j d	 d
 ƒ | d	 <t j |  ƒ } | j | d ƒ | j j | d ƒ | | g S(   Nu   sourceu	   %s.ccb-%du   ccbu   .u   -u    t   idsu	   target_idu   headingu   Codei    (   t   statet   documentt   settingst   envt   state_machinet   nodeR   t   new_serialnot   replaceR   t   targetR
   t   optionst   getR   t   runt   setup_childt   childrent   append(   t   selfR   t
   rst_sourcet   rst_filenamet	   target_idt   target_nodeR   t   cb(    (    sE   lib/python2.7/site-packages/bokeh/sphinxext/collapsible_code_block.pyR   `   s    	
(   R   R   R   t   option_spect   updateR   R   (    (    (    sE   lib/python2.7/site-packages/bokeh/sphinxext/collapsible_code_block.pyR   [   s   	c         C` s.   |  j  j t j d | d d | d ƒ ƒ d  S(   Nt   idu	   target_idR   u   heading(   t   bodyR   R   t   render(   R   R   (    (    sE   lib/python2.7/site-packages/bokeh/sphinxext/collapsible_code_block.pyt!   html_visit_collapsible_code_blockt   s    		
c         C` s   |  j  j t j ƒ  ƒ d  S(   N(   R(   R   R	   R)   (   R   R   (    (    sE   lib/python2.7/site-packages/bokeh/sphinxext/collapsible_code_block.pyt"   html_depart_collapsible_code_block|   s    c         C` s-   |  j  t d t t f ƒ|  j d t ƒ d S(   u+    Required Sphinx extension setup function. t   htmlu   collapsible-code-blockN(   t   add_nodeR
   R*   R+   t   add_directiveR   (   t   app(    (    sE   lib/python2.7/site-packages/bokeh/sphinxext/collapsible_code_block.pyt   setup   s
    
(   u   collapsible_code_blocku   CollapsibleCodeBlocku"   html_depart_collapsible_code_blocku!   html_visit_collapsible_code_blocku   setup(   t   __doc__t
   __future__R    R   R   R   t   loggingt	   getLoggerR   t   logt   os.pathR   t   docutilsR   t   docutils.parsers.rst.directivesR   t   sphinx.directives.codeR   t	   templatesR   R	   t   __all__t   Generalt   ElementR
   R   R*   R+   R0   (    (    (    sE   lib/python2.7/site-packages/bokeh/sphinxext/collapsible_code_block.pyt   <module>)   s$   "    		