Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
30b56290
Commit
30b56290
authored
Jan 05, 2009
by
Jason Evans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Take care to preserve cpdef method docstrings when prepending signatures.
parent
c9235aa4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
Cython/Compiler/AutoDocTransforms.py
Cython/Compiler/AutoDocTransforms.py
+15
-2
tests/run/embedsignatures.pyx
tests/run/embedsignatures.pyx
+32
-0
No files found.
Cython/Compiler/AutoDocTransforms.py
View file @
30b56290
...
@@ -135,7 +135,14 @@ class EmbedSignature(CythonTransform):
...
@@ -135,7 +135,14 @@ class EmbedSignature(CythonTransform):
doc_holder
=
self
.
class_node
.
entry
.
type
.
scope
doc_holder
=
self
.
class_node
.
entry
.
type
.
scope
else
:
else
:
doc_holder
=
node
.
entry
doc_holder
=
node
.
entry
new_doc
=
self
.
_embed_signature
(
signature
,
doc_holder
.
doc
)
if
doc_holder
.
doc
is
not
None
:
old_doc
=
doc_holder
.
doc
elif
not
is_constructor
and
getattr
(
node
,
'py_func'
,
None
)
is
not
None
:
old_doc
=
node
.
py_func
.
entry
.
doc
else
:
old_doc
=
None
new_doc
=
self
.
_embed_signature
(
signature
,
old_doc
)
doc_holder
.
doc
=
EncodedString
(
new_doc
)
doc_holder
.
doc
=
EncodedString
(
new_doc
)
if
not
is_constructor
and
getattr
(
node
,
'py_func'
,
None
)
is
not
None
:
if
not
is_constructor
and
getattr
(
node
,
'py_func'
,
None
)
is
not
None
:
node
.
py_func
.
entry
.
doc
=
EncodedString
(
new_doc
)
node
.
py_func
.
entry
.
doc
=
EncodedString
(
new_doc
)
...
@@ -152,7 +159,13 @@ class EmbedSignature(CythonTransform):
...
@@ -152,7 +159,13 @@ class EmbedSignature(CythonTransform):
node
.
declarator
.
args
,
node
.
declarator
.
args
,
return_type
=
node
.
return_type
)
return_type
=
node
.
return_type
)
if
signature
:
if
signature
:
new_doc
=
self
.
_embed_signature
(
signature
,
node
.
entry
.
doc
)
if
node
.
entry
.
doc
is
not
None
:
old_doc
=
node
.
entry
.
doc
elif
hasattr
(
node
,
'py_func'
)
and
node
.
py_func
is
not
None
:
old_doc
=
node
.
py_func
.
entry
.
doc
else
:
old_doc
=
None
new_doc
=
self
.
_embed_signature
(
signature
,
old_doc
)
node
.
entry
.
doc
=
EncodedString
(
new_doc
)
node
.
entry
.
doc
=
EncodedString
(
new_doc
)
if
hasattr
(
node
,
'py_func'
)
and
node
.
py_func
is
not
None
:
if
hasattr
(
node
,
'py_func'
)
and
node
.
py_func
is
not
None
:
node
.
py_func
.
entry
.
doc
=
EncodedString
(
new_doc
)
node
.
py_func
.
entry
.
doc
=
EncodedString
(
new_doc
)
...
...
tests/run/embedsignatures.pyx
View file @
30b56290
...
@@ -32,12 +32,20 @@ __doc__ = ur"""
...
@@ -32,12 +32,20 @@ __doc__ = ur"""
>>> print (Ext.k.__doc__)
>>> print (Ext.k.__doc__)
Ext.k(self, a, b, c=1, *args, d=42, e=17, f, **kwds)
Ext.k(self, a, b, c=1, *args, d=42, e=17, f, **kwds)
>>> print (Ext.l.__doc__)
Ext.l(self, a, b, c=1, *args, d=42, e=17, f, **kwds)
Existing string
>>> print (Ext.get_int.__doc__)
>>> print (Ext.get_int.__doc__)
Ext.get_int(self) -> int
Ext.get_int(self) -> int
>>> print (Ext.get_float.__doc__)
>>> print (Ext.get_float.__doc__)
Ext.get_float(self) -> float
Ext.get_float(self) -> float
>>> print (Ext.get_str.__doc__)
Ext.get_str(self) -> str
Existing string
>>> print (Ext.clone.__doc__)
>>> print (Ext.clone.__doc__)
Ext.clone(self) -> Ext
Ext.clone(self) -> Ext
...
@@ -50,6 +58,12 @@ __doc__ = ur"""
...
@@ -50,6 +58,12 @@ __doc__ = ur"""
>>> with_doc_2.__doc__
>>> with_doc_2.__doc__
'with_doc_2(a, b, c)\n\n Existing string\n '
'with_doc_2(a, b, c)\n\n Existing string\n '
>>> with_doc_3.__doc__
'with_doc_3(a, b, c)\nExisting string'
>>> with_doc_4.__doc__
'with_doc_4(int a, str b, list c) -> str\n\n Existing string\n '
>>> types.__doc__
>>> types.__doc__
'types(Ext a, int b, unsigned short c, float d, e)'
'types(Ext a, int b, unsigned short c, float d, e)'
...
@@ -146,12 +160,20 @@ cdef class Ext:
...
@@ -146,12 +160,20 @@ cdef class Ext:
def
k
(
self
,
a
,
b
,
c
=
1
,
*
args
,
d
=
42
,
e
=
17
,
f
,
**
kwds
):
def
k
(
self
,
a
,
b
,
c
=
1
,
*
args
,
d
=
42
,
e
=
17
,
f
,
**
kwds
):
pass
pass
def
l
(
self
,
a
,
b
,
c
=
1
,
*
args
,
d
=
42
,
e
=
17
,
f
,
**
kwds
):
"""Existing string"""
pass
cpdef
int
get_int
(
self
):
cpdef
int
get_int
(
self
):
return
0
return
0
cpdef
float
get_float
(
self
):
cpdef
float
get_float
(
self
):
return
0.0
return
0.0
cpdef
str
get_str
(
self
):
"""Existing string"""
return
"string"
cpdef
Ext
clone
(
self
):
cpdef
Ext
clone
(
self
):
return
Ext
(
1
,
2
)
return
Ext
(
1
,
2
)
...
@@ -171,6 +193,16 @@ def with_doc_2(a, b, c):
...
@@ -171,6 +193,16 @@ def with_doc_2(a, b, c):
"""
"""
pass
pass
cpdef
with_doc_3
(
a
,
b
,
c
):
"""Existing string"""
pass
cpdef
str
with_doc_4
(
int
a
,
str
b
,
list
c
):
"""
Existing string
"""
return
b
cpdef
char
f_c
(
char
c
):
cpdef
char
f_c
(
char
c
):
return
c
return
c
...
...
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