diff options
-rw-r--r-- | doc/python_api/sphinx_doc_gen.py | 64 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 50 |
2 files changed, 61 insertions, 53 deletions
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 4112e24d6e0..8058ebeb137 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -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 + + title = "%s Operators" % op_module_name.replace("_", " ").title() + fw("%s\n%s\n\n" % (title, "=" * len(title))) - 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 + fw(".. module:: bpy.ops.%s\n\n" % op_module_name) - title = "%s Operators" % (op.module_name[0].upper() + op.module_name[1:]) - fw("%s\n%s\n\n" % (title, "=" * len(title))) + ops_mod.sort(key=lambda op: op.func_name) - fw(".. module:: bpy.ops.%s\n\n" % op.module_name) - last_mod = op.module_name + 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)) - 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() diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index fa01eefa867..bc89dc01f9a 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -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" " :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 @@ 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" " :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 @@ 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" " :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 @@ 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" " :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 @@ static char pyrna_struct_is_property_set_doc[] = " 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 @@ static char pyrna_struct_is_property_hidden_doc[] = " 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 @@ static char pyrna_struct_path_resolve_doc[] = " :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 @@ 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" " :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 @@ static char pyrna_prop_path_from_id_doc[] = " 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 @@ 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" "\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 @@ static char pyrna_struct_get_doc[] = " :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 @@ static char pyrna_struct_as_pointer_doc[] = " :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); |