[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35051] trunk/blender: make doc generation close files (py3.2 complains about this),

Campbell Barton ideasman42 at gmail.com
Tue Feb 22 06:23:20 CET 2011


Revision: 35051
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35051
Author:   campbellbarton
Date:     2011-02-22 05:23:20 +0000 (Tue, 22 Feb 2011)
Log Message:
-----------
make doc generation close files (py3.2 complains about this),
minor formatting changes for C docstrings.

Modified Paths:
--------------
    trunk/blender/doc/python_api/sphinx_doc_gen.py
    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-02-22 05:16:04 UTC (rev 35050)
+++ trunk/blender/doc/python_api/sphinx_doc_gen.py	2011-02-22 05:23:20 UTC (rev 35051)
@@ -511,7 +511,9 @@
     else:
         pass  # will have raised an error above
 
+    file.close()
 
+
 def pyrna2sphinx(BASEPATH):
     """ bpy.types and bpy.ops
     """
@@ -731,6 +733,7 @@
 
         # docs last?, disable for now
         # write_example_ref("", fw, "bpy.types.%s" % struct.identifier)
+        file.close()
 
     if "bpy.types" not in EXCLUDE_MODULES:
         for struct in structs.values():
@@ -769,47 +772,52 @@
             for key, descr in descr_items:
                 if type(descr) == GetSetDescriptorType:
                     py_descr2sphinx("   ", fw, descr, "bpy.types", _BPY_STRUCT_FAKE, key)
+            file.close()
 
     # operators
     def write_ops():
         API_BASEURL = "https://svn.blender.org/svnroot/bf-blender/trunk/blender/release/scripts"
-        fw = None
-        last_mod = ''
 
-        for op_key in sorted(ops.keys()):
-            op = ops[op_key]
+        op_modules = {}
+        for op in ops.values():
+            op_modules.setdefault(op.module_name, []).append(op)
+        del op
+        
+        for op_module_name, ops_mod in op_modules.items():
+            filepath = os.path.join(BASEPATH, "bpy.ops.%s.rst" % op_module_name)
+            file = open(filepath, "w")
+            fw = file.write
 
-            if last_mod != op.module_name:
-                filepath = os.path.join(BASEPATH, "bpy.ops.%s.rst" % op.module_name)
-                file = open(filepath, "w")
-                fw = file.write
+            title = "%s Operators" % op_module_name.replace("_", " ").title()
+            fw("%s\n%s\n\n" % (title, "=" * len(title)))
 
-                title = "%s Operators" % (op.module_name[0].upper() + op.module_name[1:])
-                fw("%s\n%s\n\n" % (title, "=" * len(title)))
+            fw(".. module:: bpy.ops.%s\n\n" % op_module_name)
 
-                fw(".. module:: bpy.ops.%s\n\n" % op.module_name)
-                last_mod = op.module_name
+            ops_mod.sort(key=lambda op: op.func_name)
 
-            args_str = ", ".join(prop.get_arg_default(force=True) for prop in op.args)
-            fw(".. function:: %s(%s)\n\n" % (op.func_name, args_str))
+            for op in ops_mod:
+                args_str = ", ".join(prop.get_arg_default(force=True) for prop in op.args)
+                fw(".. function:: %s(%s)\n\n" % (op.func_name, args_str))
 
-            # if the description isn't valid, we output the standard warning
-            # with a link to the wiki so that people can help
-            if not op.description or op.description == "(undocumented operator)":
-                operator_description = undocumented_message('bpy.ops', op.module_name, op.func_name)
-            else:
-                operator_description = op.description
+                # if the description isn't valid, we output the standard warning
+                # with a link to the wiki so that people can help
+                if not op.description or op.description == "(undocumented operator)":
+                    operator_description = undocumented_message('bpy.ops', op.module_name, op.func_name)
+                else:
+                    operator_description = op.description
 
-            fw("   %s\n\n" % operator_description)
-            for prop in op.args:
-                write_param("   ", fw, prop)
-            if op.args:
-                fw("\n")
+                fw("   %s\n\n" % operator_description)
+                for prop in op.args:
+                    write_param("   ", fw, prop)
+                if op.args:
+                    fw("\n")
 
-            location = op.get_location()
-            if location != (None, None):
-                fw("   :file: `%s <%s/%s>`_:%d\n\n" % (location[0], API_BASEURL, location[0], location[1]))
+                location = op.get_location()
+                if location != (None, None):
+                    fw("   :file: `%s <%s/%s>`_:%d\n\n" % (location[0], API_BASEURL, location[0], location[1]))
 
+            file.close()
+
     if "bpy.ops" not in EXCLUDE_MODULES:
         write_ops()
 

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c	2011-02-22 05:16:04 UTC (rev 35050)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c	2011-02-22 05:23:20 UTC (rev 35051)
@@ -2246,8 +2246,8 @@
 "   :arg group: The name of the group the F-Curve should be added to if it doesn't exist yet.\n"
 "   :type group: str\n"
 "   :return: Success of keyframe insertion.\n"
-"   :rtype: boolean";
-
+"   :rtype: boolean\n"
+;
 static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyObject *kw)
 {
 	/* args, pyrna_struct_keyframe_parse handles these */
@@ -2289,8 +2289,8 @@
 "   :arg group: The name of the group the F-Curve should be added to if it doesn't exist yet.\n"
 "   :type group: str\n"
 "   :return: Success of keyframe deleation.\n"
-"   :rtype: boolean";
-
+"   :rtype: boolean\n"
+;
 static PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyObject *kw)
 {
 	/* args, pyrna_struct_keyframe_parse handles these */
@@ -2329,8 +2329,8 @@
 "   :arg index: array index of the property drive. Defaults to -1 for all indices or a single channel if the property is not an array.\n"
 "   :type index: int\n"
 "   :return: The driver(s) added.\n"
-"   :rtype: :class:`FCurve` or list if index is -1 with an array property.";
-
+"   :rtype: :class:`FCurve` or list if index is -1 with an array property.\n"
+;
 static PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
 {
 	const char *path, *path_full;
@@ -2401,8 +2401,8 @@
 "   :arg index: array index of the property drive. Defaults to -1 for all indices or a single channel if the property is not an array.\n"
 "   :type index: int\n"
 "   :return: Success of driver removal.\n"
-"   :rtype: boolean";
-
+"   :rtype: boolean\n"
+;
 static PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
 {
 	const char *path, *path_full;
@@ -2438,8 +2438,8 @@
 "   Check if a property is set, use for testing operator properties.\n"
 "\n"
 "   :return: True when the property has been set.\n"
-"   :rtype: boolean";
-
+"   :rtype: boolean\n"
+;
 static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args)
 {
 	PropertyRNA *prop;
@@ -2478,8 +2478,8 @@
 "   Check if a property is hidden.\n"
 "\n"
 "   :return: True when the property is hidden.\n"
-"   :rtype: boolean";
-
+"   :rtype: boolean\n"
+;
 static PyObject *pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject *args)
 {
 	PropertyRNA *prop;
@@ -2504,8 +2504,8 @@
 "   :arg path: path which this property resolves.\n"
 "   :type path: string\n"
 "   :arg coerce: optional argument, when True, the property will be converted into its python representation.\n"
-"   :type coerce: boolean\n";
-
+"   :type coerce: boolean\n"
+;
 static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
 {
 	const char *path;
@@ -2555,8 +2555,8 @@
 "   :arg property: Optional property name which can be used if the path is to a property of this object.\n"
 "   :type property: string\n"
 "   :return: The path from :class:`bpy_struct.id_data` to this struct and property (when given).\n"
-"   :rtype: str";
-
+"   :rtype: str\n"
+;
 static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args)
 {
 	const char *name= NULL;
@@ -2598,8 +2598,8 @@
 "   Returns the data path from the ID to this property (string).\n"
 "\n"
 "   :return: The path from :class:`bpy_struct.id_data` to this property.\n"
-"   :rtype: str";
-
+"   :rtype: str\n"
+;
 static PyObject *pyrna_prop_path_from_id(BPy_PropertyRNA *self)
 {
 	const char *path;
@@ -2625,8 +2625,8 @@
 "   Return a new instance, this is needed because types such as textures can be changed at runtime.\n"
 "\n"
 "   :return: a new instance of this object with the type initialized again.\n"
-"   :rtype: subclass of :class:`bpy_struct`";
-
+"   :rtype: subclass of :class:`bpy_struct`\n"
+;
 static PyObject *pyrna_struct_type_recast(BPy_StructRNA *self)
 {
 	PointerRNA r_ptr;
@@ -3244,10 +3244,10 @@
 "   :arg key: The key assosiated with the custom property.\n"
 "   :type key: string\n"
 "   :arg default: Optional argument for the value to return if *key* is not found.\n"
-// "   :type default: Undefined\n"
+"   :type default: Undefined\n"
 "\n"
-"   .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone` classes support custom properties.\n";
-
+"   .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone` classes support custom properties.\n"
+;
 static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
 {
 	IDProperty *group, *idprop;
@@ -3283,8 +3283,8 @@
 "   :return: int (memory address).\n"
 "   :rtype: int\n"
 "\n"
-"   .. note:: This is intended only for advanced script writers who need to pass blender data to their own C/Python modules.\n";
-
+"   .. note:: This is intended only for advanced script writers who need to pass blender data to their own C/Python modules.\n"
+;
 static PyObject *pyrna_struct_as_pointer(BPy_StructRNA *self)
 {
 	return PyLong_FromVoidPtr(self->ptr.data);




More information about the Bf-blender-cvs mailing list