+
    Q(i                        R t ^ RIHt ^ RIHt ^ RIHt ^ RIHtH	t	H
t
HtHtHtHtHtHtHtHtHtHt ]'       d   ^ RIHt RR R lltR	 R
 ltRR R lltRR R lltR R ltR R ltR R ltR R ltR R ltRR R lltR# )z5Documentation generation functions for cyclopts apps.)TYPE_CHECKING)extract_text)DEFAULT_FORMAT)adjust_filters_for_subcommandbuild_command_chainextract_descriptionextract_usageformat_usage_linegenerate_anchorget_app_infois_all_builtin_flagsiterate_commandsnormalize_command_filtersshould_include_commandshould_show_commands_listshould_show_usage)AppNc                   V ^8  d   QhRRR\         R\        R\        \        ,          R,          R\        \        ,          R,          R\        \        ,          R,          R	\         R
\        \        \        R3,          ,          /# )   appr   include_hiddenprefixcommands_filterNexclude_commandsparent_pathskip_filtered_commandreturn)boolstrlisttuple)formats   "\/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/cyclopts/docs/markdown.py__annotate__r#      s     3 3	33 3 #Y%	3
 3i$&3 cT!3  3 
%U

3    c                h   . pVf   . p\        W44      w  r\        W4       F  w  r\        WWV4      '       g   K  T;'       d    VP                  pV'       g#   V'       d   V V
 2MT
pVP	                  W34       WZ.,           pV V
 R2p\        VVVVVVRR7      pVP                  V4       K  	  V# )zgRecursively collect all commands for table of contents.

Returns a list of (display_name, app) tuples.
 F)r   r   r   r   r   r   )r   r   r   	_commandsappend_collect_commands_for_tocextend)r   r   r   r   r   r   r   commandsnormalized_commands_filternormalized_exclude_commandsnamesubappskip_this_commanddisplay_namenested_pathnested_prefixnesteds   &&&&&&&          r"   r)   r)      s     H>W?; )=%9X^
 
  2FFf6F6F 06fXdV,DLOO\23 "F*!(4&**) +-#"'
 	7 >: Or$   c                z    V ^8  d   QhR\         \        ,          R\         \        \        R3,          ,          RR/# )r   linesr+   r   r   N)r   r   r    )r!   s   "r"   r#   r#   Q   s4     = =c =d5e;L6M =RV =r$   c           	     2   / pV F  w  r4VP                  R4      ^,
          pRV,          pVP                  4       R,          p\        V4      pW9   d#   W(;;,          ^,          uu&   V RW(,           2pM^ W(&   V P                  V RV RV R24       K  	  R# )	zGenerate TOC entries with proper indentation.

Parameters
----------
lines : list[str]
    List to append TOC entries to.
commands : list[tuple[str, "App"]]
    List of (display_name, app) tuples.
r&   z    _z- [``](#)N)countsplitr
   r(   )	r6   r+   anchor_countsr1   _appdepthindentcmd_nameanchors	   &&       r"   _generate_toc_entriesrD   Q   s     %'M&""3'!+%%%'+ ."!Q&!xq!6 78F$%M!xtH:T&;< 'r$   c                N    V ^8  d   QhRRR\         R\        \        R3,          /# )r   r   r   r   r   )r   dictr   )r!   s   "r"   r#   r#   m   s*      E 4 4U
CS r$   c                ^    / pV P                   '       d   \        W4       F	  w  r4WBV&   K  	  V# )a  Build mapping of command names to App objects.

Parameters
----------
app : App
    The app to extract commands from.
include_hidden : bool
    Whether to include hidden commands.

Returns
-------
dict[str, App]
    Mapping of command names to App instances.
)r'   r   )r   r   command_mapr.   r/   s   &&   r"   _build_command_maprI   m   s2     K
}}},SALD & Br$   c                V    V ^8  d   QhR\         \        ,          R\        R\        RR/# )r   r6   content	add_blankr   N)r   r   r   )r!   s   "r"   r#   r#      s-      d3i # $ RV r$   c                n    V'       d   V P                  V4       V'       d   V P                  R4       R# R# )zAppend content to lines if present, optionally adding blank line.

Parameters
----------
lines : list[str]
    List to append to.
content : str
    Content to append (only if non-empty).
add_blank : bool
    Whether to add a blank line after content.
 N)r(   )r6   rK   rL   s   &&&r"   _append_if_presentrO      s'     WR r$   c                N    V ^8  d   QhRRR\         R\        \         ,          RR/# )r   r   r   help_formatr6   r   N)r   r   )r!   s   "r"   r#   r#      s-      U  T#Y SW r$   c                    \        W4      pV'       dP   VR9   p\        VRVR7      pV'       d3   VP                  VP                  4       4       VP                  R4       R# R# R# )zExtract and render app description.

Parameters
----------
app : App
    The app to extract description from.
help_format : str
    Help format (e.g., "markdown", "rich").
lines : list[str]
    List to append description to.
Npreserve_markuprN   markdownmd)r   r   r(   strip)r   rQ   r6   descriptionpreserve	desc_texts   &&&   r"   _render_description_sectionr\      sV     &c7K"44 dHM	LL*+LL 	 r$   c                d    V ^8  d   QhRRR\         \        ,          R\         \        ,          RR/# )r   r   r   command_chainr6   r   Nr   r   )r!   s   "r"   r#   r#      s1      u T#Y tCy UY r$   c                B   \        V 4      '       d   \        V 4      pV'       dy   VP                  R4       \        V\        4      '       d   TpM\        VRRR7      p\        WA4      pVP                  V4       VP                  R4       VP                  R4       R# R# R# )zRender usage console block.

Parameters
----------
app : App
    The app to extract usage from.
command_chain : list[str]
    Command chain for usage line.
lines : list[str]
    List to append usage to.
z
```consoleNFrS   z```rN   )r   r   r(   
isinstancer   r   r	   )r   r^   r6   usage
usage_text
usage_lines   &&&   r"   _render_usage_sectionre      s     c"LL&%%%"
)%uM
*:EJLL$LLLL  r$   c                    V ^8  d   QhRRR\         R\        R\        \         ,          R,          R\        \         ,          R,          R\        R	\        \         ,          R
R/# )r   r   r   app_namer   r   Nr   r   r6   r   )r   r   r   )r!   s   "r"   r#   r#      sn     ) )	)) ) #Y%	)
 3i$&)  ) 9) 
)r$   c           	         \        T TV'       d   V R2MRVVVR7      pV'       dA   VP                  R4       VP                  R4       \        Wg4       VP                  R4       R# R# )a  Generate and render table of contents.

Parameters
----------
app : App
    The app to generate TOC for.
app_name : str
    Application name for TOC prefixes.
include_hidden : bool
    Whether to include hidden commands.
commands_filter : list[str] | None
    Commands to include.
exclude_commands : list[str] | None
    Commands to exclude.
skip_filtered_command : bool
    Whether to skip the single filtered command in TOC.
lines : list[str]
    List to append TOC to.
r&   rN   )r   r   r   r   r   z## Table of ContentsN)r)   r(   rD   )r   rg   r   r   r   r   r6   toc_commandss   &&&&&&& r"   _render_tocrj      sa    : -%!)(1~r')3L +,Re2R	 r$   c                >    V ^8  d   QhR\         \        ,          RR/# )r   r6   r   Nr_   )r!   s   "r"   r#   r#      s      T#Y 4 r$   c                T   VP                  4        V P                  RR7      pV! RRV4       VP                  4       P                  4       pV'       dV   V P                  '       d    VP                  RV P                   R24       VP                  V4       VP                  R4       R# R# )zRender a parameter panel as-is.

Parameters
----------
panel : HelpPanel
    The parameter panel to render.
formatter : MarkdownFormatter
    Formatter to use for rendering.
lines : list[str]
    List to append rendered content to.
