+
    Q(i4                     D   R t ^ RIHtHt ^ RIt^ RIHt ^ RIHt ]'       d   ^ RI	H
t
 ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt ]P"                  ! ]4      t]P(                  ! R	R
7       ! R R4      4       tR R ltRR R lltRR R lltR R lt ! R R]4      tR R ltR# )z:Sphinx extension for automatic Cyclopts CLI documentation.)TYPE_CHECKINGAnyN)__version__)
import_app)Sphinx)nodes)logging)SphinxDirectiveT)kw_onlyc                      a  ] tR t^t o Rt^t^tRtRtRt	Rt
RtRtRt]V 3R lR l4       t]V 3R lR l4       tV 3R ltR	tV tR# )
DirectiveOptionsz)Configuration for the Cyclopts directive.NFc                $   < V ^8  d   QhRS[ RR/# )   optionsreturnr   )dict)format__classdict__s   "Y/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/cyclopts/ext/sphinx.py__annotate__DirectiveOptions.__annotate__&   s       );     c                    / p\         P                  ! V 4       F  pVP                  P                  RR4      pVP                  \
        J d   WA9   d   RW#P                  &   KI  KK  WA9   g   KS  W,          pVP                  R9   dm   V'       dU   VP                  R4       Uu. uF*  qfP                  4       '       g   K  VP                  4       NK,  	  upW#P                  &   K  . W#P                  &   K  WRVP                  &   K  	  V ! R/ VB # u upi )z1Create options from directive options dictionary._-T,commandsexclude_commands )attrsfieldsnamereplacetypeboolsplitstrip)clsr   kwargsfieldoption_namevaluecmds   &&     r   	from_dictDirectiveOptions.from_dict%   s     \\#&E**,,S#6KzzT! ))-F::& * ',::!AAEJ[[QTEU-eEUcYbYbYdkciikEU-ezz* .0zz*).5::&+ '0 }V} .fs    D<Dc                6   < V ^8  d   QhRS[ S[S[3,          /# )r   r   r   strr   )r   r   s   "r   r   r   D   s      $sCx. r   c                    ^ RI Hp  \        V P                  \        V P
                  \        V P                  /p/ p\        P                  ! \        4       Fg  pVP                  P                  RR4      pVP                  R9   d   V P                  pM&VP                  VP                  V P                  4      pWRV&   Ki  	  V# )z9Generate Sphinx option_spec from DirectiveOptions fields.)
directivesr   r   r   )docutils.parsers.rstr4   r%   flagintnonnegative_intr2   	unchangedr    r!   r   r"   r#   getr$   )r4   type_mappingoption_specr*   r+   	validators         r   specDirectiveOptions.specC   s     	4 *//++%%
 \\"23E**,,S#6Kzz==&00	(,,UZZ9M9MN	'0$ 4 r   c                   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[S[,          R,          ;R&   S[S[,          R,          ;R&   S[;R&   S[;R&   S[;R&   S[;R	&   S[;R
&   # )r   heading_levelmax_heading_levelNr   r   no_recursiveinclude_hiddenflatten_commandscode_block_titleskip_preamble)r7   listr2   r%   )r   r   s   "r   r   r      s      	 
   3i$%  3i$&-       "  "   r   r   )__name__
__module____qualname____firstlineno____doc__rA   rB   r   r   rC   rD   rE   rF   rG   classmethodr.   staticmethodr>   __annotate_func____static_attributes____classdictcell__r   s   @r   r   r      si     3M!%H)- L N""M :  _  r   r   c          
          V ^8  d   QhR\         R\        \         ,          R\        \         ,          R,          R\        \         ,          R,          R\        /# )r   command_namecommand_pathcommands_filterNr   r   )r2   rH   r%   )r   s   "r   r   r   [   sP     7 77s)7 #Y%7 3i$&	7
 
7r   c                   RP                  W.,           4      pV'       dN   W9   g   WC9   d   R# \        \        V4      4       F'  pRP                  VRV^,            4      pWc9   g   K&   R# 	  Ve`   W9   g   WB9   d   R# \        \        V4      4       F'  pRP                  VRV^,            4      pWb9   g   K&   R# 	  V'       g	   W9   d   R# R# R# )a  Check if a command should be included in documentation.

Parameters
----------
command_name : str
    The name of the command.
command_path : list[str]
    The full path to the command (including parent commands).
commands_filter : list[str] | None
    If specified, only include commands in this list.
exclude_commands : list[str] | None
    If specified, exclude commands in this list.

Returns
-------
bool
    True if the command should be included.
