diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py index 57918046f95..0a1b02d5759 100644 --- a/release/scripts/modules/rna_info.py +++ b/release/scripts/modules/rna_info.py @@ -110,7 +110,7 @@ class InfoStructRNA: import types functions = [] for identifier, attr in self._get_py_visible_attrs(): - if type(attr) is types.FunctionType: + if type(attr) in (types.FunctionType, types.MethodType): functions.append((identifier, attr)) return functions diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index cbd524680c1..695eb76cb53 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -573,6 +573,7 @@ static void rna_def_panel(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + PropertyRNA *parm; FunctionRNA *func; srna= RNA_def_struct(brna, "Panel", NULL); @@ -586,18 +587,21 @@ static void rna_def_panel(BlenderRNA *brna) RNA_def_function_ui_description(func, "Test if the panel is visible or not."); RNA_def_function_flag(func, FUNC_REGISTER|FUNC_REGISTER_OPTIONAL); RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); /* draw */ func= RNA_def_function(srna, "draw", NULL); RNA_def_function_ui_description(func, "Draw buttons into the panel UI layout."); RNA_def_function_flag(func, FUNC_REGISTER); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); func= RNA_def_function(srna, "draw_header", NULL); RNA_def_function_ui_description(func, "Draw buttons into the panel header UI layout."); RNA_def_function_flag(func, FUNC_REGISTER); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); prop= RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "UILayout"); @@ -641,6 +645,7 @@ static void rna_def_header(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + PropertyRNA *parm; FunctionRNA *func; srna= RNA_def_struct(brna, "Header", NULL); @@ -653,7 +658,8 @@ static void rna_def_header(BlenderRNA *brna) func= RNA_def_function(srna, "draw", NULL); RNA_def_function_ui_description(func, "Draw buttons into the header UI layout."); RNA_def_function_flag(func, FUNC_REGISTER); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); RNA_define_verify_sdna(0); // not in sdna @@ -678,6 +684,7 @@ static void rna_def_menu(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + PropertyRNA *parm; FunctionRNA *func; srna= RNA_def_struct(brna, "Menu", NULL); @@ -691,13 +698,15 @@ static void rna_def_menu(BlenderRNA *brna) RNA_def_function_ui_description(func, "Test if the menu is visible or not."); RNA_def_function_flag(func, FUNC_REGISTER|FUNC_REGISTER_OPTIONAL); RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); /* draw */ func= RNA_def_function(srna, "draw", NULL); RNA_def_function_ui_description(func, "Draw buttons into the menu UI layout."); RNA_def_function_flag(func, FUNC_REGISTER); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); RNA_define_verify_sdna(0); // not in sdna diff --git a/source/blender/python/sphinx_doc_gen.py b/source/blender/python/sphinx_doc_gen.py index fcf0f274bcf..c8e283ac447 100644 --- a/source/blender/python/sphinx_doc_gen.py +++ b/source/blender/python/sphinx_doc_gen.py @@ -192,8 +192,20 @@ def rna2sphinx(BASEPATH): py_func = None for identifier, py_func in py_funcs: - fw(" .. method:: %s%s\n\n" % (identifier, inspect.formatargspec(*inspect.getargspec(py_func)))) - write_indented_lines(" ", fw, py_func.__doc__) + arg_str = inspect.formatargspec(*inspect.getargspec(py_func)) + if arg_str.startswith("(self, "): + arg_str = "(" + arg_str[7:] + func_type = "method" + elif arg_str.startswith("(cls, "): + arg_str = "(" + arg_str[6:] + func_type = "classmethod" + else: + func_type = "staticmethod" + + fw(" .. %s:: %s%s\n\n" % (func_type, identifier, arg_str)) + if py_func.__doc__: + write_indented_lines(" ", fw, py_func.__doc__) + fw("\n") del py_funcs, py_func if struct.references: