Skip to content

Commit 075a069

Browse files
Add idle help check to CI
1 parent 1de4671 commit 075a069

File tree

7 files changed

+118
-39
lines changed

7 files changed

+118
-39
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ jobs:
4949
if: fromJSON(needs.build-context.outputs.run-docs)
5050
uses: ./.github/workflows/reusable-docs.yml
5151

52+
check-idle-help-doc:
53+
name: "Check if IDLE's help.html is up to date"
54+
needs: check-docs
55+
uses: ./.github/workflows/reusable-idle-help-doc.yml
56+
5257
check-autoconf-regen:
5358
name: 'Check if Autoconf files are up to date'
5459
# Don't use ubuntu-latest but a specific version to make the job
@@ -711,8 +716,16 @@ jobs:
711716
build-ubuntu-ssltests-openssl,
712717
test-hypothesis,
713718
cifuzz,
719+
check-idle-help-doc,
714720
allowed-skips: >-
715-
${{ !fromJSON(needs.build-context.outputs.run-docs) && 'check-docs,' || '' }}
721+
${{
722+
!fromJSON(needs.build-context.outputs.run-docs)
723+
&& '
724+
check-docs,
725+
check-idle-help-doc,
726+
'
727+
|| ''
728+
}}
716729
${{
717730
needs.build-context.outputs.run-tests != 'true'
718731
&& '

.github/workflows/reusable-docs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ jobs:
7575
--fail-if-regression \
7676
--fail-if-improved \
7777
--fail-if-new-news-nit
78+
- name: 'Upload built idle.html'
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: idle-html
82+
path: Doc/build/html/library/idle.html
83+
retention-days: 1
7884

7985
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
8086
doctest:
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Reusable check if IDLE's help.html is up to date
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
env:
10+
FORCE_COLOR: 1
11+
12+
jobs:
13+
check-idle-doc-sync:
14+
name: 'Check IDLE help.html sync'
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 10 # XXX run and possibly lower!
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
persist-credentials: false
21+
- name: 'Download built idle.html'
22+
uses: actions/download-artifact@v4
23+
with:
24+
name: idle-html
25+
path: Doc/build/html/library
26+
- name: 'Set up Python'
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: '3'
30+
- name: 'Regenerate Lib/idlelib/help.html'
31+
run: python Tools/build/generate_idle_help.py
32+
working-directory: Doc
33+
- name: 'Check for changes'
34+
run: |
35+
git add -u
36+
changes=$(git status --porcelain)
37+
# Check for changes in regenerated files
38+
if test -n "$changes"; then
39+
echo "Generated files not up to date."
40+
echo "Perhaps you forgot to run make idlehelp ;)"
41+
echo "$changes"
42+
echo ""
43+
git diff --staged || true
44+
exit 1
45+
fi

Doc/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ help:
4646
@echo " coverage to check documentation coverage for library and C API"
4747
@echo " doctest to run doctests in the documentation"
4848
@echo " pydoc-topics to regenerate the pydoc topics file"
49+
@echo " idlehelp to regenerate Lib/idlelib/help.html"
4950
@echo " dist to create a \"dist\" directory with archived docs for download"
5051
@echo " check to run a check for frequent markup errors"
5152

@@ -143,6 +144,10 @@ pydoc-topics: build
143144
"cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py" \
144145
"&& cp build/pydoc-topics/module_docs.py ../Lib/pydoc_data/module_docs.py"
145146

147+
.PHONY: idlehelp
148+
idlehelp: html
149+
$(PYTHON) ../Tools/build/generate_idle_help.py
150+
146151
.PHONY: gettext
147152
gettext: BUILDER = gettext
148153
gettext: override SPHINXOPTS := --doctree-dir build/doctrees-gettext $(SPHINXOPTS)

Lib/idlelib/help.html

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/idlelib/help.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -248,43 +248,6 @@ def __init__(self, parent, filename, title):
248248
self.grid_rowconfigure(0, weight=1)
249249

250250

251-
def copy_strip(): # pragma: no cover
252-
"""Copy the text part of idle.html to idlelib/help.html while stripping trailing whitespace.
253-
254-
Files with trailing whitespace cannot be pushed to the git cpython
255-
repository. For 3.x (on Windows), help.html is generated, after
256-
editing idle.rst on the master branch, with
257-
sphinx-build -bhtml . build/html
258-
python_d.exe -c "from idlelib.help import copy_strip; copy_strip()"
259-
Check build/html/library/idle.html, the help.html diff, and the text
260-
displayed by Help => IDLE Help. Add a blurb and create a PR.
261-
262-
It can be worthwhile to occasionally generate help.html without
263-
touching idle.rst. Changes to the master version and to the doc
264-
build system may result in changes that should not change
265-
the displayed text, but might break HelpParser.
266-
267-
As long as master and maintenance versions of idle.rst remain the
268-
same, help.html can be backported. The internal Python version
269-
number is not displayed. If maintenance idle.rst diverges from
270-
the master version, then instead of backporting help.html from
271-
master, repeat the procedure above to generate a maintenance
272-
version.
273-
"""
274-
src = join(abspath(dirname(dirname(dirname(__file__)))),
275-
'Doc', 'build', 'html', 'library', 'idle.html')
276-
dst = join(abspath(dirname(__file__)), 'help.html')
277-
278-
with open(src, 'r', encoding="utf-8") as inn, open(dst, 'w', encoding="utf-8") as out:
279-
copy = False
280-
for line in inn:
281-
if '<section id="idle">' in line: copy = True
282-
if '<div class="clearer">' in line: break
283-
if copy: out.write(line.strip() + '\n')
284-
285-
print(f'{src} copied to {dst}')
286-
287-
288251
def show_idlehelp(parent):
289252
"Create HelpWindow; called from Idle Help event handler."
290253
filename = join(abspath(dirname(__file__)), 'help.html')

Tools/build/generate_idle_help.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Copy the text part of idle.html to idlelib/help.html while stripping trailing whitespace.
2+
3+
Files with trailing whitespace cannot be pushed to the git cpython
4+
repository. help.html is regenerated, after
5+
editing idle.rst on the master branch, with, in the Doc directory
6+
make idlehelp
7+
Check build/html/library/idle.html, the help.html diff, and the text
8+
displayed by Help => IDLE Help. Add a blurb and create a PR.
9+
10+
It can be worthwhile to occasionally generate help.html without
11+
touching idle.rst. Changes to the master version and to the doc
12+
build system may result in changes that should not change
13+
the displayed text, but might break HelpParser.
14+
15+
As long as master and maintenance versions of idle.rst remain the
16+
same, help.html can be backported. The internal Python version
17+
number is not displayed. If maintenance idle.rst diverges from
18+
the master version, then instead of backporting help.html from
19+
master, repeat the procedure above to generate a maintenance
20+
version.
21+
"""
22+
23+
def copy_strip():
24+
src = 'build/html/library/idle.html'
25+
dst = '../Lib/idlelib/help.html'
26+
27+
with open(src, encoding="utf-8") as inn, open(dst, 'w', encoding="utf-8") as out:
28+
copy = False
29+
for line in inn:
30+
if '<div class="clearer">' in line:
31+
break
32+
if '<section id="idle">' in line:
33+
copy = True
34+
if copy:
35+
out.write(line.strip() + '\n')
36+
37+
print(f'{src} copied to {dst}')
38+
39+
40+
if __name__ == '__main__':
41+
copy_strip()

0 commit comments

Comments
 (0)