ó
öÀ„\c           @   s?  d  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 d l m
 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 d l m Z d d l m Z m Z d d l m Z m Z m Z e  r;d d l! m" Z" m# Z# m$ Z$ m% Z% m& Z& d d l' m( Z( n  e j) d ƒ Z* d „  Z+ d e f d „  ƒ  YZ, d e f d „  ƒ  YZ- d e f d „  ƒ  YZ. d e f d „  ƒ  YZ/ d e f d „  ƒ  YZ0 d e f d „  ƒ  YZ1 d  e f d! „  ƒ  YZ2 d" e f d# „  ƒ  YZ3 d$ e f d% „  ƒ  YZ4 d& e e f d' „  ƒ  YZ
 d( „  Z5 d S()   s«   
    sphinx.directives.other
    ~~~~~~~~~~~~~~~~~~~~~~~

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iÿÿÿÿN(   t   nodes(   t
   directives(   t   BaseAdmonition(   t   Class(   t   Include(   t   range(   t   addnodes(   t   VersionChange(   t   _(   t   url_ret   docname_join(   t   SphinxDirective(   t   Matchert	   patfilter(   t   explicit_title_ret   set_source_infot   process_index_entry(   t   Anyt   Dictt	   Generatort   Listt   Tuple(   t   Sphinxs
   .*[*?\[].*c         C   s   |  s
 d St  |  ƒ S(   Niç  (   t   int(   t   argument(    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyt   int_or_nothing%   s    t   TocTreec           B   s’   e  Z d  Z e Z d Z d Z e Z i	 e	 d 6e
 j d 6e
 j d 6e
 j d 6e
 j d 6e
 j d 6e d 6e
 j d	 6e
 j d
 6Z d „  Z d „  Z RS(   sœ   
    Directive to notify Sphinx about the hierarchical structure of the docs,
    and to include a table-of-contents like tree in the current document.
    i    t   maxdeptht   namet   captiont   globt   hiddent   includehiddent   numberedt
   titlesonlyt   reversedc         C   s   t  j ƒ  } |  j j | d <g  | d <g  | d <|  j j d d ƒ | d <|  j j d ƒ | d <d |  j k | d <d |  j k | d <d	 |  j k | d	 <|  j j d
 d ƒ | d
 <d |  j k | d <t |  | ƒ t j d d g ƒ } | j	 | ƒ |  j
 | ƒ |  j | ƒ } | j	 | ƒ | S(   Nt   parentt   entriest   includefilesR   iÿÿÿÿR   R   R   R    R!   i    R"   t   classess   toctree-wrapper(   R   t   toctreet   envt   docnamet   optionst   getR   R    t   compoundt   appendt   add_namet   parse_content(   t   selft   subnodet   wrappernodet   ret(    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyt   runA   s$    

c         C   sé  |  j  j } |  j j j ƒ  } | j |  j j ƒ g  } t |  j  j ƒ } xm|  j	 D]b} | se qS n  t
 j | ƒ } | d rLt j | ƒ rL| rLt j | ƒ rLt |  j j | ƒ } t t | | ƒ ƒ }	 xC |	 D]; }
 | j |
 ƒ | d j d  |
 f ƒ | d j |
 ƒ qÕ W|	 sµ| j |  j j j j d | d |  j ƒƒ qµqS | ry| j d ƒ } | j d ƒ } | }
 n | } }
 d  } x2 | D]* } |
 j | ƒ r|
 t | ƒ  }
 PqqWt |  j j |
 ƒ }
 t j | ƒ sî| d k r| d j | | f ƒ qS |
 |  j j k r€| |  j j |
 d  ƒ ƒ r>d	 } n d
 } | j |  j j j j | |
 d |  j ƒƒ |  j j ƒ  qS | j |
 ƒ | d j | |
 f ƒ | d j |
 ƒ qS Wd |  j k råt t  | d ƒ ƒ | d <n  | S(   NR   R%   R&   s2   toctree glob pattern %r didn't match any documentst   linei   i   R1   s2   toctree contains reference to excluded document %rs5   toctree contains reference to nonexisting document %rR#   (!   t   configt   source_suffixR)   t
   found_docst   copyt   removeR*   R   t   exclude_patternst   contentR   t   matcht   glob_reR	   R
   t   sortedR   R.   t   Nonet   statet   documentt   reportert   warningt   linenot   groupt   endswitht   lent   doc2patht   note_rereadt   discardR+   t   listR#   (   R1   R(   t   suffixest   all_docnamesR4   t   excludedt   entryt   explicitt   patnamet   docnamesR*   t   reft   titlet   suffixt   message(    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR0   Z   s^    	
	(   t   __name__t
   __module__t   __doc__t   Truet   has_contentt   required_argumentst   optional_argumentst   Falset   final_argument_whitespaceR   R   t	   unchangedt   unchanged_requiredt   flagR   t   option_specR5   R0   (    (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR   ,   s"   





	t   Authorc           B   s5   e  Z d  Z e Z d Z d Z e Z i  Z	 d „  Z
 RS(   s•   
    Directive to give the name of the author of the current document
    or section. Shown in the output only if the show_authors option is on.
    i   i    c         C   sñ   |  j  j s g  St j d t ƒ } t j ƒ  } | | 7} |  j d k rV t d ƒ } nH |  j d k rt t d ƒ } n* |  j d k r’ t d ƒ } n t d ƒ } | t j | | ƒ 7} |  j	 j
 |  j d	 |  j ƒ \ } } | j | ƒ | g | S(
   Nt   translatablet   sectionauthors   Section author: t   moduleauthors   Module author: t
   codeauthors   Code author: s   Author: i    (   R7   t   show_authorsR    t	   paragraphR`   t   emphasisR   R   t   TextRB   t   inline_textt	   argumentsRF   t   extend(   R1   t   parat   empht   textt   inodest   messages(    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR5   ¥   s"    
(   RY   RZ   R[   R`   R]   R^   R_   R\   Ra   Re   R5   (    (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyRf   š   s   t   Indexc           B   s5   e  Z d  Z e Z d Z d Z e Z i  Z	 d „  Z
 RS(   s0   
    Directive to add entries to the index.
    i   i    c         C   s¼   |  j  d j d ƒ } d |  j j d ƒ } t j d d d | g ƒ} |  j j j | ƒ t	 j
 ƒ  } g  | d <t | d <t |  | ƒ x( | D]  } | d j t | | ƒ ƒ qŽ W| | g S(	   Ni    s   
s   index-%st   indext    t   idsR%   t   inline(   Rp   t   splitR)   t   new_serialnoR    t   targetRB   RC   t   note_explicit_targetR   Rx   R`   R   Rq   R   (   R1   Rp   t   targetidt
   targetnodet	   indexnodeRQ   (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR5   Å   s    

(   RY   RZ   R[   R`   R]   R^   R_   R\   Ra   Re   R5   (    (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyRw   »   s   t   SeeAlsoc           B   s   e  Z d  Z e j Z RS(   sB   
    An admonition mentioning things to look at as reference.
    (   RY   RZ   R[   R   t   seealsot
   node_class(    (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyRƒ   Ô   s   t   TabularColumnsc           B   s5   e  Z d  Z e Z d Z d Z e Z i  Z	 d „  Z
 RS(   sL   
    Directive to give an explicit tabulary column definition to LaTeX.
    i   i    c         C   s1   t  j ƒ  } |  j d | d <t |  | ƒ | g S(   Ni    t   spec(   R   t   tabular_col_specRp   R   (   R1   t   node(    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR5   å   s    (   RY   RZ   R[   R`   R]   R^   R_   R\   Ra   Re   R5   (    (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR†   Û   s   t   Centeredc           B   s5   e  Z d  Z e Z d Z d Z e Z i  Z	 d „  Z
 RS(   s;   
    Directive to create a centered line of bold text.
    i   i    c         C   sV   |  j  s g  St j ƒ  } |  j j |  j  d |  j ƒ \ } } | j | ƒ | g | S(   Ni    (   Rp   R   t   centeredRB   Ro   RF   Rq   (   R1   R2   Ru   Rv   (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR5   ÷   s    	(   RY   RZ   R[   R`   R]   R^   R_   R\   Ra   Re   R5   (    (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyRŠ   í   s   t   Acksc           B   s5   e  Z d  Z e Z d Z d Z e Z i  Z	 d „  Z
 RS(   s(   
    Directive for a list of names.
    i    c         C   s   t  j ƒ  } |  j j | _ |  j j |  j |  j | ƒ t | j ƒ d k sf t	 | j d t
 j ƒ rˆ |  j j j j d d |  j ƒg S| g S(   Ni   i    s   .. acks content is not a listR6   (   R   t   acksRB   RC   t   nested_parseR=   t   content_offsetRI   t   childrent
   isinstanceR    t   bullet_listRD   RE   RF   (   R1   R‰   (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR5     s    "(   RY   RZ   R[   R\   R]   R^   R_   R`   Ra   Re   R5   (    (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyRŒ     s   t   HListc           B   s<   e  Z d  Z e Z d Z d Z e Z i e	 d 6Z
 d „  Z RS(   s@   
    Directive for a list that gets compacted horizontally.
    i    t   columnsc         C   s[  |  j  j d d ƒ } t j ƒ  } |  j j | _ |  j j |  j |  j | ƒ t	 | j
 ƒ d k s{ t | j
 d t j ƒ r |  j j j j d d |  j ƒg S| j
 d } t t	 | ƒ | ƒ \ } } d } t j ƒ  } xz t | ƒ D]l } | | | k  r| d p| }	 t j ƒ  }
 |
 t j ƒ  7}
 |
 d c | j
 | |	 !7<|	 } | |
 7} qä W| g S(   NR”   i   i   i    s   .. hlist content is not a listR6   (   R+   R,   R    Rl   RB   RC   RŽ   R=   R   RI   R   R‘   R’   RD   RE   RF   t   divmodR   t   hlistR   t   hlistcol(   R1   t   ncolumnsR‰   t   fulllistt   npercolt   nmoreRx   t   newnodet   columnt   endindext   col(    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR5   $  s(    " (   RY   RZ   R[   R\   R]   R^   R_   R`   Ra   R   Re   R5   (    (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR“     s   
t   Onlyc           B   s5   e  Z d  Z e Z d Z d Z e Z i  Z d „  Z	 RS(   sI   
    Directive to only include text if the given tag(s) are enabled.
    i   i    c         C   sÉ  t  j ƒ  } |  j j | _ t |  | ƒ |  j d | d <|  j j j } |  j j j } g  |  j j _ d |  j j _ z.|  j j	 |  j
 |  j | d d ƒ|  j j j } | sÔ | sÔ | d | k sÔ |  j j rÛ | g Sd } |  j j } x | r| d 7} | j } qð W| d 8} | d } t | ƒ } | | k rK| j | ƒ } n  | | d }	 |  j j } x) t |	 ƒ D] }
 | j rr| j } qrqrW| j | ƒ g  SWd  | |  j j _ | |  j j _ Xd  S(   Ni    t   exprt   match_titlesi   i   (   R   t   onlyRB   RC   R   Rp   t   memot   title_stylest   section_levelRŽ   R=   R   R$   RI   Rx   R   R.   (   R1   R‰   t   surrounding_title_stylest   surrounding_section_levelR¥   t   current_depthR$   t   title_stylet   nested_deptht   n_sects_to_raiset   i(    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR5   G  sH    	


	(
   RY   RZ   R[   R\   R]   R^   R_   Ra   Re   R5   (    (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR    =  s   R   c           B   s   e  Z d  Z d „  Z RS(   s‚   
    Like the standard "Include" directive, but interprets absolute paths
    "correctly", i.e. relative to source directory.
    c         C   s‚   |  j  d j d ƒ r9 |  j  d j d ƒ r9 t j |  ƒ S|  j j |  j  d ƒ \ } } | |  j  d <|  j j | ƒ t j |  ƒ S(   Ni    t   <t   >(   Rp   t
   startswithRH   t   BaseIncludeR5   R)   t
   relfn2patht   note_included(   R1   t   rel_filenamet   filename(    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR5   }  s    (   RY   RZ   R[   R5   (    (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyR   w  s   c         C   sù   t  j d t ƒ t  j d t ƒ t  j d t ƒ t  j d t ƒ t  j d t ƒ t  j d t ƒ t  j d t ƒ t  j d t ƒ 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(   NR(   Rh   Ri   Rj   Rx   R„   t   tabularcolumnsR‹   R   R–   R£   t   includet   cssclasss	   rst-classt   builtint   versiont   parallel_read_safet   parallel_write_safe(   R   t   register_directiveR   Rf   Rw   Rƒ   R†   RŠ   RŒ   R“   R    R   R   R\   (   t   app(    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyt   setup‰  s$    (6   R[   t   ret   docutilsR    t   docutils.parsers.rstR   t+   docutils.parsers.rst.directives.admonitionsR   t$   docutils.parsers.rst.directives.miscR   R   R±   t	   six.movesR   t   sphinxR   t   sphinx.domains.changesetR   t   sphinx.localeR   t   sphinx.utilR	   R
   t   sphinx.util.docutilsR   t   sphinx.util.matchingR   R   t   sphinx.util.nodesR   R   R   R`   t   typingR   R   R   R   R   t   sphinx.applicationR   t   compileR?   R   R   Rf   Rw   Rƒ   R†   RŠ   RŒ   R“   R    R¿   (    (    (    s6   lib/python2.7/site-packages/sphinx/directives/other.pyt   <module>   s<   (	n!%: