ó {fc@sTdZddlmZddlmZmZmZmZmZddlm Z ddl m Z m Z m Z mZmZmZmZddlZddlmZeZer½ddlmZnd efd „ƒYZd efd „ƒYZd e fd„ƒYZde fd„ƒYZd„Zd„ZedkrPddl m!Z!e!eƒndS(s help.py: Implement the Idle help menu. Contents are subject to revision at any time, without notice. Help => About IDLE: diplay About Idle dialog 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. iÿÿÿÿ(t HTMLParser(tabspathtdirnametisdirtisfiletjoin(tpython_version(tTktTopleveltFrametTextt ScrollbartMenut MenubuttonN(tidleConf(R t HelpParsercBsGeZdZd„Zdd„Zd„Zd„Zd„Zd„ZRS(s~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|ƒ||_d|_d|_t|_t|_d|_t|_ d|_ t|_ t|_ g|_ d|_dS(Nti(Rt__init__ttextttagstchartagstFalsetshowthdrlinktleveltprethprefixt nested_dlt simplelistttoctheader(tselfR((s$/usr/lib64/python2.7/idlelib/help.pyR4s            icCs>|j|7_|jdkr$dndt|jƒ|_dS(NiRtl(RtstrR(Rtamt((s$/usr/lib64/python2.7/idlelib/help.pytindentCscCsÒd}x)|D]!\}}|dkr |}q q Wd}|dkr\|dkr\t|_nD|dkr€|dkr€t|_n |dkr¡|dkr¡d}nÿ|d krÅ|d krÅd |_nÛ|d kré|d kréd |_n·|d krd |_nŸ|d!krJ|jdƒdkr4d}t|_n t|_|jƒnV|dkrt|jdkr t|_q n,|dkr˜|jr�dnd}n|dkrÅ|js³dnd}t|_nÛ|dkrä|jƒd}n¼|d kr$t|_ |jr|j j ddƒnd|_ n||dkrH|dkrHt|_ nX|dkr`||_ n@|d"kr |jr”d|_|j j ddƒn||_ n|jrÎ|j j d||j |jfƒnd S(#sHandle starttags in help.html.Rtclasstdivtsectiont sphinxsidebartptfirsts tspanRtversionmodifiedtemtultoltsimpleiÿÿÿÿs tdlitlis * s * tdttddtendtpreblocktat headerlinkth1th2th3N(R-R.(R9R:(tTrueRRRtfindRR#RRRRtinsertRRR(Rttagtattrstclass_R6tvts((s$/usr/lib64/python2.7/idlelib/help.pythandle_starttagGsd                                cCsÁ|dkrM|jdƒ|jr½|jj|j|jjdƒfƒq½np|dkred|_nX|d kr}t|_ n@|d kržt|_ d|_ n|dkr½|jddƒndS(sHandle endtags in help.html.R8R9R:iR=R*R,RR6RR-R3R.R"iÿÿÿÿN(R8R9R:(R*R,(R-R3R.( R#RRtappendRRtindexRRRRR(RR>((s$/usr/lib64/python2.7/idlelib/help.pyt handle_endtag}s   +        cCsó|jrï|j rï|jr"|n|jddƒ}|jdkr_|d|jdƒ!|_n|jd krÊ|jdkrÊ|dt|jƒ!|jkr¸|t|jƒjƒ}n|j |7_ n|j j d||j|j fƒnd S( s"Handle date segments in help.html.s t R8iR9R:RR4N(R8R9R:( RRRtreplaceRRERtlentstripRRR=R(Rtdatatd((s$/usr/lib64/python2.7/idlelib/help.pyt handle_data�s!cCs/|jr+|jjdtt|ƒƒƒndS(NR4(RRR=tunichrtint(Rtname((s$/usr/lib64/python2.7/idlelib/help.pythandle_charref™s ( t__name__t __module__t__doc__RR#RCRFRMRQ(((s$/usr/lib64/python2.7/idlelib/help.pyR+s   6  tHelpTextcBs eZdZd„Zd„ZRS(sDisplay help.html.c Cs6tjdddddƒ}tjdddddƒ}d|d}tj||d d d d 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|ƒ�}|j ƒj d4d5ƒ}Wd6QX|jj |ƒd7|d8ÀstrootRPtexiststfamilycss|]}|jƒVqdS(N(R…(R†R‡((s$/usr/lib64/python2.7/idlelib/help.pys ÃsN(R…ttkfonttnamestFontR;tactualtfamilies(RRŒRPRf((s$/usr/lib64/python2.7/idlelib/help.pyRv½s ((RRRSRTRRv(((s$/usr/lib64/python2.7/idlelib/help.pyRUžs t HelpFramecBs eZdZd„Zd„ZRS(s&Display html text, scrollbar, and toc.cCsÖtj||ƒt||ƒ}|d|dÛRtmenu(R R RRxRt add_command(RRRtdroptlblR¤((Rs$/usr/lib64/python2.7/idlelib/help.pyRžÖs & (RRRSRTRRž(((s$/usr/lib64/python2.7/idlelib/help.pyR�Ès t HelpWindowcBseZdZd„ZRS(s!Display frame with rendered html.cCstj||ƒ|j|ƒ|jd|jƒt||ƒjddddddƒ|jdddƒ|jdddƒdS( NtWM_DELETE_WINDOWR”iR•R–R˜R“i( RRtwm_titletprotocoltdestroyR�RŸtgrid_columnconfiguretgrid_rowconfigure(RR}R~ttitle((s$/usr/lib64/python2.7/idlelib/help.pyRâs  %(RRRSRTR(((s$/usr/lib64/python2.7/idlelib/help.pyRªàsc Cs¯ttttttƒƒƒƒdddddƒ}ttttƒƒdƒ}t|dƒ�G}t|dƒ�/}x%|D]}|j|jƒd ƒqyWWd QXWd QXd GHd S( s_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. tDoctbuildthtmltlibrarys idle.htmls help.htmltrtws Nsidle.html copied to help.html(RRRt__file__Rytwritetrstrip(tsrctdsttinntouttline((s$/usr/lib64/python2.7/idlelib/help.pyt copy_stripës 'cCsFttttƒƒdƒ}t|ƒs+dSt||dtƒƒdS(s7Create HelpWindow; called from Idle Help event handler.s help.htmlNsIDLE Help (%s)(RRRR¸RRªR(R}R~((s$/usr/lib64/python2.7/idlelib/help.pyt show_idlehelp s t__main__(trun("RTRtos.pathRRRRRtplatformRtTkinterRRR R R R R ttkFontR‹tidlelib.configHandlerRRtuse_ttkt tkinter.ttkRRUR�RªRÀRÁRRtidlelib.idle_test.htestRÃ(((s$/usr/lib64/python2.7/idlelib/help.pyts$(4 s*