ó
öÀ„\c           @  sH  d  Z  d d l m Z d d l 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 e rd d l m Z m Z m Z m Z m Z m Z d d l  m! Z! n  e j" e# ƒ Z$ d Z% d Z& d Z' d Z( d j) ƒ  Z* i d] d 6d^ d 6d_ d 6d` d 6da d  6db d" 6dc d% 6dd d( 6de d* 6df d, 6dg d. 6dh d0 6di d2 6dj d5 6dk d8 6dl d: 6dm d< 6dn d> 6do d@ 6dp dB 6dq dD 6dr dG 6ds dI 6dt dK 6du dM 6dv dP 6dw dR 6dx dU 6dy dX 6Z+ d dY „ Z- dZ e f d[ „  ƒ  YZ. d\ „  Z/ d S(z   s  
    sphinx.builders.htmlhelp
    ~~~~~~~~~~~~~~~~~~~~~~~~

    Build HTML help support files.
    Parts adapted from Python's Doc/tools/prechm.py.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iÿÿÿÿ(   t   print_functionN(   t   path(   t   nodes(   t   PY3(   t   addnodes(   t   StandaloneHTMLBuilder(   t   IndexEntries(   t   __(   t   logging(   t   make_filename(   t
   htmlescape(   t   Anyt   Dictt   IOt   Listt   Matcht   Tuple(   t   SphinxsÝ  [OPTIONS]
Binary TOC=No
Binary Index=No
Compiled file=%(outname)s.chm
Contents file=%(outname)s.hhc
Default Window=%(outname)s
Default topic=%(master_doc)s
Display compile progress=No
Full text search stop list file=%(outname)s.stp
Full-text search=Yes
Index file=%(outname)s.hhk
Language=%(lcid)#x
Title=%(title)s

[WINDOWS]
%(outname)s="%(title)s","%(outname)s.hhc","%(outname)s.hhk","%(master_doc)s","%(master_doc)s",,,,,0x63520,220,0x10384e,[0,0,1024,768],,,,,,,0

[FILES]
sB  <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
<!-- Sitemap 1.0 -->
</HEAD><BODY>
<OBJECT type="text/site properties">
        <param name="Window Styles" value="0x801227">
        <param name="ImageType" value="Folder">
</OBJECT>
<UL>
s   </UL></BODY></HTML>
sn   <OBJECT type="text/sitemap">
    <param name="Name" value="%s">
    <param name="Local" value="%s">
</OBJECT>
s   
a  and  are  as  at
be  but  by
for
if  in  into  is  it
near  no  not
of  on  or
such
that  the  their  then  there  these  they  this  to
was  will  with
i  t   cp1252t   cai  t   cp1250t   csi  t   dai  t   dei	  t   eni
  t   esi%  t   cp1257t   eti)  t   cp1256t   fai  t   fii  t   fri  t   hri  t   hui  t   iti  t   cp932t   jai  t   cp949t   koi'  t   lti&  t   lvi  t   nli  t   no_NBi  t   pli  t   pt_BRi  t   cp1251t   rui  t   ski$  t   sli  t   svi  t   cp1254t   tri"  t   uk_UAi  t   cp936t   zh_CNi  t   cp950t   zh_TWc         C  s:   | d k r t } n  t |  | ƒ }  |  j d d ƒ }  |  S(   s5  
    chm_htmlescape() is a wrapper of html.escape().
    .hhc/.hhk files don't recognize hex escaping, we need convert
    hex escaping to decimal escaping. for example: ``&#x27;`` -> ``&#39;``
    html.escape() may generates a hex escaping ``&#x27;`` for single
    quote ``'``, this wrapper fixes this.
    s   &#x27;s   &#39;N(   t   NoneR   R
   t   replace(   t   st   quote(    (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyt   chm_htmlescape­   s
    		t   HTMLHelpBuilderc           B  sŒ   e  Z d  Z d Z e d ƒ Z e Z d d d g Z e Z	 e
 Z e Z d Z d Z d „  Z d	 d
 „ Z d „  Z d „  Z d „  Z d „  Z RS(   sŒ   
    Builder that also outputs Windows HTML help project, contents and
    index files.  Adapted from the original Doc/tools/prechm.py.
    t   htmlhelpsD   You can now run HTML Help Workshop with the .htp file in %(outdir)s.s	   image/pngs	   image/gifs
   image/jpegi	  R   c         C  sY   t  j |  ƒ d |  _ d |  _ t j |  j j ƒ } | d  k	 rU | \ |  _	 |  _
 n  d  S(   Ns   .html(   R   t   initt
   out_suffixt   link_suffixt   chm_localest   gett   configt   languageR9   t   lcidt   encoding(   t   selft   locale(    (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyR@   Ö   s    		t   wc         C  s%   t  j t j | | ƒ | |  j d ƒ S(   Nt   xmlcharrefreplace(   t   codecst   openR   t   joinRH   (   RI   t   outdirt   basenamet   mode(    (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyt	   open_fileá   s    c         C  s   |  j  | d <d  S(   NRH   (   RH   (   RI   t   pagenamet   templatenamet   ctxt	   event_arg(    (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyt   update_page_contextç   s    c         C  s   |  j  |  j |  j j ƒ d  S(   N(   t	   build_hhxRP   RE   t   htmlhelp_basename(   RI   (    (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyt   handle_finishë   s    c         C  sb   xH | j  t j ƒ D]4 } | j d ƒ d  k r d | k r d | d <q q Wt j |  | | ƒ d  S(   Nt   internalt   refurit   _blankt   target(   t   traverseR   t	   referenceRD   R9   R   t	   write_doc(   RI   t   docnamet   doctreet   node(    (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyRb   ï   s    !c           s¶  t  j t d ƒ ƒ |  j | | d ƒ . ‰  x$ t t ƒ D] } t | d ˆ  ƒq9 WWd  QXt  j t d ƒ ƒ |  j | | d ƒ R‰  ˆ  j t i | d 6|  j	 j
 d 6|  j	 j d 6|  j	 j d	 6|  j d
 6|  j	 j |  j d 6ƒ | j t j ƒ s| t j 7} n  t | ƒ } x½ t j | ƒ D]¬ \ } } } | j ƒ  | j ƒ  | j t j | d ƒ ƒ } xk t | ƒ D]] }	 | r‡|	 j d ƒ s–|	 j d ƒ rkt t j | |	 ƒ | j t j d ƒ d ˆ  ƒqkqkWq WWd  QXt  j t d ƒ ƒ |  j | | d ƒ ô ‰  ˆ  j t ƒ ˆ  j d t |  j	 j |  j	 j |  j f ƒ x? |  j D]4 \ }
 } } } ˆ  j d t | j d |
 f ƒ qGW|  j j  |  j	 j |  d t! ƒ} d ‡  ‡ f d † ‰ d „  } x! | j" | ƒ D] } ˆ | ƒ qÎWˆ  j t# ƒ Wd  QXt  j t d ƒ ƒ t$ |  j ƒ j% |  ƒ } |  j | | d ƒ z ‰  ˆ  j d ƒ ‡  ‡ f d †  ‰ xD | D]< \ } } x- | D]% \ } \ } } } ˆ | | | ƒ qrWq_Wˆ  j d ƒ Wd  QXd  S(   Ns   dumping stopword list...s   .stpt   files   writing project file...s   .hhpt   outnamet   titlet   versiont   projectRG   t
   master_doct   _statics   .jss   .htmls   \s   writing TOC file...s   .hhcs   <LI> s   %s.htmlt   prune_toctreesi    c           s1  t  |  t j ƒ r@ ˆ  j d ƒ x|  D] } ˆ | | ƒ q& Wní t  |  t j ƒ r‹ |  d } t |  j ƒ  t ƒ } ˆ  j t | | f ƒ n¢ t  |  t j	 ƒ rú | d k r¹ ˆ  j d ƒ n  x |  D] } ˆ | | d ƒ qÀ W| d k r-ˆ  j d ƒ q-n3 t  |  t
 j ƒ r-x |  D] } ˆ | | ƒ qWn  d  S(   Ns   <LI> R]   i    s   <UL>
i   s   </UL>
(   t
   isinstanceR   t	   list_itemt   writeRa   R=   t   astextt   Truet   object_sitemapt   bullet_listR   t   compact_paragraph(   Re   t   ullevelt   subnodet   linkRh   (   t   ft	   write_toc(    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyRz   #  s$    
c         S  s   t  |  t j ƒ o d |  k S(   Nt   toctree(   Rn   R   Ru   (   Re   (    (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyt	   istoctree8  s    s   writing index file...s   .hhks   <UL>
c           s*  ‡  f d †  } t  |  t ƒ }  ˆ  j d ƒ | d |  ƒ t | ƒ d k rZ | d |  ƒ ns t | ƒ d k r„ | d | d d ƒ nI xF t | ƒ D]8 \ } } | d d	 | | d f ƒ | d | d ƒ q‘ Wˆ  j d
 ƒ | r&ˆ  j d ƒ x& | D] } ˆ | d | d g  ƒ qô Wˆ  j d ƒ n  d  S(   Nc           s!   d |  | f } ˆ  j  | ƒ d  S(   Ns!       <param name="%s" value="%s">
(   Rp   (   t   namet   valuet   item(   Ry   (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyt   write_paramG  s    s"   <LI> <OBJECT type="text/sitemap">
t   Keywordi    s   See Alsoi   t   Localt   Names   [%d] %ss
   </OBJECT>
s   <UL> s   </UL>(   R=   Rr   Rp   t   lent	   enumerate(   Rh   t   refst   subitemsR€   t   it   reft   subitem(   Ry   t   write_index(    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyR‹   E  s"    s   </UL>
(&   t   loggert   infoR   RS   t   sortedt	   stopwordst   printRp   t   project_templateRE   t
   html_titleRi   Rj   RG   Rk   RA   t   endswitht   ost   sepR„   t   walkt   sortt
   startswithR   RO   R:   t   contents_headerRs   t   html_short_titlet   domain_indicest	   localnamet   envt   get_and_resolve_doctreet   FalseR`   t   contents_footerR   t   create_index(   RI   RP   Rg   t   wordt   olent   roott   dirst   filest	   staticdirt   fnt	   indexnamet   indexclst   contentt   collapset   tocdocR|   Re   t   indext   keyt   groupRh   R†   R‡   t   key_(    (   Ry   R‹   Rz   s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyRY   ø   sb    


(		(   t   __name__t
   __module__t   __doc__R}   R   t   epilogRŸ   t
   copysourcet   supported_image_typest   add_permalinksRr   t   embeddedt   searchRG   RH   R@   RS   RX   R[   Rb   RY   (    (    (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyR>   ¾   s    					c         C  sI   |  j  d ƒ |  j t ƒ |  j d d „  d  ƒ i d d 6t d 6t d 6S(   Ns   sphinx.builders.htmlRZ   c         S  s   t  |  j ƒ S(   N(   R	   Rj   (   RI   (    (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyt   <lambda>h  s    t   builtinRi   t   parallel_read_safet   parallel_write_safe(   t   setup_extensiont   add_builderR>   t   add_config_valueR9   Rr   (   t   app(    (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyt   setupc  s    (   i  R   (   i  R   (   i  R   (   i  R   (   i	  R   (   i
  R   (   i%  R   (   i)  R   (   i  R   (   i  R   (   i  R   (   i  R   (   i  R   (   i  R#   (   i  R%   (   i'  R   (   i&  R   (   i  R   (   i  R   (   i  R   (   i  R   (   i  R-   (   i  R   (   i$  R   (   i  R   (   i  R2   (   i"  R-   (   i  R5   (   i  R7   (0   R´   t
   __future__R    RM   R”   R   t   docutilsR   t   sixR   t   sphinxR   t   sphinx.builders.htmlR   t(   sphinx.environment.adapters.indexentriesR   t   sphinx.localeR   t   sphinx.utilR   t   sphinx.util.osutilR	   t   sphinx.util.pycompatR
   RŸ   t   typingR   R   R   R   R   R   t   sphinx.applicationR   t	   getLoggerR²   RŒ   R‘   R™   R    Rs   t   splitR   RC   R9   R=   R>   RÃ   (    (    (    s7   lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyt   <module>   sn   .9
¥