Your IP : 18.118.166.45


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/help.cpython-36.pyc

3

� f=,�@s�dZddlmZddlmZmZmZmZddlm	Z	ddl
mZmZm
Z
mZddlmZmZddl
mZddlmZGd	d
�d
e�ZGdd�de
�ZGd
d�de�ZGdd�de�Zdd�Zdd�Zedkr�ddlmZedddd�ddlm Z e e�dS)a help.py: Implement the Idle help menu.
Contents are subject to revision at any time, without notice.


Help => About IDLE: diplay About Idle dialog

<to be moved here from help_about.py>


Help => IDLE Help: Display help.html with proper formatting.
Doc/library/idle.rst (Sphinx)=> Doc/build/html/library/idle.html
(help.copy_strip)=> Lib/idlelib/help.html

HelpParser - Parse help.html and render to tk Text.

HelpText - Display formatted help.html.

HelpFrame - Contain text, scrollbar, and table-of-contents.
(This will be needed for display in a future tabbed window.)

HelpWindow - Display HelpFrame in a standalone window.

copy_strip - Copy idle.html to help.html, rstripping each line.

show_idlehelp - Create HelpWindow.  Called in EditorWindow.help_dialog.
�)�
HTMLParser)�abspath�dirname�isfile�join)�python_version)�Toplevel�Frame�Text�Menu)�
Menubutton�	Scrollbar)�font)�idleConfc@s:eZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
S)�
HelpParsera~Render help.html into a text widget.

    The overridden handle_xyz methods handle a subset of html tags.
    The supplied text should have the needed tag configurations.
    The behavior for unsupported tags, such as table, is undefined.
    If the tags generated by Sphinx change, this class, especially
    the handle_starttag and handle_endtags methods, might have to also.
    cCsZtj|dd�||_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_g|_d|_
dS)NT)Zconvert_charrefs�Fr)r�__init__�text�tags�chartags�show�hdrlink�level�pre�hprefix�	nested_dl�
simplelist�toc�header)�selfr�r �1/opt/alt/python36/lib64/python3.6/idlelib/help.pyr3szHelpParser.__init__�cCs0|j|7_|jdkrdndt|j�|_dS)Nrr�l)r�strr)r�amtr r r!�indentBszHelpParser.indentcCsd}x|D]\}}|dkr
|}q
Wd}|dkr@|dkr@d|_�n�|dkrZ|dkrZd|_�n�|dkrr|d	krrd
}�nv|dkr�|dkr�d|_�n\|dkr�|d
kr�d|_�nB|dkr�d|_�n0|d#kr�|jd�d$kr�d}d|_nd|_|j��n�|dk�r
|jdk�r�d|_n�|dk�r&|j�r dnd}n�|dk�rH|j�s<d
nd}d|_n�|dk�r`|j�d}n�|dk�r�d|_|j�r�|jj	dd
�d|_
nZ|dk�r�|dk�r�d|_n>|dk�r�||_
n,|d%k�r�|j�r�d|_|jj	dd
�||_
|j�r|jj	d||j
|jf�d"S)&zHandle starttags in help.html.r�classZdivZsectionTZ
sphinxsidebarF�p�firstz

�spanrZversionmodified�em�ul�olZsimpler"�
ZdlrZliz
* z

* Zdt�dd�end�preblock�aZ
headerlink�h1�h2�h3N)r,r-���)r4r5)
rr�findrr&rrrr�insertrrr)r�tagZattrsZclass_r2�v�sr r r!�handle_starttagFsd











zHelpParser.handle_starttagcCs�|dkrT|jd�|jr�|dkr$dn|dkr0dnd}|jj||j|jjd�f�nJ|dkrdd|_n:|dkrtd|_n*|d
kr�d|_	d|_
n|dkr�|jdd�dS)zHandle endtags in help.html.r3r4r5rz        z    rr8r*r+r2Frr,r/r-r")r%N)r3r4r5)r*r+)r,r/r-r6)r&rr�appendrr�indexrrrr)rr9r&r r r!�
handle_endtag|s 
 zHelpParser.handle_endtagc
Cs�|jr�|jr�|jr|n
|jdd�}|jdkrby|d|jd��|_Wntk
r`d|_YnX|jd
kr�|jdkr�|dt|j��|jkr�|t|j�d�}|j	|j
�7_	|jjd	||j|j
f�dS)z"Handle date segments in help.html.r.� r3rrr4r5Nr0)r3r4r5)rrr�replacerr>r�
ValueError�lenr�striprr8r)r�data�dr r r!�handle_data�s


zHelpParser.handle_dataN)r")	�__name__�
__module__�__qualname__�__doc__rr&r<r?rGr r r r!r*s
6rc@s eZdZdZdd�Zdd�ZdS)�HelpTextzDisplay help.html.c	
Csvtjddddd�}tjddddd�}d|d}tj||d	d
dd
||d�|jd
ddg�}|jdddg�}|df|d<|jd|ddfd�|jd|ddfd�|jd|ddfd�|jd|ddfd�|jd|dfd d!�|jd"|d#fd$d%d&d'd(�|jd)d$d$d*�|jd+d,d,d*�|jd-d.d.d*�|jd/d0d0d*�t|�|_t|d1d2��}|j	�}Wd3QRX|jj
|�d4|d5<d3S)6z'Configure tags and feed file to parser.�mainZEditorWindow�width�int)�type�height��Zwordr�)ZwrapZhighlightthicknessZpadx�borderwidthrNrQZ
TkDefaultFontZarialZ	helveticaZTkFixedFontZmonacoZcourier�rr+Zitalic)rr3�Zboldr4�r5�rz#f6f6ff)r�
backgroundr1�
�r"Zsolidz#eeffcc)r�lmargin1rUZreliefrZ�l1)r]Zlmargin2�l2�2�l3�K�l4�dzutf-8)�encodingNZdisabled�state)rZ	GetOptionr
r�findfontZ
tag_configurer�parser�open�readZfeed)	r�parent�filenameZuwideZuhighZ
normalfontZ	fixedfont�f�contentsr r r!r�s0
zHelpText.__init__cCsnxh|D]`}|j�dd�tj|d�D�krDtj|d|d�}|j�dS|j�dd�tj|d�D�kr|SqWdS)	z4Return name of first font family derived from names.css|]}|j�VqdS)N)�lower)�.0�xr r r!�	<genexpr>�sz$HelpText.findfont.<locals>.<genexpr>)�rootT)�name�existsrsZfamilycss|]}|j�VqdS)N)ro)rprqr r r!rr�sN)ro�tkfont�namesZFontZactualZfamilies)rrwrtrr r r!rg�s
zHelpText.findfontN)rHrIrJrKrrgr r r r!rL�srLc@s eZdZdZdd�Zdd�ZdS)�	HelpFramez&Display html text, scrollbar, and toc.cCs�tj||�t||�|_}|d|d<|j|�|_}t||jd�|_}|j	|d<|j
ddd�|jddd�|jdddd�|jddd	d�|jdd
dd�dS)NrZ)�commandZyscrollcommandrr")�weightZnw)�row�column�sticky�nsew��ns)
r	rrLr�toc_menurr
�yview�scroll�setZrowconfigureZcolumnconfigure�grid)rrkrlrrr�r r r!r�s
zHelpFrame.__init__csTt|dd�}t|dd�}x.�jjD]"\}}|j||f�fdd�	d�q"W||d<|S)	z+Create table of contents as drop-down menu.ZTOC)rF)Ztearoffcs
�j|�S)N)r�)�dex)rr r!�<lambda>�sz$HelpFrame.toc_menu.<locals>.<lambda>)ZlabelryZmenu)rrrhrZadd_command)rrrZdropZlblr�r )rr!r��szHelpFrame.toc_menuN)rHrIrJrKrr�r r r r!rx�srxc@seZdZdZdd�ZdS)�
HelpWindowz!Display frame with rendered html.cCsZtj||�|j|�|jd|j�t||�jdddd�|jddd�|jddd�dS)NZWM_DELETE_WINDOWrr~)r|r{r}r")rz)	rrZwm_titleZprotocolZdestroyrxr�Zgrid_columnconfigureZgrid_rowconfigure)rrkrl�titler r r!r�s
zHelpWindow.__init__N)rHrIrJrKrr r r r!r��sr�cCs�tttttt����ddddd�}tttt��d�}t|d��<}t|d��&}x|D]}|j|j�d	�qRWWd
QRXWd
QRXt|�d|���d
S)a_Copy idle.html to idlelib/help.html, stripping trailing whitespace.

    Files with trailing whitespace cannot be pushed to the git cpython
    repository.  For 3.x (on Windows), help.html is generated, after
    editing idle.rst on the master branch, with
      sphinx-build -bhtml . build/html
      python_d.exe -c "from idlelib.help import copy_strip; copy_strip()"
    Check build/html/library/idle.html, the help.html diff, and the text
    displayed by Help => IDLE Help.  Add a blurb and create a PR.

    It can be worthwhile to occasionally generate help.html without
    touching idle.rst.  Changes to the master version and to the doc
    build system may result in changes that should not changed
    the displayed text, but might break HelpParser.

    As long as master and maintenance versions of idle.rst remain the
    same, help.html can be backported.  The internal Python version
    number is not displayed.  If maintenance idle.rst diverges from
    the master version, then instead of backporting help.html from
    master, repeat the proceedure above to generate a maintenance
    version.
    ZDocZbuildZhtmlZlibraryz	idle.htmlz	help.html�rb�wb�
Nz copied to )rrr�__file__ri�write�rstrip�print)�src�dstZinn�out�liner r r!�
copy_strip�s
*r�cCs4tttt��d�}t|�sdSt||dt��dS)z7Create HelpWindow; called from Idle Help event handler.z	help.htmlNzIDLE Help (%s))rrrr�rr�r)rkrlr r r!�
show_idlehelpsr��__main__)rMzidlelib.idle_test.test_helprF)�	verbosity�exit)�runN)!rKZhtml.parserrZos.pathrrrr�platformrZtkinterrr	r
rZtkinter.ttkrr
rrvZidlelib.configrrrLrxr�r�r�rHZunittestrMZidlelib.idle_test.htestr�r r r r!�<module>s$v* 

?>