From c3ab6bc509b4a322e66b59fd9c12b9954f851b66 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Apr 2010 20:43:58 +0000 Subject: [PATCH] rna reference docs, list inherited properties and functions at the bottom of each type. --- release/scripts/modules/rna_info.py | 18 +++++----- source/blender/python/doc/sphinx_doc_gen.py | 38 +++++++++++++++++++++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py index 89f170ade44..75b03405f49 100644 --- a/release/scripts/modules/rna_info.py +++ b/release/scripts/modules/rna_info.py @@ -31,10 +31,10 @@ def _get_direct_attr(rna_type, attr): base = rna_type.base if not base: - return props + return [prop for prop in props] else: props_base = getattr(base, attr).values() - return dict([(prop.identifier, prop) for prop in props if prop not in props_base]) + return [prop for prop in props if prop not in props_base] def get_direct_properties(rna_type): @@ -86,8 +86,8 @@ class InfoStructRNA: def build(self): rna_type = self.bl_rna parent_id = self.identifier - self.properties[:] = [GetInfoPropertyRNA(rna_prop, parent_id) for rna_id, rna_prop in get_direct_properties(rna_type).items() if rna_id != "rna_type"] - self.functions[:] = [GetInfoFunctionRNA(rna_prop, parent_id) for rna_prop in get_direct_functions(rna_type).values()] + self.properties[:] = [GetInfoPropertyRNA(rna_prop, parent_id) for rna_prop in get_direct_properties(rna_type) if rna_prop.identifier != "rna_type"] + self.functions[:] = [GetInfoFunctionRNA(rna_prop, parent_id) for rna_prop in get_direct_functions(rna_type)] def get_bases(self): bases = [] @@ -385,7 +385,7 @@ def BuildRNAInfo(): rna_full_path_dict = {} # store the result of full_rna_struct_path(rna_struct) rna_children_dict = {} # store all rna_structs nested from here rna_references_dict = {} # store a list of rna path strings that reference this type - rna_functions_dict = {} # store all functions directly in this type (not inherited) + # rna_functions_dict = {} # store all functions directly in this type (not inherited) def rna_id_ignore(rna_id): if rna_id == "rna_type": @@ -445,7 +445,8 @@ def BuildRNAInfo(): rna_full_path_dict[identifier] = full_rna_struct_path(rna_struct) # Store a list of functions, remove inherited later - rna_functions_dict[identifier] = get_direct_functions(rna_struct) + # NOT USED YET + ## rna_functions_dict[identifier] = get_direct_functions(rna_struct) # fill in these later @@ -494,7 +495,8 @@ def BuildRNAInfo(): # rna_struct_path = full_rna_struct_path(rna_struct) rna_struct_path = rna_full_path_dict[identifier] - for rna_prop_identifier, rna_prop in get_direct_properties(rna_struct).items(): + for rna_prop in get_direct_properties(rna_struct): + rna_prop_identifier = rna_prop.identifier if rna_prop_identifier == 'RNA' or rna_id_ignore(rna_prop_identifier): continue @@ -504,7 +506,7 @@ def BuildRNAInfo(): if rna_prop_ptr: rna_references_dict[rna_prop_ptr.identifier].append("%s.%s" % (rna_struct_path, rna_prop_identifier)) - for rna_func in get_direct_functions(rna_struct).values(): + for rna_func in get_direct_functions(rna_struct): for rna_prop_identifier, rna_prop in rna_func.parameters.items(): if rna_prop_identifier == 'RNA' or rna_id_ignore(rna_prop_identifier): diff --git a/source/blender/python/doc/sphinx_doc_gen.py b/source/blender/python/doc/sphinx_doc_gen.py index 37bc123ee53..9a5294bed82 100644 --- a/source/blender/python/doc/sphinx_doc_gen.py +++ b/source/blender/python/doc/sphinx_doc_gen.py @@ -488,6 +488,44 @@ def rna2sphinx(BASEPATH): write_example_ref(" ", fw, struct.identifier + "." + attribute) fw("\n") + lines = [] + + if struct.base: + bases = list(reversed(struct.get_bases())) + + # props + lines[:] = [] + for base in bases: + for prop in base.properties: + lines.append("* :class:`%s.%s`\n" % (base.identifier, prop.identifier)) + + for identifier, py_prop in base.get_py_properties(): + lines.append("* :class:`%s.%s`\n" % (base.identifier, identifier)) + + if lines: + fw(".. rubric:: Inherited Properties\n\n") + for line in lines: + fw(line) + fw("\n") + + + # funcs + lines[:] = [] + for base in bases: + for func in base.functions: + lines.append("* :class:`%s.%s`\n" % (base.identifier, func.identifier)) + for identifier, py_func in base.get_py_functions(): + lines.append("* :class:`%s.%s`\n" % (base.identifier, identifier)) + + if lines: + fw(".. rubric:: Inherited Functions\n\n") + for line in lines: + fw(line) + fw("\n") + + lines[:] = [] + + if struct.references: # use this otherwise it gets in the index for a normal heading. fw(".. rubric:: References\n\n")