Skip to content

Commit 01421be

Browse files
csabellaterryjreedy
authored andcommitted
bpo-35521: IDLE: Add code context section to docs (python#11205)
Also add some internal cross-references.
1 parent afe17a7 commit 01421be

File tree

3 files changed

+65
-17
lines changed

3 files changed

+65
-17
lines changed

Doc/library/idle.rst

+35-6
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,16 @@ Go to Line
146146

147147
Show Completions
148148
Open a scrollable list allowing selection of keywords and attributes. See
149-
Completions in the Tips sections below.
149+
:ref:`Completions <completions>` in the Editing and navigation section below.
150150

151151
Expand Word
152152
Expand a prefix you have typed to match a full word in the same window;
153153
repeat to get a different expansion.
154154

155155
Show call tip
156156
After an unclosed parenthesis for a function, open a small window with
157-
function parameter hints.
157+
function parameter hints. See :ref:`Calltips <calltips>` in the
158+
Editing and navigation section below.
158159

159160
Show surrounding parens
160161
Highlight the surrounding parenthesis.
@@ -278,8 +279,8 @@ Configure IDLE
278279

279280
Code Context (toggle)(Editor Window only)
280281
Open a pane at the top of the edit window which shows the block context
281-
of the code which has scrolled above the top of the window. Clicking a
282-
line in this pane exposes that line at the top of the editor.
282+
of the code which has scrolled above the top of the window. See
283+
:ref:`Code Context <code-context>` in the Editing and Navigation section below.
283284

284285
Window menu (Shell and Editor)
285286
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -310,8 +311,8 @@ Turtle Demo
310311
Run the turtledemo module with example Python code and turtle drawings.
311312

312313
Additional help sources may be added here with the Configure IDLE dialog under
313-
the General tab. See the "Help sources" subsection below for more
314-
on Help menu choices.
314+
the General tab. See the :ref:`Help sources <help-sources>` subsection below
315+
for more on Help menu choices.
315316

316317
.. index::
317318
single: Cut
@@ -359,6 +360,8 @@ Squeeze
359360
the code above and the prompt below down to a 'Squeezed text' label.
360361

361362

363+
.. _editing-and-navigation:
364+
362365
Editing and navigation
363366
----------------------
364367

@@ -431,6 +434,9 @@ are restricted to four spaces due to Tcl/Tk limitations.
431434

432435
See also the indent/dedent region commands in the edit menu.
433436

437+
438+
.. _completions:
439+
434440
Completions
435441
^^^^^^^^^^^
436442

@@ -475,6 +481,8 @@ much can be found by default, e.g. the re module.
475481
If you don't like the ACW popping up unbidden, simply make the delay
476482
longer or disable the extension.
477483

484+
.. _calltips:
485+
478486
Calltips
479487
^^^^^^^^
480488

@@ -503,6 +511,25 @@ In an editor, import statements have no effect until one runs the file. One
503511
might want to run a file after writing the import statements at the top,
504512
or immediately run an existing file before editing.
505513

514+
.. _code-context:
515+
516+
Code Context
517+
^^^^^^^^^^^^
518+
519+
Within an editor window containing Python code, code context can be toggled
520+
in order to show or hide a pane at the top of the window. When shown, this
521+
pane freezes the opening lines for block code, such as those beginning with
522+
``class``, ``def``, or ``if`` keywords, that would have otherwise scrolled
523+
out of view. The size of the pane will be expanded and contracted as needed
524+
to show the all current levels of context, up to the maximum number of
525+
lines defined in the Configure IDLE dialog (which defaults to 15). If there
526+
are no current context lines and the feature is toggled on, a single blank
527+
line will display. Clicking on a line in the context pane will move that
528+
line to the top of the editor.
529+
530+
The text and background colors for the context pane can be configured under
531+
the Highlights tab in the Configure IDLE dialog.
532+
506533
Python Shell window
507534
^^^^^^^^^^^^^^^^^^^
508535

@@ -768,6 +795,8 @@ with the default subprocess if at all possible.
768795
Help and preferences
769796
--------------------
770797

798+
.. _help-sources:
799+
771800
Help sources
772801
^^^^^^^^^^^^
773802

Lib/idlelib/help.html

+28-11
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,14 @@ <h3>Edit menu (Shell and Editor)<a class="headerlink" href="#edit-menu-shell-and
202202
<dd>Move cursor to the line number requested and make that line visible.</dd>
203203
<dt>Show Completions</dt>
204204
<dd>Open a scrollable list allowing selection of keywords and attributes. See
205-
Completions in the Tips sections below.</dd>
205+
<a class="reference internal" href="#completions"><span class="std std-ref">Completions</span></a> in the Editing and navigation section below.</dd>
206206
<dt>Expand Word</dt>
207207
<dd>Expand a prefix you have typed to match a full word in the same window;
208208
repeat to get a different expansion.</dd>
209209
<dt>Show call tip</dt>
210210
<dd>After an unclosed parenthesis for a function, open a small window with
211-
function parameter hints.</dd>
211+
function parameter hints. See <a class="reference internal" href="#calltips"><span class="std std-ref">Calltips</span></a> in the
212+
Editing and navigation section below.</dd>
212213
<dt>Show surrounding parens</dt>
213214
<dd>Highlight the surrounding parenthesis.</dd>
214215
</dl>
@@ -314,8 +315,8 @@ <h3>Options menu (Shell and Editor)<a class="headerlink" href="#options-menu-she
314315
</dd>
315316
<dt>Code Context (toggle)(Editor Window only)</dt>
316317
<dd>Open a pane at the top of the edit window which shows the block context
317-
of the code which has scrolled above the top of the window. Clicking a
318-
line in this pane exposes that line at the top of the editor.</dd>
318+
of the code which has scrolled above the top of the window. See
319+
<a class="reference internal" href="#code-context"><span class="std std-ref">Code Context</span></a> in the Editing and Navigation section below.</dd>
319320
</dl>
320321
</div>
321322
<div class="section" id="window-menu-shell-and-editor">
@@ -344,8 +345,8 @@ <h3>Help menu (Shell and Editor)<a class="headerlink" href="#help-menu-shell-and
344345
<dd>Run the turtledemo module with example Python code and turtle drawings.</dd>
345346
</dl>
346347
<p>Additional help sources may be added here with the Configure IDLE dialog under
347-
the General tab. See the Help sources subsection below for more
348-
on Help menu choices.</p>
348+
the General tab. See the <a class="reference internal" href="#help-sources"><span class="std std-ref">Help sources</span></a> subsection below
349+
for more on Help menu choices.</p>
349350
</div>
350351
<div class="section" id="context-menus">
351352
<span id="index-4"></span><h3>Context Menus<a class="headerlink" href="#context-menus" title="Permalink to this headline"></a></h3>
@@ -383,7 +384,7 @@ <h3>Help menu (Shell and Editor)<a class="headerlink" href="#help-menu-shell-and
383384
</div>
384385
</div>
385386
<div class="section" id="editing-and-navigation">
386-
<h2>Editing and navigation<a class="headerlink" href="#editing-and-navigation" title="Permalink to this headline"></a></h2>
387+
<span id="id2"></span><h2>Editing and navigation<a class="headerlink" href="#editing-and-navigation" title="Permalink to this headline"></a></h2>
387388
<div class="section" id="editor-windows">
388389
<h3>Editor windows<a class="headerlink" href="#editor-windows" title="Permalink to this headline"></a></h3>
389390
<p>IDLE may open editor windows when it starts, depending on settings
@@ -445,7 +446,7 @@ <h3>Automatic indentation<a class="headerlink" href="#automatic-indentation" tit
445446
<p>See also the indent/dedent region commands in the edit menu.</p>
446447
</div>
447448
<div class="section" id="completions">
448-
<h3>Completions<a class="headerlink" href="#completions" title="Permalink to this headline"></a></h3>
449+
<span id="id3"></span><h3>Completions<a class="headerlink" href="#completions" title="Permalink to this headline"></a></h3>
449450
<p>Completions are supplied for functions, classes, and attributes of classes,
450451
both built-in and user-defined. Completions are also provided for
451452
filenames.</p>
@@ -480,7 +481,7 @@ <h3>Completions<a class="headerlink" href="#completions" title="Permalink to thi
480481
longer or disable the extension.</p>
481482
</div>
482483
<div class="section" id="calltips">
483-
<h3>Calltips<a class="headerlink" href="#calltips" title="Permalink to this headline"></a></h3>
484+
<span id="id4"></span><h3>Calltips<a class="headerlink" href="#calltips" title="Permalink to this headline"></a></h3>
484485
<p>A calltip is shown when one types <kbd class="kbd docutils literal notranslate">(</kbd> after the name of an <em>accessible</em>
485486
function. A name expression may include dots and subscripts. A calltip
486487
remains until it is clicked, the cursor is moved out of the argument area,
@@ -502,6 +503,21 @@ <h3>Calltips<a class="headerlink" href="#calltips" title="Permalink to this head
502503
might want to run a file after writing the import statements at the top,
503504
or immediately run an existing file before editing.</p>
504505
</div>
506+
<div class="section" id="code-context">
507+
<span id="id5"></span><h3>Code Context<a class="headerlink" href="#code-context" title="Permalink to this headline"></a></h3>
508+
<p>Within an editor window containing Python code, code context can be toggled
509+
in order to show or hide a pane at the top of the window. When shown, this
510+
pane freezes the opening lines for block code, such as those beginning with
511+
<code class="docutils literal notranslate"><span class="pre">class</span></code>, <code class="docutils literal notranslate"><span class="pre">def</span></code>, or <code class="docutils literal notranslate"><span class="pre">if</span></code> keywords, that would have otherwise scrolled
512+
out of view. The size of the pane will be expanded and contracted as needed
513+
to show the all current levels of context, up to the maximum number of
514+
lines defined in the Configure IDLE dialog (which defaults to 15). If there
515+
are no current context lines and the feature is toggled on, a single blank
516+
line will display. Clicking on a line in the context pane will move that
517+
line to the top of the editor.</p>
518+
<p>The text and background colors for the context pane can be configured under
519+
the Highlights tab in the Configure IDLE dialog.</p>
520+
</div>
505521
<div class="section" id="python-shell-window">
506522
<h3>Python Shell window<a class="headerlink" href="#python-shell-window" title="Permalink to this headline"></a></h3>
507523
<p>With IDLE’s Shell, one enters, edits, and recalls complete statements.
@@ -733,7 +749,7 @@ <h3>Running without a subprocess<a class="headerlink" href="#running-without-a-s
733749
<div class="section" id="help-and-preferences">
734750
<h2>Help and preferences<a class="headerlink" href="#help-and-preferences" title="Permalink to this headline"></a></h2>
735751
<div class="section" id="help-sources">
736-
<h3>Help sources<a class="headerlink" href="#help-sources" title="Permalink to this headline"></a></h3>
752+
<span id="id6"></span><h3>Help sources<a class="headerlink" href="#help-sources" title="Permalink to this headline"></a></h3>
737753
<p>Help menu entry “IDLE Help” displays a formatted html version of the
738754
IDLE chapter of the Library Reference. The result, in a read-only
739755
tkinter text window, is close to what one sees in a web browser.
@@ -801,6 +817,7 @@ <h3><a href="../contents.html">Table of Contents</a></h3>
801817
<li><a class="reference internal" href="#automatic-indentation">Automatic indentation</a></li>
802818
<li><a class="reference internal" href="#completions">Completions</a></li>
803819
<li><a class="reference internal" href="#calltips">Calltips</a></li>
820+
<li><a class="reference internal" href="#code-context">Code Context</a></li>
804821
<li><a class="reference internal" href="#python-shell-window">Python Shell window</a></li>
805822
<li><a class="reference internal" href="#text-colors">Text colors</a></li>
806823
</ul>
@@ -899,7 +916,7 @@ <h3>Navigation</h3>
899916
<br />
900917
<br />
901918

902-
Last updated on Nov 12, 2018.
919+
Last updated on Dec 19, 2018.
903920
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
904921
<br />
905922

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Document the IDLE editor code context feature. Add some internal references
2+
within the IDLE doc.

0 commit comments

Comments
 (0)