
    Fey                       d Z ddlmZ ddlZddlZddl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mZmZ ddlmZ dd	lmZ dd
lmZmZmZ ddlm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!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/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z; ddl<m=Z=m>Z> ddl?m@Z@ er&ddlAmBZB ddlCmDZDmEZE ddlFmGZG ddlHmIZI ddlJmKZK dd lLmMZM  e4j                  eO      ZP ej                  d!      ZR ej                  d"      ZSd#ZT G d$ d%ej                        ZVdBd&ZWdCd'ZX G d( d)ej                        ZYdDd*ZZ G d+ d,      Z[ G d- d.e$      Z\dEd/Z] G d0 d1e8      Z^dFd2Z_dFd3Z`dGdHd4ZadId5Zb	 	 dJ	 	 	 dKd6Zc G d7 d8ed      ZedLd9Zf	 dM	 	 	 	 	 dNd:ZgdOdPd;Zh	 	 dQ	 	 	 dRd<Zi G d= d>e9      ZjdSd?ZkdTd@ZldUdAZmy)Va_  Extension that adds an autosummary:: directive.

The directive can be used to generate function/method/attribute/etc. summary
lists, similar to those output eg. by Epydoc and other API doc generation tools.

An :autolink: role is also provided.

autosummary directive
---------------------

The autosummary directive has the form::

    .. autosummary::
       :nosignatures:
       :toctree: generated/

       module.function_1
       module.function_2
       ...

and it generates an output table (containing signatures, optionally)

    ========================  =============================================
    module.function_1(args)   Summary line from the docstring of function_1
    module.function_2(args)   Summary line from the docstring
    ...
    ========================  =============================================

If the :toctree: option is specified, files matching the function names
are inserted to the toctree with the given prefix:

    generated/module.function_1
    generated/module.function_2
    ...

Note: The file names contain the module:: or currentmodule:: prefixes.

.. seealso:: autosummary_generate.py


autolink role
-------------

The autolink role functions as ``:obj:`` when the name referred can be
resolved to a Python object, and otherwise it becomes simple emphasis.
This can be used as the default role to make links 'smart'.
    )annotationsN)	Parameter)path)
ModuleType)TYPE_CHECKINGAnycast)nodes)
directives)RSTStateMachineStructstate_classes)
StringList)addnodes)Config)BuildEnvironment)INSTANCEATTR
Documenter)DocumenterBridgeOptions)import_module)mock)__)Project)ModuleAnalyzerPycodeError)SphinxComponentRegistry)loggingrst)NullReporterSphinxDirective
SphinxRolenew_documentswitch_source_input)getmrosignature_from_str)Matcher)Sequence)Nodesystem_message)Sphinx)	Extension)
OptionSpec)HTML5Translatorz	\.(?:\s+)z::\s*$)zet al.ze.g.zi.e.c                      e Zd Zy)autosummary_tocN__name__
__module____qualname__     A/usr/lib/python3/dist-packages/sphinx/ext/autosummary/__init__.pyr0   r0   n       r6   r0   c                "    t         j                  )z-Hide autosummary toctree list in HTML output.)r
   SkipNodeselfnodes     r7   autosummary_toc_visit_htmlr>   r   s    
..r6   c                     y Nr5   r;   s     r7   autosummary_nooprA   w   s    r6   c                      e Zd Zy)autosummary_tableNr1   r5   r6   r7   rC   rC   }   r8   r6   rC   c                t   	 t        t        j                  |d         }t        t        j                  |d         }t        t        j                  |d         }t        t
        t        j                     |      }|D ]  }t        t        j                  |d         }t        t        j                  |d         }t        t        |            D ]X  \  }	}
t        |
t        j                        s!|
j                         j                  dd      }t        j                  |      ||	<   Z  y# t        $ r Y yw xY w)z0Make the first column of the table non-breaking.r        N)r	   r
   tabletgrouptbodylistrowentry	paragraph	enumerate
isinstanceTextastextreplace
IndexError)r<   r=   rH   rI   rJ   rowsrL   
col1_entryparjsubnodenew_texts               r7   autosummary_table_visit_htmlr[      s    U[[$q'*ellE!H-U[[&*-DOU+ 	2Cekk3q62Ju
16C'S	2 2
7guzz2&~~/77XFH"ZZ1CF2	2  s   C+D+ .<D+ +	D76D7c                      e Zd ZddZy)FakeApplicationc                    d | _         d | _        i | _        d | _        t	               | _        t        di       | _        t               | _	        y )N )

doctreedirevents
extensionssrcdirr   configr   projectr   registry)r<   s    r7   __init__zFakeApplication.__init__   s>    02hr2/1r6   NreturnNone)r2   r3   r4   rg   r5   r6   r7   r]   r]      s    2r6   r]   c                        e Zd Zd fdZ xZS )FakeDirectivec                    t        d      }t        |      }t               }|j                  j                  dddd        t	        |      }t        |      }t
        |   |d t               d|       y )	N   )	tab_width)settingsautodoc_class_signaturemixedT)documentr   )r   r]   rd   addr   superrg   r   )r<   rp   rs   appenvstate	__class__s         r7   rg   zFakeDirective.__init__   sa    A&8,

0'4Fs#)dGIq%8r6   rh   )r2   r3   r4   rg   __classcell__ry   s   @r7   rl   rl      s    9 9r6   rl   c           	        ddl m}m} t        j                  |      r|S |t        | |d      }n|}t        |d      r |t               |j                        }n |t               d      }| j                  j                  j                         D cg c]  }|j                  |dd|      r| }}|r|j                  d        |d	   S |S c c}w )
zGet an autodoc.Documenter class suitable for documenting the given
    object.

    *obj* is the Python object to be documented, and *parent* is an
    another Python object (e.g. a module or a class) to which *obj*
    belongs to.
    r   )DataDocumenterModuleDocumenterNr2   r_   Fc                    | j                   S r@   )priority)clss    r7   <lambda>z get_documenter.<locals>.<lambda>   s
    S\\ r6   )keyrE   )sphinx.ext.autodocr}   r~   inspectismoduleget_documenterhasattrrl   r2   rf   documentersvaluescan_document_membersort)	rv   objparentr}   r~   parent_doc_cls
parent_docr   classess	            r7   r   r      s     D 'VT:)vz"#MOV__E
#MOR8
 "ll66==? Gs))#r5*E  GG G12r{Gs   Cc                      e Zd ZU dZdZdZdZdZej                  ej                  ej                  ej                  ej                  dZded<   ddZ	 	 	 	 	 	 dd	Z	 	 	 	 	 	 dd
