Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Embedded signature doc behavior for classes different from regular Python #2876
When creating a Python class, if I put docstrings under the class name or under
class cl: """ds1""" def __init__(self, a=1): """ds2""" self.a = a
cl.__doc__ == "ds1" cl.__init__.__doc__ == "ds2"
Usually, documentation is picked by other tools from the
But with Cython classes having embedded signatures, if I put a docstring under
cimport cython @cython.embedsignature(True) cdef class cl: cdef int a def __init__(self, a = 1): """ds""" self.a = a
(And if I don't put it, it wouldn't document the arguments)
Would be nice if documentation would work the same as in regular Python (i.e. don't create
A word of warning for whoever tries to work on this: it seems after making the
This is what I tried but I'm not sure if there are still other differences in terms of the internal Python documentation through
if signature: if is_constructor: doc_holder = self.class_node.entry.type.scope else: doc_holder = node.entry
if signature: if not is_constructor or not self.class_node.entry.type.scope.doc: doc_holder = node.entry else: doc_holder = self.class_node.entry.type.scope
Putting the docstring under both seems to accomplish the purpose of having it show in sphinx and IDEs, but it doesn't seem an elegant solution.