
    k7i                        S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	J
r
  SSKJr  SSKJr  SSKJr  SS	KJr  S
 r\" \S9r\R*                  " \" SS9S9 SSSSS.S\S\\S-  \" S\S94   S\\	S-  \" S\S94   S\S\4
S jjj5       rg)z1Generate documentation for Cyclopts applications.    )Path)	Annotated)app)FORMAT_ALIASES	DocFormatnormalize_format)Group)load_app_from_script)	Parameter)UNSETc                    U R                  S5      nU R                  S5      nUR                  [        L Ga:  UR                  [        L a  [        S5      eUR                  (       a  [	        UR                  S5      (       d  [        S5      eUR                  R
                  R                  5       nU(       d  [        S5      eUR                  S5      nU(       d  [        S5      e[        R                   " U5      nUcl  [        R                  " 5        Vs/ s H  n[        U5      S	::  d  M  SU 3PM     nn[        S
U SSR                  [        [        U5      5      5       S35      eXQl        g g s  snf )Nz--formatz--outputz>"--format" must be specified when output path is not provided.suffixzB"--output" must be a valid file path when format is not specified.zOutput file must have an extension to infer format (e.g., .md, .html, .rst). Please specify "--format" explicitly or add an extension to the output file..zwInvalid file extension. Output file must have a valid extension after the period. Please specify "--format" explicitly.   z+Cannot infer format from output extension "z". Supported extensions: z, z'. Please specify "--format" explicitly.)getvaluer   
ValueErrorhasattrr   lowerlstripr   keyslenjoinsortedset)argument_collection
format_arg
output_argr   
suffix_keyinferred_formatextsupported_extensionss           K/home/james-whalen/.local/lib/python3.13/site-packages/cyclopts/cli/docs.py_format_group_validatorr$      sh   $((4J$((4J5 u$]^^wz/?/?'J'Jabb!!((..0_  ]]3'
8 
 ),,Z8"9G9L9L9N#`9N#RUVYRZ^_R_IauI9N #`=fX F))-6#>R:S3T)U(V W89  +E !6 $as   E2,	E2)	validator )negative)default_parameterNF   )formatinclude_hiddenheading_levelscriptoutputz-o)aliasgroupr*   z-fr+   r,   c                    Uc  [        S5      e[        U5      n[        U 5      u  pVUR                  UUUS9nU(       a  UR	                  U5        g[        U5        g)ad  Generate documentation for a Cyclopts application.

Parameters
----------
script : str
    Python script path, optionally with ``':app_object'`` notation to specify
    the App object. If not specified, will search for App objects in the
    script's global namespace.
output : Optional[Path]
    Output file path. If not specified, prints to stdout.
format : Optional[DocFormat]
    Output format for documentation. If not specified, inferred from output
    file extension.
include_hidden : bool
    Include hidden commands in documentation.
heading_level : int
    Starting heading level for markdown format.
NzMust specify format.)output_formatr+   r,   )r   r   r
   generate_docs
write_textprint)r-   r.   r*   r+   r,   app_obj_docs_contents           r#   r3   r3   >   sd    < ~/00f%F%f-JG((%# ) L ,'l    )N)__doc__pathlibr   typingr   cyclopts.clir   cyclopts.docs.typesr   r   r   cyclopts.groupr	   cyclopts.loaderr
   cyclopts.parameterr   cyclopts.utilsr   r$   format_groupcommandstrboolintr3    r9   r#   <module>rI      s    7    
 ! 0 (  &+R 67 y"56 QU* 	 **dTk94|#LLM* DL1	3	* * * 7*r9   