
    G@d                     b    d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZ  G d de          ZdS )	z*SphinxThread used in richtext help plugin.    )QThreadSignal)_)to_text_string)CSS_PATHgenerate_context	sphinxifyc                   j     e Zd ZdZ ee          Z ee          Zdef fd	Z	dddefdZ
d Z xZS )SphinxThreada  
    A worker thread for handling rich text rendering.
    Parameters
    ----------
    doc : str or dict
        A string containing a raw rst text or a dict containing
        the doc string components to be rendered.
        See spyder.utils.dochelpers.getdoc for description.
    context : dict
        A dict containing the substitution variables for the
        layout template
    html_text_no_doc : unicode
        Text to be rendered if doc string cannot be extracted.
    math_option : bool
        Use LaTeX math rendering.
     c                     t          t          |                               |           d | _        d | _        || _        d| _        || _        d S )NF)superr   __init__doccontexthtml_text_no_docmath_optioncss_path)selfparentr   r   	__class__s       Flib/python3.11/site-packages/spyder/plugins/help/utils/sphinxthread.pyr   zSphinxThread.__init__(   sJ    lD!!**6222 0      NFc                     |                                  r9|| _        || _        || _        || _        || _        |                                  dS dS )z,Start thread to render a given documentationN)waitr   r   r   img_pathr   start)r   r   r   r   r   r   s         r   renderzSphinxThread.render0   sS    
 99;; 	DH"DL*D$DM$DMJJLLLLL	 	r   c                 @   | j         }| j        }|rt          |          t          u rd|                                v r	 t          |d         |d         |d         | j        | j        | j                  }t          |d         |          }|d         dk    rPt          |d         |d         |d         g          rt          d          }|dz  }nt          d	          }|d
|z  z  }n# t          $ r2}| j                            t          |                     Y d }~d S d }~ww xY w| j        V	 t          || j                  }n?# t          $ r2}| j                            t          |                     Y d }~d S d }~ww xY w| j                            |           d S )N	docstringnameargspecnote)r!   r"   r#   mathr   r   r   z"No further documentation availablez<div class="hr"></div>zNo documentation availablez<div id="doc-warning">%s</div>)r   r   typedictkeysr   r   r   r   r	   anyr   	Exception	error_msgemitr   r   
html_ready)r   	html_textr   r   msgerrors         r   runzSphinxThread.run>   s   )	h?CyyD  [CHHJJ%>%>.CK7:9~47K484D8<8<G G GG !*#k*:G D DI;'2--FS^S[IJJ B"#$H"I"IC%)AAII"#$@"A"AC!%E%KK	    N''u(=(=>>>FFFFF ) )#t| < <II    N''u(=(=>>>FFFFF 	Y'''''s0   B(C( (
D$2'DD$/E 
F'E<<F)__name__
__module____qualname____doc__r   strr*   r,   r   r   r   r0   __classcell__)r   s   @r   r   r      s         " sIJ02X ! ! ! ! ! ! #'EB    ( ( ( ( ( ( (r   r   N)r4   qtpy.QtCorer   r   spyder.config.baser   spyder.py3compatr   #spyder.plugins.help.utils.sphinxifyr   r   r	   r    r   r   <module>r<      s    1 0 ( ' ' ' ' ' ' ' !           + + + + + +< < < < < < < < < <H( H( H( H( H(7 H( H( H( H( H(r   