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

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

View File

@@ -511,6 +511,8 @@ def pycontext2sphinx(BASEPATH):
else:
pass # will have raised an error above
file.close()
def pyrna2sphinx(BASEPATH):
""" bpy.types and bpy.ops
@@ -731,6 +733,7 @@ def pyrna2sphinx(BASEPATH):
# 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,46 +772,51 @@ def pyrna2sphinx(BASEPATH):
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()