mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
#11926: add missing keywords to help("keywords").
This commit is contained in:
parent
507cbc1773
commit
b185a04aa1
3 changed files with 51 additions and 38 deletions
11
Lib/pydoc.py
11
Lib/pydoc.py
|
@ -1538,6 +1538,9 @@ class Helper:
|
||||||
# in Doc/ and copying the output file into the Lib/ directory.
|
# in Doc/ and copying the output file into the Lib/ directory.
|
||||||
|
|
||||||
keywords = {
|
keywords = {
|
||||||
|
'False': '',
|
||||||
|
'None': '',
|
||||||
|
'True': '',
|
||||||
'and': 'BOOLEAN',
|
'and': 'BOOLEAN',
|
||||||
'as': 'with',
|
'as': 'with',
|
||||||
'assert': ('assert', ''),
|
'assert': ('assert', ''),
|
||||||
|
@ -1552,12 +1555,13 @@ class Helper:
|
||||||
'finally': 'try',
|
'finally': 'try',
|
||||||
'for': ('for', 'break continue while'),
|
'for': ('for', 'break continue while'),
|
||||||
'from': 'import',
|
'from': 'import',
|
||||||
'global': ('global', 'NAMESPACES'),
|
'global': ('global', 'nonlocal NAMESPACES'),
|
||||||
'if': ('if', 'TRUTHVALUE'),
|
'if': ('if', 'TRUTHVALUE'),
|
||||||
'import': ('import', 'MODULES'),
|
'import': ('import', 'MODULES'),
|
||||||
'in': ('in', 'SEQUENCEMETHODS'),
|
'in': ('in', 'SEQUENCEMETHODS'),
|
||||||
'is': 'COMPARISON',
|
'is': 'COMPARISON',
|
||||||
'lambda': ('lambda', 'FUNCTIONS'),
|
'lambda': ('lambda', 'FUNCTIONS'),
|
||||||
|
'nonlocal': ('nonlocal', 'global NAMESPACES'),
|
||||||
'not': 'BOOLEAN',
|
'not': 'BOOLEAN',
|
||||||
'or': 'BOOLEAN',
|
'or': 'BOOLEAN',
|
||||||
'pass': ('pass', ''),
|
'pass': ('pass', ''),
|
||||||
|
@ -1652,7 +1656,7 @@ class Helper:
|
||||||
'NUMBERMETHODS': ('numeric-types', 'NUMBERS AUGMENTEDASSIGNMENT '
|
'NUMBERMETHODS': ('numeric-types', 'NUMBERS AUGMENTEDASSIGNMENT '
|
||||||
'SPECIALMETHODS'),
|
'SPECIALMETHODS'),
|
||||||
'EXECUTION': ('execmodel', 'NAMESPACES DYNAMICFEATURES EXCEPTIONS'),
|
'EXECUTION': ('execmodel', 'NAMESPACES DYNAMICFEATURES EXCEPTIONS'),
|
||||||
'NAMESPACES': ('naming', 'global ASSIGNMENT DELETION DYNAMICFEATURES'),
|
'NAMESPACES': ('naming', 'global nonlocal ASSIGNMENT DELETION DYNAMICFEATURES'),
|
||||||
'DYNAMICFEATURES': ('dynamic-features', ''),
|
'DYNAMICFEATURES': ('dynamic-features', ''),
|
||||||
'SCOPING': 'NAMESPACES',
|
'SCOPING': 'NAMESPACES',
|
||||||
'FRAMES': 'NAMESPACES',
|
'FRAMES': 'NAMESPACES',
|
||||||
|
@ -1752,6 +1756,9 @@ has the same effect as typing a particular string at the help> prompt.
|
||||||
elif request[:8] == 'modules ':
|
elif request[:8] == 'modules ':
|
||||||
self.listmodules(request.split()[1])
|
self.listmodules(request.split()[1])
|
||||||
elif request in self.symbols: self.showsymbol(request)
|
elif request in self.symbols: self.showsymbol(request)
|
||||||
|
elif request in ['True', 'False', 'None']:
|
||||||
|
# special case these keywords since they are objects too
|
||||||
|
doc(eval(request), 'Help on %s:')
|
||||||
elif request in self.keywords: self.showtopic(request)
|
elif request in self.keywords: self.showtopic(request)
|
||||||
elif request in self.topics: self.showtopic(request)
|
elif request in self.topics: self.showtopic(request)
|
||||||
elif request: doc(request, 'Help on %s:')
|
elif request: doc(request, 'Help on %s:')
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6,6 +6,7 @@ import subprocess
|
||||||
import re
|
import re
|
||||||
import pydoc
|
import pydoc
|
||||||
import inspect
|
import inspect
|
||||||
|
import keyword
|
||||||
import unittest
|
import unittest
|
||||||
import test.support
|
import test.support
|
||||||
import xml.etree
|
import xml.etree
|
||||||
|
@ -344,8 +345,13 @@ class TestDescriptions(unittest.TestCase):
|
||||||
self.assertTrue(expected in pydoc.render_doc(c))
|
self.assertTrue(expected in pydoc.render_doc(c))
|
||||||
|
|
||||||
|
|
||||||
|
class TestHelper(unittest.TestCase):
|
||||||
|
def test_keywords(self):
|
||||||
|
self.assertEqual(sorted(pydoc.Helper.keywords),
|
||||||
|
sorted(keyword.kwlist))
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
test.support.run_unittest(PyDocDocTest, TestDescriptions)
|
test.support.run_unittest(PyDocDocTest, TestDescriptions, TestHelper)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
test_main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue