Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c3a98034
Kaydet (Commit)
c3a98034
authored
Ara 27, 2008
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #4739 by David Laban: add symbols to pydoc help topics,
so that ``help('@')`` works as expected.
üst
bedc3431
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
2 deletions
+58
-2
pydoc.py
Lib/pydoc.py
+55
-2
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/pydoc.py
Dosyayı görüntüle @
c3a98034
...
...
@@ -1574,6 +1574,42 @@ class Helper:
'with'
:
(
'with'
,
'CONTEXTMANAGERS EXCEPTIONS yield'
),
'yield'
:
(
'yield'
,
''
),
}
# Either add symbols to this dictionary or to the symbols dictionary
# directly: Whichever is easier. They are merged later.
_symbols_inverse
=
{
'STRINGS'
:
(
"'"
,
"'''"
,
"r'"
,
"u'"
,
'"""'
,
'"'
,
'r"'
,
'u"'
),
'OPERATORS'
:
(
'+'
,
'-'
,
'*'
,
'**'
,
'/'
,
'//'
,
'
%
'
,
'<<'
,
'>>'
,
'&'
,
'|'
,
'^'
,
'~'
,
'<'
,
'>'
,
'<='
,
'>='
,
'=='
,
'!='
,
'<>'
),
'COMPARISON'
:
(
'<'
,
'>'
,
'<='
,
'>='
,
'=='
,
'!='
,
'<>'
),
'UNARY'
:
(
'-'
,
'~'
),
'AUGMENTEDASSIGNMENT'
:
(
'+='
,
'-='
,
'*='
,
'/='
,
'
%
='
,
'&='
,
'|='
,
'^='
,
'<<='
,
'>>='
,
'**='
,
'//='
),
'BITWISE'
:
(
'<<'
,
'>>'
,
'&'
,
'|'
,
'^'
,
'~'
),
'COMPLEX'
:
(
'j'
,
'J'
)
}
symbols
=
{
'
%
'
:
'OPERATORS FORMATTING'
,
'**'
:
'POWER'
,
','
:
'TUPLES LISTS FUNCTIONS'
,
'.'
:
'ATTRIBUTES FLOAT MODULES OBJECTS'
,
'...'
:
'ELLIPSIS'
,
':'
:
'SLICINGS DICTIONARYLITERALS'
,
'@'
:
'def class'
,
'
\\
'
:
'STRINGS'
,
'_'
:
'PRIVATENAMES'
,
'__'
:
'PRIVATENAMES SPECIALMETHODS'
,
'`'
:
'BACKQUOTES'
,
'('
:
'TUPLES FUNCTIONS CALLS'
,
')'
:
'TUPLES FUNCTIONS CALLS'
,
'['
:
'LISTS SUBSCRIPTS SLICINGS'
,
']'
:
'LISTS SUBSCRIPTS SLICINGS'
}
for
topic
,
symbols_
in
_symbols_inverse
.
iteritems
():
for
symbol
in
symbols_
:
topics
=
symbols
.
get
(
symbol
,
topic
)
if
topic
not
in
topics
:
topics
=
topics
+
' '
+
topic
symbols
[
symbol
]
=
topics
topics
=
{
'TYPES'
:
(
'types'
,
'STRINGS UNICODE NUMBERS SEQUENCES MAPPINGS '
...
...
@@ -1717,10 +1753,12 @@ has the same effect as typing a particular string at the help> prompt.
if
type
(
request
)
is
type
(
''
):
if
request
==
'help'
:
self
.
intro
()
elif
request
==
'keywords'
:
self
.
listkeywords
()
elif
request
==
'symbols'
:
self
.
listsymbols
()
elif
request
==
'topics'
:
self
.
listtopics
()
elif
request
==
'modules'
:
self
.
listmodules
()
elif
request
[:
8
]
==
'modules '
:
self
.
listmodules
(
split
(
request
)[
1
])
elif
request
in
self
.
symbols
:
self
.
showsymbol
(
request
)
elif
request
in
self
.
keywords
:
self
.
showtopic
(
request
)
elif
request
in
self
.
topics
:
self
.
showtopic
(
request
)
elif
request
:
doc
(
request
,
'Help on
%
s:'
)
...
...
@@ -1766,6 +1804,14 @@ Here is a list of the Python keywords. Enter any keyword to get more help.
'''
)
self
.
list
(
self
.
keywords
.
keys
())
def
listsymbols
(
self
):
self
.
output
.
write
(
'''
Here is a list of the punctuation symbols which Python assigns special meaning
to. Enter any symbol to get more help.
'''
)
self
.
list
(
self
.
symbols
.
keys
())
def
listtopics
(
self
):
self
.
output
.
write
(
'''
Here is a list of available topics. Enter any topic name to get more help.
...
...
@@ -1773,7 +1819,7 @@ Here is a list of available topics. Enter any topic name to get more help.
'''
)
self
.
list
(
self
.
topics
.
keys
())
def
showtopic
(
self
,
topic
):
def
showtopic
(
self
,
topic
,
more_xrefs
=
''
):
try
:
import
pydoc_topics
except
ImportError
:
...
...
@@ -1787,7 +1833,7 @@ module "pydoc_topics" could not be found.
self
.
output
.
write
(
'no documentation found for
%
s
\n
'
%
repr
(
topic
))
return
if
type
(
target
)
is
type
(
''
):
return
self
.
showtopic
(
target
)
return
self
.
showtopic
(
target
,
more_xrefs
)
label
,
xrefs
=
target
try
:
...
...
@@ -1796,6 +1842,8 @@ module "pydoc_topics" could not be found.
self
.
output
.
write
(
'no documentation found for
%
s
\n
'
%
repr
(
topic
))
return
pager
(
strip
(
doc
)
+
'
\n
'
)
if
more_xrefs
:
xrefs
=
(
xrefs
or
''
)
+
' '
+
more_xrefs
if
xrefs
:
import
StringIO
,
formatter
buffer
=
StringIO
.
StringIO
()
...
...
@@ -1803,6 +1851,11 @@ module "pydoc_topics" could not be found.
'Related help topics: '
+
join
(
split
(
xrefs
),
', '
)
+
'
\n
'
)
self
.
output
.
write
(
'
\n
%
s
\n
'
%
buffer
.
getvalue
())
def
showsymbol
(
self
,
symbol
):
target
=
self
.
symbols
[
symbol
]
topic
,
_
,
xrefs
=
target
.
partition
(
' '
)
self
.
showtopic
(
topic
,
xrefs
)
def
listmodules
(
self
,
key
=
''
):
if
key
:
self
.
output
.
write
(
'''
...
...
Misc/NEWS
Dosyayı görüntüle @
c3a98034
...
...
@@ -86,6 +86,9 @@ Core and Builtins
Library
-------
- Issue #4739: Add pydoc help topics for symbols, so that e.g. help('@')
works as expected in the interactive environment.
- Issue #4756: zipfile.is_zipfile() now supports file-like objects. Patch by
Gabriel Genellina.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment