Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 53 additions & 17 deletions Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,55 @@ def writedocs(dir, pkgpath='', done=None):
writedoc(modname)
return


def _intro_basic():
# Intro text if basic REPL is used.
ver = '%d.%d' % sys.version_info[:2]
return f'''\
Welcome to Python {ver}'s help utility! If this is your first time using
Python, you should definitely check out the tutorial at
https://docs.python.org/{ver}/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To get a list of available
modules, keywords, symbols, or topics, enter "modules", "keywords",
"symbols", or "topics".

Each module also comes with a one-line summary of what it does; to list
the modules whose name or summary contain a given string such as "spam",
enter "modules spam".

To quit this help utility and return to the interpreter,
enter "q", "quit" or "exit".
'''


def _intro_pyrepl():
# Intro text if enhanced (non-basic) REPL is used.
ver = '%d.%d' % sys.version_info[:2]
return f'''
Welcome to Python {ver}'s help utility! If this is your first time using
Python, you should definitely check out the tutorial at
https://docs.python.org/{ver}/tutorial/.

You can use the following keyboard shortcuts at the main interpreter prompt.
F1: enter interactive help, F2: enter history browsing mode, F3: enter paste
mode (press again to exit).

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To get a list of available
modules, keywords, symbols, or topics, enter "modules", "keywords",
"symbols", or "topics".

Each module also comes with a one-line summary of what it does; to list
the modules whose name or summary contain a given string such as "spam",
enter "modules spam".

To quit this help utility and return to the interpreter,
enter "q", "quit" or "exit".
'''


class Helper:

# These dictionaries map a topic name to either an alias, or a tuple
Expand Down Expand Up @@ -2063,23 +2112,10 @@ def help(self, request, is_cli=False):
self.output.write('\n')

def intro(self):
self.output.write('''\
Welcome to Python {0}'s help utility! If this is your first time using
Python, you should definitely check out the tutorial at
https://docs.python.org/{0}/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To get a list of available
modules, keywords, symbols, or topics, enter "modules", "keywords",
"symbols", or "topics".

Each module also comes with a one-line summary of what it does; to list
the modules whose name or summary contain a given string such as "spam",
enter "modules spam".

To quit this help utility and return to the interpreter,
enter "q", "quit" or "exit".
'''.format('%d.%d' % sys.version_info[:2]))
if os.environ.get('PYTHON_BASIC_REPL'):
self.output.write(_intro_basic())
else:
self.output.write(_intro_pyrepl())

def list(self, items, columns=4, width=80):
items = list(sorted(items))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
As part of the builtin help intro text, show the keyboard shortcuts for the
new, non-basic REPL (F1, F2, and F3).
Loading