
    -Ph                         d 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mZ d	ed
eddfdZdededefdZdde
fdZdS )zrHandle Pygments css.

inspired by the Furo theme
https://github.com/pradyunsg/furo/blob/main/src/furo/__init__.py
    )partial)Path)HtmlFormatter)get_all_styles)Sphinx   )get_theme_options_dict
maybe_warn	formatterprefixreturnNc              #      K   |                                  D ]}| d| V  |                     |          E d{V  |                     |          E d{V  dS )zGGet styles out of a formatter, where everything has the correct prefix. N)get_linenos_style_defsget_background_style_defsget_token_style_defs)r   r   lines      \/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pydata_sphinx_theme/pygments.py_get_stylesr      s      0022 ! !  $      226:::::::::--f55555555555    light_style
dark_stylec                    t          |           }t          |          }g }d}|                    t          ||                     d}|                    t          ||                     d                    |          S )zoGenerate the theme-specific pygments.css.

    There is no way to tell Sphinx how the theme handles modes.
    )stylez#html[data-theme="light"] .highlight)r   z"html[data-theme="dark"] .highlight
)r   extendr   join)r   r   light_formatterdark_formatterlineslight_prefixdark_prefixs          r   get_pygments_stylesheetr#      s    
 $+666O"444NE8L	LL_\BBBCCC6K	LL^K@@@AAA99Ur   appc                    |dS | j         sJ t          |           }t          t          |           }t	          t                                }t          dd          }|                                D ]\  }}||vr|d         }d| d}|                    |d          }	|	9t          | j         d          r$| j         j
                                        |         }	|	|vr|	 |d	|	 d
| d           |}	|dk    r|	}
|	}t          | j         j                  dz  dz  }|                    d          5 }|                    t!          |
|                     ddd           dS # 1 swxY w Y   dS )a  Overwrite pygments.css to allow dynamic light/dark switching.

    Sphinx natively supports config variables `pygments_style` and
    `pygments_dark_style`. However, quoting from
    www.sphinx-doc.org/en/master/development/theming.html#creating-themes

        The pygments_dark_style setting [...is used] when the CSS media query
        (prefers-color-scheme: dark) evaluates to true.

    This does not allow for dynamic switching by the user, so at build time we
    overwrite the pygment.css file so that it embeds 2 versions:

    - the light theme prefixed with "[data-theme="light"]"
    - the dark theme prefixed with "[data-theme="dark"]"

    Fallbacks are defined in this function in case the user-requested (or our
    theme-specified) pygments theme is not available.
    Ntangomonokai)lightdarkr   	pygments__stylethemezHighlighting style z( not found by pygments, falling back to .r(   _staticzpygments.cssw)builderr	   r   r
   listr   dictitemsgethasattrr,   get_optionsr   outdiropenwriter#   )r$   	exceptiontheme_optionswarningpygments_styles	fallbackslight_or_darkfallback	style_key
style_namelight_theme
dark_themepygments_cssfs                 r   overwrite_pygments_cssrG   ,   s   & ;*3//Mj#&&G>++,,O7333I#,??#4#4 $ $x?**&q)H 6555	"&&y$77
'#+w"?"?*6688CJ _,,%3* 3 3'/3 3 3   "J G##$KK#JJ *++i7.HL			3		 B1	'Z@@AAAB B B B B B B B B B B B B B B B B Bs   4$E%%E),E))N)__doc__	functoolsr   pathlibr   pygments.formattersr   pygments.stylesr   sphinx.applicationr   utilsr	   r
   strr   r#   rG    r   r   <module>rQ      s                - - - - - - * * * * * * % % % % % % 5 5 5 5 5 5 5 56= 6# 6$ 6 6 6 6 # #    &;B ;B ;B ;B ;B ;B ;B ;Br   