
    '<i                     ,   d 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
 ddlmZ ddlmZ ddlmZ dd	lmZ d
 Z ee      Z ej*                   ed            	 ddddddedeedz   ede      f   dee	dz   ede      f   dedef
d       Zy)z1Generate documentation for Cyclopts applications.    )Path)	Annotated)app)FORMAT_ALIASES	DocFormatnormalize_format)Group)load_app_from_script)	Parameter)UNSETc                    | j                  d      }| j                  d      }|j                  t        u r|j                  t        u rt        d      |j                  rt	        |j                  d      st        d      |j                  j
                  j                         }|st        d      |j                  d      }|st        d      t        j                   |      }|ft        j                         D cg c]  }t        |      d	k  sd|  }}t        d
| ddj                  t        t        |                   d      ||_        y y c c}w )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           w/home/jay/workspace/.worktrees/task-2057-dev2/scripts/.codegraph-venv/lib/python3.12/site-packages/cyclopts/cli/docs.py_format_group_validatorr$      sb   $((4J$((4J5 u$]^^wz/?/?'Jabb!!((..0_  ]]3'
8 
 ),,Z8"9G9L9L9N#`#RUVYRZ^_R_auI#` #`=fX F))-6#>R:S3T)U(V W89  +
E !6 $as   <EE)	validator )negative)default_parameterNF   )formatinclude_hiddenheading_levelscriptoutputz-o)aliasgroupr*   z-fr+   r,   c                    |t        d      t        |      }t        |       \  }}|j                  |||      }|r|j	                  |       yt        |       y)a  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   >   sf    < ~/00f%F%f-JGQ((%# ) 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   