.FNT)joinrangelen)rU   rV   rW   r   	full_pathiparent_paths   &&&&   r   _should_include_commandr`   [   s    2 67I +y/Ls<()A((<!a%#89K. * " *i.Js<()A((<!a%#89K- *
  ? r   c          
          V ^8  d   QhR\         R\        \        ,          R,          R\        \        ,          R,          R\        \        ,          R,          R\         /# )r   r   rW   Nr   r_   r   )r   rH   r2   )r   s   "r   r   r      sU         #Y%  3i$&  cT!	 
 
 r   c                x    Vf   . p/ pV P                  4        F  w  rV\        WSW4      '       g   K  WdV&   K  	  V# )a  Filter commands based on inclusion/exclusion lists.

Parameters
----------
commands : dict
    Dictionary mapping command names to App instances.
commands_filter : Optional[List[str]]
    If specified, only include commands in this list.
exclude_commands : Optional[List[str]]
    If specified, exclude commands in this list.
parent_path : List[str]
    Path to the parent command for nested commands.

Returns
-------
dict
    Filtered commands dictionary.
)itemsr`   )r   rW   r   r_   filteredr"   apps   &&&&   r   _filter_commandsrf      sB    0 H^^%	"4oXX TN & Or   c                R    V ^8  d   QhR\         R\        R\        \         ,          /# )r   content
skip_titler   )r2   r%   rH   )r   s   "r   r   r      s%      # 4 DI r   c                   V P                  4       p. p^ pV\        V4      8  EdU   W$,          pV'       dw   V^ 8X  dp   VP                  4       '       dZ   V^,           \        V4      8  dC   W$^,           ,          P                  4       pV'       d   \        V4      0 Rm8:  d   V^,          pK  VP                  4       P	                  R4      '       d   V^,          pV\        V4      8  d<   W$,          P                  4       '       d    W$,          ^ ,          R9   d   V^,          pKK  V\        V4      8  d&   W$,          P                  4       '       g
   V^,          pEKH  VP                  V4       V^,          pEKe  V# )z3Process RST content to remove problematic elements.z.. contents::z 	>   "r   =^~)
