make doc generation close files (py3.2 complains about this),

minor formatting changes for C docstrings.
This commit is contained in:
Campbell Barton 2011-02-22 05:23:20 +00:00
parent a8f04dfb52
commit dd8383e469
2 changed files with 61 additions and 53 deletions

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

@ -2246,8 +2246,8 @@ static char pyrna_struct_keyframe_insert_doc[] =
" :arg group: The name of the group the F-Curve should be added to if it doesn't exist yet.\n" " :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" " :type group: str\n"
" :return: Success of keyframe insertion.\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) static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyObject *kw)
{ {
/* args, pyrna_struct_keyframe_parse handles these */ /* args, pyrna_struct_keyframe_parse handles these */
@ -2289,8 +2289,8 @@ static char pyrna_struct_keyframe_delete_doc[] =
" :arg group: The name of the group the F-Curve should be added to if it doesn't exist yet.\n" " :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" " :type group: str\n"
" :return: Success of keyframe deleation.\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) static PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyObject *kw)
{ {
/* args, pyrna_struct_keyframe_parse handles these */ /* args, pyrna_struct_keyframe_parse handles these */
@ -2329,8 +2329,8 @@ static char pyrna_struct_driver_add_doc[] =
" :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" " :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" " :type index: int\n"
" :return: The driver(s) added.\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) static PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
{ {
const char *path, *path_full; const char *path, *path_full;
@ -2401,8 +2401,8 @@ static char pyrna_struct_driver_remove_doc[] =
" :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" " :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" " :type index: int\n"
" :return: Success of driver removal.\n" " :return: Success of driver removal.\n"
" :rtype: boolean"; " :rtype: boolean\n"
;
static PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args) static PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
{ {
const char *path, *path_full; const char *path, *path_full;
@ -2438,8 +2438,8 @@ static char pyrna_struct_is_property_set_doc[] =
" Check if a property is set, use for testing operator properties.\n" " Check if a property is set, use for testing operator properties.\n"
"\n" "\n"
" :return: True when the property has been set.\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) static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args)
{ {
PropertyRNA *prop; PropertyRNA *prop;
@ -2478,8 +2478,8 @@ static char pyrna_struct_is_property_hidden_doc[] =
" Check if a property is hidden.\n" " Check if a property is hidden.\n"
"\n" "\n"
" :return: True when the property is hidden.\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) static PyObject *pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject *args)
{ {
PropertyRNA *prop; PropertyRNA *prop;
@ -2504,8 +2504,8 @@ static char pyrna_struct_path_resolve_doc[] =
" :arg path: path which this property resolves.\n" " :arg path: path which this property resolves.\n"
" :type path: string\n" " :type path: string\n"
" :arg coerce: optional argument, when True, the property will be converted into its python representation.\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) static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
{ {
const char *path; const char *path;
@ -2555,8 +2555,8 @@ static char pyrna_struct_path_from_id_doc[] =
" :arg property: Optional property name which can be used if the path is to a property of this object.\n" " :arg property: Optional property name which can be used if the path is to a property of this object.\n"
" :type property: string\n" " :type property: string\n"
" :return: The path from :class:`bpy_struct.id_data` to this struct and property (when given).\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) static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args)
{ {
const char *name= NULL; const char *name= NULL;
@ -2598,8 +2598,8 @@ static char pyrna_prop_path_from_id_doc[] =
" Returns the data path from the ID to this property (string).\n" " Returns the data path from the ID to this property (string).\n"
"\n" "\n"
" :return: The path from :class:`bpy_struct.id_data` to this property.\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) static PyObject *pyrna_prop_path_from_id(BPy_PropertyRNA *self)
{ {
const char *path; const char *path;
@ -2625,8 +2625,8 @@ static char pyrna_struct_type_recast_doc[] =
" Return a new instance, this is needed because types such as textures can be changed at runtime.\n" " Return a new instance, this is needed because types such as textures can be changed at runtime.\n"
"\n" "\n"
" :return: a new instance of this object with the type initialized again.\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) static PyObject *pyrna_struct_type_recast(BPy_StructRNA *self)
{ {
PointerRNA r_ptr; PointerRNA r_ptr;
@ -3244,10 +3244,10 @@ static char pyrna_struct_get_doc[] =
" :arg key: The key assosiated with the custom property.\n" " :arg key: The key assosiated with the custom property.\n"
" :type key: string\n" " :type key: string\n"
" :arg default: Optional argument for the value to return if *key* is not found.\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" "\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) static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
{ {
IDProperty *group, *idprop; IDProperty *group, *idprop;
@ -3283,8 +3283,8 @@ static char pyrna_struct_as_pointer_doc[] =
" :return: int (memory address).\n" " :return: int (memory address).\n"
" :rtype: int\n" " :rtype: int\n"
"\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) static PyObject *pyrna_struct_as_pointer(BPy_StructRNA *self)
{ {
return PyLong_FromVoidPtr(self->ptr.data); return PyLong_FromVoidPtr(self->ptr.data);