
    Pi                        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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)RUFF_INSTALLED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          s|                    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.tomlzu
:warning: [yellow]Ruff is not installed. Code snippets will not be formatted. To install, run `pip install ruff`.[/]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   
isinstancer   run_command)r   r   r   r   r   r   r   r!   r4   r2   
_demo_namer1   r3   r.   fdatar,   s                    w/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/gradio/cli/commands/components/docs.py_docsrD      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?@@@ 	KK I   	 3)+!%)	
 	
 	
 	
7(
 (
 (
 (
 (
 (
 (
 (
 (
 (
 (
 (
 (
 (
 (
 (
 (
 (
s8   BH
'F9H
F			H
F		A0H

HHr.   r
   r,   r8   r/   dict[str, Any]boolr0   r1   r   r2   r3   
str | Noner4   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+   rM   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,   rK   local_versionr%   rO   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.[/])r:   r=   httpxgetstatus_coder   r8   r6   	importlibimport_moduler   r7   r   writer   r   r   	read_textresearchspanrelative_to)r.   r,   r/   r!   r   r   r0   r1   r2   r3   r   r4   r-   rA   r%   rR   rP   rK   rQ   rO   moduler$   sourcereadmereadme_content
yaml_regexshort_readme_pathshort_demo_paths                               rC   r?   r?   v   s(    
j7	+	+	+ qvvxx               )@T@@@AAMK$-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,   r8   r/   rE   r!   rF   r   rF   r   rF   r0   r8   r1   r   r2   r   r3   r   r   rG   r4   r   r-   rF   )
__future__r   rX   r\   pathlibr   typingr   r   rU   tomlkitr;   typerr   r   gradio.analyticsr	   gradio.cli.commands.displayr
   _docs_assetsr   _docs_utilsr   r   r   r   r   rD   r?        rC   <module>rr      sy   " " " " " "     				       ! ! ! ! ! ! ! !      " " " " " " " " 7 7 7 7 7 7 8 8 8 8 8 8                    	S		SWNR 	 	 	 	 	9Z
 Z
 Z
 Z
 Z
T _
 _
 _
 _
 _
 _
 _
rq   