splitlinesr\   r'   set
startswithappend)rh   ri   lines	processedr^   line	next_lines   &&     r   _process_rst_contentrw      s    EI	A
c%j.x !q&TZZ\\a!ec%j6H!e**,IS^/HHQ ::<""?33FAc%j.UX^^%5%5%(1+:NQ3u:~ehnn&6&6Q	Qr   c                `    V ^8  d   QhR\         \        ,          R\        R\         R,          /# )r   rs   stater   
nodes.Node)rH   r2   r   )r   s   "r   r   r      s/     h hc h3 h4;M hr   c                D
   ^ RI Hp . p^ pV\        V 4      8  Ed   W,          pV^,           \        V 4      8  Ed   W^,           ,          P                  4       pV'       Ed   \        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       Edc   \
        P                  ! 4       pVP                  4       pVP                  4       P                  RR4      P                  RR4      .VR	&   V\
        P                  ! VR
7      ,          p. p	V^,          pV\        V 4      8  d   V^,           \        V 4      8  d   W^,           ,          P                  4       MRp
V
'       d<   \        ;QJ d    R V
 4       F  '       d   K   RM	  RM! R V
 4       4      '       d   M"V	P                  W,          4       V^,          pK  V	'       d   VP                  V! V	4      ^ V4       VP                  V4       EK  VP                  4       R8X  EdG   V^,          pV\        V 4      8  d&   W,          P                  4       '       g
   V^,          p. pV\        V 4      8  dG   W,          P                  R4      '       d*   VP                  W,          R,          4       V^,          pKV  V'       dq   \
        P                  ! 4       pRP                  V4      Vn        VP                  \
        P                   ! RP                  V4      4      4       VP                  V4       V\        V 4      8  d&   W,          P                  4       '       g
   V^,          pEKP  VP                  4       '       Ed   V.p	V^,          pV\        V 4      8  Ed%   V^,           \        V 4      8  d   W^,           ,          P                  4       MRpV'       d<   \        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       d   MW,          P                  4       R8X  d   MW,          P                  4       '       gQ   V	P                  W,          4       V^,          pV\        V 4      8  g   W,          P                  4       '       g   M&EK  V	P                  W,          4       V^,          pEK5  \
        P"                  ! 4       pVP                  V! V	4      ^ V4       VP$                  '       d   VP'                  VP$                  4       EK  EK	  V^,          pEK  V# )z$Create section nodes from RST lines.)
StringListc              3   *   "   T F	  qR 8H  x  K  	  R# 5ir   Nr   .0cs   & r   	<genexpr>(_create_section_nodes.<locals>.<genexpr>   s      =9ac9   FT r   z	cyclopts-zcli-cyclopts-idstext c              3   *   "   T F	  qR 8H  x  K  	  R# 5ir~   r   r   s   & r   r   r      s     1WDVqs(DVr   z::z    :   NN
c              3   *   "   T F	  qR 8H  x  K  	  R# 5ir~   r   r   s   & r   r   r   #  s     $Ay!#Xyr   )docutils.statemachiner|   r\   r'   allr   sectionlowerr#   titlerr   nested_parserq   literal_blockrZ   	rawsourceText	paragraphchildrenextend)rs   ry   r|   resultr^   ru   rv   r   
title_textcontent_linesnext_line_strippedliteral_contentr   paras   &&            r   _create_section_nodesr      s   0F	A
c%j.x q53u:!e**,IySS =9 =SSS =9 ===--/!ZZ\
","2"2"4"<"<S#"F"N"N{\k"l!m5;;J77 !#Q#e*nABQUAS1u););)=Y[&)cc1WDV1Wccc1WDV1W.W.W!((2FA &&z-'@!WMg& ::<4FA 3u:~ehnn&6&6Q !Oc%j.UX%8%8%@%@&&ux|4Q  % 3 3 5*.))O*D'$$UZZ		/0J%KLm, 3u:~ehnn&6&6Q ::<<!FMFA c%j.45ECJ4FEa%L..0B	$Ay$A$Ay$A!A!A 8>>#t+ x~~''!((2FACJehnn.>.> /? "((2FA ??$Dz-8!TB}}}dmm,  FAMr   c                      a  ] tR tRt o RtRt^t^ tRt]	P                  4       tV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR ltRtV tR# )CycloptsDirectiveiB  z;Sphinx directive for documenting Cyclopts CLI applications.Fc                .   < V ^8  d   QhRS[ R,          /# )r   r   rz   )rH   )r   r   s   "r   r   CycloptsDirective.__annotate__K  s     	U 	UT,' 	Ur   c                   V P                   ^ ,          p\        P                  V P                  4      p V P	                  W4      pV P                  W24      #   \         d   pT P                  RT 24      u Rp?# Rp?ii ; i)z2Generate documentation nodes for the Cyclopts app.z)Error generating Cyclopts documentation: N)	argumentsr   r.   r   _generate_documentation_create_nodes	Exception_error_node)selfmodule_pathoptsrst_contentes   &    r   runCycloptsDirective.runK  sw    nnQ'))$,,7	U66{IK%%k88 	U##&OPQs$STT	Us   !A A?!A:4A?:A?c                ,   < V ^8  d   QhRS[ RS[RS[ /# )r   r   r   r   )r2   r   )r   r   s   "r   r   r   V  s$     
 
3 
>N 
SV 
r   c                   ^ RI Hp \        V4      pV! VVP                  '       * VP                  VP
                  VP                  VP                  VP                  VP                  RVP                  VP                  R7      # )z'Generate RST documentation for the app.)generate_rst_docsT)
	recursiverD   rA   rB   rE   rW   r   no_root_titlerF   rG   )cyclopts.docs.rstr   r   rC   rD   rA   rB   rE   r   r   rF   rG   )r   r   r   r   re   s   &&&  r   r   )CycloptsDirective._generate_documentationV  sv    7% !+++..,,"44!22 MM!22!22,,
 	
r   c                :   < V ^8  d   QhRS[ RS[RS[R,          /# )r   r   r   r   rz   )r2   r   rH   )r   r   s   "r   r   r   k  s(     8 8 84D 8lI[ 8r   c                F    \        VRR7      p\        W0P                  4      # )z'Create docutils nodes from RST content.F)ri   )rw   r   ry   )r   r   r   rs   s   &&& r   r   CycloptsDirective._create_nodesk  s    $[UC %UJJ77r   c                4   < V ^8  d   QhRS[ RS[R,          /# )r   messager   rz   )r2   rH   )r   r   s   "r   r   r   r  s$     @ @3 @4+= @r   c                    \         P                  V4       \        P                  ! R\        P                  ! VR7      4      .# )z,Create an error node with the given message.r   r   )loggererrorr   r   )r   r   s   &&r   r   CycloptsDirective._error_noder  s+    WBW =>??r   r   N)rI   rJ   rK   rL   rM   has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacer   r>   r<   r   r   r   r   rQ   rR   rS   s   @r   r   r   B  sY     EK %"'')K	U 	U
 
*8 8@ @r   r   c                J    V ^8  d   QhRRR\         \        \        3,          /# )r   re   r   r   r1   )r   s   "r   r   r   x  s"      x DcN r   c                F    V P                  R\        4       R\        RRRR/# )z(Setup function for the Sphinx extension.cycloptsversionparallel_read_safeTparallel_write_safe)add_directiver   r   )re   s   &r   setupr   x  s,    j"34;dt r   )N)F)rM   typingr   r   r    r   r   cyclopts.utilsr   sphinx.applicationr   docutilsr   sphinx.utilr   sphinx.util.docutilsr	   	getLoggerrI   r   definer   r`   rf   rw   r   r   r   r   r   r   <module>r      s    @ %    %)  %  0			8	$ dB B BJ7t F>hV3@ 3@lr   