fixed sphinx doc generator

- arguments, return values indentation means they get correctly interpreted by sphinx
- functions with no return values were displaying return as ()
- return values were getting the '(optional)' added in some cases.

Example:
http://www.blender.org/documentation/250PythonDoc/bpy.ops.object.html
This commit is contained in:
Campbell Barton 2010-01-17 20:59:35 +00:00
parent f50ec12d9f
commit 381e926600
2 changed files with 12 additions and 14 deletions

@ -201,7 +201,7 @@ class InfoPropertyRNA:
return "%s=%s" % (self.identifier, default)
return self.identifier
def get_type_description(self, as_arg=False, class_fmt="%s"):
def get_type_description(self, as_ret=False, as_arg=False, class_fmt="%s"):
type_str = ""
if self.fixed_type is None:
type_str += self.type
@ -223,7 +223,9 @@ class InfoPropertyRNA:
type_str += collection_str + (class_fmt % self.fixed_type.identifier)
if as_arg:
if as_ret:
pass
elif as_arg:
if not self.is_required:
type_str += ", (optional)"
else: # readonly is only useful for selfs, not args

@ -29,10 +29,6 @@ Generate html docs by running...
sphinx-build source/blender/python/doc/sphinx-in source/blender/python/doc/sphinx-out
'''
# if you dont have graphvis installed ommit the --graph arg.
# GLOBALS['BASEDIR'] = './source/blender/python/doc'
import os
import inspect
import bpy
@ -108,8 +104,8 @@ def rna2sphinx(BASEPATH):
type_descr = prop.get_type_description(as_arg=True, class_fmt=":class:`%s`")
if prop.name or prop.description:
fw(ident + " :%s %s: %s\n" % (id_name, prop.identifier, ", ".join([val for val in (prop.name, prop.description) if val])))
fw(ident + " :%s %s: %s\n" % (id_type, prop.identifier, type_descr))
fw(ident + ":%s %s: %s\n" % (id_name, prop.identifier, ", ".join([val for val in (prop.name, prop.description) if val])))
fw(ident + ":%s %s: %s\n" % (id_type, prop.identifier, type_descr))
def write_struct(struct):
#if not struct.identifier.startswith("Sc") and not struct.identifier.startswith("I"):
@ -160,7 +156,7 @@ def rna2sphinx(BASEPATH):
fw(" .. attribute:: %s\n\n" % prop.identifier)
if prop.description:
fw(" %s\n\n" % prop.description)
type_descr = prop.get_type_description(as_arg=False, class_fmt=":class:`%s`")
type_descr = prop.get_type_description(class_fmt=":class:`%s`")
fw(" *type* %s\n\n" % type_descr)
# python attributes
@ -184,14 +180,14 @@ def rna2sphinx(BASEPATH):
if len(func.return_values) == 1:
write_param(" ", fw, func.return_values[0], is_return=True)
else: # multiple return values
fw(" :return (%s):\n" % ", ".join([prop.identifier for prop in func.return_values]))
elif func.return_values: # multiple return values
fw(" :return (%s):\n" % ", ".join([prop.identifier for prop in func.return_values]))
for prop in func.return_values:
type_descr = prop.get_type_description(as_arg=True, class_fmt=":class:`%s`")
type_descr = prop.get_type_description(as_ret=True, class_fmt=":class:`%s`")
descr = prop.description
if not descr:
descr = prop.name
fw(" `%s`, %s, %s\n\n" % (prop.identifier, descr, type_descr))
fw(" `%s`, %s, %s\n\n" % (prop.identifier, descr, type_descr))
fw("\n")
@ -257,7 +253,7 @@ def rna2sphinx(BASEPATH):
if op.description:
fw(" %s\n\n" % op.description)
for prop in op.args:
write_param(" ", fw, prop)
write_param(" ", fw, prop)
if op.args:
fw("\n")