[Bf-blender-cvs] [136a06285f0] blender-v3.2-release: Fix T88792: WindowManager.clipboard missing in Python API docs

Campbell Barton noreply at git.blender.org
Wed May 18 13:48:21 CEST 2022


Commit: 136a06285f0e953f65dc432a4dba1ff3d1f781ee
Author: Campbell Barton
Date:   Wed May 18 21:43:38 2022 +1000
Branches: blender-v3.2-release
https://developer.blender.org/rB136a06285f0e953f65dc432a4dba1ff3d1f781ee

Fix T88792: WindowManager.clipboard missing in Python API docs

Support RNA types using the Py/C-API PyGetSetDef defined properties.
Currently `WindowManager.clipboard` is the only instance of this.

===================================================================

M	doc/python_api/sphinx_doc_gen.py
M	release/scripts/modules/rna_info.py
M	source/blender/python/intern/bpy_rna_types_capi.c

===================================================================

diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index eba12b75b63..d87d8b71ce5 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -1474,6 +1474,12 @@ def pyrna2sphinx(basepath):
             pyprop2sphinx("   ", fw, identifier, py_prop)
         del py_properties, py_prop
 
+        # C/Python attributes: `GetSetDescriptorType`.
+        key = descr = None
+        for key, descr in sorted(struct.get_py_c_properties_getset()):
+            py_descr2sphinx("   ", fw, descr, "bpy.types", struct_id, key)
+        del key, descr
+
         for func in struct.functions:
             args_str = ", ".join(prop.get_arg_default(force=False) for prop in func.args)
 
diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py
index b009cc4fefe..687f3c95d0b 100644
--- a/release/scripts/modules/rna_info.py
+++ b/release/scripts/modules/rna_info.py
@@ -206,6 +206,14 @@ class InfoStructRNA:
                 functions.append((identifier, attr))
         return functions
 
+    def get_py_c_properties_getset(self):
+        import types
+        properties_getset = []
+        for identifier, descr in self.py_class.__dict__.items():
+            if type(descr) == types.GetSetDescriptorType:
+                properties_getset.append((identifier, descr))
+        return properties_getset
+
     def __str__(self):
 
         txt = ""
diff --git a/source/blender/python/intern/bpy_rna_types_capi.c b/source/blender/python/intern/bpy_rna_types_capi.c
index d58adb66b37..c3a07847aff 100644
--- a/source/blender/python/intern/bpy_rna_types_capi.c
+++ b/source/blender/python/intern/bpy_rna_types_capi.c
@@ -107,6 +107,7 @@ static struct PyMethodDef pyrna_text_methods[] = {
  * and creating the buffer, causing writes past the allocated length.
  * \{ */
 
+PyDoc_STRVAR(pyrna_WindowManager_clipboard_doc, "Clipboard text storage.\n\n:type: string");
 static PyObject *pyrna_WindowManager_clipboard_get(PyObject *UNUSED(self), void *UNUSED(flag))
 {
   int text_len = 0;
@@ -154,7 +155,7 @@ static struct PyGetSetDef pyrna_windowmanager_getset[] = {
     {"clipboard",
      pyrna_WindowManager_clipboard_get,
      pyrna_WindowManager_clipboard_set,
-     NULL,
+     pyrna_WindowManager_clipboard_doc,
      NULL},
     {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };



More information about the Bf-blender-cvs mailing list