aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2022-01-24 13:12:27 +0100
committerShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2022-01-24 23:38:01 +0100
commitc5688f95f008ddea8ccfadccc491052da6a98dd1 (patch)
tree8a63aaad2bbe23073f5e756c56f2f012481c2e69
parent8daf85c871384db7a130415578873e73f3c04d84 (diff)
Keyword and Default Arguments - Documentation
This patch augments the <add-function/> node documentation with examples on how to enable function prameters to be used as keyword arguments with default values. It also adds a short sentence to use the "rename" attribute of the <modify-argument/> node to enable keyword arguments for existing functions. Change-Id: Id5ea7bf8a0f6e3edab20acef1738a30d5673c164 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/shiboken6/doc/typesystem_manipulating_objects.rst18
-rw-r--r--sources/shiboken6/doc/typesystem_modify_function.rst3
2 files changed, 16 insertions, 5 deletions
diff --git a/sources/shiboken6/doc/typesystem_manipulating_objects.rst b/sources/shiboken6/doc/typesystem_manipulating_objects.rst
index 79add6d57..e37d04718 100644
--- a/sources/shiboken6/doc/typesystem_manipulating_objects.rst
+++ b/sources/shiboken6/doc/typesystem_manipulating_objects.rst
@@ -284,13 +284,23 @@ add-function
static C++ code, while Python needs the explicit "self" parameter that ``classmethod``
provides.
- Within the signature, names for the function parameters can be specified by
- enclosing them within the delimiter *@*:
+ In order to create keyword argument supporting function parameters, enclose the specific
+ function parameter with a *@* in the `signature` field.
- .. code-block::
+ .. code-block:: xml
+
+ <add-function signature="foo(int @parameter1@,float @parameter2@)">
+ ...
+ </add-function>
- void foo(int @parameter1@,float)
+ With keyword arguments, ``add-function`` makes it easy to specify a default argument
+ within the `signature` field
+
+ .. code-block:: xml
+ <add-function signature="foo(int @parameter1@=1,float @parameter2@=2)">
+ ...
+ </add-function>
See :ref:`sequence-protocol` for adding the respective functions.
diff --git a/sources/shiboken6/doc/typesystem_modify_function.rst b/sources/shiboken6/doc/typesystem_modify_function.rst
index d7cb50dd6..7de7abeb7 100644
--- a/sources/shiboken6/doc/typesystem_modify_function.rst
+++ b/sources/shiboken6/doc/typesystem_modify_function.rst
@@ -29,7 +29,8 @@ modify-argument
respectively.
The optional ``rename`` attribute is used to rename a argument and use this
- new name in the generated code.
+ new name in the generated code. This attribute can be used to enable the usage
+ of ``keyword arguments``.
The optional ``pyi-type`` attribute specifies the type to appear in the
signature strings and ``.pyi`` files. The type string is determined by