This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cython: embed signatures in docstrings
- Loading branch information
Showing
7 changed files
with
108 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.22 | ||
0.22.p1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
commit 9139a7f836151fb5bdb1624a05dce13b1bb17164 | ||
Author: Stefan Behnel <stefan_ml@behnel.de> | ||
Date: Mon Apr 6 10:45:48 2015 +0200 | ||
|
||
support NULL as default argument in auto doc transform | ||
|
||
diff --git a/Cython/Compiler/AutoDocTransforms.py b/Cython/Compiler/AutoDocTransforms.py | ||
index 775f635..88b0cd8 100644 | ||
--- a/Cython/Compiler/AutoDocTransforms.py | ||
+++ b/Cython/Compiler/AutoDocTransforms.py | ||
@@ -51,6 +51,8 @@ class EmbedSignature(CythonTransform): | ||
default_val = arg.default | ||
if not default_val: | ||
return None | ||
+ if isinstance(default_val, ExprNodes.NullNode): | ||
+ return 'NULL' | ||
try: | ||
denv = self.denv # XXX | ||
ctval = default_val.compile_time_value(self.denv) | ||
diff --git a/tests/run/embedsignatures.pyx b/tests/run/embedsignatures.pyx | ||
index 0bfebfe..781cd21 100644 | ||
--- a/tests/run/embedsignatures.pyx | ||
+++ b/tests/run/embedsignatures.pyx | ||
@@ -199,6 +199,9 @@ __doc__ = ur""" | ||
|
||
>>> print(funcdoc(f_defexpr5)) | ||
f_defexpr5(int x=4) | ||
+ | ||
+ >>> print(funcdoc(f_charptr_null)) | ||
+ f_charptr_null(char *s=NULL) -> char * | ||
""" | ||
|
||
cdef class Ext: | ||
@@ -403,6 +406,10 @@ cpdef f_defexpr4(int x = (Ext.CONST1 + FLAG1) * Ext.CONST2): | ||
cpdef f_defexpr5(int x = 2+2): | ||
pass | ||
|
||
+cpdef (char*) f_charptr_null(char* s=NULL): | ||
+ return s or b'abc' | ||
+ | ||
+ | ||
# no signatures for lambda functions | ||
lambda_foo = lambda x: 10 | ||
lambda_bar = lambda x: 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters