ó
 Xc           @   s˙   d  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 d d l m Z d e f d     YZ d   Z d S(   s@  
    sphinxlocal.builders.manpage
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    A replacement for the manpage builder which come bundled with Sphinx.

    :version: 0.1
    :author: Nic Bernstein <nic@onlight.com>

    :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
i˙˙˙˙(   t   path(   t   string_types(   t
   FileOutput(   t   OptionParser(   t   addnodes(   t   SphinxError(   t   Builder(   t   NoUri(   t   inline_all_toctrees(   t   boldt	   darkgreen(   t   ManualPageWriter(   t   ManualPageBuilder(   t   CyrusManualPageWritert   CyrusManualPageBuilderc           B   s2   e  Z d  Z d Z d Z g  Z d   Z d   Z RS(   s4   
    Builds groff output in manual page format.
    t   cyrmant   manc         C   s    |  j  j s |  j d  n  d  S(   NsB   no "man_pages" config value found; no manual pages will be written(   t   configt	   man_pagest   warn(   t   self(    (    s@   /home/ken/cyrus-sasl/docsrc/exts/sphinxlocal/builders/manpage.pyt   init.   s    c         G   sÜ  t  |   } t d |  j j d | f d t  j   } |  j t d  d t x||  j j	 D]n} | \ } } } } }	 t
 | t  rĄ | r | g } qĄ g  } n  d | |	 f }
 |  j t |
  d d t t d t j |  j |
  d	 d
  } |  j j |  } t   } t |  | | | t | g  } |  j d d t |  j j | | |   x* | j t j  D] } | j | j  qgW| | _ | | j _ | | j _ | | j _ |	 | j _ | j | |  q\ W|  j   d  S(   Nt   defaultst
   componentst   read_config_filess   writing... t   nonls   %s.%ss    { t   destination_patht   encodings   utf-8s   } (   R   R   t   envt   settingst   Truet   get_default_valuest   infoR	   R   R   t
   isinstanceR   R
   R   R    t   joint   outdirt   get_doctreet   setR   t   resolve_referencest   traverseR   t   pending_xreft   replace_selft   childrent   titlet   subtitlet   authorst   sectiont   write(   R   t   ignoredt	   docwritert   docsettingsR    t   docnamet   namet   descriptionR-   R.   t
   targetnamet   destinationt   treet   docnamest	   largetreet   pendingnode(    (    s@   /home/ken/cyrus-sasl/docsrc/exts/sphinxlocal/builders/manpage.pyR/   3   s@    					(   t   __name__t
   __module__t   __doc__R4   t   formatt   supported_image_typesR   R/   (    (    (    s@   /home/ken/cyrus-sasl/docsrc/exts/sphinxlocal/builders/manpage.pyR   #   s   	c         C   s   |  j  t  i d d 6S(   Ns   0.1t   version(   t   add_builderR   (   t   app(    (    s@   /home/ken/cyrus-sasl/docsrc/exts/sphinxlocal/builders/manpage.pyt   setup^   s    N(   R>   t   osR    t   sixR   t   docutils.ioR   t   docutils.frontendR   t   sphinxR   t   sphinx.errorsR   t   sphinx.buildersR   t   sphinx.environmentR   t   sphinx.util.nodesR   t   sphinx.util.consoleR	   R
   t   sphinx.writers.manpageR   t   sphinx.builders.manpageR   t   sphinxlocal.writers.manpageR   R   RD   (    (    (    s@   /home/ken/cyrus-sasl/docsrc/exts/sphinxlocal/builders/manpage.pyt   <module>   s   ;