
    ;3h                       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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	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)    )annotationsN)Path)	AnnotatedAnyOptional)ArgumentOption)custom_component_analytics)LivePanelDisplay   )css)extract_docstringsget_deepmake_markdown
make_space.TFc                @   t        ddddd       t        |       j                         }|rt        |      j                         nt        d      j                         }	|r|nd}
|	|
z  }|rt        |      j                         n|dz  }|s|st        d      t	               5 }|j                  dt        |j                         dd	
       |j                  d| d       |dz  j                         st        d| d      t        |dz  d      5 }t        j                  |j                               }ddd       t        ddg      }t        |t              st        d      t        ||||||d||	|||       ddd       y# 1 sw Y   RxY w# 1 sw Y   yxY w)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   suppress_demo_checkpyproject_tomlgenerate_spacegenerate_readme	type_mode
_demo_path	_demo_dir_readme_path	space_url_component_dir)r
   r   resolve
ValueErrorr   updatestrr   existsopentomlloadsreadr   
isinstancerun_command)pathdemo_dir	demo_namereadme_pathr'   r!   r"   r   r(   r%   
_demo_namer$   r&   r   fdatar   s                    c/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/gradio/cli/commands/components/docs.py_docsr<      s   B  $Z'')N,4X&&($v,:N:N:PI'XJZ'J'2[!!#8T  /HII		 #
tEc.J]J]F^E__bc 	 	
 	<^<LL`a	
 !1199;>~>NcR  .#33gF 	(!::affh'D	( y&12$$?@@ 3)+!%)	
-#
 #
	( 	(#
 #
s&   !A2F$F7AFF	FFc                   t        |d      5 }|j                         }d d d        t        j                  d| d      j                  }|dk(  xs d}t        |ddg      }t        t        |dd	g      xs d
      }t        |g d      }|
r|
nt        |g d      }|s|st        d| d      t        j                  |      }t        |      \  }}|r|s| j                  d       t        |||||n
t        |      ||n
t        |      ||n
t        |      ||	      }t        |dz  dd      5 }|j                  |       |s| j                  d| d       d d d        t        |dz  dd      5 }|j                  t               d d d        |r|s| j                  d       t        |||||||      }t!        |	      j#                         }t        |	dd      5 }t%        j&                  d|      }||d |j)                         d    |z   }|j                  |       |s| j                  d|	 d       d d d        |rOt!        |	      j+                  |      }t!        |dz        j+                  |      }| j                  d| d| d       |dk(  r| j                  d       y y # 1 sw Y   xY w# 1 sw Y   _xY w# 1 sw Y   =xY w# 1 sw Y   xY w) Nr   r   zhttps://pypi.org/pypi/z/json   Fr   versiondescription )r   urls
repository)r   rB   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   r@   local_versionr   rD   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.   r1   requestsgetstatus_coder   r,   r*   	importlibimport_moduler   r+   r   writer   r   r   	read_textresearchspanrelative_to)r   r   r    r   r!   r"   r#   r$   r%   r&   r'   r(   r   r9   r   rG   rE   r@   rF   rD   moduler   sourcereadmereadme_content
yaml_regexshort_readme_pathshort_demo_paths                               r;   r3   r3   m   s&    
j7	+ qvvx ,,!7vUCDPPK$-K^i-CDMh~	=/IJPbQKN$EFD  	n&BC 
 LTF  Se  f
 	
 $$T*F*62T9KK?@#$ (]# =%c%j3t9# 3
 )j(#@ 	AGGFOCI;n]	 )i'w? 	1GGCL	 KK>?$]D%{
 l+557,g6 
	!H.J %'(?*//*;B*?@6IGGFOF|nTWX
	  .::>Jy:56BB>REoEVVghygz  {v  w	
 H ^	
 [ R	 		 	
	 
	s0   J,3)J95K!AK,J69KKK)r4   zHAnnotated[Path, Argument(help='The directory of the custom component.')]r5   zEAnnotated[Optional[Path], Option(help='Path to the demo directory.')]r6   z?Annotated[Optional[str], Option(help='Name of the demo file.')]r7   zEAnnotated[Optional[Path], Option(help='Path to the README.md file.')]r'   zNAnnotated[Optional[str], Option(help='URL of the Space to use for the demo.')]r!   zbAnnotated[bool, Option(help='Create a documentation space for the custom compone.', is_flag=True)]r"   z_Annotated[bool, Option(help='Create a README.md file for the custom component.', is_flag=True)]r   zPAnnotated[bool, Option(help='Suppress demo warnings and errors.', is_flag=True)])F)r   r   r   r,   r    zdict[str, Any]r   boolr!   r\   r"   r\   r#   r,   r$   r   r%   r   r&   r   r'   z
str | Noner(   r   r   r\   )
__future__r   rM   rQ   pathlibr   typingr   r   r   rJ   tomlkitr/   typerr   r	   gradio.analyticsr
   gradio.cli.commands.displayr   _docs_assetsr   _docs_utilsr   r   r   r   r<   r3        r;   <module>rh      sO   "  	  + +   " 7 8  P P 	S	 	QU 	 	 	 	 	=W
W
	W
 OW
W
W
W
()W
01W
N _

_

_
 #_
 	_

 _
 _
 _
 _
 _
 _
 _
 _
 _
rg   