ó
öÀ\c           @   sŒ   d  Z  d d l m Z d d l Z d d l m Z d d l m Z e rw d d l	 m
 Z
 m Z m Z d d l m Z n  d e j f d	     YZ d
 e f d     YZ d   Z d   Z d S(   s  
    sphinx.ext.ifconfig
    ~~~~~~~~~~~~~~~~~~~

    Provides the ``ifconfig`` directive that allows to write documentation
    that is included depending on configuration variables.

    Usage::

        .. ifconfig:: releaselevel in ('alpha', 'beta', 'rc')

           This stuff is only included in the built docs for unstable versions.

    The argument for ``ifconfig`` is a plain Python expression, evaluated in the
    namespace of the project configuration (that is, all variables from
    ``conf.py`` are available.)

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iÿÿÿÿ(   t   nodesN(   t   SphinxDirective(   t   set_source_info(   t   Anyt   Dictt   List(   t   Sphinxt   ifconfigc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s2   lib/python2.7/site-packages/sphinx/ext/ifconfig.pyR   #   s   t   IfConfigc           B   s/   e  Z e Z d  Z d Z e Z i  Z d   Z RS(   i   i    c         C   s_   t    } |  j j | _ t |  |  |  j d | d <|  j j |  j |  j | d d | g S(   Ni    t   exprt   match_titlesi   (   R   t   statet   documentR   t	   argumentst   nested_parset   contentt   content_offset(   t   selft   node(    (    s2   lib/python2.7/site-packages/sphinx/ext/ifconfig.pyt   run/   s    	(	   R   R	   t   Truet   has_contentt   required_argumentst   optional_argumentst   final_argument_whitespacet   option_specR   (    (    (    s2   lib/python2.7/site-packages/sphinx/ext/ifconfig.pyR
   '   s   c   
      C   s  t  d   |  j D  } | j |  j j j    |  j j | d <xŸ | j t  D]­ } y t	 | d |  } Wng t
 k
 rØ } d d l m } d j | | j |   } | j j d | d | }	 | j |	  qR X| sï | j g   qR | j | j  qR Wd  S(	   Nc         s   s!   |  ] } | j  | j f Vq d  S(   N(   t   namet   value(   t   .0t   confval(    (    s2   lib/python2.7/site-packages/sphinx/ext/ifconfig.pys	   <genexpr><   s    t   builderR   iÿÿÿÿ(   t   format_exception_onlyt    s-   Exception occured in ifconfig expression: 
%st	   base_node(   t   dictt   configt   updatet   __dict__t   copyR    R   t   traverseR   t   evalt	   Exceptiont	   tracebackR!   t   joint	   __class__t   reportert   errort   replace_selft   children(
   t   appt   doctreet   docnamet   nsR   t   rest   errR!   t   msgt   newnode(    (    s2   lib/python2.7/site-packages/sphinx/ext/ifconfig.pyt   process_ifconfig_nodes:   s    c         C   sB   |  j  t  |  j d t  |  j d t  i t j d 6t d 6S(   NR   s   doctree-resolvedt   versiont   parallel_read_safe(	   t   add_nodeR   t   add_directiveR
   t   connectR;   t   sphinxt   __display_version__R   (   R3   (    (    s2   lib/python2.7/site-packages/sphinx/ext/ifconfig.pyt   setupQ   s    (   t   __doc__t   docutilsR    RA   t   sphinx.util.docutilsR   t   sphinx.util.nodesR   t   Falset   typingR   R   R   t   sphinx.applicationR   t   ElementR   R
   R;   RC   (    (    (    s2   lib/python2.7/site-packages/sphinx/ext/ifconfig.pyt   <module>   s   	