Repository navigation
Generate Idle help from Doc/library/idle.rst #61097
Description
Activity
Lib/idlelib/help.txt and Doc/library/idle.rst contain almost exactly the same information, only formatted a bit differently. This issue is to suggest the merger of the two files, by way of creating help.txt from idle.rst as a part of the build or install process.
This could be as simple as merely copying the one to the other, but that of course leaves in place all reST directives that mean nothing to a simple text document. Thus, idle.rst should be processed to create help.txt. This could be done with sphinx/docutils, but to avoid having the CPython build process (not just the doc build process) depend on those tools, I think a very simple dedicated script could be created to do the processing without much trouble.
As far as I can tell, this new script would only have to do a few simple steps:
- Remove comments (including index markers, etc.)
- Remove reST roles (replace ":role:`" with "`", possibly remove "`" as well)
- Remove backslash escapes
- Remove (or undouble) double colons
- Replace "#." with "1.", etc.
Thoughts?
- addeddocsDocumentation in the Doc dirDocumentation in the Doc dirtype-featureA feature request or enhancementA feature request or enhancement
on Jan 8, 2013 I think getting this issue fixed makes sense, it would save time and remove duplication.
I like the proposition in general, but files should be synchronized first.
Note that Sphinx' "make text" output already should be suitable. We already update the pydoc topics with that on every release, so we could just as well do the same for the IDLE doc. No need for another separate script.
Andrew,
Zachary and I worked on another issue together to sync idle.rst with help.txt here:
http://bugs.python.org/issue5066bpo-5066 is ready for commit if you have time by the way. Thanks!
Georg:
Note that Sphinx' "make text" output already should be suitable. We
already update the pydoc topics with that on every release, so we could
just as well do the same for the IDLE doc. No need for another
separate script.I take it this would mean generating help.txt and then checking it in? Otherwise, users who built their own Python would likely run into issues with IDLE not finding its help file, or would be required to have sphinx available. That's not quite what I had in mind, but if we already do it for pydoc topics, it sounds fine to me.
Regenerating idle.txt and committing it is fine to me.
I take it this would mean generating help.txt and then checking it in? Otherwise, users who built their own Python would likely run into issues with IDLE not finding its help file, or would be required to have sphinx available.
Yes, it will be checked in.
That's not quite what I had in mind, but if we already do it for pydoc topics, it sounds fine to me.
I don't think we have to worry about it getting out of date quickly. Automatically generating the IDLE help at run time from a documentation source file is not posssible anyway, since the doc sources are not available in a standard location for installed Pythons.
I don't think we have to worry about it getting out of date quickly.
Fair point :)
Automatically generating the IDLE help at run time from a documentation
source file is not posssible anyway, since the doc sources are not
available in a standard location for installed Pythons.This isn't quite what I meant either; I had intended it to be done at either Python build or install time. Your method is much simpler, though, I like it.
That said, here's the diff between the (now) current Lib/idlelib/help.txt and the Sphinx
make textoutput of Doc/library/idle.rst. I've not found where we've automated the pydoc topics generation, else I'd try to provide a patch to do this as well.The unified diff is not very helpful; I think somebody has to put the files side by side and merge.
The pydoc topics are built with a custom Sphinx builder implemented in tools/sphinxext/pyspecific.py -- but if we just want the vanilla text builder output it should be enough to add a Doc/Makefile target:
idledoc: BUILDER = text
idledoc: SOURCES = library/idle
idledoc: build
@echo "Build finished; now copying build/text/library/idle.txt to ../Lib/idlelib/help.txt."
@cp build/text/library/idle.txt ../Lib/idlelib/help.txtand I add a step to PEP-101 to run this.
To make it actually work, replace "library/idle" by "library/idle.rst".
23 remaining items
Ok. In case you're curious or might find it useful elsewhere, I've attached sphinxview.py, which renders the HTML into a text widget (with formatting, it's not converted to plain text).
This looks more maintainable than I expected, so I will definite try it out.
In msg185726 Ned said "Ironically, the Tk text widget is perfectly capable of rendering richer text styles." He was and is correct. Mark Roseman offered to take up the challenge. In spite of my skepticism, he went ahead and built sphinxview around HTMLParser. This reduced the core of the problem to "for each tag, content, and end tag, what state change or text insertion is needed. The result is simple enough for me to understand and even edit.
I sent Mark a detailed comparison of the Firefox rendering of idle.html and his tk rendering. He replied with a new version whose output is essentially identical to Firefox's (minus links), including the green example box. I intend to use a third version and will work on a full patch.
When running in a repository clone, Idle could access ../../Doc/build/html/library/idle.html. But for installations, idle.html needs to be in idlelib. I guess the only was to guarantee this everywhere (excepting overt downstream removals) is to commit it into the repository, unlike most other files built from .rst files).
To help make sure this happens, I would like to add a comment at the top of idle.rst. The devguide sentence on comments is unclear to me. Will the following work?
.. # After editing this, also build html, copy idle.html to idlelib,
test, and upload or commit the html diff also.It would be nice if the copy and commit process were added to the release process, but I will go ahead even without that. A nicely rendered, slightly out-of-date .html will be a great improvement over the current situation.
I'd be happy to work on making an 'idledoc' target for the Doc/ makefiles that works with Mark's viewer. I can't guarantee any kind of timeframe, but the idledoc target wouldn't be necessary right off the bat; it could be done after the main bulk of the patch is committed.
As far as reST comments, the syntax is:
"""
.. This is a comment.
This is still the same comment.
And more of the same comment.This is no longer part of the comment
"""See http://docutils.sourceforge.net/docs/user/rst/quickref.html#comments
New changeset 4038508240a1 by Terry Jan Reedy in branch '2.7':
Issue bpo-16893: Replace help.txt with idle.html for Idle doc display.
https://hg.python.org/cpython/rev/4038508240a1New changeset 52510bc368f8 by Terry Jan Reedy in branch '2.7':
Issue bpo-16893: include new files
https://hg.python.org/cpython/rev/52510bc368f8New changeset 2d808b72996d by Terry Jan Reedy in branch '3.4':
Issue bpo-16893: Replace help.txt with idle.html for Idle doc display.
https://hg.python.org/cpython/rev/2d808b72996dNew changeset e66fbfa282c6 by Terry Jan Reedy in branch '2.7':
Issue bpo-16893: whitespace in idle.html.
https://hg.python.org/cpython/rev/e66fbfa282c6New changeset 9b79a4901069 by Terry Jan Reedy in branch '3.4':
Issue bpo-16893: whitespace in idle.html.
https://hg.python.org/cpython/rev/9b79a4901069New changeset 1107e3ee6103 by Terry Jan Reedy in branch '2.7':
Issue bpo-16893: whitespace in help.py.
https://hg.python.org/cpython/rev/1107e3ee6103I committed a patch that works well enough for release as it. I attached the diff for changed files in case anyone wants to view in Rietveld.
Still to do for this issue:
- Automate getting the 2.7 and earliest 3.x idle.html copied to idlelib and whitespace-normalized. (Commit/push should stay manual.) Several lines have 1 to many blanks at the end, while the file lacks a final \n. See e66fbfa282c6. (These anomalies come from Sphinx; idle.rst has been normalized to be checked in.)
I have a .bat file that builds any and copies as needed. I will to add a pass through Idle's trailing-whitespace deleter, which did just what was needed to commit. (Patchcheck.normalize_docs_whitespace does a here unneeded comparision (always unequal), creates an unwanted and nuisance .bak, and does not appear to work when the last list has no '\n'.)
When I have automation working for me, I would like to add make targets for others to use (Zach's patch 4).
- Edit idle.rst
I will push NEWS and idlelib.NEWS entries separately, along with others for Idle.
I opened new issue bpo-25198 for further viewer improvements (and bug fixes, if any).
New changeset e749080fa0f9 by Terry Jan Reedy in branch '2.7':
Issue bpo-16893: finish deprecation.
https://hg.python.org/cpython/rev/e749080fa0f9New changeset ff0270e9bdfb by Terry Jan Reedy in branch '3.4':
Issue bpo-16893: finish deprecation.
https://hg.python.org/cpython/rev/ff0270e9bdfbNew changeset 855484b55da3 by Terry Jan Reedy in branch '2.7':
Issue bpo-16893: Add idlelib.help.copy_strip() to copy-rstrip Doc/.../idle.html.
https://hg.python.org/cpython/rev/855484b55da3New changeset df987a0bc350 by Terry Jan Reedy in branch '3.4':
Issue bpo-16893: Add idlelib.help.copy_strip() to copy-rstrip Doc/.../idle.html.
https://hg.python.org/cpython/rev/df987a0bc350New changeset f08437278049 by Terry Jan Reedy in branch '3.5':
Issue bpo-16893: Add idlelib.help.copy_strip() to copy-rstrip Doc/.../idle.html.
https://hg.python.org/cpython/rev/f08437278049New changeset 09ebed6a8cb8 by Terry Jan Reedy in branch 'default':
Issue bpo-16893: Add idlelib.help.copy_strip() to copy-rstrip Doc/.../idle.html.
https://hg.python.org/cpython/rev/09ebed6a8cb8NEWS entries are done.
I added a function, copy_strip, to help.py to rstrip (in bytes mode) idle.html as it copies to help.html. (I changed the name to better remember which is which.) In my .bat file, with Doc as current directory, I use
..\pcbuild\python_d.exe -c "from idlelib.help import copy_strip; copy_strip()"
I could change the if __name__ block so that
..\pcbuild\python_d.exe -m idlelib.help copy_strip
would work. Either way, I would like to add 'idlehelp' to makefiles. But not tonight.The tests seem to have grown a new Deprecation Warning (triggered when run with python -bWall). Looks like this may be a side effect of revision 2d808b72996d.
[160/392] test_idle
/media/disk/home/proj/python/cpython/Lib/idlelib/EditorWindow.py:88: DeprecationWarning: EditorWindow.HelpDialog is no longer used by Idle.
It will be removed in 3.6 or later.
It has been replaced by private help.HelpWindowhelpDialog = HelpDialog() # singleton instance, no longer used
New changeset 26e819909891 by Terry Jan Reedy in branch '2.7':
Issue bpo-16893: Move idlelib.EditorWindow.HelpDialog deprecation warning
https://hg.python.org/cpython/rev/26e819909891New changeset c607004a98bf by Terry Jan Reedy in branch '3.4':
Issue bpo-16893: Move idlelib.EditorWindow.HelpDialog deprecation warning
https://hg.python.org/cpython/rev/c607004a98bfThank you for reporting this. My general problem is that idlelib was only informally private until PEP-434 and I only started adding 'private' and 'deprecated' to the code a week ago. So I am trying to make changes in existing versions while not breaking even unlikely uses of the current API. The specific problem is the the class init method *is* used -- to create an unused instance -- on import.
helpDialog = HelpDialog() # singleton instance, no longer used
The patch fixes the problem by moving the deprecation to the show method, which Idle really does not now call.
Through the contributions of several people, Zack's key idea, that Idle documentation should have a single source, idle.rst, has come to fruition. So I think it time to close this. I already mentioned bpo-25198 for improving the tkinter viewer. I also opened bpo-25218 for revising Zack's patch and possibly using an 'idledoc' target in the release process.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: