o
    iF                     @   s   d Z ddlmZ ddlmZmZ ddlmZ erddlm	Z	 	dde
e ddd	ed
edededdfddZdZ								dddded	ededededB de
e dB dededefddZdS ) z0HTML documentation generation for cyclopts apps.    )TYPE_CHECKING)escape_htmlextract_text)BaseDocGenerator)Applinesappr   include_hiddenapp_nameprefixdepthreturnNc              	   C   s   |j sdS t||D ]X\}}|r| | n|}| d|dd  }	d|d  }
| |
 d|	 d| d |j r[| |
 d	 t| |||| d|d  | |
 d
 | |
 d qdS )z,Recursively generate HTML table of contents.N- z     z<li><a href="#z"><code>z</code></a>z  <ul>z  </ul>z</li>)	_commandsr   iterate_commandsreplacelowerappend_generate_html_toc)r   r   r	   r
   r   r   namesubappdisplay_name	full_pathindent r   X/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/cyclopts/docs/html.pyr      s   	r   a=  
:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --code-bg: #f5f5f5;
    --link-color: #0066cc;
    --header-bg: #f8f9fa;
    --required-color: #d73027;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--bg-color);
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

h1 { font-size: 2em; border-bottom: 2px solid var(--border-color); padding-bottom: 0.3em; }
h2 { font-size: 1.5em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
h3 { font-size: 1.25em; }
h4 { font-size: 1em; }

code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.9em;
}

pre {
    background: var(--code-bg);
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.9em;
}

pre code {
    background: none;
    padding: 0;
}

.usage-block {
    margin: 16px 0;
}

.usage {
    background: #f8f9fa;
    border-left: 4px solid #0066cc;
}

.description, .app-description, .command-description {
    margin: 16px 0;
    color: var(--text-color);
}

.panel-description {
    margin: 12px 0;
    color: #666;
}

.help-panel {
    margin: 24px 0;
}

/* List styles for commands and parameters */
.commands-list, .parameters-list {
    list-style: none;
    padding-left: 0;
    margin: 16px 0;
}

.commands-list li, .parameters-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.commands-list li:last-child, .parameters-list li:last-child {
    border-bottom: none;
}

.commands-list code, .parameters-list code {
    font-weight: 600;
}

