Commit 30b56290 authored by Jason Evans's avatar Jason Evans

Take care to preserve cpdef method docstrings when prepending signatures.

parent c9235aa4
3.0a6-cypclass 3.0a5-cypclass_pyobject_virtual 3.0a5-cypclass_virtual 3.0a6-cypclass-remove-logging 3.0a6-cypclass_attribute_lock 3.0a6-cypclass_attribute_lock_nonrecursive_rw 3.0a6-cypclass_consume 3.0a6-cypclass_frozen 3.0a6-cypclass_lock 3.0a6-cypclass_recover_consume cypclass_pyobject cypclass_pyobject_virtual cypclass_virtual master nogil_cypclass_acthon_on_rc8v3 3.0a6 3.0a5 3.0a4 3.0a3 3.0a2 3.0a1 0.29.21 0.29.20 0.29.19 0.29.18 0.29.17 0.29.16 0.29.15 0.29.14 0.29.13 0.29.12 0.29.11 0.29.10 0.29.9 0.29.8 0.29.7 0.29.6 0.29.5 0.29.4 0.29.3 0.29.2 0.29.1 0.29 0.29rc2 0.29rc1 0.29b1 0.28.6 0.28.5 0.28.4 0.28.3 0.28.2 0.28.1 0.28 0.28rc1 0.28b2 0.28b1 0.27.3 0.27.2 0.27.1 0.27.1b1 0.27 0.27rc1 0.27b1 0.27a1 0.26.1 0.26.1rc1 0.26 0.26rc2 0.26rc1 0.26rc0 0.26b2 0.26b1 0.26b0 0.26.alpha0 0.25.2 0.25.2rc0 0.25.2b1 0.25.1 0.25.1b1 0.25.1b0 0.25 0.25b2 0.25b1 0.25b0 0.25a0 0.24.1 0.24 0.24b0 0.24a0 0.23.5 0.23.4 0.23.3 0.23.2 0.23.1 0.23 0.23.beta1 0.23b2 0.22.1 0.22.1rc1 0.22 0.22.beta0 0.22.alpha0 0.21.2 0.21.1 0.21 0.21rc1 0.21b2 0.21b1 0.21a1 0.20.2 0.20.2b1 0.20.1 0.20.1rc1 0.20 0.20rc1 0.20b2 0.20b1 0.19.2 0.19.1 0.19 0.19rc1 0.19b2 0.19b1 0.18 0.18rc1 0.18b1 0.17.4 0.17.3 0.17.2 0.17.1 0.17 0.17.beta1 0.17b4 0.17b3 0.17b2 0.16 0.16rc2 0.16rc1 0.16rc0 0.16.beta0 0.15.1 0.15 0.15rc2 0.15rc1 0.15rc0 0.14.1 0.14.1rc3 0.14.1rc2 0.14.1rc1 0.14.1rc0 0.14 0.14.rc0 0.14.beta2 0.14.beta1 0.14.beta0 0.14.alpha0 0.13 0.13.beta1 0.13.beta0 0.12.1 0.12 0.12.rc0 0.12.alpha0 0.11.3 0.11.3.rc0 0.11.2 0.11.2.rc1 0.11.1 0.11.1.beta 0.11.1.alpha 0.11.rc 0.11-beta snippets_article nogil_cypclass_rc8 nogil_cypclass_lock_on_rc8v3 cythonplus-0.3 cythonplus-0.2 cythonplus-0.1 cypclass_pyobject_before_mro_rebase_12_06_2020
No related merge requests found
......@@ -135,7 +135,14 @@ class EmbedSignature(CythonTransform):
doc_holder = self.class_node.entry.type.scope
else:
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)
if not is_constructor and getattr(node, 'py_func', None) is not None:
node.py_func.entry.doc = EncodedString(new_doc)
......@@ -152,7 +159,13 @@ class EmbedSignature(CythonTransform):
node.declarator.args,
return_type=node.return_type)
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)
if hasattr(node, 'py_func') and node.py_func is not None:
node.py_func.entry.doc = EncodedString(new_doc)
......
......@@ -32,12 +32,20 @@ __doc__ = ur"""
>>> print (Ext.k.__doc__)
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__)
Ext.get_int(self) -> int
>>> print (Ext.get_float.__doc__)
Ext.get_float(self) -> float
>>> print (Ext.get_str.__doc__)
Ext.get_str(self) -> str
Existing string
>>> print (Ext.clone.__doc__)
Ext.clone(self) -> Ext
......@@ -50,6 +58,12 @@ __doc__ = ur"""
>>> with_doc_2.__doc__
'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(Ext a, int b, unsigned short c, float d, e)'
......@@ -146,12 +160,20 @@ cdef class Ext:
def k(self, a, b, c=1, *args, d = 42, e = 17, f, **kwds):
pass
def l(self, a, b, c=1, *args, d = 42, e = 17, f, **kwds):
"""Existing string"""
pass
cpdef int get_int(self):
return 0
cpdef float get_float(self):
return 0.0
cpdef str get_str(self):
"""Existing string"""
return "string"
cpdef Ext clone(self):
return Ext(1,2)
......@@ -171,6 +193,16 @@ def with_doc_2(a, b, c):
"""
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):
return c
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment