ó
öÀ„\c           @   sZ  d  Z  d d l m Z d d l m Z d d l m Z d d l m Z m	 Z	 m
 Z
 d d l m Z d d l m Z d d l m Z e r· d d	 l m Z m Z m Z d d
 l m Z n  d e j f d „  ƒ  YZ d e	 j e f d „  ƒ  YZ d e
 j f d „  ƒ  YZ d e
 j f d „  ƒ  YZ d e
 j f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d S(   s¯   
    sphinx.directives.patches
    ~~~~~~~~~~~~~~~~~~~~~~~~~

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iÿÿÿÿ(   t   nodes(   t   make_id(   t
   directives(   t   imagest   htmlt   tables(   t   addnodes(   t   SphinxDirective(   t   set_source_info(   t   Dictt   Listt   Tuple(   t   Sphinxt   Figurec           B   s   e  Z d  Z d „  Z RS(   si   The figure directive which applies `:name:` option to the figure node
    instead of the image node.
    c         C   sº   |  j  j d d  ƒ } t j j |  ƒ } t | ƒ d k sO t | d t j	 ƒ rS | S| \ } | r | |  j  d <|  j
 | ƒ n  | j d  k r³ t | ƒ d k r³ | d j | _ n  | g S(   Nt   namei   i    i   (   t   optionst   popt   NoneR   R   t   runt   lent
   isinstanceR    t   system_messaget   add_namet   line(   t   selfR   t   resultt   figure_node(    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR      s    (	!(   t   __name__t
   __module__t   __doc__R   (    (    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR      s   t   Metac           B   s   e  Z d  „  Z RS(   c         C   s­   t  j j |  ƒ } x” | D]Œ } t | t j ƒ r t | j d d t  j j ƒ r | j d d } |  j	 j
 |  j	 j ƒ | _ |  j | _ | d | _ t j | _ q q W| S(   NR    i    t   content(   R   R   R   R   R    t   pendingt   detailst   MetaBodyt   metat   envt   doc2patht   docnamet   sourcet   linenoR   t
   rawcontentR   t	   __class__(   R   R   t   nodeR#   (    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR   2   s     (   R   R   R   (    (    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR   1   s   t   RSTTablec           B   s   e  Z d  Z d „  Z RS(   sx   The table directive which sets source and line information to its caption.

    Only for docutils-0.13 or older version.c         C   s8   t  j j |  ƒ \ } } | r. t |  | ƒ n  | | f S(   N(   R   R,   t
   make_titleR   (   R   t   titlet   message(    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR-   H   s    (   R   R   R   R-   (    (    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR,   C   s   t   CSVTablec           B   s   e  Z d  Z d „  Z RS(   s|   The csv-table directive which sets source and line information to its caption.

    Only for docutils-0.13 or older version.c         C   s8   t  j j |  ƒ \ } } | r. t |  | ƒ n  | | f S(   N(   R   R0   R-   R   (   R   R.   R/   (    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR-   V   s    (   R   R   R   R-   (    (    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR0   Q   s   t	   ListTablec           B   s   e  Z d  Z d „  Z RS(   s}   The list-table directive which sets source and line information to its caption.

    Only for docutils-0.13 or older version.c         C   s8   t  j j |  ƒ \ } } | r. t |  | ƒ n  | | f S(   N(   R   R1   R-   R   (   R   R.   R/   (    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR-   d   s    (   R   R   R   R-   (    (    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR1   _   s   t   MathDirectivec           B   sV   e  Z e Z d  Z d Z e Z i e j d 6e j d 6e j	 d 6Z
 d „  Z d „  Z RS(   i    i   t   labelR   t   nowrapc         C   s×   d j  |  j ƒ } |  j r@ |  j d r@ |  j d d | } n  |  j j d |  j j d ƒ ƒ } t j | | d |  j j j	 j
 j d d  d | d d |  j k ƒ} |  j | ƒ t |  | ƒ | g } |  j | ƒ | S(	   Ns   
i    s   

R3   R   R&   t   numberR4   (   t   joinR   t	   argumentsR   t   getR    t
   math_blockt   statet   documentt   settingsR$   R&   R   R   R   t
   add_target(   R   t   latexR3   R+   t   ret(    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR   y   s    !	c   	      C   s?  | d } | d d k s1 |  j  j r` | d r` |  j j d ƒ } d |  j j | f | d <n  | d sn d  S|  j j d ƒ } y‚ | j |  j |  j j | d ƒ } | | d <t d | d ƒ } t j	 d d d	 | g ƒ} |  j
 j j | ƒ | j d | ƒ Wn6 t k
 r:} |  j j j | j d d
 |  j ƒn Xd  S(   Ni    R3   t    s   sphinx.ext.math#equationss   %s:%dt   mathR5   s   equation-%st   idsR   (   t   configt   math_number_allR$   t   new_serialnoR&   t
   get_domaint   add_equationR   R    t   targetR:   R;   t   note_explicit_targett   insertt   UserWarningt   state_machinet   reportert   warningt   argsR(   (	   R   R?   R+   t   seqt   domaint   eqnot   node_idRH   t   exc(    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR=   ‹   s     
'
"
(   R   R   t   Truet   has_contentt   required_argumentst   optional_argumentst   final_argument_whitespaceR   t	   unchangedt   flagt   option_specR   R=   (    (    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyR2   m   s   

	c         C   sy   t  j d t ƒ t  j d t ƒ t  j d t ƒ t  j d t ƒ t  j d t ƒ t  j d t ƒ i d d 6t d	 6t d
 6S(   Nt   figureR#   t   tables	   csv-tables
   list-tableRA   t   builtint   versiont   parallel_read_safet   parallel_write_safe(	   R   t   register_directiveR   R   R,   R0   R1   R2   RU   (   t   app(    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyt   setup§   s    N(   R   t   docutilsR    t   docutils.nodesR   t   docutils.parsers.rstR   t   docutils.parsers.rst.directivesR   R   R   t   sphinxR   t   sphinx.util.docutilsR   t   sphinx.util.nodesR   t   Falset   typingR	   R
   R   t   sphinx.applicationR   R   R   R,   R0   R1   R2   Re   (    (    (    s8   lib/python2.7/site-packages/sphinx/directives/patches.pyt   <module>   s"   :