AlkantarClanX12

Your IP : 3.16.51.237


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/help.cpython-35.pyc



��Yf�*�@sXdZddlmZddlmZmZmZmZmZddl	m
Z
ddlmZm
Z
mZmZmZmZmZddlmZddlmZdZer�dd	lmZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de
�Zdd�Zdd�ZedkrTddl m!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 aboutDialog.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�isdir�isfile�join)�python_version)�Tk�Toplevel�Frame�Text�	Scrollbar�Menu�
Menubutton)�font)�idleConfF)rc@sUeZdZdZdd�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.
    cCs�tj|dd�||_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_g|_d|_
dS)NZconvert_charrefsT�Fr)r�__init__�text�tags�chartags�show�hdrlink�level�pre�hprefix�	nested_dl�
simplelist�toc�header)�selfr�r"�1/opt/alt/python35/lib64/python3.5/idlelib/help.pyr4s											zHelpParser.__init__�cCs>|j|7_|jdkr$dndt|j�|_dS)Nrr�l)r�strr)r!�amtr"r"r#�indentCszHelpParser.indentcCs�d}x&|D]\}}|dkr
|}q
Wd}|dkrY|dkrYd|_n8|dkr}|dkr}d|_n|dkr�|d	kr�d
}n�|dkr�|dkr�d|_n�|dkr�|d
kr�d|_n�|dkr�d|_n�|d#krG|jd�d$kr1d}d|_n	d|_|j�nJ|dkrn|jdkr�d|_n#|dkr�|jr�dnd}n�|dkr�|js�d
nd}d|_n�|dkr�|j�d}n�|dkrd|_|jr|jj	dd
�d|_
nv|dkr?|dkr?d|_nR|dkrW||_
n:|d%kr�|jr�d|_|jj	dd
�||_
|jr�|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/���)r6r7)
rr�findrr(rrrr�insertrrr )r!�tagZattrsZclass_r4�v�sr"r"r#�handle_starttagGsd
		

							zHelpParser.handle_starttagcCs�|dkrJ|jd�|jr�|jj|j|jjd�f�nm|dkrbd|_nU|d	krzd