ZddZddZy)Autosummaryz
    Pretty table containing short signatures and summaries of functions etc.

    autosummary can also optionally generate a hidden toctree:: node.
    r   FT)captiontoctreenosignatures	recursivetemplater-   option_specc                8   t        | j                  | j                  j                  j                  t               | j                  | j                        | _        | j                  D cg c]Z  }|j                         rHt        j                  d|j                         d         r!|j                         j                         d   \ }}| j                  |      }| j                  |      }d| j                  v rt!        j"                  | j                  j$                        }| j                  d   j                         }g }t'        | j(                  j*                        }| j(                  j,                  }	|D ]  \  }
}}}|	j/                  ||      }t!        j0                  ||      }t!        j2                  t!        j0                  ||            }|| j                  j4                  vr` || j                  j7                  |d            rt9        d      }nt9        d      }t:        j=                  ||| j?                                |jA                  |        |rstC        jD                         }||d<   |D cg c]  }d |f c}|d	<   d
|d<   d |d<   | j                  j/                  d      |d<    |j@                  tG        dd|             d| j                  vr1d| j                  v r#t:        j=                  t9        d      |d
          |S c c}w c c}w )Nz^[~a-zA-Z_]r   r   Fz5autosummary references excluded document %r. Ignored.zMautosummary: stub file not found %r. Check your autosummary_generate setting.locationincludefilesentriesrE   maxdepthglobr   r_   z;A captioned autosummary requires :toctree: option. ignored.)$r   rw   rx   rs   reporterr   linenobridgecontentstripresearchsplit	get_items	get_tableoptions	posixpathdirnamedocnamer'   rd   exclude_patternsautosummary_filename_mapgetjoinnormpath
found_docsdoc2pathr   loggerwarningget_locationappendr   r   r0   )r<   xnamesitemsr
   r   tree_prefixdocnamesexcludedfilename_map_name_sig_summary	real_namer   msgtocnodedocns                     r7   runzAutosummary.run   s   &txx1D1D1M1M'.y$++tzzK 04|| K!GGI"))NAGGIaL"I "1% K Ku%u%$''(8(89G,,y1779KHt{{;;<H;;??L49 )0tXy(,,Y	B	#..i@#,,Y^^GW-MN$(("5"55 1 1'5 AB !XY  "L M NN3	D<M<M<ONP()  "**,*2'?G%HttTl%H	"&(
#"&%)\\%5%5i%@	"_RW=>DLL(Y$,,-FNN2[\$)"I  / UK> &Is   'AL;Lc                   t        | j                  j                        5  	 t        ||      cd d d        S # t        $ r}	 t        ||      cY d }~cd d d        S # t        $ rV}|j                  r|j                  |j                  gz   }n|j                  |gz   }t	        |j                  d   |      d d }~ww xY wd }~ww xY w# 1 sw Y   y xY w)Nr   )
r   rd   autosummary_mock_importsimport_by_nameImportExceptionGroupimport_ivar_by_nameImportError	__cause__
exceptionsargs)r<   nameprefixesexcexc2errorss         r7   r   zAutosummary.import_by_name  s     $++667 	NN%dH5	N 	N ( 
NN.tX>>	N 	N # N~~69nnGW6W!$4&!8.sxx{FCMN	
N	N 	NsK   C7	CACC	B:$AB55B::B==CCCc                B    t        |||      } || j                  |      S )zGet an autodoc.Documenter class suitable for documenting the given
        object.

        Wraps get_documenter and is meant as a hook for extensions.
        )r   r   )r<   rv   r   r   	full_namedocclss         r7   create_documenterzAutosummary.create_documenter%  s#      S&1dkk9--r6   c                   t        | j                        }g }d}|D ]L  }|}|j                  d      r|dd }|j                  d      d   }	 | j	                  ||      \  }}}	}
t               | j                   _        |}t%        |t&              s|
dz   |t)        |
      dz   d z   }| j+                  | j                  j,                  ||	|      }|j/                         sFt        j                  t        d      || j                                |j1                  |dd|f       	|j3                         sFt        j                  t        d      || j                                |j1                  |dd|f       _	 t5        j6                  |j9                               |_        |j:                  j=                          	 |jC                  d      }|sd}n%tG        d|t)        |      z
        }tI        ||      }d|_%        |jM                  d       tO        | j                   j"                  jP                  dd | jR                  jT                        }|j1                  ||||f       O |S # t
        $ r}t        |j                  D ch c]  }dt        |      j                   d	|  nc c}w c}      }t        j                  t        d
      |dj                  |      | j                                Y d}~d}~ww xY w# t>        $ r(}t        jA                  d|       d|_        Y d}~td}~ww xY w# tD        $ r |jC                         }Y w xY w)z}Try to import the given names, and return a list of
        ``[(name, signature, summary_string, real_name), ...]``.
        2   ~   N.rE   )r   z* z: z4autosummary: failed to import %s.
Possible hints:
%s
r   z::zfailed to parse name %sr_   zfailed to import object %sz$[autodoc] module analyzer failed: %sF)show_annotation
   	max_chars)+get_import_prefixes_from_envrw   
startswithr   r   r   rK   r   typer2   r   r   r   r   r   r   r   resultrP   r   lenr   rv   
parse_namer   import_objectr   
for_moduleget_real_modnameanalyzerfind_attr_docsr   debugformat_signature	TypeErrormaxmangle_signature_extra_indentadd_contentextract_summarydatarx   rs   )r<   r   r   r   max_item_charsr   display_namer   r   r   modnamer   er   r   
documentererrsigr   summarys                       r7   r   zAutosummary.get_items/  s    0913 D	BDLs#ABx#zz#r2262E2EdU]2E2^/	3 ",DKK!Ic:. $dNYs7|a7G7H-II	 //c69UJ((*r";<i(,(9(9(;  =lBI>?++-r">?(,(9(9(;  =lBI>?	+&4&?&?//1'3
# ##2244 11%1H
 NS5F$FG	&si@
 (*J$""4(%dkk&8&8&=&=a&@$**BUBUVGLL,Wi@AID	BL } ( S^^TDG$4$4#5Rs;TTUr"Z[#TYYv%6ARARAT  V	B  +CSI&*
##+  4 1134sP   I.<AL?L:.	L7K>
"J-,AK>>L	L7L22L7:MMc                    t        j                         }d|d<   t        d      }t        j                  ddg      }|j                  |       t        j                  dd      }|j                  |       |j                  t        j                  dd	             |j                  t        j                  dd
	             t        j                  d      |j                         d fd}|D ]P  \  }}}	}
d}d j                  vr"d| d| d|
 dt        j                  |       }nd| d| d|
 d}|	} |||       R ||gS )zGenerate a proper list of table nodes for autosummary:: directive.

        *items* is a list produced by :meth:`get_items`.
        z\X{1}{2}\X{1}{2}specr_   zautosummary longtabler      )colsr   )colwidthZ   c                 D   t        j                  d      }j                  j                         \  }}| D ]  }t        j                  d      }t               }|j                  |d||fz         t        j                  |      5  j                  j                  |d|       	 t        |d   t         j                        r|d   }|j                  t        j                  d|             d d d         j                  |       y # t        $ r Y Lw xY w# 1 sw Y   xY w)Nr_   z%s:%d:<autosummary>r   )r
   rL   state_machineget_source_and_linerN   r   r   r$   rx   nested_parserP   rT   rM   )	column_textsrL   sourcelinetextr=   vlbodyr<   s	          r7   
append_rowz)Autosummary.get_table.<locals>.append_row  s    ))B-C--AACLFD$ 6r*\		$ 5 FG(R8 6JJ++B48%d1gu?#'7D JJu{{2t456 6	6 KK & 6 6s0   D$"D%D	DDDDD	r   r   z:py:z:`z <z>`\ z>`)r  strri   rj   )r   tabular_col_specrC   r
   rH   r   rI   colspecrJ   r   r   escape)r<   r   
