
    -Ph                         d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ dee         fd	Zdee         fd
Zdee         deeef         fdZdS )    N)Path)Union)HtmlFormatter)get_style_by_name)Text)find_packagesreturnc                      h d} t          t                                }t          || z
            }d |D             }|S )zFinds the currently supported themes in the a11y_pygments package.

    Returns:
        themes: list of themes under the a11y_pygments package
    >   a11y_pygments.utilstestscriptsa11y_pygmentsc                 D    g | ]}|                     d           d         S ).   )split.0xs     Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/a11y_pygments/utils/utils.py
<listcomp>z,find_all_themes_packages.<locals>.<listcomp>   s&    ...!aggcll1o...    )setr   list)excludepackagesthemess      r   find_all_themes_packagesr      sK     JIIG=??##H(W$%%F..v...FMr   c                  h    t                      } d | D             } t          j        d|             | S )zhGet themes names from the a11y_pygments package.

    Returns:
        themes: list of themes names
    c                 :    g | ]}|                     d d          S )_-)replacer   s     r   r   z$get_themes_names.<locals>.<listcomp>"   s&    222aaiiS!!222r   zFound pygment themes: )r   logginginfo)r   s    r   get_themes_namesr&      s@     &''F226222FL2&22333Mr   r   save_dirc                     |s
J d            | D ]}}t          |          }t          |dg d          }|                                }|                    t                    d         }|d|j         d| dz  }|                    d	d
          }t          |                              d          	                                s4t          j        t          |                              d                     d|v r't          |                              d| d          }nt          |          |z  dz  }t          j        d|            t          |d          5 }	|	                    |           ddd           n# 1 swxY w Y   dS )zaGenerate css for the available themes.
    Args:
        themes (list): list of themes names
    zMust provide directoryT)         )stylefullhl_linescolorz
.highlight { background: z
; color: #z; }r"   r!   cssdocsz
-style.cssz	style.csszSaving css to wN)r   r   get_style_defsstyle_for_tokenr   background_colorr#   r   joinpathexistsosmkdirr$   r%   openwrite)
r   r'   themer,   	formatterr0   r/   packageoutfs
             r   generate_cssrA   '   s   
 ------  !%((!D999MMM	&&((%%d++G4X5+AXXUXXX	
 --S))H~~&&u--4466 	5HT(^^,,U33444Xx..))%G1G1G1GHHCCx..7*[8C+c++,,,#s^^ 	qGGCLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	% s   FF	F	)r$   r8   pathlibr   typingr   pygments.formattersr   pygments.stylesr   pygments.tokenr   
setuptoolsr   r   strr   r&   rA    r   r   <module>rJ      s     				             - - - - - - - - - - - -       $ $ $ $ $ $$s)    	$s) 	 	 	 	c eCI.>      r   