From 63c56a5d67ea526176bcc66806d0db59779c42cb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 9 Nov 2024 13:19:26 +1100 Subject: [PATCH] PyDoc: show keyword-only signifier for all RNA functions --- doc/python_api/sphinx_doc_gen.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 1e35a8937dc..45615492a4c 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -1658,7 +1658,18 @@ def pyrna2sphinx(basepath): del key, descr for func in struct.functions: - args_str = ", ".join(prop.get_arg_default(force=False) for prop in func.args) + args_kw_only_index = next((i for i in i, prop in enumerate(func.args) if not prop.is_required), -1) + if args_kw_only_index == -1: + args_str = ", ".join(prop.get_arg_default(force=False) for prop in func.args) + else: + args_str = ", ".join([ + *[prop.get_arg_default(force=False) for prop in func.args[:args_kw_only_index]], + # Keyword only. + "*", + *[prop.get_arg_default(force=False) for prop in func.args[args_kw_only_index:]], + + ]) + del args_kw_only_index fw(" .. {:s}:: {:s}({:s})\n\n".format( "classmethod" if func.is_classmethod else "method",