ó
öÀ„\c           @   s+  d  Z  d d l 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 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 n  d e f d „  ƒ  YZ d e f d „  ƒ  YZ  d e f d „  ƒ  YZ! d S(   s'  
    sphinx.domains
    ~~~~~~~~~~~~~~

    Support for domains, which are groupings of description directives
    and roles describing e.g. constructs of one programming language.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iÿÿÿÿN(   t	   iteritems(   t   SphinxError(   t   _(   t   Anyt   Callablet   Dictt   Iterablet   Listt   Tuplet   Typet   Union(   t   nodes(   t   Inliner(   t   Builder(   t   BuildEnvironment(   t   XRefRole(   t   RoleFunctiont   ObjTypec           B   s$   e  Z d  Z i d d 6Z d „  Z RS(   s3  
    An ObjType is the description for a type of object that a domain can
    document.  In the object_types attribute of Domain subclasses, object type
    names are mapped to instances of this class.

    Constructor arguments:

    - *lname*: localized name of the type (do not include domain name)
    - *roles*: all the roles that can refer to an object of this type
    - *attrs*: object attributes -- currently only "searchprio" is known,
      which defines the object's priority in the full-text search index,
      see :meth:`Domain.get_objects()`.
    i   t
   searchprioc         O   s8   | |  _  | |  _ |  j j ƒ  |  _ |  j j | ƒ d  S(   N(   t   lnamet   rolest   known_attrst   copyt   attrst   update(   t   selfR   R   R   (    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   __init__2   s    		(   t   __name__t
   __module__t   __doc__R   R   (    (    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyR      s   
t   Indexc           B   s5   e  Z d  Z d Z d Z d Z d „  Z d d „ Z RS(   sŒ  
    An Index is the description for a domain-specific index.  To add an index to
    a domain, subclass Index, overriding the three name attributes:

    * `name` is an identifier used for generating file names.
    * `localname` is the section title for the index.
    * `shortname` is a short name for the index, for use in the relation bar in
      HTML output.  Can be empty to disable entries in the relation bar.

    and providing a :meth:`generate()` method.  Then, add the index class to
    your domain's `indices` list.  Extensions can add indices to existing
    domains using :meth:`~sphinx.application.Sphinx.add_index_to_domain()`.
    c         C   sD   |  j  d  k s |  j d  k r7 t d |  j j ƒ ‚ n  | |  _ d  S(   Ns0   Index subclass %s has no valid name or localname(   t   namet   Nonet	   localnameR   t	   __class__R   t   domain(   R   R#   (    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyR   M   s    c         C   s
   t  ‚ d S(   s  Return entries for the index given by *name*.  If *docnames* is
        given, restrict to entries referring to these docnames.

        The return value is a tuple of ``(content, collapse)``, where *collapse*
        is a boolean that determines if sub-entries should start collapsed (for
        output formats that support collapsing sub-entries).

        *content* is a sequence of ``(letter, entries)`` tuples, where *letter*
        is the "heading" for the given *entries*, usually the starting letter.

        *entries* is a sequence of single entries, where a single entry is a
        sequence ``[name, subtype, docname, anchor, extra, qualifier, descr]``.
        The items in this sequence have the following meaning:

        - `name` -- the name of the index entry to be displayed
        - `subtype` -- sub-entry related type:
          0 -- normal entry
          1 -- entry with sub-entries
          2 -- sub-entry
        - `docname` -- docname where the entry is located
        - `anchor` -- anchor for the entry within `docname`
        - `extra` -- extra info for the entry
        - `qualifier` -- qualifier for the description
        - `descr` -- description for the entry

        Qualifier and description are not rendered e.g. in LaTeX output.
        N(   t   NotImplementedError(   R   t   docnames(    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   generateT   s    N(	   R   R   R   R    R   R!   t	   shortnameR   R&   (    (    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyR   :   s   	t   Domainc           B   sÚ   e  Z d  Z d Z d Z i  Z i  Z i  Z g  Z i  Z	 i  Z
 i  Z d Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z d „  Z d „  Z RS(   sÔ  
    A Domain is meant to be a group of "object" description directives for
    objects of a similar nature, and corresponding roles to create references to
    them.  Examples would be Python modules, classes, functions etc., elements
    of a templating language, Sphinx roles and directives, etc.

    Each domain has a separate storage for information about existing objects
    and how to reference them in `self.data`, which must be a dictionary.  It
    also must implement several functions that expose the object information in
    a uniform way to parts of Sphinx that allow the user to reference or search
    for objects in a domain-agnostic way.

    About `self.data`: since all object and cross-referencing information is
    stored on a BuildEnvironment instance, the `domain.data` object is also
    stored in the `env.domaindata` dict under the key `domain.name`.  Before the
    build process starts, every active domain is instantiated and given the
    environment object; the `domaindata` dict must then either be nonexistent or
    a dictionary whose 'version' key is equal to the domain class'
    :attr:`data_version` attribute.  Otherwise, `IOError` is raised and the
    pickled environment is discarded.
    t    i    c         C   s¬  | |  _  i  |  _ i  |  _ i  |  _ i  |  _ t |  j ƒ |  _ t |  j ƒ |  _ t |  j ƒ |  _ t	 |  j
 ƒ |  _
 |  j | j k rØ t |  j t ƒ sŸ t ‚ t j |  j ƒ } |  j | d <| |  _ | j |  j <n? | j |  j |  _ |  j d |  j k rt d |  j ƒ ‚ n  xp t |  j ƒ D]_ \ } } x- | j D]" } |  j j | g  ƒ j | ƒ q=W| j ry| j d n d |  j | <q'W|  j j |  _ |  j j |  _ d  S(   Nt   versions   data of %r domain out of datei    R)   (   t   envt   _role_cachet   _directive_cachet
   _role2typet
   _type2rolet   dictt   object_typest
   directivesR   t   listt   indicesR   t
   domaindatat
   isinstancet   initial_datat   AssertionErrorR   t   deepcopyt   data_versiont   datat   IOErrort   labelR    t
   setdefaultt   appendt   gett   objtypes_for_rolet   role_for_objtype(   R   R+   t   new_dataR   t   objt   rolename(    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyR   £   s.    					 'c         C   sn   | |  j  | <| j r- | j d |  j | <n d |  j | <x- | j D]" } |  j j | g  ƒ j | ƒ qD Wd S(   s   Add an object type.i    R)   N(   R1   R   R/   R.   R>   R?   (   R   R   t   objtypet   role(    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   add_object_typeÁ   s    	c            sl   ˆ ˆ j  k r ˆ j  ˆ Sˆ ˆ j k r- d Sd ˆ j ˆ f ‰  i  g  ‡  ‡ ‡ f d † } | ˆ j  ˆ <| S(   sŠ   Return a role adapter function that always gives the registered
        role its full name ('domain:name') as the first argument.
        s   %s:%sc            s#   ˆ j  ˆ ˆ  | | | | | | ƒ S(   N(   R   (   t   typt   rawtextt   textt   linenot   inlinert   optionst   content(   t   fullnameR   R   (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   role_adapterØ   s    N(   R,   R   R    R   (   R   R   RQ   (    (   RP   R   R   s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyRG   Í   s    c            s}   | |  j  k r |  j  | S| |  j k r- d Sd |  j | f ‰ |  j | ‰  d ˆ  f ‡  ‡ f d †  ƒ  Y} | |  j  | <| S(   sŒ   Return a directive adapter class that always gives the registered
        directive its full name ('domain:name') as ``self.name``.
        s   %s:%st   DirectiveAdapterc              s   e  Z ‡  ‡ f d  †  Z RS(   c            s   ˆ |  _  ˆ  j |  ƒ S(   N(   R   t   run(   R   (   t   BaseDirectiveRP   (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyRS   ì   s    	(   R   R   RS   (    (   RT   RP   (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyRR   ë   s   N(   R-   R2   R    R   (   R   R   RR   (    (   RT   RP   s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt	   directiveß   s    c         C   s   d S(   s?   Remove traces of a document in the domain-specific inventories.N(    (   R   t   docname(    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt	   clear_docõ   s    c         C   s   t  d |  j ƒ ‚ d S(   sˆ   Merge in data regarding *docnames* from a different domaindata
        inventory (coming from a subprocess in parallel builds).
        sL   merge_domaindata must be implemented in %s to be able to do parallel builds!N(   R$   R"   (   R   R%   t	   otherdata(    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   merge_domaindataú   s    c         C   s   d S(   s7   Process a document after it is read by the environment.N(    (   R   R+   RV   t   document(    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   process_doc  s    c         C   s   d S(   s)   Do consistency checks (**experimental**).N(    (   R   (    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   check_consistency  s    c         C   s   d S(   sx   Process a pending xref created in a doc field.
        For example, attach information about the current scope.
        N(    (   R   t   pnode(    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   process_field_xref  s    c         C   s   d S(   sL  Resolve the pending_xref *node* with the given *typ* and *target*.

        This method should return a new node, to replace the xref node,
        containing the *contnode* which is the markup content of the
        cross-reference.

        If no resolution can be found, None can be returned; the xref node will
        then given to the :event:`missing-reference` event, and if that yields no
        resolution, replaced by *contnode*.

        The method can also raise :exc:`sphinx.environment.NoUri` to suppress
        the :event:`missing-reference` event being emitted.
        N(    (   R   R+   t   fromdocnamet   builderRI   t   targett   nodet   contnode(    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   resolve_xref  s    c         C   s
   t  ‚ d S(   s9  Resolve the pending_xref *node* with the given *target*.

        The reference comes from an "any" or similar role, which means that we
        don't know the type.  Otherwise, the arguments are the same as for
        :meth:`resolve_xref`.

        The method must return a list (potentially empty) of tuples
        ``('domain:role', newnode)``, where ``'domain:role'`` is the name of a
        role that could have created the same reference, e.g. ``'py:func'``.
        ``newnode`` is what :meth:`resolve_xref` would return.

        .. versionadded:: 1.3
        N(   R$   (   R   R+   R_   R`   Ra   Rb   Rc   (    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   resolve_any_xref&  s    c         C   s   g  S(   sý  Return an iterable of "object descriptions", which are tuples with
        five items:

        * `name`     -- fully qualified name
        * `dispname` -- name to display when searching/linking
        * `type`     -- object type, a key in ``self.object_types``
        * `docname`  -- the document where it is to be found
        * `anchor`   -- the anchor name for the object
        * `priority` -- how "important" the object is (determines placement
          in search results)

          - 1: default priority (placed before full-text matches)
          - 0: object is important (placed before default-priority objects)
          - 2: object is unimportant (placed after full-text matches)
          - -1: object should not show up in search at all
        (    (   R   (    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   get_objects7  s    c         C   s'   | r | j  St d ƒ |  j | j  f S(   s#   Return full name for given ObjType.s   %s %s(   R   R   R=   (   R   t   typet   primary(    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   get_type_nameK  s    c         C   s"   |  j  j | j d ƒ \ } } | S(   s,   Get type of enumerable nodes (experimental).N(   NN(   t   enumerable_nodesR@   R"   R    (   R   Rb   t   enum_node_typeR   (    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   get_enumerable_node_typeR  s    c         C   s   d S(   s*   Return full qualified name for given node.N(   R    (   R   Rb   (    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   get_full_qualified_nameX  s    N(   R   R   R   R   R=   R1   R2   R   R4   t   dangling_warningsRj   R7   R    R;   R:   R   RH   RG   RU   RW   RY   R[   R\   R^   Rd   Re   Rf   t   FalseRi   Rl   Rm   (    (    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyR(   t   s6   														("   R   R   t   sixR    t   sphinx.errorsR   t   sphinx.localeR   Ro   t   typingR   R   R   R   R   R   R	   R
   t   docutilsR   t   docutils.parsers.rst.statesR   t   sphinx.buildersR   t   sphinx.environmentR   t   sphinx.rolesR   t   sphinx.util.typingR   t   objectR   R   R(   (    (    (    s6   lib/python2.7/site-packages/sphinx/domains/__init__.pyt   <module>   s   ::