Cython has moved to github.
cython-devel
view tests/run/embedsignatures.pyx @ 1476:31644ed14440
embed __init__ signature in class docstring
| author | Stefan Behnel <scoder@users.berlios.de> |
|---|---|
| date | Thu Dec 11 09:57:31 2008 +0100 (3 years ago) |
| parents | d065589d0191 |
| children | 4486c09becf3 |
line source
1 #cython: embedsignature=True
3 # note the r, we use \n below
4 __doc__ = ur"""
5 >>> print (Ext.__doc__)
6 Ext(a, b, c=None)
8 >>> print (Ext.a.__doc__)
9 Ext.a(self)
11 >>> print (Ext.b.__doc__)
12 Ext.b(self, a, b, c)
14 >>> print (Ext.c.__doc__)
15 Ext.c(self, a, b, c=1)
17 >>> print (Ext.d.__doc__)
18 Ext.d(self, a, b, *, c=88)
20 >>> print (Ext.e.__doc__)
21 Ext.e(self, a, b, c=88, **kwds)
23 >>> print (Ext.f.__doc__)
24 Ext.f(self, a, b, *, c, d=42)
26 >>> print (Ext.g.__doc__)
27 Ext.g(self, a, b, *, c, d=42, e=17, f, **kwds)
29 >>> print (Ext.h.__doc__)
30 Ext.h(self, a, b, *args, c, d=42, e=17, f, **kwds)
32 >>> print (Ext.k.__doc__)
33 Ext.k(self, a, b, c=1, *args, d=42, e=17, f, **kwds)
35 >>> print (Ext.get_int.__doc__)
36 Ext.get_int(self) -> int
38 >>> print (Ext.get_float.__doc__)
39 Ext.get_float(self) -> float
41 >>> print (Ext.clone.__doc__)
42 Ext.clone(self) -> Ext
44 >>> print (foo.__doc__)
45 foo()
47 >>> with_doc_1.__doc__
48 'with_doc_1(a, b, c)\nExisting string'
50 >>> with_doc_2.__doc__
51 'with_doc_2(a, b, c)\n\n Existing string\n '
53 >>> types.__doc__
54 'types(Ext a, int b, unsigned short c, float d, e)'
56 >>> print (f_c.__doc__)
57 f_c(char c) -> char
59 >>> print (f_uc.__doc__)
60 f_uc(unsigned char c) -> unsigned char
62 >>> print (f_sc.__doc__)
63 f_sc(signed char c) -> signed char
66 >>> print (f_s.__doc__)
67 f_s(short s) -> short
69 >>> print (f_us.__doc__)
70 f_us(unsigned short s) -> unsigned short
72 >>> print (f_ss.__doc__)
73 f_ss(signed short s) -> signed short
76 >>> print (f_i.__doc__)
77 f_i(int i) -> int
79 >>> print (f_ui.__doc__)
80 f_ui(unsigned int i) -> unsigned int
82 >>> print (f_si.__doc__)
83 f_si(signed int i) -> signed int
86 >>> print (f_l.__doc__)
87 f_l(long l) -> long
89 >>> print (f_ul.__doc__)
90 f_ul(unsigned long l) -> unsigned long
92 >>> print (f_sl.__doc__)
93 f_sl(signed long l) -> signed long
96 >>> print (f_L.__doc__)
97 f_L(long long L) -> long long
99 >>> print (f_uL.__doc__)
100 f_uL(unsigned long long L) -> unsigned long long
102 >>> print (f_sL.__doc__)
103 f_sL(signed long long L) -> signed long long
106 >>> print (f_f.__doc__)
107 f_f(float f) -> float
109 >>> print (f_d.__doc__)
110 f_d(double d) -> double
112 >>> print (f_D.__doc__)
113 f_D(long double D) -> long double
115 """
117 cdef class Ext:
119 def __init__(self, a, b, c=None):
120 pass
122 def a(self):
123 pass
125 def b(self, a, b, c):
126 pass
128 def c(self, a, b, c=1):
129 pass
131 def d(self, a, b, *, c = 88):
132 pass
134 def e(self, a, b, c = 88, **kwds):
135 pass
137 def f(self, a, b, *, c, d = 42):
138 pass
140 def g(self, a, b, *, c, d = 42, e = 17, f, **kwds):
141 pass
143 def h(self, a, b, *args, c, d = 42, e = 17, f, **kwds):
144 pass
146 def k(self, a, b, c=1, *args, d = 42, e = 17, f, **kwds):
147 pass
149 cpdef int get_int(self):
150 return 0
152 cpdef float get_float(self):
153 return 0.0
155 cpdef Ext clone(self):
156 return Ext(1,2)
158 def foo():
159 pass
161 def types(Ext a, int b, unsigned short c, float d, e):
162 pass
164 def with_doc_1(a, b, c):
165 """Existing string"""
166 pass
168 def with_doc_2(a, b, c):
169 """
170 Existing string
171 """
172 pass
174 cpdef char f_c(char c):
175 return c
177 cpdef unsigned char f_uc(unsigned char c):
178 return c
180 cpdef signed char f_sc(signed char c):
181 return c
184 cpdef short f_s(short s):
185 return s
187 cpdef unsigned short f_us(unsigned short s):
188 return s
190 cpdef signed short f_ss(signed short s):
191 return s
194 cpdef int f_i(int i):
195 return i
197 cpdef unsigned int f_ui(unsigned int i):
198 return i
200 cpdef signed int f_si(signed int i):
201 return i
204 cpdef long f_l(long l):
205 return l
207 cpdef unsigned long f_ul(unsigned long l):
208 return l
210 cpdef signed long f_sl(signed long l):
211 return l
214 cpdef long long f_L(long long L):
215 return L
217 cpdef unsigned long long f_uL(unsigned long long L):
218 return L
220 cpdef signed long long f_sL(signed long long L):
221 return L
224 cpdef float f_f(float f):
225 return f
227 cpdef double f_d(double d):
228 return d
230 cpdef long double f_D(long double D):
231 return D
