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
a4b6b531
Kaydet (Commit)
a4b6b531
authored
Ock 27, 2014
tarafından
Terry Jan Reedy
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge heads.
üst
1ac00950
a0f1e220
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
14 deletions
+33
-14
CallTips.py
Lib/idlelib/CallTips.py
+9
-6
test_calltips.py
Lib/idlelib/idle_test/test_calltips.py
+24
-8
No files found.
Lib/idlelib/CallTips.py
Dosyayı görüntüle @
a4b6b531
...
...
@@ -5,16 +5,16 @@ parameter and docstring information when you type an opening parenthesis, and
which disappear when you type a closing parenthesis.
"""
import
__main__
import
inspect
import
re
import
sys
import
textwrap
import
types
import
inspect
from
idlelib
import
CallTipWindow
from
idlelib.HyperParser
import
HyperParser
import
__main__
class
CallTips
:
menudefs
=
[
...
...
@@ -117,8 +117,9 @@ def get_entity(expression):
return
None
# The following are used in get_argspec and some in tests
_MAX_COLS
=
79
_MAX_COLS
=
85
_MAX_LINES
=
5
# enough for bytes
_INDENT
=
' '
*
4
# for wrapped signatures
_first_param
=
re
.
compile
(
'(?<=
\
()
\
w*
\
,?
\
s*'
)
_default_callable_argspec
=
"See source or doc"
...
...
@@ -149,13 +150,15 @@ def get_argspec(ob):
isinstance
(
ob_call
,
types
.
MethodType
)):
argspec
=
_first_param
.
sub
(
""
,
argspec
)
lines
=
(
textwrap
.
wrap
(
argspec
,
_MAX_COLS
,
subsequent_indent
=
_INDENT
)
if
len
(
argspec
)
>
_MAX_COLS
else
[
argspec
]
if
argspec
else
[])
if
isinstance
(
ob_call
,
types
.
MethodType
):
doc
=
ob_call
.
__doc__
else
:
doc
=
getattr
(
ob
,
"__doc__"
,
""
)
if
doc
:
lines
=
[
argspec
]
if
argspec
else
[]
for
line
in
doc
.
split
(
'
\n
'
,
5
)[:
_MAX_LINES
]:
for
line
in
doc
.
split
(
'
\n
'
,
_MAX_LINES
)[:
_MAX_LINES
]:
line
=
line
.
strip
()
if
not
line
:
break
...
...
Lib/idlelib/idle_test/test_calltips.py
Dosyayı görüntüle @
a4b6b531
import
unittest
import
idlelib.CallTips
as
ct
import
textwrap
import
types
default_tip
=
ct
.
_default_callable_argspec
...
...
@@ -64,20 +65,35 @@ class Get_signatureTest(unittest.TestCase):
gtest
(
types
.
MethodType
,
"method(function, instance)"
)
gtest
(
SB
(),
default_tip
)
def
test_signature_wrap
(
self
):
self
.
assertEqual
(
signature
(
textwrap
.
TextWrapper
),
'''
\
(width=70, initial_indent='', subsequent_indent='', expand_tabs=True,
replace_whitespace=True, fix_sentence_endings=False, break_long_words=True,
drop_whitespace=True, break_on_hyphens=True, tabsize=8)'''
)
def
test_docline_truncation
(
self
):
def
f
():
pass
f
.
__doc__
=
'a'
*
300
self
.
assertEqual
(
signature
(
f
),
'()
\n
'
+
'a'
*
(
ct
.
_MAX_COLS
-
3
)
+
'...'
)
def
test_multiline_docstring
(
self
):
# Test fewer lines than max.
self
.
assertEqual
(
signature
(
list
),
"list() -> new empty list
\n
"
"list(iterable) -> new list initialized from iterable's items"
)
# Test max lines and line (currently) too long.
self
.
assertEqual
(
signature
(
bytes
),
"bytes(iterable_of_ints) -> bytes
\n
"
"bytes(string, encoding[, errors]) -> bytes
\n
"
"bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
\n
"
#bytes(int) -> bytes object of size given by the parameter initialized with null bytes
"bytes(int) -> bytes object of size given by the parameter initialized with n...
\n
"
"bytes() -> empty bytes object"
)
# Test max lines
self
.
assertEqual
(
signature
(
bytes
),
'''
\
bytes(iterable_of_ints) -> bytes
bytes(string, encoding[, errors]) -> bytes
bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
bytes(int) -> bytes object of size given by the parameter initialized with null bytes
bytes() -> empty bytes object'''
)
# Test more than max lines
def
f
():
pass
f
.
__doc__
=
'a
\n
'
*
15
self
.
assertEqual
(
signature
(
f
),
'()'
+
'
\n
a'
*
ct
.
_MAX_LINES
)
def
test_functions
(
self
):
def
t1
():
'doc'
...
...
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