rN   )titleN****:
)resetcopy
get_outputrX   rm   r(   )panel	formatterr6   
panel_copyoutputs   &&&  r"   _render_parameter_panelrw      s     OO"%JdD*%!!#))+F ;;;LL2ekk]%01VR	 r$   c                    V ^8  d   QhR\         R\        \        R3,          R\         \        ,          R\        \        ,          R,          R\        \        ,          R,          R\         /# )	r   entriesrH   r   r   normalized_filterNnormalized_excluder   )r   rF   r   set)r!   s   "r"   r#   r#     sa     ( ((c5j!( c( 3x$	(
 C4( 
(r$   c                   . pV  F  pVP                   '       g   K  VP                   ^ ,          pVP                  V4      pVf    Vf   Vf   VP                  V4       KZ  K\  K^  \        WrW4V4      '       g   Ks  VP                  V4       K  	  V# )a  Filter command entries based on inclusion/exclusion rules.

Parameters
----------
entries : list
    Command entries to filter.
command_map : dict[str, App]
    Mapping of command names to App objects.
parent_path : list[str]
    Parent command path.
normalized_filter : set[str] | None
    Normalized filter set.
normalized_exclude : set[str] | None
    Normalized exclude set.

Returns
-------
list
    Filtered command entries.
)namesgetr(   r   )	ry   rH   r   rz   r{   filtered_entriesentryrB   r/   s	   &&&&&    r"   _filter_command_entriesr     s    6 ;;;{{1~H __X.F~$,1C1K$++E2 2L, *(ARhnoo$++E2  r$   c                $   V ^8  d   QhRRR\         R\         R\        R\        R\        \        ,          R,          R	\         R
\         R\        \        ,          R,          R\        \        ,          R,          R\         R\         R\         R\        /# )r   r   r   	recursiver   heading_levelmax_heading_levelr^   Ngenerate_tocflatten_commandsr   r   no_root_titlecode_block_titleskip_preambler   )r   intr   r   )r!   s   "r"   r#   r#   6  s     G G	GG G 	G
 G 9t#G G G #Y%G 3i$&G G G G 	Gr$   c                   ^ RI Hp . pVf   . pRpMRpT;'       d    VRJ;'       d    \        V4      ^8H  p\        W4      w  pppV'       d   V'       d   RV R2MTpMTpV'       gJ   V
'       d	   V'       g:   \	        W44      pVP                  RV,           RV 24       VP                  R4       V P                  P                  R	\        R
7      pV'       g   V'       g   \        WV4       V'       g   V'       g   \        V VV4       V'       d+   V'       g#   V P                  '       d   \        V VW(V	VV4       V'       Eg)   V P                  V .4      ;_uu_ 4        V P                  . V4      pRRR4       \        W4      w  pp. p\        V RR7      pV! V^,           VRR7      pX EF  w  ppV'       g   V'       d   VP                   '       g   K+  VP"                  R8X  Ed_   VP$                   Uu. uF5  pVP&                  '       d   \)        V VP&                  4      '       d   K3  VNK7  	  p pV '       g   K  \+        V VVVV4      p!V!'       d   VP,                  '       d    VP                  RVP,                   R24       V! F  p"V"P&                  '       g   K  V"P&                  ^ ,          p#V RV# 2p$\/        V$4      p%V"P0                  '       d   \3        V"P0                  RRR7      MRp&V&'       d   VP                  RV# RV% RV& 24       K  VP                  RV# RV% R24       K  	  VP                  R4       EK  EK  VP"                  R8X  g   EK  \5        VVV4       EK  	  M\        W4      w  pp. pV P                  '       Ede   \7        W4       EFT  w  p'p(\9        V'VVVV(4      '       g   K  \;        VV'V4      p)V'       d   Tp*MV
'       d   V'       g   Tp*M	V^,           p*VRJ;'       d    \        V4      ^8H  p+T+;'       d    VRJ;'       d    V'V^ ,          8H  p,T+;'       d,    VRJ;'       d     V^ ,          P=                  V'R,           4      p-T;'       d    T,p.T;'       d    T;'       d    T-p/T;'       d    T,p0V.'       gd   V/'       g\   RP?                  V)4      p1V'       d   RV1 R2MT1p2\	        V*V4      p3VP                  RV3,           RV2 24       VP                  R4       T0;'       g    T/p4V(P                  V V(.4      ;_uu_ 4        V(P                  P                  R	VR
7      p5V5R9   p6V4'       g   \        V(V)V4       \        V(V5V4       V'       Ed   V(P                  . V54      p7\A        V'VV4      w  p8p9\        V8V94      w  p:p;\        V(RR7      p<. p=V'       d   V^,           p>M	V^,           p>V! V>VRR7      p?T;'       d    V(P                  p@V7 EFZ  w  ppV'       g   V'       d   VP                   '       g   K+  VP"                  R8X  Ed   \C        V(4      '       Ed   VP$                   Uu. uF5  pVP&                  '       d   \)        V(VP&                  4      '       d   K3  VNK7  	  pApVA'       g   K  X@'       EdP   . p XA F  p"V"P&                  '       g   K  V"P&                  ^ ,          p#V<PE                  V#4      pBVB'       d   \9        V#V=V:V;XB4      '       g   KZ  V"P0                  '       d   \3        V"P0                  RV6R7      MRp&RP?                  V)V#.,           4      p$\/        V$4      p%V&'       d   V P                  RV# RV% RV& 24       K  V P                  RV# RV% R24       K  	  V '       dW   VP,                  '       d    VP                  RVP,                   R24       VPG                  V 4       VP                  R4       EK  EK  . p!XA Fk  p"V"P&                  '       g   K  V"P&                  ^ ,          p#V<PE                  V#4      pBVB'       d   \9        V#V=V:V;XB4      '       g   KZ  V!P                  V"4       Km  	  V!'       d   VP,                  '       d    VP                  RVP,                   R24       V?PI                  4        VPK                  RV!VP"                  VP0                  R7      pCV?! RRVC4       V?PM                  4       PO                  4       pDVD'       d   VP                  XD4       VP                  R4       EK6  EK9  VP"                  R8X  g   EKM  \5        VV?V4       EK]  	  V'       Ed   V(P                  '       Ed   \A        V'VV4      w  pEpF\        VEVF4      w  pGpH. pI\7        V(V4       EFP  w  pJpK\9        VJXIXGXHVK4      '       g   K  \;        V)XJV4      pLV'       d   TpMMV.'       d   T*pMM	V*^,           pMXG'       d   \A        XJXGXH4      w  pNpOMRpNT;'       d/    XERJ;'       d#    \        XE4      ^8H  ;'       d    XJXE^ ,          8H  pPT;'       dB    XERJ;'       d6    \        XE4      ^8H  ;'       d     XE^ ,          P=                  XJR,           4      pQXKP                  V(VK.4      ;_uu_ 4        \Q        TKTTXMTXLRTXNXFTQTXP;'       g    XQR7      pRRRR4       VP                  XR4       VP                  R4       EKS  	  RRR4       EKW  	  RP?                  V4      PS                  4       R,           pS^ RI*pTVTPW                  RRVS4      pSVS#   + '       g   i     E	L; iu upi u upi   + '       g   i     L; i  + '       g   i     EK  ; i)a  Generate markdown documentation for a CLI application.

Parameters
----------
app : App
    The cyclopts App instance to document.
recursive : bool
    If True, generate documentation for all subcommands recursively.
    Default is True.
include_hidden : bool
    If True, include hidden commands/parameters in documentation.
    Default is False.
heading_level : int
    Starting heading level for the main application title.
    Default is 1 (single #).
max_heading_level : int
    Maximum heading level to use. Headings deeper than this will be capped
    at this level. Standard Markdown supports levels 1-6.
    Default is 6.
command_chain : list[str]
    Internal parameter to track command hierarchy.
    Default is None.
generate_toc : bool
    If True, generate a table of contents for multi-command apps.
    Default is True.
flatten_commands : bool
    If True, generate all commands at the same heading level instead of nested.
    Default is False.
commands_filter : list[str] | None
    If specified, only include commands in this list.
    Supports nested command paths like "db.migrate".
    Default is None (include all commands).
exclude_commands : list[str] | None
    If specified, exclude commands in this list.
    Supports nested command paths like "db.migrate".
    Default is None (no exclusions).
no_root_title : bool
    If True, skip the root application title. Used for plugin contexts.
    Default is False.
skip_preamble : bool
    If True, skip the description and usage sections for the target command
    when filtering to a single command via ``commands_filter``.
    Useful when the user provides their own section introduction.
    Default is False.

Returns
-------
str
    The generated markdown documentation.
)MarkdownFormatterNTF`#r&   rN   rQ   )fallback)r   r   )r   r   table_stylecommandrn   ro   rS   z* [`r9   z): r:   	parameter.)rm   ry   r!   rY   )r   r   r   r   r^   r   r   r   r   r   r   r   
z\n{3,}z

