ó
öÀ„\c           @   s´  d  Z  d d l Z d d l m Z d d l m Z m 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 m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z d d
 l m Z m  Z  e! rAd d l" m# Z# m$ Z$ m% Z% d d l& m' Z' d d l( m) Z) d d l* m+ Z+ n  e j, d ƒ Z- e j, d ƒ Z. d e f d „  ƒ  YZ/ e/ Z0 d e f d „  ƒ  YZ1 d e f d „  ƒ  YZ2 d „  Z3 d S(   sÍ   
    sphinx.directives
    ~~~~~~~~~~~~~~~~~

    Handlers for additional ReST directives.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iÿÿÿÿN(   t   nodes(   t
   directivest   roles(   t   addnodes(   t   DocFieldTransformer(   t   SphinxDirective(   t	   Highlightt	   CodeBlockt   LiteralInclude(   t   TocTreet   Authort   Indext   VersionChanget   SeeAlsot   TabularColumnst   Centeredt   Ackst   HListt   Onlyt   Includet   Class(   t   Figuret   Meta(   t   Anyt   Dictt   List(   t   Sphinx(   t   Config(   t   BuildEnvironments   \\\ns   \\(.)t   ObjectDescriptionc           B   s„   e  Z d  Z e Z d Z d Z e Z i e j	 d 6Z
 g  Z d
 Z d
 Z d
 Z d „  Z d „  Z d „  Z d „  Z d „  Z d	 „  Z RS(   s§   
    Directive to describe a class, function or similar object.  Not used
    directly, but subclassed (in domain-specific directives) to add custom
    behavior.
    i   i    t   noindexc         C   sK   t  j d |  j d ƒ j d ƒ } g  | D] } t j d | j ƒ  ƒ ^ q) S(   sÏ   
        Retrieve the signatures to document from the directive arguments.  By
        default, signatures are given as arguments, one per line.

        Backslash-escaping of newlines is supported.
        t    i    s   
s   \1(   t   nl_escape_ret   subt	   argumentst   splitt   strip_backslash_ret   strip(   t   selft   linest   line(    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyt   get_signaturesC   s    "c         C   s
   t  ‚ d S(   s“  
        Parse the signature *sig* into individual nodes and append them to
        *signode*. If ValueError is raised, parsing is aborted and the whole
        *sig* is put into a single desc_name node.

        The return value should be a value that identifies the object.  It is
        passed to :meth:`add_target_and_index()` unchanged, and otherwise only
        used to skip duplicates.
        N(   t
   ValueError(   R&   t   sigt   signode(    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyt   handle_signatureO   s    c         C   s   d S(   s˜   
        Add cross-reference IDs and entries to self.indexnode, if applicable.

        *name* is whatever :meth:`handle_signature()` returned.
        N(    (   R&   t   nameR+   R,   (    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyt   add_target_and_index\   s    c         C   s   d S(   sŽ   
        Called before parsing content. Used to set information about the current
        directive context on the build environment.
        N(    (   R&   (    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyt   before_contente   s    c         C   s   d S(   s   
        Called after parsing content. Used to reset information about the
        current directive context on the build environment.
        N(    (   R&   (    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyt   after_contentm   s    c   	      C   s4  d |  j  k r3 |  j  j d d ƒ \ |  _ |  _ n d |  j  |  _ |  _ t j d g  ƒ |  _ t j ƒ  } |  j j	 | _	 |  j | d <|  j | d <| d <d |  j
 k | d <} g  |  _ |  j ƒ  } xÎ t | ƒ D]À \ } } t j | d ƒ } t | d	 <| j | ƒ y |  j | | ƒ } Wn4 t k
 rU| j ƒ  | t j | | ƒ 7} qÔ n X| |  j k rÔ |  j j | ƒ | s”|  j | | | ƒ q”qÔ qÔ Wt j ƒ  } | j | ƒ |  j rÔ|  j d
 |  j j d <n  |  j ƒ  |  j j |  j |  j | ƒ t |  ƒ j | ƒ d |  j j d <|  j  ƒ  |  j | g S(   s  
        Main directive entry function, called by docutils upon encountering the
        directive.

        This directive is meant to be quite easily subclassable, so it delegates
        to several additional methods.  What it does:

        * find out if called as a domain-specific directive, set self.domain
        * create a `desc` node to fit all description inside
        * parse standard options, currently `noindex`
        * create an index node if needed as self.indexnode
        * parse all given signatures (as returned by self.get_signatures())
          using self.handle_signature(), which should either return a name
          or raise ValueError
        * add index entries using self.add_target_and_index()
        * parse the content and handle doc fields in it
        t   :i   R   t   entriest   domaint   objtypet   desctypeR   t   firsti    t   objectN(!   R.   R#   R4   R5   R   t   indext	   indexnodet   desct   statet   documentt   optionst   namesR)   t	   enumeratet   desc_signaturet   Falset   appendR-   R*   t   cleart	   desc_nameR/   t   desc_contentt   envt	   temp_dataR0   t   nested_parset   contentt   content_offsetR   t   transform_allt   NoneR1   (	   R&   t   nodeR   t
   signaturest   iR+   R,   R.   t   contentnode(    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyt   runu   sF    $	

	

N(   t   __name__t
   __module__t   __doc__t   Truet   has_contentt   required_argumentst   optional_argumentst   final_argument_whitespaceR   t   flagt   option_spect   doc_field_typesRM   R4   R5   R:   R)   R-   R/   R0   R1   RR   (    (    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyR   .   s"   						t   DefaultRolec           B   s#   e  Z d  Z d Z e Z d „  Z RS(   sK   
    Set the default interpreted text role.  Overridden from docutils.
    i   c         C   sÒ   |  j  s) d t j k r% t j d =n  g  S|  j  d } t j | |  j j |  j |  j j ƒ \ } } | d  k r± |  j j j
 d | t j |  j |  j ƒ d |  j ƒ} | | g S| t j d <| |  j j d <| S(   NR   i    s#   Unknown interpreted text role "%s".R(   t   default_role(   R"   R   t   _rolest   rolet   state_machinet   languaget   linenoR<   t   reporterRM   t   errorR    t   literal_blockt
   block_textRG   RH   (   R&   t	   role_nameRa   t   messagesRf   (    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyRR   Ç   s     	(   RS   RT   RU   RY   RB   RZ   RR   (    (    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyR^   ¿   s   t   DefaultDomainc           B   s5   e  Z d  Z e Z d Z d Z e Z i  Z d „  Z	 RS(   sH   
    Directive to (re-)set the default domain for this source file.
    i   i    c         C   s6   |  j  d j ƒ  } |  j j j | ƒ |  j j d <g  S(   Ni    t   default_domain(   R"   t   lowerRG   t   domainst   getRH   (   R&   t   domain_name(    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyRR   ç   s    (
   RS   RT   RU   RB   RW   RX   RY   RZ   R\   RR   (    (    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyRk   Ü   s   c         C   sY   t  j d t ƒ t  j d t ƒ t  j d t ƒ t  j d t ƒ i d d 6t d 6t d 6S(	   Ns   default-roles   default-domaint   describeR8   t   builtint   versiont   parallel_read_safet   parallel_write_safe(   R   t   register_directiveR^   Rk   R   RV   (   t   app(    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyt   setupô   s    (4   RU   t   ret   docutilsR    t   docutils.parsers.rstR   R   t   sphinxR   t   sphinx.util.docfieldsR   t   sphinx.util.docutilsR   t   sphinx.directives.codeR   R   R   t   sphinx.directives.otherR	   R
   R   R   R   R   R   R   R   R   R   R   t   sphinx.directives.patchesR   R   RB   t   typingR   R   R   t   sphinx.applicationR   t   sphinx.configR   t   sphinx.environmentR   t   compileR    R$   R   t   DescDirectiveR^   Rk   Rx   (    (    (    s9   lib/python2.7/site-packages/sphinx/directives/__init__.pyt   <module>
   s*   RŽ