From 1a6b9ea5d94716f376e6dcd0b77d140f41a12801 Mon Sep 17 00:00:00 2001 From: Luca Bonavita Date: Mon, 28 Jun 2010 00:06:23 +0000 Subject: [PATCH] == python api docs == - properties are now listed on alphabetical order - readonly properties use "data" directive, so that we see them in green in the web docs example (after Campbell will rebuild the docs): http://www.blender.org/documentation/250PythonDoc/bpy.types.RenderLayer.html (note that green attributes still need final CSS-ing, but smerch is a bit busy atm) - fixed indentation in http://www.blender.org/documentation/250PythonDoc/bpy.data.html --- source/blender/python/doc/sphinx_doc_gen.py | 27 +++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/source/blender/python/doc/sphinx_doc_gen.py b/source/blender/python/doc/sphinx_doc_gen.py index 195a91e7539..27524c66c36 100644 --- a/source/blender/python/doc/sphinx_doc_gen.py +++ b/source/blender/python/doc/sphinx_doc_gen.py @@ -178,7 +178,11 @@ def pyprop2sphinx(ident, fw, identifier, py_prop): ''' python property to sphinx ''' - fw(ident + ".. attribute:: %s\n\n" % identifier) + # readonly properties use "data" directive, variables use "attribute" directive + if py_prop.fset is None: + fw(ident + ".. data:: %s\n\n" % identifier) + else: + fw(ident + ".. attribute:: %s\n\n" % identifier) write_indented_lines(ident + " ", fw, py_prop.__doc__) if py_prop.fset is None: fw(ident + " (readonly)\n\n") @@ -420,9 +424,9 @@ def rna2sphinx(BASEPATH): fw("\n") fw("This module is used for all blender/python access.\n") fw("\n") - fw(" .. literalinclude:: ../examples/bpy.data.py\n") + fw(".. literalinclude:: ../examples/bpy.data.py\n") fw("\n") - fw(" .. data:: data\n") + fw(".. data:: data\n") fw("\n") fw(" Access to blenders internal data\n") fw("\n") @@ -547,12 +551,21 @@ def rna2sphinx(BASEPATH): fw(".. class:: %s\n\n" % struct.identifier) fw(" %s\n\n" % struct.description) - - for prop in struct.properties: - fw(" .. attribute:: %s\n\n" % prop.identifier) + + # properties sorted in alphabetical order + zip_props_ids = zip(struct.properties, [prop.identifier for prop in struct.properties]) + zip_props_ids = sorted(zip_props_ids, key=lambda p: p[1]) + sorted_struct_properties = [x[0] for x in zip_props_ids] + + for prop in sorted_struct_properties: + type_descr = prop.get_type_description(class_fmt=":class:`%s`") + # readonly properties use "data" directive, variables properties use "attribute" directive + if 'readonly' in type_descr: + fw(" .. data:: %s\n\n" % prop.identifier) + else: + fw(" .. attribute:: %s\n\n" % prop.identifier) if prop.description: fw(" %s\n\n" % prop.description) - type_descr = prop.get_type_description(class_fmt=":class:`%s`") fw(" :type: %s\n\n" % type_descr) # python attributes