
    wi                        d dl mZ d dlZd dlZd dlmZ d dlmZmZ d dl	Z	d dl
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mZmZmZ  ed          dddddddfd/dZ	 d0d1d.ZdS )2    )annotationsN)Path)	AnnotatedAny)ArgumentOption)custom_component_analytics)LivePanelDisplay   )css)extract_docstringsget_deepmake_markdown
make_space.TFpathHAnnotated[Path, Argument(help='The directory of the custom component.')]demo_dirBAnnotated[Path | None, Option(help='Path to the demo directory.')]	demo_name<Annotated[str | None, Option(help='Name of the demo file.')]readme_pathBAnnotated[Path | None, Option(help='Path to the README.md file.')]	space_urlKAnnotated[str | None, Option(help='URL of the Space to use for the demo.')]generate_spacebAnnotated[bool, Option(help='Create a documentation space for the custom compone.', is_flag=True)]generate_readme_Annotated[bool, Option(help='Create a README.md file for the custom component.', is_flag=True)]suppress_demo_checkPAnnotated[bool, Option(help='Suppress demo warnings and errors.', is_flag=True)]c                   t          ddddd           t          |                                           }|r!t          |                                          n t          d                                          }	|r|nd}
|	|
z  }|r!t          |                                          n|dz  }|s|st          d          t	                      5 }|                    dt          |j                   dd	
           |                    d| d           |dz                                  st          d| d          t          |dz  d          5 }t          j        |                                          }ddd           n# 1 swxY w Y   t          |ddg          }t          |t                    st          d          t          ||||||d||	|||           ddd           dS # 1 swxY w Y   dS )z!Runs the documentation generator.docsNdemozapp.pyz	README.mdz-Must generate at least one of space or readmez7:page_facing_up: Generating documentation for [orange3][/]g?)	add_sleepz.:eyes: Reading project metadata from [orange3]z/pyproject.toml[/]
zpyproject.tomlz,Cannot find pyproject.toml file in [orange3]utf-8encodingprojectnamez Name not found in pyproject.tomlsimple)liver+   r    pyproject_tomlr   r   	type_mode
_demo_path	_demo_dir_readme_pathr   _component_dir)r	   r   resolve
ValueErrorr
   updatestrr+   existsopentomlloadsreadr   
isinstancerun_command)r   r   r   r   r   r   r   r    r3   r1   
_demo_namer0   r2   r-   fdatar+   s                    s/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/gradio/cli/commands/components/docs.py_docsrC      s   >    $ZZ''))N,4PX&&((($v,,:N:N:P:PI'5XJZ'J'2T[!!###8T   J/ JHIII			 #
tcc.J]F^F^ccc 	 	
 	
 	
 	a^aaa	
 	
 	
 !1199;; 	R~RRR   .#33gFFF 	(!:affhh''D	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( y&122$$$ 	A?@@@ 3)+!%)	
 	
 	
 	
-#
 #
 #
 #
 #
 #
 #
 #
 #
 #
 #
 #
 #
 #
 #
 #
 #
 #
s8   BG.'F9G.F			G.F		AG..G25G2r-   r
   r+   r7   r.   dict[str, Any]boolr/   r0   r   r1   r2   
str | Noner3   r,   c                   t          |d          5 }|                                }d d d            n# 1 swxY w Y   t          j        d| d          j        }|dk    pd}t          |ddg          }t          t          |dd	g          pd
          }t          |g d          }|
r|
nt          |g d          }|s|st          d| d          t          j	        |          }t          |          \  }}|r|s|                     d           t          |||||nt          |          |||nt          |          ||nt          |          ||	  	        }t          |dz  dd          5 }|                    |           |s|                     d| d           d d d            n# 1 swxY w Y   t          |dz  dd          5 }|                    t                     d d d            n# 1 swxY w Y   |r|s|                     d           t          ||||||||          }t!          |	                                          }t          |	dd          5 }t%          j        d|          }|%|d |                                d                  |z   }|                    |           |s|                     d|	 d           d d d            n# 1 swxY w Y   |rct!          |	                              |          }t!          |dz                                |          }|                     d| d| d           |dk    r|                     d           d S d S ) Nr'   r(   zhttps://pypi.org/pypi/z/json   Fr*   versiondescription )r*   urls
repository)r*   rL   spacez>Cannot find version in pyproject.toml or on PyPI for [orange3]zQ[/].
If you have just published to PyPI, please wait a few minutes and try again.z%:computer: [blue]Generating space.[/])	r#   r+   rJ   local_versionr$   rN   repopypi_existsr    zspace.pywz-:white_check_mark: Space created in [orange3]z/space.py[/]
zcss.cssz$:pencil: [blue]Generating README.[/]z,(?:^|[
])---[
]+([\S\s]*?)[
]+---([
]|$)z0:white_check_mark: README generated in [orange3]r%   z7:white_check_mark: Documentation generated in [orange3]z[/] and [orange3]z;[/]. Pass --no-generate-docs to disable auto documentation.r,   z
:orange_circle: [red]The docs were generated in simple mode. Updating python to a more recent version will result in richer documentation.[/])r9   r<   requestsgetstatus_coder   r7   r5   	importlibimport_moduler   r6   r   writer   r   r   	read_textresearchspanrelative_to)r-   r+   r.   r    r   r   r/   r0   r1   r2   r   r3   r,   r@   r$   rQ   rO   rJ   rP   rN   moduler#   sourcereadmereadme_content
yaml_regexshort_readme_pathshort_demo_paths                               rB   r>   r>   k   s(    
j7	+	+	+ qvvxx               ,CCCCDDPK$-K^i-CDDMh~	=/IJJPbQQKN$E$E$EFFD 	D		n&B&B&BCC 
  
 
 fT  f  f  f
 
 	
 $T**F*622T9  	AKK?@@@#$ (-]## =%%c%jj3t99# 3
 
 
 )j(#@@@ 	AGGFOOO ]I]]]  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 )i'w??? 	1GGCLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   	@KK>???$]D%{
 
 l++5577,g666 
	!H. J %'(?*//*;*;B*?(?@6IGGFOOO X|XXX  
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	  
 ..::>JJy:566BB>RR wo  w  why  w  w  w	
 	
 	
 H ^	
 	
 	
 	
 	
 sC   37751F22F69F6G99G= G=&A-KK#&K#)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   )F)r-   r
   r+   r7   r.   rD   r    rE   r   rE   r   rE   r/   r7   r0   r   r1   r   r2   r   r   rF   r3   r   r,   rE   )
__future__r   rW   r[   pathlibr   typingr   r   rT   tomlkitr:   typerr   r   gradio.analyticsr	   gradio.cli.commands.displayr
   _docs_assetsr   _docs_utilsr   r   r   r   rC   r>        rB   <module>rq      sW   " " " " " "     				       ! ! ! ! ! ! ! !      " " " " " " " " 7 7 7 7 7 7 8 8 8 8 8 8       P P P P P P P P P P P P 	S		SWNR 	 	 	 	 	9U
 U
 U
 U
 U
J _
 _
 _
 _
 _
 _
 _
rp   