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

    Allow todos to be inserted into your documentation.  Inclusion of todos can
    be switched of by a configuration variable.  The todolist directive collects
    all todos of your project and lists them along with a backlink to the
    original location.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iÿÿÿÿ(   t   nodes(   t
   directives(   t   BaseAdmonitionN(   t   NoUri(   t   _t   __(   t   logging(   t   SphinxDirective(   t   set_source_info(   t   tex_escape_map(   t   Anyt   Dictt   Iterablet   List(   t   Sphinx(   t   BuildEnvironmentt	   todo_nodec           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyR   $   s   t   todolistc           B   s   e  Z RS(    (   R   R   (    (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyR   (   s   t   Todoc           B   sE   e  Z d  Z e Z e Z d Z d Z e	 Z
 i e j d 6Z d „  Z RS(   sO   
    A todo entry, displayed (if configured) in the form of an admonition.
    i    t   classc         C   sÚ   |  j  j d ƒ s% d g |  j  d <n  t t |  ƒ j ƒ  \ } t | t j ƒ rV | g S| j d t j	 d t
 d ƒ ƒ ƒ t |  | ƒ d |  j j d ƒ } d |  j j | f | d	 <t j d
 d
 d | g ƒ} | | g S(   NR   s   admonition-todoi    t   textR   s   index-%st   indexs   %s:%st	   targetreft    t   ids(   t   optionst   gett   superR   t   runt
   isinstanceR    t   system_messaget   insertt   titleR   R   t   envt   new_serialnot   docnamet   target(   t   selft   todot   targetidt
   targetnode(    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyR   :   s    "(   R   R   t   __doc__R   t
   node_classt   Truet   has_contentt   required_argumentst   optional_argumentst   Falset   final_argument_whitespaceR   t   class_optiont   option_specR   (    (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyR   ,   s   c         C   sA  |  j  j } t | d ƒ s' g  | _ n  x| j t ƒ D]} |  j d | ƒ y< | j | j j | ƒ d } t	 | t
 j ƒ sˆ t ‚ n  Wn t k
 r¢ d  } n X| j ƒ  } | d =| j j i | j d 6| j pä | j | j ƒ d 6| j d 6| d 6| d	 6ƒ | j j r7 t j t d
 ƒ | d j ƒ  d | ƒq7 q7 Wd  S(   Nt   todo_all_todoss   todo-definedi   R   R%   t   sourcet   linenoR(   R&   s   TODO entry found: %st   location(   t   builderR#   t   hasattrR5   t   traverseR   t   emitt   parentR   R   R    R&   t
   IndexErrort   Nonet   deepcopyt   appendR%   R6   t   doc2patht   linet   configt   todo_emit_warningst   loggert   warningR   t   astext(   t   appt   doctreeR#   t   nodeR*   t   newnode(    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyt   process_todosM   s,    


t   TodoListc           B   s5   e  Z d  Z e Z d Z d Z e Z i  Z d „  Z	 RS(   s%   
    A list of all todo entries.
    i    c         C   s   t  d ƒ g S(   NR   (   R   (   R'   (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyR   x   s    (
   R   R   R+   R1   R.   R/   R0   R2   R4   R   (    (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyRN   m   s   c         C   s±  |  j  d s: x* | j t ƒ D] } | j j | ƒ q Wn  |  j j } t | d ƒ sa g  | _ n  xI| j t	 ƒ D]8} | j
 d ƒ r˜ t j ƒ  g } n g  } |  j  d s¾ | j | ƒ qq n  xÛ| j D]Ð} t j d d g ƒ } |  j  d rÿ t d ƒ } n t d ƒ | d	 | d
 f } | | j d ƒ  }	 | | j d ƒ d }
 | t j |	 |	 ƒ 7} t j d d d t ƒ} t j t d ƒ t d ƒ ƒ } yp |  j j | | d ƒ | d <d | d k râ| d c d | d d 7<n  | d c d | d d d 7<Wn t k
 rn X| j | ƒ | | 7} | t j |
 |
 ƒ 7} | d } d | k rd| d =n  | j | | d |  j ƒ | j | ƒ | j | ƒ qÈ W| j | ƒ qq Wd  S(   Nt   todo_include_todosR5   R   t   classess   todo-sourcet   todo_link_onlys   <<original entry>>s3   (The <<original entry>> is located in %s, line %d.)R6   R7   s   <<s   >>i   R   t   internals   original entryR%   t   refurit   refidR&   t   #i    R(   R   (   RD   R;   R   R=   t   removeR9   R#   R:   R5   R   R   R    R&   t   replace_selft	   paragraphR   t   findt   Textt	   referenceR-   t   emphasist   get_relative_uriR   RA   t   resolve_references(   RI   RJ   t   fromdocnameRK   R#   t   contentt	   todo_infot   parat   descriptiont   desc1t   desc2RL   t	   innernodet
   todo_entry(    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyt   process_todo_nodes   sV    		$



c         C   sF   t  | d ƒ s d  Sg  | j D] } | d | k r | ^ q | _ d  S(   NR5   R%   (   R:   R5   (   RI   R#   R%   R(   (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyt   purge_todosÅ   s    c         C   sE   t  | d ƒ s d  St  | d ƒ s. g  | _ n  | j j | j ƒ d  S(   NR5   (   R:   R5   t   extend(   RI   R#   t   docnamest   other(    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyt
   merge_infoÍ   s
    c         C   s   |  j  | ƒ d  S(   N(   t   visit_admonition(   R'   RK   (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyt   visit_todo_nodeÖ   s    c         C   s   |  j  | ƒ d  S(   N(   t   depart_admonition(   R'   RK   (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyt   depart_todo_nodeÜ   s    c         C   sx   | j  d ƒ j ƒ  j t ƒ } |  j j d ƒ | j d ƒ } | d  k	 r` |  j j d | ƒ n  |  j j d | ƒ d  S(   Ni    u    
\begin{sphinxadmonition}{note}{R   u
   \label{%s}s   %s:}(   t   popRH   t	   translateR	   t   bodyRA   R   R?   (   R'   RK   R"   R&   (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyt   latex_visit_todo_nodeá   s    c         C   s   |  j  j d ƒ d  S(   Ns   \end{sphinxadmonition}
(   Rt   RA   (   R'   RK   (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyt   latex_depart_todo_nodeí   s    c         C   s  |  j  d ƒ |  j d t d ƒ |  j d t d ƒ |  j d t d ƒ |  j t ƒ |  j t d t t f d t t	 f d t t f d t t f d	 t t f ƒ|  j
 d
 t ƒ |  j
 d t ƒ |  j d t ƒ |  j d t ƒ |  j d t ƒ |  j d t ƒ i t j d 6d d 6t d 6S(   Ns   todo-definedRO   t   htmlRQ   RE   t   latexR   t   mant   texinfoR(   R   s   doctree-reads   doctree-resolveds   env-purge-docs   env-merge-infot   versioni   t   env_versiont   parallel_read_safe(   t	   add_eventt   add_config_valueR1   t   add_nodeR   R   Ro   Rq   Ru   Rv   t   add_directiveR   RN   t   connectRM   Rh   Ri   Rm   t   sphinxt   __display_version__R-   (   RI   (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyt   setupò   s*    
(1   R+   t   docutilsR    t   docutils.parsers.rstR   t+   docutils.parsers.rst.directives.admonitionsR   Rƒ   t   sphinx.environmentR   t   sphinx.localeR   R   t   sphinx.utilR   t   sphinx.util.docutilsR   t   sphinx.util.nodesR   t   sphinx.util.texescapeR	   R1   t   typingR
   R   R   R   t   sphinx.applicationR   R   t	   getLoggerR   RF   t
   Admonitiont   ElementR   t   GeneralR   R   RM   RN   Rh   Ri   Rm   Ro   Rq   Ru   Rv   R…   (    (    (    s.   lib/python2.7/site-packages/sphinx/ext/todo.pyt   <module>   s8   "!	 	F							