From 2501d002683d5bbe9ea82c0c3f58e47cf97d3b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 28 Oct 2021 10:30:13 +0200 Subject: Python doc generator: raise explanatory error when context key is missing When a new key is added to the context, it also needs to be added to the `sphinx_doc_gen.py` file for generating the Python API documentation. When this isn't done, the script would raise a generic `KeyError`. Now it explains what needs to be updated to solve the problem. No functional changes to Blender. --- doc/python_api/sphinx_doc_gen.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 903136ea9f2..3fdb4ca0bc3 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -1223,7 +1223,10 @@ def pycontext2sphinx(basepath): while char_array[i] is not None: member = ctypes.string_at(char_array[i]).decode(encoding="ascii") fw(".. data:: %s\n\n" % member) - member_type, is_seq = context_type_map[member] + try: + member_type, is_seq = context_type_map[member] + except KeyError: + raise SystemExit("Error: context key %r not found in context_type_map; update %s" % (member, __file__)) from None fw(" :type: %s :class:`bpy.types.%s`\n\n" % ("sequence of " if is_seq else "", member_type)) unique.add(member) i += 1 -- cgit v1.2.3