[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25569] trunk/blender: classmethods were excluded from docs, hide self & cls arguments for functions and class methods,

Campbell Barton ideasman42 at gmail.com
Sat Dec 26 18:49:09 CET 2009


Revision: 25569
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25569
Author:   campbellbarton
Date:     2009-12-26 18:49:08 +0100 (Sat, 26 Dec 2009)

Log Message:
-----------
classmethods were excluded from docs, hide self & cls arguments for functions and class methods, 
made some rna ui funcs not display as optional.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/rna_info.py
    trunk/blender/source/blender/makesrna/intern/rna_ui.c
    trunk/blender/source/blender/python/sphinx_doc_gen.py

Modified: trunk/blender/release/scripts/modules/rna_info.py
===================================================================
--- trunk/blender/release/scripts/modules/rna_info.py	2009-12-26 16:47:25 UTC (rev 25568)
+++ trunk/blender/release/scripts/modules/rna_info.py	2009-12-26 17:49:08 UTC (rev 25569)
@@ -110,7 +110,7 @@
         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
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_ui.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_ui.c	2009-12-26 16:47:25 UTC (rev 25568)
+++ trunk/blender/source/blender/makesrna/intern/rna_ui.c	2009-12-26 17:49:08 UTC (rev 25569)
@@ -573,6 +573,7 @@
 {
 	StructRNA *srna;
 	PropertyRNA *prop;
+	PropertyRNA *parm;
 	FunctionRNA *func;
 	
 	srna= RNA_def_struct(brna, "Panel", NULL);
@@ -586,18 +587,21 @@
 	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 @@
 {
 	StructRNA *srna;
 	PropertyRNA *prop;
+	PropertyRNA *parm;
 	FunctionRNA *func;
 	
 	srna= RNA_def_struct(brna, "Header", NULL);
@@ -653,7 +658,8 @@
 	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 @@
 {
 	StructRNA *srna;
 	PropertyRNA *prop;
+	PropertyRNA *parm;
 	FunctionRNA *func;
 	
 	srna= RNA_def_struct(brna, "Menu", NULL);
@@ -691,13 +698,15 @@
 	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
 

Modified: trunk/blender/source/blender/python/sphinx_doc_gen.py
===================================================================
--- trunk/blender/source/blender/python/sphinx_doc_gen.py	2009-12-26 16:47:25 UTC (rev 25568)
+++ trunk/blender/source/blender/python/sphinx_doc_gen.py	2009-12-26 17:49:08 UTC (rev 25569)
@@ -192,8 +192,20 @@
         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:





More information about the Bf-blender-cvs mailing list