table_specrH   
real_tablegroupr  r   r   r   r   	qualifiercol1col2r  s   `             @r7   r   zAutosummary.get_table  s9   
 ..0
0
6!"%[[.E-FG
Z Ra(% U]]234U]]234{{2T	" .3 	#)D#w	IT\\1i[4&9+U3::c?BSTi[4&9+R@DtT"	# E""r6   N)ri   
list[Node])r   r  r   list[str | None]ri   tuple[str, Any, Any, str])
rv   r+   r   r   r   r   r   r  ri   r   )r   	list[str]ri   list[tuple[str, str, str, str]])r   r!  ri   r  )r2   r3   r4   __doc__required_argumentsoptional_argumentsfinal_argument_whitespacehas_contentr   unchanged_required	unchangedflagr   __annotations__r   r   r   r   r   r5   r6   r7   r   r      s      %K00''"__((K .`NN#3N	"N$."%.25.:D.Pd,#r6   r   c                F    | j                  d      d   j                         S )z+Strip a type hint from argument definition.:r   )r   r   )ss    r7   strip_arg_typehintr.    s    773<?  ""r6   c                   	 t        |       }t        |j                  j                               }t	        |      D ]t  \  }}|j
                  t        j                  ur |j                  t        j                        }|j                  t        j                  ur|j                  d      }|||<   v |j                  |t        j                        }t        |      S # t        $ r | cY S w xY w)zCClean up signature using inspect.signautre() for mangle_signature())
