diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-08-16 19:46:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-08-16 19:46:09 +0400 |
commit | 5555ef8a767de8a45c69c2b390032beb8a56479c (patch) | |
tree | 6e4557233dda42f57af79e3d95849fbf27562d52 /source/blender/python | |
parent | 0e06b0bdf109ab69d406a72654c37b0f6ce377e6 (diff) |
rna function return values in generated docs,
added prop.use_return so you can tell if a prop is a return value.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/epy_doc_gen.py | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/source/blender/python/epy_doc_gen.py b/source/blender/python/epy_doc_gen.py index 8630a0c8f8e..1da69c622a6 100644 --- a/source/blender/python/epy_doc_gen.py +++ b/source/blender/python/epy_doc_gen.py @@ -76,6 +76,7 @@ def write_func(rna, ident, out, func_type): rna_func_desc = rna.description.strip() items = rna.parameters.items() + for rna_prop_identifier, rna_prop in items: if rna_prop_identifier=='rna_type': continue @@ -88,13 +89,25 @@ def write_func(rna, ident, out, func_type): rna_prop_type = rna_prop.type.lower() # enum, float, int, boolean + # only for rna funcions, operators should not get pointers as args + if rna_prop_type=='pointer': + rna_prop_type_refine = "L{%s}" % rna_prop.fixed_type.identifier + else: + rna_prop_type_refine = rna_prop_type + + try: length = rna_prop.array_length except: length = 0 array_str = get_array_str(length) - kw_type_str= "@type %s: %s%s" % (rna_prop_identifier, rna_prop_type, array_str) - kw_param_str= "@param %s: %s" % (rna_prop_identifier, rna_prop.description.strip()) + if rna_prop.use_return: + kw_type_str= "@rtype: %s%s" % (rna_prop_type_refine, array_str) + kw_param_str= "@return: %s" % (rna_prop.description.strip()) + else: + kw_type_str= "@type %s: %s%s" % (rna_prop_identifier, rna_prop_type_refine, array_str) + kw_param_str= "@param %s: %s" % (rna_prop_identifier, rna_prop.description.strip()) + kw_param_set = False if func_type=='OPERATOR': @@ -159,8 +172,11 @@ def write_func(rna, ident, out, func_type): # stora else: # currently functions dont have a default value - kw_args.append('%s' % (rna_prop_identifier)) - + if not rna_prop.use_return: + kw_args.append('%s' % (rna_prop_identifier)) + else: + kw_param_set = True + # Same for operators and functions kw_arg_attrs.append(kw_type_str) @@ -174,7 +190,8 @@ def write_func(rna, ident, out, func_type): out.write(ident+'\t%s\n' % rna_func_desc) for desc in kw_arg_attrs: out.write(ident+'\t%s\n' % desc) - out.write(ident+'\t@rtype: None\n') + + # out.write(ident+'\t@rtype: None\n') # implicit out.write(ident+'\t"""\n') @@ -269,7 +286,8 @@ def rna2epy(target_path): out.write(ident+ '\t@ivar %s: %s in (%s)\n' % (rna_prop_identifier, rna_desc, ', '.join(rna_prop.items.keys()))) else: out.write(ident+ '\t@ivar %s: %s in...\n' % (rna_prop_identifier, rna_desc)) - for e in rna_prop.items.keys(): + for e, e_rna_prop in rna_prop.items.items(): + #out.write(ident+ '\t\t- %s: %s\n' % (e, e_rna_prop.description)) # XXX - segfaults, FIXME out.write(ident+ '\t\t- %s\n' % e) out.write(ident+ '\t@type %s: %s%s%s\n' % (rna_prop_identifier, rna_prop_type, array_str, readonly_str)) |