|_n=|dkr�d
|_	d|_
n|dkr�|jdd�dS)zHandle endtags in help.html.r5r6r7rr:r,r-rr4Frr.r1r/r'r$N)r5r6r7)r,r-)r.r1r/r8)r(rr�appendr r�indexrrrr)r!r;r"r"r#�
handle_endtag}s
	(	zHelpParser.handle_endtagcCs�|jr�|jr�|jr"|n|jdd�}|jdkr_|d|jd��|_|jd
kr�|jdkr�|dt|j��|jkr�|t|j�d�j�}|j	|7_	|j
jd	||j|jf�dS)z"Handle date segments in help.html.r0� r5rr6r7rNr2)r5r6r7)
rrr�replacerr@r�len�stripr rr:r)r!�data�dr"r"r#�handle_data�s!"zHelpParser.handle_dataN)	�__name__�
__module__�__qualname__�__doc__rr(r>rArHr"r"r"r#r+s6rc@s.eZdZdZdd�Zdd�ZdS)�HelpTextzDisplay help.html.c	Cs1tjddddd�}tjddddd�}d|d}tj||d	d
ddd
dddd|d|�|jdddg�}|jdddg�}|df|d<|jdd|ddf�|jdd|ddf�|jdd|ddf�|jdd|d df�|jd!d|dfd"d#�|jd$d|d%fd&d'dd(d)d*d"d+�|jd,d&d'd-d'�|jd.d&d/d-d/�|jd0d&d1d-d1�|jd2d&d3d-d3�t|�|_t|d4d5��}|j	�}Wd6QRX|jj
|�d7|d8<d6S)9z'Configure tags and feed file to parser.�mainZEditorWindow�width�type�intZheight��ZwrapZwordZhighlightthicknessrZpadx�ZborderwidthZ
TkDefaultFontZarialZ	helveticaZTkFixedFontZmonacoZcourier�rr-Zitalicr5�Zboldr6�r7�r�
backgroundz#f6f6ffr3�
Zlmargin1�r$ZreliefZsolidz#eeffcc�l1Zlmargin2�l2�2�l3�K�l4�d�encodingzutf-8NZdisabled�state)rZ	GetOptionrr�findfontZ
tag_configurer�parser�open�readZfeed)	r!�parent�filenameZuwideZuhighZ
normalfontZ	fixedfont�f�contentsr"r"r#r�s0zHelpText.__init__cCs�x�|D]�}|j�dd�tjd|�D�krdtjd|ddd|�}|j�dS|j�dd�tjd|�D�kr|SqWd	S)
z4Return name of first font family derived from names.css|]}|j�VqdS)N)�lower)�.0�xr"r"r#�	<genexpr>�sz$HelpText.findfont.<locals>.<genexpr>�root�name�existsTZfamilycss|]}|j�VqdS)N)rm)rnror"r"r#rp�sN)rm�tkfont�namesZFontZactualZfamilies)r!rurrrr"r"r#re�s
+zHelpText.findfontN)rIrJrKrLrrer"r"r"r#rM�srMc@s.eZdZdZdd�Zdd�ZdS)�	HelpFramez&Display html text, scrollbar, and toc.cCs�tj||�t||�}|d|d<t|d|j�}|j|d<|jddd�|jddd�|j|�j	ddddd	d
�|j	ddddd	d�|j	ddddd	d
�dS)NrY�commandZyscrollcommandr�weightr$�column�row�stickyZnw�nsew��ns)
rrrMr
�yview�setZrowconfigureZcolumnconfigure�toc_menu�grid)r!rirjrZscrollr"r"r#r�s
%zHelpFrame.__init__c	stt|dd�}t|dd�}x?�jjD]1\}}|jd|d|�fdd��q1W||d	<|S)
z+Create table of contents as drop-down menu.rZTOCZtearoffFZlabelrwcs
�j|�S)N)r)�dex)rr"r#�<lambda>�sz$HelpFrame.toc_menu.<locals>.<lambda>Zmenu)rrrfrZadd_command)r!rrZdropZlblr�r")rr#r��s)
zHelpFrame.toc_menuN)rIrJrKrLrr�r"r"r"r#rv�srvc@s"eZdZdZdd�ZdS)�
HelpWindowz!Display frame with rendered html.cCstj||�|j|�|jd|j�t||�jdddddd�|jddd�|jddd�dS)	NZWM_DELETE_WINDOWryrrzr{r|rxr$)	r
rZwm_titleZprotocolZdestroyrvr�Zgrid_columnconfigureZgrid_rowconfigure)r!rirj�titler"r"r#r�s
%zHelpWindow.__init__N)rIrJrKrLrr"r"r"r#r��sr�cCs�tttttt����ddddd�}tttt��d�}t|d��H}t|d��/}x%|D]}|j|j�d	�qyWWd
QRXWd
QRXtd�d
S)a_Copy idle.html to idlelib/help.html, stripping trailing whitespace.

    Files with trailing whitespace cannot be pushed to the hg cpython
    repository.  For 3.x (on Windows), help.html is generated, after
    editing idle.rst in the earliest maintenance version, with
      sphinx-build -bhtml . build/html
      python_d.exe -c "from idlelib.help import copy_strip; copy_strip()"
    After refreshing TortoiseHG workshop to generate a diff,
    check  both the diff and displayed text.  Push the diff along with
    the idle.rst change and merge both into default (or an intermediate
    maintenance version).

    When the 'earlist' version gets its final maintenance release,
    do an update as described above, without editing idle.rst, to
    rebase help.html on the next version of idle.rst.  Do not worry
    about version changes as version is not displayed.  Examine other
    changes and the result of Help -> IDLE Help.

    If maintenance and default versions of idle.rst diverge, and
    merging does not go smoothly, then consider generating
    separate help.html files from separate idle.htmls.
    ZDocZbuildZhtmlZlibraryz	idle.htmlz	help.html�rb�wbs
Nzidle.html copied to help.html)rrr�__file__rg�write�rstrip�print)�srcZdstZinn�out�liner"r"r#�
copy_strip�s
)r�cCsFtttt��d�}t|�s+dSt||dt��dS)z7Create HelpWindow; called from Idle Help event handler.z	help.htmlNzIDLE Help (%s))rrrr�rr�r)rirjr"r"r#�
show_idlehelpsr��__main__)�runN)"rLZhtml.parserrZos.pathrrrrr�platformrZtkinterr	r
rrr
rrrrtZidlelib.configHandlerrZuse_ttkZtkinter.ttkrrMrvr�r�r�rIZidlelib.idle_test.htestr�r"r"r"r#�<module>s$(4o*