annotationN)default)
parametersreturn_annotation)r&   rK   r2  r   rO   r0  r   emptyrS   r1  r  	Exception)r-  r   r2  iparams        r7   _cleanup_signaturer8    s     ##..//12
!*- 	"HAuy6A}}IOO3d3!JqM	" kkZ9??kS3x s   CC C,+C,c           
     b   t        |       }t        j                  dd|      }t        j                  dd|      j                         }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  d	d|      }t        j                  d
d|      }t        j                  d|      r.t        j                  dd|      }t        j                  d|      r.t        j                  d|      r.t        j                  dd|      }t        j                  d|      r.t        j                  d|      r.t        j                  dd|      }t        j                  d|      r.g }g }t        j
                  d      }|r]|j	                  |      }|s|j                  d      }n8|j                  d|j                  d             |j                  d      dd }|r]t        |      D ]  \  }}t        |      ||<    t        |      D ]  \  }}	t        |	      ||<    t        d||dz
        } |rX| sdt        d||dz
        z  } d| z  S t        |       |dz
  dz
  dz
  k  r&| dt        d||t        |       z
  dz
  dz
        z  z  } d| z  S )z5Reformat a function signature to a more compact form.z\)\s*->\s.*$)z
^\((.*)\)$z\1z\\\\r_   z\\'z\\"z'[^']*'z"[^"]*"z	\([^)]*\)z<[^>]*>z{[^}]*}z^(.*, |)([a-zA-Z0-9_*]+)\s*=\s*z, r   r  r   Nr   z[%s]      z[, %s]z(%s))r8  r   subr   r   compiler   insertr  rO   r.  limited_joinr   )
r   r   r-  r   optsopt_remr6  argopts
             r7   r   r     s   3A 	Q'A 	}eQ'--/A 	wAA
vr1A
vr1A
z2q!A
z2q!A ))L!
$FF<Q' ))L!
$
))J
"FF:r1% ))J
"
))J
"FF:r1% ))J
" DDZZ:;F
MM!774=DAqwwqz"GGAJsO  D/ *3$S)Q* D/ *3$S)Q* tTY]
;C<di!mLLC
 C<	 X	A)A--8l45>S5IA5MPQ5QS S SC C<r6   c                   d	d}| r:| d   j                         s'| j                  d       | r| d   j                         s't        |       D ]  \  }}|j                         r| d| }  n | g k(  ry || |j                        }t	        |d   t
        j                        r#|d   j                         j                         }nt	        |d   t
        j                        s| d   j                         }nt        j                  dj                  |             }t        |      dk(  r|d   j                         }nd}t        t        |            D ]  }dj                  |d|dz          j                  d      dz   }g |dd  || |j                        }|j                  t               rZt#        |j%                  t
        j&                              r n t(        j+                  d|      }|S )
zExtract summary from docstring.c                    t        t        d      }t        d|      }t               |_        |j                  | |       |S )NBodyr_   )r   r   r#   r    r   r   )docrp   r	  r=   s       r7   parsezextract_summary.<locals>.parse  s8    'v>B)$#t$r6   r   Nr_   rF   r   z. r   )rJ  r   rp   r   ri   znodes.document)r   poprO   rp   rP   r
   sectionrR   rN   
periods_rer   r   r   rangerstripendswithWELL_KNOWN_ABBREVIATIONSanyfindallr*   
literal_rer>  )rJ  rs   rK  r6  piecer=   r   	sentencess           r7   r   r     s    c!flln
 c!flln cN 5{{}bq'C
 by h''(D$q'5==)q'.."((*Q1a&,,. $$SXXc]3	y>Ql((*GG3y>* ))Ifq1u$56==cBSHQS("3"34##$<=T\\%*>*>?@ nnS'*GNr6   c                    | j                  |      }t        |      |k  r|S d}d}|D ]4  }|t        |      t        |       z   z  }||t        |      z
  k  r|dz  }4 n | j                  t        |d|       |gz         S )zJoin a number of strings into one, limiting the length to *max_chars*.

    If the string overflows this limit, replace the last fitting item by
    *overflow_marker*.

    Returns: joined_string
    r   r   N)r   r   rK   )sepr   r   overflow_markerfull_strn_charsn_itemsitems           r7   rA  rA  <  s     xxH
8}y GG 3t9s3x''Y_!555qLG 88Dx)_,==>>r6   c                  $     e Zd ZdZd fdZ xZS )r   zExceptions raised during importing the target objects.

    It contains an error messages and a list of exceptions as its arguments.
    c                D    t         |   |       t        |      | _        y r@   )ru   rg   rK   r   )r<   messager   ry   s      r7   rg   zImportExceptionGroup.__init__^  s    !z*r6   )ra  
str | Noner   zSequence[BaseException])r2   r3   r4   r"  rg   rz   r{   s   @r7   r   r   X  s    
+ +r6   r   c                    dg}| j                   j                  d      }|r|j                  d|       | j                   j                  d      }|r.|r|j                  d|dz   |z          |S |j                  d|       |S )z`
    Obtain current Python import prefixes (for `import_by_name`)
    from ``document.env``
    Nz	py:moduler   zpy:classr   )ref_contextr   r@  )rw   r   
currmodule	currclasss       r7   r   r   c  s~    
 #'H$$[1J:&##J/IOOAzC/);< O OOAy)Or6   c                   g }g }|D ]3  }	 |rdj                  || g      }n| }t        |d      \  }}}||||fc S  t        d |D        g       }
t	        ddj                  |      z  |
      # t        $ r |j                         Y t        $ r,}	|j                         |j                  |	       Y d}	~	d}	~	ww xY w)z~Import a Python object that has the given *name*, under one of the
    *prefixes*.  The first name that succeeds is used.
    r   T)grouped_exceptionNc              3  4   K   | ]  }|j                     y wr@   )r   ).0r   s     r7   	<genexpr>z!import_by_name.<locals>.<genexpr>  s     *HA1<<*Hs   zno module named %sz or )r   _import_by_namer   r   r   sum)r   r   triedr   prefixprefixed_namer   r   r   r   r   s              r7   r   r   x  s     E)+F 	 #&$ 8 $#2=TX#Y C #vw66 '**H*H"&MJ
3fkk%6HH*
UU  	(LL'# 	LL'MM#	s   .A..B>
B>"B99B>c                   g }	 | j                  d      }dj                  |dd       }|r	 t        |      }t        ||d         ||fS d}d}t        t        dt        |      dz               D ]8  }|}dj                  |d|       }	 t        |       |t        j                  v s8 n |t        |      k  r2d}	t        j                  |   }
||d D ]  }|
}	t        |
|      }
 |
|	|fS t        j                  |   d|fS # t        t
        t        f$ r)}|j                  |j                  xs |       Y d}~d}~ww xY w# t        $ r)}|j                  |j                  xs |       Y d}~d}~ww xY w# t        t        t        t        f$ r8}|j                  |       |rt!        d|      dt	        |j"                   |d}~ww xY w)z+Import a Python object given its full name.r   NrE   r   r_   r   )r   r   r   getattrr   rT   AttributeErrorr   r   reversedrO  r   sysmodules
ValueErrorKeyErrorr   r   )r   rh  r   
name_partsr   modr   last_jrX   r   r   obj_names               r7   rl  rl    s   "$F(2ZZ_
 ((:cr?+4#G,sJrN3S'AA
 %3z?Q#678 		AFhhz"1~.G4g& #++%		 C
O#F++g&C&vw/ -c8,- '';;w'w663  ^< 4cmm2s334  4cmm2s334 ^X> 2c&r62<sxx(c12sw   'E4 C? 	>E4 D?E4 &AE4 )E4 ?D<D72E4 7D<<E4 ?	E1E,'E4 ,E11E4 4G3G  Gc                <   	 | j                  dd      \  } }t        | |      \  }}}}t        |      }t        |      dk(  r|f}|D ]  }	t	        j
                  t        |	d|            }
|
j                          t               }||
j                  D ch c]  \  }}|	 c}}z  }||
j                  D ch c]  \  }}|	 c}}z  }|v s|dz   |z   t        ||fc S  	 t        c c}}w c c}}w # t        t        t        f$ r}t        |d}~wt        $ r  w xY w)zImport an instance variable that has the given *name*, under one of the
    *prefixes*.  The first name that succeeds is used.
    r   r   r   r3   N)rsplitr   r%   r   r   r   rr  analyzeset	attr_docsr   r   r   rw  r   r   )r   r   rh  attrr   r   r   r   candidate_objectscandidate_objr   found_attrsqualnamer   s                 r7   r   r     s-   
[[a(
d*8x*H'	3 #3K !Q&!$. 	JM%00V]1^_H%K9K9KL%5hDLLK9M9MN%5hDNNK{" 3-|S'II	J  MN [1 #s" sB   BC2 C&
C2 5C,

C2 C2 C2 &C2 2DDDc                      e Zd ZdZddZy)AutoLinkzSmart linking role.

    Expands to ':obj:`text`' if `text` is an object that can be imported;
    otherwise expands to '*text*'.
    c           	     z   | j                   j                  d      j                  d      }|J  |d| j                  | j                  | j
                  | j                  | j                  | j                        \  }}|r||fS t        |      dk(  sJ t        t        j                  |d         }	 t        | j                         }t        |d   |       ||fS # t        $ rY t        t         j"                  |d         }t!        j$                  | j                  |j'                         |d         |d<   Y ||fS w xY w)Npyr   r   r   	reftargetr   r  )rw   
get_domainrolerawtextr  r   inlinerr   r   r   r	   r   pending_xrefr   r   r   r
   literalemphasisrR   )r<   
pyobj_roleobjectsr   r  r   r  s          r7   r   zAutoLink.run  s$   XX((.33E:
%%%$UDLL$))T[[%)\\4<<OF?"7|q   H1171:>	D3DHH=H<4h?  $ 	D5==,q/:Ggnn6F07	0BDGAJ 	Ds   0$C AD:9D:N)ri   z'tuple[list[Node], list[system_message]])r2   r3   r4   r"  r   r5   r6   r7   r  r    s    
r6   r  c                h     d fd}d } j                   j                  D ]  }d ||      v s|c S  y )Nc                t    j                   j                         j                  |       }|y|j                  S )N)restructuredtext)rf   get_source_parsersr   	supported)suffixparser_classrv   s     r7   get_supported_formatz,get_rst_suffix.<locals>.get_supported_format   s5    ||668<<VD(%%%r6   r  )r  r  ri   ztuple[str, ...])rd   source_suffix)rv   r  r  s   `  r7   get_rst_suffixr    s@    & F**** !5f!==M r6   c           
     0   | j                   j                  }|du ro| j                  j                  }|j                  D cg c]C  }t
        j                  j                  |j                  |            r|j                  |d      E }}n|du rnt        | j                   j                        }|D cg c]&  }||j                  t        |            s|d   ndz   ( }}|d d  D ]f  }t        j                  t        j                  | j                  |            r7t        j!                  t#        d      |       |j%                  |       h |sy t'        |       }|t        j!                  t#        d             y ddlm} | j                   j,                  }	t/        | j                   j0                        5   |||| j                  | |	| j                   j2                  | j                   j4                  	       d d d        y c c}w c c}w # 1 sw Y   y xY w)