rU   ),!cyclopts.help.formatters.markdownr   lenr   minr(   	app_stackresolver   re   r\   r'   rj   _assemble_help_panelsr   rI   showr!   ry   r~   r   r   rm   r
   rY   r   rw   r   r   r   
startswithjoinr   r   r   r*   rp   	__class__rr   rX   generate_markdown_docsrstripresub)Ur   r   r   r   r   r^   r   r   r   r   r   r   r   r   r6   is_rootskip_current_levelrg   full_command
base_titlerm   effective_levelrQ   help_panels_with_groupsr,   r-   r   rH   rt   grouprs   ecommand_entriesr   r   rB   full_cmd_pathrC   r[   r.   r/   sub_command_chainsub_heading_levelis_single_filteris_exact_targetis_intermediate_pathskip_this_command_titleskip_intermediateskip_target_preambler1   display_fmteffective_sub_levelskip_this_preamblesub_help_formatpreserve_sub
sub_panelssub_commands_filter_for_panelsub_exclude_commands_for_panelnormalized_sub_filter_panelnormalized_sub_exclude_panelsub_command_mapnested_parent_path_for_panelpanel_heading_levelsub_formatterwill_recursecommand_entries_listsub_cmd_appfiltered_panelrv   sub_commands_filtersub_exclude_commandsnormalized_sub_filternormalized_sub_excludenested_parent_pathnested_name
nested_appnested_command_chainnested_heading_levelnested_commands_filterr8   nested_is_targetnested_is_intermediatenested_docsdocr   sU   &&&&&&&&&&&&&                                                                        r"   r   r   6  s6   B D E !^^_D%@^^SEY]^E^ *6c)I&HlJ '7!L>#\  }m?o-.aw78R --'''OK mc%8 m#Ce< McmmmC>DTVhjop ]]C5!!&)&?&?K&P# " C\C
?"$?  )TB &'!+)
	 4LE5!eEJJJ||y( /4mm"tmAGGGPdehjkjqjqPr11m"t& $;#[+?Y[v$ 
 ${{{r%++e%<= "2 ;;;',{{1~H 0<nAhZ,HM%4]%CF_d_p_p_pU->->VZ [vx &  ) %tH:T&YK-X Y %tH:T&-K L "2 LL$' $( ,'y%@S 4X C\C
?"$?  }}} -SALD&)k#=?Z\b   !4M4 R  $1!}$1!$1A$5!  /d:XXs??SWX?X.mm?$3NmmSW[jkl[mSmO nn_D%@nn_UVEWEbEbcgjmcmEn ! '9&L&L_# - ] ]2D ] ]I]#0#D#D_  +3D"xx(9:5E,q1<&)*;=N&O#&9 9:!K=IJR  "6!J!J9J !!3-00"("2"2":":=S^":"_.2DD))&2CUK/O 9!'!=!=b/!RJ Ur8:UUQ13Q Qj57UQM/1M
 '9PT&UO 460 (.;a.?+.;a.?+$5&9.fl%M
 $-#A#A1A1AL )3u-%


$ <<949RSY9Z9Z ,1==4+8aMabhjkjqjqMr= 1 4 $8 (  ,|24-AE',{{{38;;q>6E6I6I(6S+6?U,4,H,G,H,7@* @* -5 05/@/@/@ -99J9JDbn,o13 )2 9<ARV^U_A_8`1@1O+4,;,B,BT(SWX^W__bclbmCn,o,;,B,BT(SWX^W__`Ca,b1 .B4 $3',{{{(-r%++e5L(M$)LL$A$)LL$4	 $3 46 0-AE',{{{38;;q>6E6I6I(6S+6?U,4,H,G,H,7@* @* -5(8(?(?(F .B $4',{{{(-r%++e5L(M$1$7$7$95:__.00@/4||494E4E	 6E 6&N %2$n$M-:-E-E-G-M-M-OF'-(-V(<$)LL$4 $4  #\\[83E=%Pi )3n 9!1!1!1@]8:UA=')= E^+-AEA)+A *,&3CFN3[/Z5');=RTjlv    % 0CCTVack/l,+3@043D03Dq3H0 18U +-BDZ952A 6:2
 * F F 34 ?F F #$7 8A =F F !,/B1/E E	 ) * U U 34 ?U U #$7 8A =U U !4A 6 A A+PSBS T	 / (116:2FGG*@ **3/=.B2C.B-21A0F1E.D1A.>.X.XBX+K H" [1R({ 4\a 10g BF ))E

!
!
#d
*C 
&&FC
(CJi
 "!!8 #uf4P HGw 100s  "l69m
m
.m
!Am'/A.m'%m'm'4m'
m!m?mm'm'5+m'!(m'
Bm'm'"Am'+m'03m'$m'6Bm'>6m':m'm'(A*m'm''m'm'm'%m';m'm';m'#m;/m'6m	m'm$m''m9)FrN   NNNF)T)TF      NTFNNFFF) __doc__typingr   cyclopts._markupr   cyclopts.corer   cyclopts.docs.baser   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r)   rD   rI   rO   r\   re   rj   rw   r   r    r$   r"   <module>r      si    ;   ) (     !3l=8,$,4)X4(VG Gr$   