ó
öÀ„\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 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 e rC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( n  e j) e* ƒ Z+ e, d d d g ƒ Z- 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. f d& „  ƒ  YZ5 i e j6 d' 6e j7 d( 6e j8 d) 6e j9 d* 6e j: d+ 6Z; d, e. f d- „  ƒ  YZ< d. e. f d/ „  ƒ  YZ= d0 e. f d1 „  ƒ  YZ> d2 e. f d3 „  ƒ  YZ? d4 e. f d5 „  ƒ  YZ@ d6 e f d7 „  ƒ  YZA d8 e
 e. f d9 „  ƒ  YZB d: e. f d; „  ƒ  YZC d< e. f d= „  ƒ  YZD d S(>   sß   
    sphinx.transforms
    ~~~~~~~~~~~~~~~~~

    Docutils transforms used by Sphinx when reading documents.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iÿÿÿÿN(   t   nodes(   t	   Transformt   Transformer(   t   ContentsFilter(   t   SmartQuotes(   t   normalize_language_tag(   t
   smartchars(   t   addnodes(   t   _t   __(   t   logging(   t   new_document(   t   format_date(   t   apply_source_workaroundt   is_smartquotable(   t	   Generatort   List(   t   Sphinx(   t   Config(   t   StandardDomain(   t   BuildEnvironmentt   versiont   releaset   todayt   SphinxTransformc           B   s;   e  Z d  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z RS(   sŒ   A base class of Transforms.

    Compared with ``docutils.transforms.Transform``, this class improves accessibility to
    Sphinx APIs.
    c         C   s   |  j  j j j S(   s)   Reference to the :class:`.Sphinx` object.(   t   documentt   settingst   envt   app(   t   self(    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR   5   s    c         C   s   |  j  j j S(   s3   Reference to the :class:`.BuildEnvironment` object.(   R   R   R   (   R   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR   ;   s    c         C   s   |  j  j j j S(   s)   Reference to the :class:`.Config` object.(   R   R   R   t   config(   R   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR   A   s    (   t   __name__t
   __module__t   __doc__t   propertyR   R   R   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR   .   s   t   SphinxTransformerc           B   s,   e  Z d  Z d Z d Z d „  Z d „  Z RS(   s#   
    A transformer for Sphinx.
    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyt   set_environmentP   s    c         C   s¿   t  |  j t j ƒ rY t |  j j d ƒ rI |  j rI |  j |  j j _ n  t j |  ƒ nb zN t d ƒ } |  j rƒ |  j | j _ n  | |  j 7} | |  _ t j |  ƒ Wd  |  j d |  _ Xd  S(   NR   t    i    (	   t
   isinstanceR   R    t   hasattrR   R   R   t   apply_transformsR   (   R   R   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR(   T   s    		N(   R   R    R!   t   NoneR   R   R$   R(   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR#   H   s
   	t   DefaultSubstitutionsc           B   s   e  Z d  Z d Z d „  Z RS(   sL   
    Replace some substitutions if they aren't defined in the document.
    iÒ   c         C   s¹   t  t |  j j ƒ } xœ |  j j t j ƒ D]… } | d } | | k r, |  j | } | d k r• | r• t |  j j	 p€ t
 d ƒ d |  j j ƒ} n  | j t j | | ƒ ƒ q, q, Wd  S(   Nt   refnameR   s	   %b %d, %Yt   language(   t   default_substitutionst   setR   t   substitution_defst   traverseR    t   substitution_referenceR   R   t	   today_fmtR   R,   t   replace_selft   Text(   R   t	   to_handlet   refR+   t   text(    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyt   applyo   s    
(   R   R    R!   t   default_priorityR8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR*   h   s   t   MoveModuleTargetsc           B   s   e  Z d  Z d Z d „  Z RS(   sv   
    Move module targets that are the first thing in a section to the section
    title.

    XXX Python specific
    iÒ   c         C   s˜   x‘ |  j  j t j ƒ D]z } | d s, q n  d | k r | j j t j k r | j j | ƒ d k r | d | j d d d +| j j | ƒ q q Wd  S(   Nt   idst   ismodi   i    (	   R   R0   R    t   targett   parentt	   __class__t   sectiont   indext   remove(   R   t   node(    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   ‡   s    
(   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR:   ~   s   t   HandleCodeBlocksc           B   s   e  Z d  Z d Z d „  Z RS(   s5   
    Several code block related transformations.
    iÒ   c         C   sP   xI |  j  j t j ƒ D]2 } t d „  | j Dƒ ƒ r | j | j ƒ q q Wd  S(   Nc         s   s!   |  ] } t  | t j ƒ Vq d  S(   N(   R&   R    t   doctest_block(   t   .0t   child(    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pys	   <genexpr>ž   s    (   R   R0   R    t   block_quotet   allt   childrenR3   (   R   RC   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   š   s    	(   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyRD   ”   s   t   AutoNumberingc           B   s   e  Z d  Z d Z d „  Z RS(   sO   
    Register IDs of tables, figures and literal_blocks to assign numbers.
    iÒ   c         C   sm   |  j  j d ƒ } xT |  j j t j ƒ D]= } | j | ƒ r( | j | ƒ d  k	 r( |  j j	 | ƒ q( q( Wd  S(   Nt   std(
   R   t
   get_domainR   R0   R    t   Elementt   is_enumerable_nodet   get_numfig_titleR)   t   note_implicit_target(   R   t   domainRC   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   ³   s    $(   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyRK   ­   s   t   SortIdsc           B   s   e  Z d  Z d Z d „  Z RS(   s@   
    Sort secion IDs so that the "id[0-9]+" one comes last.
    i  c         C   su   xn |  j  j t j ƒ D]W } t | d ƒ d k r | d d j d ƒ r | d d | d d g | d <q q Wd  S(   NR;   i   i    t   id(   R   R0   R    R@   t   lent
   startswith(   R   RC   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   Â   s    -(   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyRS   ¼   s   t   CitationReferencesc           B   s   e  Z d  Z d Z d „  Z RS(   s|   
    Replace citation references by pending_xref nodes before the default
    docutils transform tries to resolve them.
    ik  c         C   só   x+ |  j  j t j ƒ D] } t | d d <q Wx¾ |  j  j t j ƒ D]§ } | j ƒ  } t j | d d d d d | d t	 d t d	 | d	 ƒ} | j
 pŸ | j j
 | _
 | j p· | j j | _ | t j d
 | d ƒ 7} | j j | | ƒ qD Wd  S(   Ni    t   support_smartquotest	   refdomainRL   t   reftypet   citationt	   reftargett   refwarnR;   t   [t   ](   R   R0   R    R[   t   Falset   citation_referencet   astextR   t   pending_xreft   Truet   sourceR>   t   lineR4   t   replace(   R   t   citnodet   cittextt   refnode(    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   Ð   s    (   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyRW   É   s   s   literal-blocks   doctest-blockt   rawRA   t   imaget   ApplySourceWorkaroundc           B   s   e  Z d  Z d Z d „  Z RS(   s0   
    update source and rawsource attributes
    i
   c         C   sF   x? |  j  j ƒ  D]. } t | t j t j f ƒ r t | ƒ q q Wd  S(   N(   R   R0   R&   R    t   TextElementRl   R   (   R   t   n(    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   ñ   s    (   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyRm   ë   s   t   AutoIndexUpgraderc           B   s   e  Z d  Z d Z d „  Z RS(   sZ   
    Detect old style; 4 column based indices and automatically upgrade to new style.
    iÒ   c         C   s¼   xµ |  j  j t j ƒ D]ž } d | k r t d „  | d Dƒ ƒ r t d ƒ | d } t j | d | ƒxH t | d ƒ D]3 \ } } t	 | ƒ d k rz | d | d | <qz qz Wq q Wd  S(   Nt   entriesc         s   s!   |  ] } t  | ƒ d  k Vq d S(   i   N(   RU   (   RF   t   entry(    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pys	   <genexpr>  s    sG   4 column based index found. It might be a bug of extensions you use: %rt   locationi   (   N(   R   R0   R   RA   t   anyR	   t   loggert   warningt	   enumerateRU   R)   (   R   RC   t   msgt   iRr   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   þ   s    &	(   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyRp   ø   s   t   ExtraTranslatableNodesc           B   s   e  Z d  Z d Z d „  Z RS(   s!   
    make nodes translatable
    i
   c            s   |  j  j } g  t j ƒ  D] \ } } | | k r | ^ q ‰  ˆ  sG d  S‡  f d †  } x$ |  j j | ƒ D] } t | d <qi Wd  S(   Nc            s   t  |  t ˆ  ƒ ƒ S(   N(   R&   t   tuple(   RC   (   t   target_nodes(    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyt   is_translatable_node  s    t   translatable(   R   t   gettext_additional_targetst   TRANSLATABLE_NODESt   itemsR   R0   Rd   (   R   t   targetst   kt   vR}   RC   (    (   R|   s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8     s    1(   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyRz   
  s   t   UnreferencedFootnotesDetectorc           B   s   e  Z d  Z d Z d „  Z RS(   s9   
    detect unreferenced footnotes and emit warnings
    iÈ   c      
      sÜ   xt |  j  j D]f ‰  ˆ  d g  k r& q ˆ  d d |  j  j k r t j t d ƒ ˆ  d d d d d d d ˆ  ƒq q Wx^ |  j  j D]P ‰  t ‡  f d	 †  |  j  j Dƒ ƒ s„ t j t d
 ƒ d d d d d ˆ  ƒq„ q„ Wd  S(   Nt   namesi    s    Footnote [%s] is not referenced.t   typeR6   t   subtypet   footnoteRs   c         3   s#   |  ] } | d  ˆ  d  k Vq d S(   t   autoN(    (   RF   R6   (   RC   (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pys	   <genexpr>1  s    s   Footnote [#] is not referenced.(	   R   t	   footnotest   footnote_refsRu   Rv   R	   t   autofootnotesRt   t   autofootnote_refs(   R   (    (   RC   s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   %  s    "(   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR…     s   t   FilterSystemMessagesc           B   s   e  Z d  Z d Z d „  Z RS(   s&   Filter system messages from a doctree.iç  c         C   su   |  j  j r d p d } xV |  j j t j ƒ D]? } | d | k  r. t j d | j ƒ  ƒ | j	 j
 | ƒ q. q. Wd  S(   Ni   i   t   levels   %s [filtered system message](   R   t   keep_warningsR   R0   R    t   system_messageRu   t   debugRb   R>   RB   (   R   t   filterlevelRC   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   ;  s
    (   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR   7  s   t   SphinxContentsFilterc           B   s    e  Z d  Z d „  Z d „  Z RS(   sx   
    Used with BuildEnvironment.add_toc_from() to discard cross-file links
    within table-of-contents link nodes.
    c         C   s5   | j  ƒ  } |  j j t j | | ƒ ƒ t j ‚ d  S(   N(   Rb   R>   t   appendR    t   literalt   SkipNode(   R   RC   R7   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyt   visit_pending_xrefI  s    c         C   s   t  j ‚ d  S(   N(   R    R˜   (   R   RC   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyt   visit_imageO  s    (   R   R    R!   R™   Rš   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR•   D  s   	t   SphinxSmartQuotesc           B   s>   e  Z d  Z d Z d „  Z d „  Z e d „  ƒ Z d „  Z RS(   sr   
    Customized SmartQuotes to avoid transform for some extra node types.

    refs: sphinx.parsers.RSTParser
    iî  c         C   s!   |  j  ƒ  s d  St j |  ƒ d  S(   N(   t   is_availableR   R8   (   R   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   \  s    c         C   sÐ   |  j  j j d g  ƒ } |  j  j j d g  ƒ } |  j j j t k rI t S|  j  j t k r_ t S|  j j	 j
 | k rx t S|  j  j | k rŽ t S|  j j d } x+ t | ƒ D] } | t j k r« t Sq« Wt Sd  S(   Nt   builderst	   languagest   language_code(   R   t   smartquotes_excludest   getR   R   t   smart_quotesR`   t   smartquotesR   t   buildert   nameR,   R   R   R   t   quotesRd   (   R   R   Rž   R,   t   tag(    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyRœ   c  s    c         C   s
   |  j  j S(   s„   A smartquotes_action setting for SmartQuotes.

        Users can change this setting through :confval:`smartquotes_action`.
        (   R   t   smartquotes_action(   R   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR¨   }  s    c         c   sK   i d t  6d t 6} x0 | D]( } t | ƒ } | | | j ƒ  f Vq Wd  S(   NR—   t   plain(   Rd   R`   R   Rb   (   R   t   txtnodest   texttypet   txtnodet   notsmartquotable(    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyt
   get_tokens†  s
    

(	   R   R    R!   R9   R8   Rœ   R"   R¨   R®   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR›   T  s   			t   DoctreeReadEventc           B   s   e  Z d  Z d Z d „  Z RS(   s!   Emit :event:`doctree-read` event.ip  c         C   s   |  j  j d |  j ƒ d  S(   Ns   doctree-read(   R   t   emitR   (   R   (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   –  s    (   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR¯   ’  s   t   ManpageLinkc           B   s   e  Z d  Z d Z d „  Z RS(   s&   Find manpage section numbers and namesiç  c         C   s¹   x² |  j  j t j ƒ D]› } d j g  | j D]$ } t | t j ƒ r, t	 | ƒ ^ q, ƒ } d } i | d 6| d 6d d 6} t
 j | | ƒ } | r¡ | j ƒ  } n  | j j | ƒ q Wd  S(   Nt    s7   ^(?P<path>(?P<page>.+)[\(\.](?P<section>[1-9]\w*)?\)?)$t   patht   pageR%   R@   (   R   R0   R   t   manpaget   joinRJ   R&   R    R4   t   strt   ret   matcht	   groupdictt
   attributest   update(   R   RC   t   xRµ   t   patternt   infot   r(    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR8   Ÿ  s    '

(   R   R    R!   R9   R8   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyR±   ›  s   (E   R!   R¸   t   docutilsR    t   docutils.transformsR   R   t   docutils.transforms.partsR   t   docutils.transforms.universalR   t   docutils.utilsR   t   docutils.utils.smartquotesR   t   sphinxR   t   sphinx.localeR   R	   t   sphinx.utilR
   t   sphinx.util.docutilsR   t   sphinx.util.i18nR   t   sphinx.util.nodesR   R   R`   t   typingR   R   t   sphinx.applicationR   t   sphinx.configR   t   sphinx.domain.stdR   t   sphinx.environmentR   t	   getLoggerR   Ru   R.   R-   R   R#   R*   R:   RD   RK   RS   RW   t   literal_blockRE   Rk   RA   Rl   R€   Rm   Rp   Rz   R…   R   R•   R›   R¯   R±   (    (    (    s9   lib/python2.7/site-packages/sphinx/transforms/__init__.pyt   <module>
   s^    



>	