Skip to content

Commit 73f4268

Browse files
docs: consolidate interactive prompt guidance (#1135)
Move prompt style notes into the Code examples section of the style guide, cross-link markup and style-guide sections, and prefer copy-and-paste wording.
1 parent d773e39 commit 73f4268

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎documentation/markup.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,8 @@ There is also a generic version of these directives:
617617
Describes a Python bytecode instruction.
618618

619619

620+
.. _showing-code-examples:
621+
620622
Showing code examples
621623
---------------------
622624

@@ -634,6 +636,9 @@ be no trailing prompt. An example of correct usage is:
634636
>>> 1 + 1
635637
2
636638
639+
Style guidance for when to use secondary prompts, and related copy-and-paste
640+
notes, lives under :ref:`code-examples` in the style guide.
641+
637642
Syntax highlighting is handled in a smart way:
638643

639644
* There is a "highlighting language" for each source file. By default,

‎documentation/style-guide.rst‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,19 @@ a typical use case. For instance, the :meth:`str.rpartition` method is better
350350
demonstrated with an example splitting the domain from a URL than it would be
351351
with an example of removing the last word from a line of Monty Python dialog.
352352

353-
The ellipsis for the :py:data:`sys.ps2` secondary interpreter prompt should only
354-
be used sparingly, where it is necessary to clearly differentiate between input
355-
lines and output lines. Besides contributing visual clutter, it makes it
356-
difficult for readers to cut-and-paste examples so they can experiment with
357-
variations.
353+
When writing interactive examples, keep prompt style consistent and copy-friendly:
354+
355+
* Use the ellipsis for the :py:data:`sys.ps2` secondary interpreter prompt only
356+
sparingly, where it is necessary to clearly differentiate between input lines
357+
and output lines. Besides contributing visual clutter, it makes it harder for
358+
readers to copy-and-paste examples so they can experiment with variations.
359+
(Published docs also offer a copy control on interactive examples that strips
360+
prompts for pasting.)
361+
* After the last line of input or output, do not leave a trailing unused primary
362+
prompt (``>>>``).
363+
364+
For the reST markup used to present interactive sessions, see
365+
:ref:`showing-code-examples`.
358366

359367

360368
Code equivalents

0 commit comments

Comments
 (0)