This is nice! It does introduce an issue though, __doc__ now contains that text signature in its contents, you'll need to tweak doc to ignore the signature at the start (similar to CPythons _PyType_DocWithoutSignature).
Originally posted by @DimitrisJim in #2904 (comment)
Overview
Documentations of methods, types in CPython can have format like below:
<SIGNATURE>
--
<DOCUMENT>
And CPython's __doc__ property strips the signature through _PyType_DocWithoutSignature. Then, when you call <?>.__doc__, you will see only <DOCUMENT>. But RustPython hasn't implemented it so it should be implemented.
Example
Let's see the case of object type.
The full doc is:
PyDoc_STRVAR(object_doc,
"object()\n--\n\n"
"The base class of the class hierarchy.\n\n"
"When called, it accepts no arguments and returns a new featureless\n"
"instance that has no instance attributes and cannot be given any.\n");
As human-familiar:
object()
--
The base class of the class hierarchy.
When called, it accepts no arguments and returns a new featureless
Instance that has no instance attributes and cannot be given any.
And when call print(object.__doc__) in CPython 3.8.0, you will see:
The base class of the class hierarchy.
When called, it accepts no arguments and returns a new featureless
instance that has no instance attributes and cannot be given any.
References
Overview
Documentations of methods, types in CPython can have format like below:
And CPython's
__doc__property strips the signature through_PyType_DocWithoutSignature. Then, when you call<?>.__doc__, you will see only<DOCUMENT>. But RustPython hasn't implemented it so it should be implemented.Example
Let's see the case of
objecttype.The full doc is:
As human-familiar:
And when call
print(object.__doc__)in CPython 3.8.0, you will see:References
_PyType_DocWithoutSignatureimplementation: https://github.com/python/cpython/blob/fa919fdf2583bdfead1df00e842f24f30b2a34bf/Objects/typeobject.c#L158-L169