
    ~Tiq                    :   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mZ ddlmZmZmZmZ dd	lmZ erdd
lmZmZ ddlmZ ddlmZ  eh d      Ze eh d      z  ZddZ	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 ddZ 	 	 	 	 	 	 	 	 	 	 ddZ!y)z7Sphinx extension for auto-generating API documentation.    )annotationsN)Path)TYPE_CHECKING)bold)create_modules_toc_filerecurse_tree)LOGGERApidocDefaultsApidocOptions_remove_old_files)__)
CollectionSequence)Any)Sphinx>   no_headingsfollow_linksmodule_firstinclude_privateseparate_modulesimplicit_namespaces>   path	max_depthdestinationexclude_patternsautomodule_optionsc                2   t        j                  | j                        }| j                  j                  }| j                  }| j
                  }t        j                  t        t        d                   t        |      D ]  \  }}t        |||||        y)zRun the apidoc extension.zRunning apidocoptionsdefaultssrcdirconfdirN)r
   from_configconfigapidoc_modulesr!   r"   r	   infor   r   	enumerate_run_apidoc_module)appr    r%   r!   r"   imodule_optionss          O/home/agent/.local/lib/python3.12/site-packages/sphinx/ext/apidoc/_extension.py
run_apidocr-   +   s    ))#**5H/2zz/H/HN::FKKG
KKR()*+ '~6 
>"	

    c                  t        | ||||      }|y|j                  D cg c]*  }t        j                  t	        j
                  |            , }}t        |j                  |||j                        \  }}	|j                  r1|j                  t        |	||j                  |j                               |j                  r"t        ||j                  |j                         yyc c}w )zRun apidoc for a single module.r   N)_parse_module_optionsexclude_patternrecompilefnmatch	translater   module_pathtemplate_dirtoc_fileappendr   
remove_oldr   dest_dirsuffix)
r*   r   r    r!   r"   argsexcludeexclude_patterns_compiledwritten_filesmoduless
             r,   r(   r(   ?   s     !	7XfgD | ?C>R>R83:

7$$W-.8 8 *3T4;L;LM7 }}#GT4==$BSBST	
 -D 8s   /C$c                  t        |t              s"t        j                  t	        d      | d       y 	 t        |d         }||z  }|j                         s#t        j                  t	        d      | |d       y 	 t        |d         }|j                         r"t        j                  t	        d      | d       y ||z  }	 |j                  dd       t        | |d|j                        D 
cg c]  }
t        ||
z         }}
|j                   }d|v r;t        |d   t"              s#t        j                  t	        d      | dd       n|d   }i }t%        t&              D ]c  }||vrt)        ||      ||<   t        ||   t*              s2t        j                  t	        d      | |d       t)        ||      ||<   \||   ||<   e t-        t        | |d|j.                              }|j1                         t2        z
  x}r:t        j                  t	        d      | dj5                  t%        |            d       t7        ||||d|d   |d   |d   |d   |d   |d   ||j8                        S # t        $ r$ t        j                  t	        d      | d       Y y t        $ r$ t        j                  t	        d      | d       Y y w xY w# t        $ r$ t        j                  t	        d	      | d       Y y t        $ r$ t        j                  t	        d
      | d       Y y w xY w# t        $ r6}	t        j                  t	        d      | |	j                  d       Y d }	~	y d }	~	ww xY wc c}
w )Nz%apidoc_modules item %i must be a dictapidoctyper   z-apidoc_modules item %i must have a 'path' keyz.apidoc_modules item %i 'path' must be a stringz;apidoc_modules item %i 'path' is not an existing folder: %sr   z4apidoc_modules item %i must have a 'destination' keyz5apidoc_modules item %i 'destination' must be a stringz>apidoc_modules item %i 'destination' should be a relative pathT)parentsexist_okz>apidoc_modules item %i cannot create destination directory: %sr   )keydefaultr   z*apidoc_modules item %i '%s' must be an intz-apidoc_modules item %i '%s' must be a booleanr   z.apidoc_modules item %i has unexpected keys: %sz, r   r   r   r   r   r   )r;   r6   r1   r   quietr   r   r   r   r   r   r   header)
isinstancedictr	   warningr   r   KeyError	TypeErroris_diris_absolutemkdirOSErrorstrerror_check_collection_of_stringsr   strr   intsorted
_BOOL_KEYSgetattrbool	frozensetr   keys_ALLOWED_KEYSjoinr   name)r*   r   r    r!   r"   r   r6   r   	dest_pathexcpatternr   r   bool_optionsrH   r   diffs                    r,   r0   r0   ]   s    gt$rABAHUGFO$ D.KLM		
 7=12  OP	

 $I	t4 4w.8Q8Q
# 	Gg# # ""Ig'+.4NN?@	  ,I$&Lj! -g '# 6LGCL$/NNBC	 !(# 6L 'L- #$w0(:U:U	
 ||~--t-?@IIfTl#		
 (!.1%&89$%67 /!.1()>?- Y  >?	
  ?@!(	
 	$  EF	

  FG	

 "  OPLL		
 #sM   I1 ;K L' /M)1*K	)K	K	*L$8)L$#L$'	M&0,M!!M&c               &   ||vr|S t        ||   t        t        t        t        f      s$t        j                  t        d      | |d       |S ||   D ]8  }t        |t              rt        j                  t        d      | |d       |c S  ||   S )zCheck that a key's value is a collection of strings in the options.

    :returns: The value of the key, or None if invalid.
    z.apidoc_modules item %i '%s' must be a sequencerC   rD   z0apidoc_modules item %i '%s' must contain strings)	rL   listtuplesetr]   r	   rN   r   rW   )indexr   rH   rI   items        r,   rV   rV      s     'gclT5#y$AB?@		
  $$NNEF	 N 3<r.   )r)   r   returnNone)r*   rX   r   dict[str, Any]r    r
   r!   r   r"   r   rm   rn   )r*   rX   r   ro   r    r
   r!   r   r"   r   rm   zApidocOptions | None)
rk   rX   r   ro   rH   rW   rI   Collection[str]rm   rp   )"__doc__
__future__r   r4   r2   pathlibr   typingr   sphinx._cli.util.colourr   sphinx.ext.apidoc._generater   r   sphinx.ext.apidoc._sharedr	   r
   r   r   sphinx.localer   collections.abcr   r   r   sphinx.applicationr   r]   rZ   r_   r-   r(   r0   rV    r.   r,   <module>r|      s$   = "  	    ( M  4)  
 Y (  
(E
E E 	E
 E E 
E<I
I I 	I
 I I IX 
	
  r.   