forked from bartvdbraak/blender
sphinx support for documenting multiple return values
This commit is contained in:
parent
78b2eb8d3c
commit
cef8b2088f
@ -252,19 +252,22 @@ class InfoFunctionRNA:
|
|||||||
self.description = rna_func.description.strip()
|
self.description = rna_func.description.strip()
|
||||||
|
|
||||||
self.args = []
|
self.args = []
|
||||||
self.return_value = None
|
self.return_values = ()
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
rna_func = self.bl_func
|
rna_func = self.bl_func
|
||||||
parent_id = rna_func
|
parent_id = rna_func
|
||||||
|
self.return_values = []
|
||||||
|
|
||||||
for rna_prop in rna_func.parameters.values():
|
for rna_prop in rna_func.parameters.values():
|
||||||
prop = GetInfoPropertyRNA(rna_prop, parent_id)
|
prop = GetInfoPropertyRNA(rna_prop, parent_id)
|
||||||
if rna_prop.use_return:
|
if rna_prop.use_return:
|
||||||
self.return_value = prop
|
self.return_values.append(prop)
|
||||||
else:
|
else:
|
||||||
self.args.append(prop)
|
self.args.append(prop)
|
||||||
|
|
||||||
|
self.return_values = tuple(self.return_values)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
txt = ''
|
txt = ''
|
||||||
txt += ' * ' + self.identifier + '('
|
txt += ' * ' + self.identifier + '('
|
||||||
@ -566,8 +569,8 @@ def BuildRNAInfo():
|
|||||||
func.build()
|
func.build()
|
||||||
for prop in func.args:
|
for prop in func.args:
|
||||||
prop.build()
|
prop.build()
|
||||||
if func.return_value:
|
for prop in func.return_values:
|
||||||
func.return_value.build()
|
prop.build()
|
||||||
|
|
||||||
# now for operators
|
# now for operators
|
||||||
op_mods = dir(bpy.ops)
|
op_mods = dir(bpy.ops)
|
||||||
|
@ -115,8 +115,8 @@ def rna2sphinx(BASEPATH):
|
|||||||
#if not struct.identifier.startswith("Sc") and not struct.identifier.startswith("I"):
|
#if not struct.identifier.startswith("Sc") and not struct.identifier.startswith("I"):
|
||||||
# return
|
# return
|
||||||
|
|
||||||
#if not struct.identifier.startswith("Bone"):
|
if not struct.identifier == "Object":
|
||||||
# return
|
return
|
||||||
|
|
||||||
filepath = os.path.join(BASEPATH, "bpy.types.%s.rst" % struct.identifier)
|
filepath = os.path.join(BASEPATH, "bpy.types.%s.rst" % struct.identifier)
|
||||||
file = open(filepath, "w")
|
file = open(filepath, "w")
|
||||||
@ -182,8 +182,17 @@ def rna2sphinx(BASEPATH):
|
|||||||
for prop in func.args:
|
for prop in func.args:
|
||||||
write_param(" ", fw, prop)
|
write_param(" ", fw, prop)
|
||||||
|
|
||||||
if func.return_value:
|
if len(func.return_values) == 1:
|
||||||
write_param(" ", fw, func.return_value, is_return=True)
|
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]))
|
||||||
|
for prop in func.return_values:
|
||||||
|
type_descr = prop.get_type_description(as_arg=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("\n")
|
fw("\n")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user