From ae75a0b10b22f64ca2d4a049feaea1e5252fd207 Mon Sep 17 00:00:00 2001
From: Zackery Spytz
Date: Fri, 8 Nov 2019 14:32:50 -0700
Subject: [PATCH] bpo-27465: Make IDLE help source menu entries unique and
sorted
---
Doc/library/idle.rst | 11 ++++++++---
Lib/idlelib/configdialog.py | 11 ++++++++++-
Lib/idlelib/help.html | 7 +++++--
Lib/idlelib/idle_test/test_query.py | 11 +++++++++++
Lib/idlelib/query.py | 3 +++
.../IDLE/2019-11-08-14-29-24.bpo-27465.RUKMNw.rst | 2 ++
6 files changed, 39 insertions(+), 6 deletions(-)
create mode 100644 Misc/NEWS.d/next/IDLE/2019-11-08-14-29-24.bpo-27465.RUKMNw.rst
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index 0bd248c22b1..7375679ea2e 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -340,9 +340,14 @@ Python Docs
Turtle Demo
Run the turtledemo module with example Python code and turtle drawings.
-Additional help sources may be added here with the Configure IDLE dialog under
-the General tab. See the :ref:`Help sources ` subsection below
-for more on Help menu choices.
+Additional help sources
+ Menu items for display here are added on the General tab of Options =>
+ Configure IDLE. Menu entries should be unique (new in 3.9) and will be
+ sorted. Documents can be located either on the current machine or on the
+ internet. The allowed file types may depend on the system. Local file
+ paths are checked when submitted; internet addresses are not. See the
+ :ref:`Help sources ` subsection below for more on Help menu
+ choices.
.. index::
single: Cut
diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py
index df216582fe6..5fea56c6904 100644
--- a/Lib/idlelib/configdialog.py
+++ b/Lib/idlelib/configdialog.py
@@ -2103,6 +2103,10 @@ class GenPage(Frame):
# Set additional help sources.
self.user_helplist = idleConf.GetAllExtraHelpSourcesList()
+ self.set_additional_help_sources()
+
+ def set_additional_help_sources(self):
+ self.user_helplist.sort(key=lambda x: x[0])
self.helplist.delete(0, 'end')
for help_item in self.user_helplist:
self.helplist.insert(END, help_item[0])
@@ -2131,7 +2135,9 @@ class GenPage(Frame):
Query for name and location of new help sources and add
them to the list.
"""
- help_source = HelpSource(self, 'New Help Source').result
+ used_names = idleConf.GetExtraHelpSourceList('user')
+ help_source = HelpSource(self, 'New Help Source',
+ used_names=[item[0] for item in used_names]).result
if help_source:
self.user_helplist.append(help_source)
self.helplist.insert(END, help_source[0])
@@ -2145,10 +2151,12 @@ class GenPage(Frame):
"""
item_index = self.helplist.index(ANCHOR)
help_source = self.user_helplist[item_index]
+ used_names = idleConf.GetExtraHelpSourceList('user')
new_help_source = HelpSource(
self, 'Edit Help Source',
menuitem=help_source[0],
filepath=help_source[1],
+ used_names=[item[0] for item in used_names]
).result
if new_help_source and new_help_source != help_source:
self.user_helplist[item_index] = new_help_source
@@ -2171,6 +2179,7 @@ class GenPage(Frame):
def update_help_changes(self):
"Clear and rebuild the HelpFiles section in changes"
changes['main']['HelpFiles'] = {}
+ self.set_additional_help_sources()
for num in range(1, len(self.user_helplist) + 1):
changes.add_option(
'main', 'HelpFiles', str(num),
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 0754f2453ba..cdcd0459cf5 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -363,9 +363,12 @@ and open docs.python.org showing the latest Python documentation.
Turtle DemoRun the turtledemo module with example Python code and turtle drawings.
-Additional help sources may be added here with the Configure IDLE dialog under
-the General tab. See the Help sources subsection below
+
Additional help sourcesMenu items for display here are added on the General tab of Options => Configure IDLE.
+Menu entries should be unique (new in 3.9) and will be sorted. Documents can be located either on the current machine or on the internet.
+The allowed file types may depend on the system. Local file paths are checked when submitted; internet addresses are not.
+See the Help sources subsection below
for more on Help menu choices.
+