forked from bartvdbraak/blender
document bpy.types.Struct methods C methods, currently only keyframe_delete() and keyframe_insert() have useful docstrings.
http://www.blender.org/documentation/250PythonDoc/bpy.types.Struct.html?highlight=bpy.types.struct#bpy.types.Struct.keyframe_insert
This commit is contained in:
parent
a9fa23c624
commit
e302f33be7
@ -43,6 +43,10 @@ import bpy
|
|||||||
import rna_info
|
import rna_info
|
||||||
reload(rna_info)
|
reload(rna_info)
|
||||||
|
|
||||||
|
# lame, python wont give some access
|
||||||
|
MethodDescriptorType = type(dict.get)
|
||||||
|
GetSetDescriptorType = type(int.real)
|
||||||
|
|
||||||
EXAMPLE_SET = set()
|
EXAMPLE_SET = set()
|
||||||
EXAMPLE_SET_USED = set()
|
EXAMPLE_SET_USED = set()
|
||||||
|
|
||||||
@ -144,11 +148,6 @@ def pyprop2sphinx(ident, fw, identifier, py_prop):
|
|||||||
|
|
||||||
def pymodule2sphinx(BASEPATH, module_name, module, title):
|
def pymodule2sphinx(BASEPATH, module_name, module, title):
|
||||||
import types
|
import types
|
||||||
# lame, python wont give some access
|
|
||||||
MethodDescriptorType = type(dict.get)
|
|
||||||
GetSetDescriptorType = type(int.real)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
filepath = os.path.join(BASEPATH, module_name + ".rst")
|
filepath = os.path.join(BASEPATH, module_name + ".rst")
|
||||||
|
|
||||||
@ -180,7 +179,7 @@ def pymodule2sphinx(BASEPATH, module_name, module, title):
|
|||||||
|
|
||||||
classes = []
|
classes = []
|
||||||
|
|
||||||
for attribute in dir(module):
|
for attribute in sorted(dir(module)):
|
||||||
if not attribute.startswith("_"):
|
if not attribute.startswith("_"):
|
||||||
value = getattr(module, attribute)
|
value = getattr(module, attribute)
|
||||||
|
|
||||||
@ -194,6 +193,14 @@ def pymodule2sphinx(BASEPATH, module_name, module, title):
|
|||||||
py_c_func2sphinx("", fw, attribute, value, is_class=False)
|
py_c_func2sphinx("", fw, attribute, value, is_class=False)
|
||||||
elif value_type == type:
|
elif value_type == type:
|
||||||
classes.append((attribute, value))
|
classes.append((attribute, value))
|
||||||
|
elif value_type in (bool, int, float, str, tuple):
|
||||||
|
# constant, not much fun we can do here except to list it.
|
||||||
|
# TODO, figure out some way to document these!
|
||||||
|
fw(".. data:: %s\n\n" % attribute)
|
||||||
|
write_indented_lines(" ", fw, "constant value %s" % repr(value), False)
|
||||||
|
fw("\n")
|
||||||
|
else:
|
||||||
|
print("\tnot documenting %s.%s" % (module_name, attribute))
|
||||||
# TODO, more types...
|
# TODO, more types...
|
||||||
|
|
||||||
# write collected classes now
|
# write collected classes now
|
||||||
@ -472,6 +479,15 @@ def rna2sphinx(BASEPATH):
|
|||||||
pyfunc2sphinx(" ", fw, identifier, py_func, is_class=True)
|
pyfunc2sphinx(" ", fw, identifier, py_func, is_class=True)
|
||||||
del py_funcs, py_func
|
del py_funcs, py_func
|
||||||
|
|
||||||
|
# c/python methods, only for the base class
|
||||||
|
if struct.identifier == "Struct":
|
||||||
|
for attribute, descr in bpy.types.Struct.__bases__[0].__dict__.items():
|
||||||
|
if type(descr) == MethodDescriptorType: # GetSetDescriptorType, GetSetDescriptorType's are not documented yet
|
||||||
|
if descr.__doc__:
|
||||||
|
write_indented_lines(" ", fw, descr.__doc__, False)
|
||||||
|
write_example_ref(" ", fw, struct.identifier + "." + attribute)
|
||||||
|
fw("\n")
|
||||||
|
|
||||||
if struct.references:
|
if struct.references:
|
||||||
# use this otherwise it gets in the index for a normal heading.
|
# use this otherwise it gets in the index for a normal heading.
|
||||||
fw(".. rubric:: References\n\n")
|
fw(".. rubric:: References\n\n")
|
||||||
|
@ -1711,6 +1711,18 @@ int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, char *error_pre
|
|||||||
return 0; /* success */
|
return 0; /* success */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char pyrna_struct_keyframe_insert_doc[] =
|
||||||
|
".. function:: keyframe_insert(path, index=-1, frame=bpy.context.scene.frame_current)\n"
|
||||||
|
"\n"
|
||||||
|
" Returns a boolean, True if the keyframe is set.\n"
|
||||||
|
"\n"
|
||||||
|
" :arg path: path to the property to key, analogous to the fcurve's data path.\n"
|
||||||
|
" :type path: string\n"
|
||||||
|
" :arg index: array index of the property to key. Defaults to -1 which will key all indicies or a single channel if the property is not an array.\n"
|
||||||
|
" :type index: int\n"
|
||||||
|
" :arg frame: The frame on which the keyframe is inserted, defaulting to the current frame.\n"
|
||||||
|
" :type frame: float";
|
||||||
|
|
||||||
static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args)
|
static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
@ -1728,6 +1740,18 @@ static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *arg
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char pyrna_struct_keyframe_delete_doc[] =
|
||||||
|
".. function:: keyframe_delete(path, index=-1, frame=bpy.context.scene.frame_current)\n"
|
||||||
|
"\n"
|
||||||
|
" Returns a boolean, True if the keyframe is removed.\n"
|
||||||
|
"\n"
|
||||||
|
" :arg path: path to the property to remove a key, analogous to the fcurve's data path.\n"
|
||||||
|
" :type path: string\n"
|
||||||
|
" :arg index: array index of the property to remove a key. Defaults to -1 removing all indicies or a single channel if the property is not an array.\n"
|
||||||
|
" :type index: int\n"
|
||||||
|
" :arg frame: The frame on which the keyframe is deleted, defaulting to the current frame.\n"
|
||||||
|
" :type frame: float";
|
||||||
|
|
||||||
static PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args)
|
static PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
@ -2714,8 +2738,8 @@ static struct PyMethodDef pyrna_struct_methods[] = {
|
|||||||
{"as_pointer", (PyCFunction)pyrna_struct_as_pointer, METH_NOARGS, NULL},
|
{"as_pointer", (PyCFunction)pyrna_struct_as_pointer, METH_NOARGS, NULL},
|
||||||
|
|
||||||
/* maybe this become and ID function */
|
/* maybe this become and ID function */
|
||||||
{"keyframe_insert", (PyCFunction)pyrna_struct_keyframe_insert, METH_VARARGS, NULL},
|
{"keyframe_insert", (PyCFunction)pyrna_struct_keyframe_insert, METH_VARARGS, pyrna_struct_keyframe_insert_doc},
|
||||||
{"keyframe_delete", (PyCFunction)pyrna_struct_keyframe_delete, METH_VARARGS, NULL},
|
{"keyframe_delete", (PyCFunction)pyrna_struct_keyframe_delete, METH_VARARGS, pyrna_struct_keyframe_delete_doc},
|
||||||
{"driver_add", (PyCFunction)pyrna_struct_driver_add, METH_VARARGS, NULL},
|
{"driver_add", (PyCFunction)pyrna_struct_driver_add, METH_VARARGS, NULL},
|
||||||
{"is_property_set", (PyCFunction)pyrna_struct_is_property_set, METH_VARARGS, NULL},
|
{"is_property_set", (PyCFunction)pyrna_struct_is_property_set, METH_VARARGS, NULL},
|
||||||
{"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, NULL},
|
{"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, NULL},
|
||||||
|
Loading…
Reference in New Issue
Block a user