aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/shibokenmodule/support/signature/errorhandler.py
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2019-01-13 17:56:00 +0100
committerChristian Tismer <tismer@stackless.com>2019-01-15 13:33:08 +0000
commitb7707a51337cd7982d298041fa3db2ed225bfc54 (patch)
treed264067b87e9a466d275e73843921ef8f966045a /sources/shiboken2/shibokenmodule/support/signature/errorhandler.py
parentaef6a443a241756e9dfaff192b69d51eaa235ef6 (diff)
Support help() using the Signature Module
The signature module will be used to generate automated documentation by using the function signatures as docstrings. This functionality should be low-hanging fruit. Actually, it was a bit tricky to get this working. The crucial point was to use PyType_Modified(). The function works fine on methods. Supporting types needs some more effort. It is not clear why the __signature__ attribute can be added, but the change to __doc__ is not recognized. May be related to the absence of Py_TPFLAGS_HAVE_VERSION_TAG ? This will be addressed another time. Task-number: PYSIDE-908 Change-Id: If8faa87927899f4c072d42b91eafd8f7658c6abc Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/shibokenmodule/support/signature/errorhandler.py')
-rw-r--r--sources/shiboken2/shibokenmodule/support/signature/errorhandler.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/sources/shiboken2/shibokenmodule/support/signature/errorhandler.py b/sources/shiboken2/shibokenmodule/support/signature/errorhandler.py
index 902bb05af..df24234e3 100644
--- a/sources/shiboken2/shibokenmodule/support/signature/errorhandler.py
+++ b/sources/shiboken2/shibokenmodule/support/signature/errorhandler.py
@@ -121,4 +121,20 @@ def seterror_argument(args, func_name):
# We don't raise the error here, to avoid the loader in the traceback.
return TypeError, msg
+
+def make_helptext(func):
+ existing_doc = func.__doc__
+ sigs = get_signature(func)
+ if not sigs:
+ return existing_doc
+ if type(sigs) != list:
+ sigs = [sigs]
+ try:
+ func_name = func.__name__
+ except AttribureError:
+ func_name = func.__func__.__name__
+ sigtext = "\n".join(func_name + str(sig) for sig in sigs)
+ msg = sigtext + "\n\n" + existing_doc if existing_doc else sigtext
+ return msg
+
# end of file