/* Metadata styling */
.parameter-metadata {
    display: inline-flex;
    gap: 8px;
    margin-left: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.metadata-item {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.85em;
    border-radius: 4px;
    background: var(--code-bg);
    border: 1px solid var(--border-color);
}

.metadata-required {
    background: #fee;
    border-color: #fcc;
    color: #c00;
    font-weight: 600;
}

.metadata-default {
    background: #f0f8ff;
    border-color: #d0e8ff;
    color: #0066cc;
}

.metadata-env {
    background: #f0fff0;
    border-color: #d0ffd0;
    color: #080;
}

.metadata-choices {
    background: #fffaf0;
    border-color: #ffd0a0;
    color: #840;
}

.metadata-label {
    font-weight: 600;
    opacity: 0.8;
    text-transform: uppercase;
    font-size: 0.9em;
}

/* Table of Contents */
.table-of-contents {
    background: var(--header-bg);
    border-radius: 6px;
    padding: 16px;
    margin: 24px 0;
}

.table-of-contents h2 {
    margin-top: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.table-of-contents ul {
    margin: 8px 0;
    padding-left: 24px;
}

.table-of-contents li {
    margin: 4px 0;
}

.table-of-contents a {
    color: var(--link-color);
    text-decoration: none;
}

.table-of-contents a:hover {
    text-decoration: underline;
}

/* General link styles */
a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.commands-list a code {
    color: var(--link-color);
}

/* Back to top link */
.back-to-top {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.9em;
    opacity: 0.7;
}

.back-to-top:hover {
    opacity: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .commands-list, .parameters-list {
        font-size: 0.9em;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1e1e1e;
        --text-color: #e0e0e0;
        --border-color: #444;
        --code-bg: #2d2d2d;
        --link-color: #66b3ff;
        --header-bg: #2d2d2d;
    }

    .usage {
        background: #2d2d2d;
        border-left-color: #66b3ff;
    }

    .table-of-contents {
        background: #2d2d2d;
    }

    .metadata-required {
        background: #4a2020;
        border-color: #6a3030;
        color: #ff9999;
    }

    .metadata-default {
        background: #20304a;
        border-color: #304060;
        color: #99ccff;
    }

    .metadata-env {
        background: #204a20;
        border-color: #306030;
        color: #99ff99;
    }

    .metadata-choices {
        background: #4a3020;
        border-color: #604030;
        color: #ffcc99;
    }
}

/* Command sections */
.command-section {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 2px solid var(--border-color);
}

.command-section:first-child {
    border-top: none;
}
TFr   	recursiveheading_level
standalone
custom_csscommand_chaingenerate_tocflatten_commandsc	           1      C   s  ddl m}	 |du rg }g }
|s|s|
d |s2| jd }|}|}|
d| d| d| d n?|r8|d n| jd }d	|}| d
d
|dd  }| d	d
}|
d |
d| d| dt| d| d	 | jj	ddd}t
| |}|rt|d}|r|
dt| d |r|s| jr|
d |
d |
d t|
| ||dd |
d |
d t
| }|r|
d|d  d|d  d |
d t|tr|}nt|d}t
j||dd}|
dt| d |
d | g |}|	|d |||d }|  |D ]%\}}|s#|r#|js#q|s-t
|||_|jr7|dd| q|  }|rG|
| | jrt
| |D ]q\}}t
|||}|rc|}n|d }|
d t|dkr| d
d
|dd   n| d
|  }|
d| d| dtd	| d| d	 ||g |jj	d|d}t
||}|rt|d}|r|
d!t| d t
|} | r|r|d }!n|d" }!|
d|! d|! d |
d t| tr| }"nt| d}"t
j|"|dd}"|
dt|" d |
d |ro|g |}#|r+|d }$n|d" }$|	|$|||d }%|#D ]'\}&}'|sI|&rI|&jsIq9|sUd#d$ |'jD |'_|'jr_|%dd|' q9|%  }(|(ro|
|( |r|jrt
||D ](\})}*t
||)|}+|r|},n|d" },t|*|||,d%d|+d%|d&	}-|
|- q|W d   n	1 sw   Y  |r|
d' |
d( qQ|r|
d( |s|s|
d d)|
}.|r|r|nt}/d*t| d+|/ d,|. d-}0|0S |.S ).a  Generate HTML 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.
    standalone : bool
        If True, generate a complete HTML document with <html>, <head>, etc.
        If False, generate only the body content. Default is True.
    custom_css : str
        Custom CSS to use instead of the default styles.
    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.

    Returns
    -------
    str
        The generated HTML documentation.
    r   )HtmlFormatterNz<div class="cli-documentation">z<hz class="app-title">z</h>r   r   r   z!<section class="command-section">z id="z" class="command-title"><code>z
</code></hhelp_formatrestructuredtext)fallbackz<div class="app-description">z</div>z<div class="table-of-contents">z<h2>Table of Contents</h2>z<ul> z</ul>z	>Usage</hz<div class="usage-block">$)r   z<pre class="usage">z</pre>)r   r	   r
   r"   z!<div class="command-description">   c                 S   s*   g | ]}|j rtd d |j D s|qS )c                 s   s,    | ]}| d p| dp|dkV  qdS )z--helpz	--versionz-hN)
startswith).0nr   r   r   	<genexpr>  s
    
z0generate_html_docs.<locals>.<listcomp>.<genexpr>)namesall)r.   er   r   r   
<listcomp>  s    z&generate_html_docs.<locals>.<listcomp>F)r   r	   r   r    r!   r"   r#   r$   u6   <a href="#top" class="back-to-top">↑ Back to top</a>z
</section>
z<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>z) - CLI Documentation</title>
    <style>
z&
    </style>
</head>
<body id="top">
z
</body>
</html>)cyclopts.help.formatters.htmlr%   r   r   joinr   r   r   	app_stackresolver   extract_descriptionr   r   r   extract_usage
isinstancestrformat_usage_line_assemble_help_panelsresetshowfilter_help_entriesentries
get_outputstripr   build_command_chainlengenerate_html_docsDEFAULT_CSS)1r   r   r	   r   r    r!   r"   r#   r$   r%   r   r
   full_commandtitle	anchor_idr'   description	desc_textusage
usage_texthelp_panels_with_groups	formattergrouppanel
panel_docsr   r   sub_command_chainsub_heading_levelsub_help_formatsub_descriptionsub_desc_text	sub_usageusage_heading_levelsub_usage_text
sub_panelspanel_heading_levelsub_formatter	sub_group	sub_panelsub_panel_docsnested_name
nested_appnested_chainnested_heading_levelnested_docsbody_contentcssdocr   r   r   rH   ?  s<  .

 

 






 





 &







Y



rH   )r   )TFr   TNNTF)__doc__typingr   cyclopts._markupr   r   cyclopts.docs.baser   cyclopts.corer   listr=   boolintr   rI   rH   r   r   r   r   <module>   sl    	
  
	
