[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35683] trunk/blender: fix [#25688] undocumted functions in pyapi
Campbell Barton
ideasman42 at gmail.com
Tue Mar 22 05:28:52 CET 2011
Revision: 35683
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35683
Author: campbellbarton
Date: 2011-03-22 04:28:51 +0000 (Tue, 22 Mar 2011)
Log Message:
-----------
fix [#25688] undocumted functions in pyapi
expose collection function docs.
Modified Paths:
--------------
trunk/blender/doc/python_api/sphinx_doc_gen.py
trunk/blender/release/scripts/modules/rna_info.py
trunk/blender/source/blender/editors/transform/transform_manipulator.c
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/doc/python_api/sphinx_doc_gen.py
===================================================================
--- trunk/blender/doc/python_api/sphinx_doc_gen.py 2011-03-22 02:39:08 UTC (rev 35682)
+++ trunk/blender/doc/python_api/sphinx_doc_gen.py 2011-03-22 04:28:51 UTC (rev 35683)
@@ -36,7 +36,7 @@
sphinx-build doc/python_api/sphinx-in doc/python_api/sphinx-out
- assuming that you have sphinx 0.6.7 installed
+ assuming that you have sphinx 1.0.7 installed
For PDF generation
------------------
@@ -61,7 +61,7 @@
"bpy.app",
"bpy.path",
"bpy.data",
- #"bpy.props",
+ "bpy.props",
"bpy.utils",
"bpy.context",
# "bpy.types", # supports filtering
@@ -102,8 +102,13 @@
EXAMPLE_SET_USED = set()
_BPY_STRUCT_FAKE = "bpy_struct"
+_BPY_PROP_COLLECTION_FAKE = "bpy_prop_collection"
_BPY_FULL_REBUILD = False
+if _BPY_PROP_COLLECTION_FAKE:
+ _BPY_PROP_COLLECTION_ID = ":class:`%s`" % _BPY_PROP_COLLECTION_FAKE
+else:
+ _BPY_PROP_COLLECTION_ID = "collection"
def undocumented_message(module_name, type_name, identifier):
if str(type_name).startswith('<module'):
@@ -155,6 +160,10 @@
return "\n".join(text), line_no
+def write_title(fw, text, heading_char):
+ fw("%s\n%s\n\n" % (text, len(text) * heading_char))
+
+
def write_example_ref(ident, fw, example_id, ext="py"):
if example_id in EXAMPLE_SET:
@@ -310,8 +319,7 @@
fw = file.write
- fw(title + "\n")
- fw(("=" * len(title)) + "\n\n")
+ write_title(fw, title, "=")
fw(".. module:: %s\n\n" % module_name)
@@ -535,14 +543,18 @@
if is_return:
id_name = "return"
id_type = "rtype"
- kwargs = {"as_ret": True, "class_fmt": ":class:`%s`"}
+ kwargs = {"as_ret": True}
identifier = ""
else:
id_name = "arg"
id_type = "type"
- kwargs = {"as_arg": True, "class_fmt": ":class:`%s`"}
+ kwargs = {"as_arg": True}
identifier = " %s" % prop.identifier
+ kwargs["class_fmt"] = ":class:`%s`"
+
+ kwargs["collection_id"] = _BPY_PROP_COLLECTION_ID
+
type_descr = prop.get_type_description(**kwargs)
if prop.name or prop.description:
fw(ident + ":%s%s: %s\n" % (id_name, identifier, ", ".join(val for val in (prop.name, prop.description) if val)))
@@ -570,7 +582,7 @@
else:
title = struct.identifier
- fw("%s\n%s\n\n" % (title, "=" * len(title)))
+ write_title(fw, title, "=")
fw(".. module:: bpy.types\n\n")
@@ -615,7 +627,7 @@
sorted_struct_properties.sort(key=lambda prop: prop.identifier)
for prop in sorted_struct_properties:
- type_descr = prop.get_type_description(class_fmt=":class:`%s`")
+ type_descr = prop.get_type_description(class_fmt=":class:`%s`", collection_id=_BPY_PROP_COLLECTION_ID)
# readonly properties use "data" directive, variables properties use "attribute" directive
if 'readonly' in type_descr:
fw(" .. data:: %s\n\n" % prop.identifier)
@@ -646,7 +658,7 @@
elif func.return_values: # multiple return values
fw(" :return (%s):\n" % ", ".join(prop.identifier for prop in func.return_values))
for prop in func.return_values:
- type_descr = prop.get_type_description(as_ret=True, class_fmt=":class:`%s`")
+ type_descr = prop.get_type_description(as_ret=True, class_fmt=":class:`%s`", collection_id=_BPY_PROP_COLLECTION_ID)
descr = prop.description
if not descr:
descr = prop.name
@@ -755,38 +767,46 @@
continue
write_struct(struct)
- # special case, bpy_struct
- if _BPY_STRUCT_FAKE:
- filepath = os.path.join(BASEPATH, "bpy.types.%s.rst" % _BPY_STRUCT_FAKE)
+ def fake_bpy_type(class_value, class_name, descr_str, use_subclasses=True):
+ filepath = os.path.join(BASEPATH, "bpy.types.%s.rst" % class_name)
file = open(filepath, "w")
fw = file.write
- fw("%s\n" % _BPY_STRUCT_FAKE)
- fw("=" * len(_BPY_STRUCT_FAKE) + "\n")
- fw("\n")
+ write_title(fw, class_name, "=")
+
fw(".. module:: bpy.types\n")
fw("\n")
- subclass_ids = [s.identifier for s in structs.values() if s.base is None if not rna_info.rna_id_ignore(s.identifier)]
- if subclass_ids:
- fw("subclasses --- \n" + ", ".join((":class:`%s`" % s) for s in sorted(subclass_ids)) + "\n\n")
+ if use_subclasses:
+ subclass_ids = [s.identifier for s in structs.values() if s.base is None if not rna_info.rna_id_ignore(s.identifier)]
+ if subclass_ids:
+ fw("subclasses --- \n" + ", ".join((":class:`%s`" % s) for s in sorted(subclass_ids)) + "\n\n")
- fw(".. class:: %s\n\n" % _BPY_STRUCT_FAKE)
- fw(" built-in base class for all classes in bpy.types.\n\n")
+ fw(".. class:: %s\n\n" % class_name)
+ fw(" %s\n\n" % descr_str)
fw(" .. note::\n\n")
- fw(" Note that bpy.types.%s is not actually available from within blender, it only exists for the purpose of documentation.\n\n" % _BPY_STRUCT_FAKE)
+ fw(" Note that bpy.types.%s is not actually available from within blender, it only exists for the purpose of documentation.\n\n" % class_name)
- descr_items = [(key, descr) for key, descr in sorted(bpy.types.Struct.__bases__[0].__dict__.items()) if not key.startswith("__")]
+ descr_items = [(key, descr) for key, descr in sorted(class_value.__dict__.items()) if not key.startswith("__")]
for key, descr in descr_items:
if type(descr) == MethodDescriptorType: # GetSetDescriptorType, GetSetDescriptorType's are not documented yet
- py_descr2sphinx(" ", fw, descr, "bpy.types", _BPY_STRUCT_FAKE, key)
+ py_descr2sphinx(" ", fw, descr, "bpy.types", class_name, key)
for key, descr in descr_items:
if type(descr) == GetSetDescriptorType:
- py_descr2sphinx(" ", fw, descr, "bpy.types", _BPY_STRUCT_FAKE, key)
+ py_descr2sphinx(" ", fw, descr, "bpy.types", class_name, key)
file.close()
+ # write fake classes
+ if _BPY_STRUCT_FAKE:
+ class_value = bpy.types.Struct.__bases__[0]
+ fake_bpy_type(class_value, _BPY_STRUCT_FAKE, "built-in base class for all classes in bpy.types.", use_subclasses=True)
+
+ if _BPY_PROP_COLLECTION_FAKE:
+ class_value = bpy.data.objects.__class__
+ fake_bpy_type(class_value, _BPY_PROP_COLLECTION_FAKE, "built-in class used for all collections.", use_subclasses=False)
+
# operators
def write_ops():
API_BASEURL = "https://svn.blender.org/svnroot/bf-blender/trunk/blender/release/scripts"
@@ -802,8 +822,9 @@
fw = file.write
title = "%s Operators" % op_module_name.replace("_", " ").title()
- fw("%s\n%s\n\n" % (title, "=" * len(title)))
+ write_title(fw, title, "=")
+
fw(".. module:: bpy.ops.%s\n\n" % op_module_name)
ops_mod.sort(key=lambda op: op.func_name)
@@ -1074,7 +1095,9 @@
fw("\n")
title = ":mod:`bpy` --- Blender Python Module"
- fw("%s\n%s\n\n" % (title, "=" * len(title)))
+
+ write_title(fw, title, "=")
+
fw(".. module:: bpy.types\n\n")
file.close()
Modified: trunk/blender/release/scripts/modules/rna_info.py
===================================================================
--- trunk/blender/release/scripts/modules/rna_info.py 2011-03-22 02:39:08 UTC (rev 35682)
+++ trunk/blender/release/scripts/modules/rna_info.py 2011-03-22 04:28:51 UTC (rev 35683)
@@ -253,7 +253,7 @@
return "%s=%s" % (self.identifier, default)
return self.identifier
- def get_type_description(self, as_ret=False, as_arg=False, class_fmt="%s"):
+ def get_type_description(self, as_ret=False, as_arg=False, class_fmt="%s", collection_id="Collection"):
type_str = ""
if self.fixed_type is None:
type_str += self.type
@@ -277,9 +277,9 @@
else:
if self.type == "collection":
if self.collection_type:
- collection_str = (class_fmt % self.collection_type.identifier) + " collection of "
+ collection_str = (class_fmt % self.collection_type.identifier) + (" %s of " % collection_id)
else:
- collection_str = "Collection of "
+ collection_str = "%s of " % collection_id
else:
collection_str = ""
Modified: trunk/blender/source/blender/editors/transform/transform_manipulator.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_manipulator.c 2011-03-22 02:39:08 UTC (rev 35682)
+++ trunk/blender/source/blender/editors/transform/transform_manipulator.c 2011-03-22 04:28:51 UTC (rev 35683)
@@ -1566,7 +1566,6 @@
return 0;
}
-int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, PointerRNA *properties, ReportList *reports);
/* return 0; nothing happened */
int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
@@ -1623,7 +1622,7 @@
}
RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, op->ptr);
- //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_translate", 0), event, op->ptr, NULL);
+ //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_translate", 0), event, op->ptr, NULL, FALSE);
}
else if (drawflags & MAN_SCALE_C) {
switch(drawflags) {
@@ -1654,11 +1653,11 @@
}
RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
WM_operator_name_call(C, "TRANSFORM_OT_resize", WM_OP_INVOKE_DEFAULT, op->ptr);
- //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_resize", 0), event, op->ptr, NULL);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list