From 48abc7aabca054d1f3d17931e2caeb4c1065ddcd Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 18 Feb 2025 10:32:52 +1100 Subject: [PATCH] PyAPI: document never none pointer/collection properties Set never null for pointer props automatically during RNA generation. Ref: !126755 --- source/blender/makesrna/intern/makesrna.cc | 5 +++++ source/blender/python/intern/bpy_props.cc | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/source/blender/makesrna/intern/makesrna.cc b/source/blender/makesrna/intern/makesrna.cc index 16ab86f040f..71d3e0e983f 100644 --- a/source/blender/makesrna/intern/makesrna.cc +++ b/source/blender/makesrna/intern/makesrna.cc @@ -2228,6 +2228,11 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp) DefRNA.error = true; } + if (dp->dnapointerlevel == 0 && pprop->get == nullptr) { + /* Set the flag for generated documentation. */ + RNA_def_property_flag(prop, PROP_NEVER_NULL); + } + pprop->get = reinterpret_cast( rna_def_property_get_func(f, srna, prop, dp, (const char *)pprop->get)); pprop->set = reinterpret_cast( diff --git a/source/blender/python/intern/bpy_props.cc b/source/blender/python/intern/bpy_props.cc index 2358d6a8ebe..7724fd3f7c0 100644 --- a/source/blender/python/intern/bpy_props.cc +++ b/source/blender/python/intern/bpy_props.cc @@ -4275,6 +4275,9 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) bpy_prop_assign_flag_override(prop, override_enum.value); } + /* Set the flag for generated documentation. */ + RNA_def_property_flag(prop, PROP_NEVER_NULL); + if (RNA_struct_idprops_contains_datablock(ptype)) { if (RNA_struct_is_a(srna, &RNA_PropertyGroup)) { RNA_def_struct_flag(srna, STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES); @@ -4412,6 +4415,10 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) bpy_prop_assign_flag_override(prop, override_enum.value); } + if (RNA_struct_is_a(ptype, &RNA_PropertyGroup)) { + /* Set the flag for generated documentation. */ + RNA_def_property_flag(prop, PROP_NEVER_NULL); + } if (RNA_struct_idprops_contains_datablock(ptype)) { if (RNA_struct_is_a(srna, &RNA_PropertyGroup)) { RNA_def_struct_flag(srna, STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES);