
    Je                     Z    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y)	z*SphinxThread used in richtext help plugin.    )QThreadSignal)_)to_text_string)CSS_PATHgenerate_context	sphinxifyc                   ^     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                 r    t         t        |   |       d | _        d | _        || _        d| _        || _        y )NF)superr   __init__doccontexthtml_text_no_docmath_optioncss_path)selfparentr   r   	__class__s       H/usr/lib/python3/dist-packages/spyder/plugins/help/utils/sphinxthread.pyr   zSphinxThread.__init__(   s7    lD*62 0      NFc                     | j                         r4|| _        || _        || _        || _        || _        | j                          yy)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   s?    
 99;DH"DL*D$DM$DMJJL r   c                    | j                   }| j                  }|t        |      t        u rd|j	                         v r	 t        |d   |d   |d   | j                  | j                  | j                        }t        |d   |      }|d   dk(  r;t        |d   |d   |d   g      rt        d      }|dz  }nt        d	      }|d
|z  z  }n#| j                   	 t        || j                         }| j"                  j                  |       y # t        $ r.}| j                  j                  t        |             Y d }~y d }~ww xY w# t        $ r.}| j                  j                  t        |             Y d }~y d }~ww xY w)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>   sh   ))	hh?CyD [CHHJ%>.CK7:9~47K484D4D8<8<GG !*#k*:G DI;'2-FS^S[IJ"#$H"IC%)AAI"#$@"AC!%E%KK	 ) )#t|| <I 	Y' ! NN''u(=> ! NN''u(=>s0   B
D	 E 		E $D;;E 	E:$E55E:)__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 ( ! +< <H(7 H(r   