diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-10-28 11:30:13 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-10-28 11:32:13 +0300 |
commit | 2501d002683d5bbe9ea82c0c3f58e47cf97d3b4b (patch) | |
tree | c4929b7487ee06b1e893bdd21fca9cd20c34d8cf /doc | |
parent | 45439dfe4c05eabaa83d0c1b75463966b5ba896d (diff) |
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.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/python_api/sphinx_doc_gen.py | 5 |
1 files changed, 4 insertions, 1 deletions
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 |