NTF)baser   r_   z(autosummary_generate: file not found: %szbautosummary generats .rst files internally. But your source_suffix does not contain .rst. Skipped.)generate_autosummary_docs)r  	base_pathrv   imported_members	overwriteencoding)rd   autosummary_generatebuilderrw   r   osr   isfiler   rK   r  rQ  tupler   rc   r   r   r   remover  sphinx.ext.autosummary.generater  autosummary_imported_membersr   r   autosummary_generate_overwritesource_encoding)
rv   genfilesrw   r   extgenfilerM   r  r  r  s
             r7   process_generate_optionsr    s   zz..H4kkoo9< 8Aww~~cll1o6 LLL/ 8 8	U	3::++,#+- W-=-=eCj-Is1vrR - - a[ 	'E;;tyyU;<r"LMuU&	'
 C F~r S T 	UIzz>>	cjj11	2 G!(6SZZ&)<L,/JJ,U,U+.::+E+E	GG G58-(G Gs   AH2+H7AHHc           	     B   | j                  d       | j                  t        t        t        ft        t        ft        t        ft        t        ft        t        f       | j                  t
        t        t        ft        t        ft        t        ft        t        ft        t        f       | j                  dt               | j                  dt                      | j                  dt               | j                  di d       | j                  di d	       | j                  d
ddt        t        g       | j                  ddd       | j                  dd d       | j                  dg dt        g       | j                  dddt               t         j"                  ddS )Nzsphinx.ext.autodoc)htmllatexr  mantexinfoautosummaryautolinkzbuilder-initedautosummary_contextTr   r  r  r  Fr   c                    | j                   S r@   )autodoc_mock_imports)rd   s    r7   r   zsetup.<locals>.<lambda>K  s    (C(C r6   rw   r  autosummary_ignore_module_all)versionparallel_read_safe)setup_extensionadd_noder0   r>   rA   rC   r[   add_directiver   add_roler  connectr  add_config_valueboolrK   sphinx__display_version__)rv   s    r7   setupr  4  sl   ,-LL13CD(*:;')9:&(89*,<=  ? LL"35EF(*:;')9:&(89*,<=  ? m[1LLXZ(KK ":;.D93R@/tdD\J94G3CUL7UTFK8$tL11NNr6   )r<   nodes.NodeVisitorr=   r0   ri   rj   )r<   r  r=   r)   ri   rj   )r<   r.   r=   rC   ri   rj   )rv   r+   r   r   r   r   ri   ztype[Documenter])r-  r  ri   r  )   )r   r  r   intri   r  )rJ  r   rs   r   ri   r  )r  z...)
rY  r  r   r   r   r  rZ  r  ri   r  )rw   r   ri   r  )r@   )r   r  r   Sequence[str | None]ri   r  )T)r   r  rh  r  ri   ztuple[Any, Any, str])r@   T)r   r  r   r  rh  r  ri   r  )rv   r+   ri   rb  )rv   r+   ri   rj   )rv   r+   ri   zdict[str, Any])nr"  
__future__r   r   r  r   r   ru  r   r   typesr   typingr   r   r	   docutilsr
   docutils.parsers.rstr   docutils.parsers.rst.statesr   r   r   docutils.statemachiner   r  r   sphinx.configr   sphinx.environmentr   r   r   r   sphinx.ext.autodoc.directiver   r   sphinx.ext.autodoc.importerr   sphinx.ext.autodoc.mockr   sphinx.localer   sphinx.projectr   sphinx.pycoder   r   sphinx.registryr   sphinx.utilr   r   sphinx.util.docutilsr    r!   r"   r#   r$   sphinx.util.inspectr%   r&   sphinx.util.matchingr'   collections.abcr(   docutils.nodesr)   r*   sphinx.applicationr+   sphinx.extensionr,   sphinx.util.typingr-   sphinx.writers.htmlr.   	getLoggerr2   r   r?  rN  rU  rR  commentr0   r>   rA   rC   r[   r]   rl   r   r   r.  r8  r   r   rA  r5  r   r   r   rl  r   r  r  r  r  r5   r6   r7   <module>r     s  .` #  	  	 
    + +  + N N ,     / 7 B 5 (  " 5 3 $  ; ((3)*-3			8	$ RZZ%
RZZ	"
5 
	emm 	
		 	(2 29$ 9 J]#/ ]#@#
(8v5p ?A(-?"%?25?8+9 +, 18V
V-VV4,2^ EL26+/;TDz 8#GLOr6   