[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31420] trunk/blender: document rna functions that have the no_self flag set as classmethods

Campbell Barton ideasman42 at gmail.com
Tue Aug 17 16:32:14 CEST 2010


Revision: 31420
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31420
Author:   campbellbarton
Date:     2010-08-17 16:32:14 +0200 (Tue, 17 Aug 2010)

Log Message:
-----------
document rna functions that have the no_self flag set as classmethods

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

Modified: trunk/blender/release/scripts/modules/rna_info.py
===================================================================
--- trunk/blender/release/scripts/modules/rna_info.py	2010-08-17 14:09:53 UTC (rev 31419)
+++ trunk/blender/release/scripts/modules/rna_info.py	2010-08-17 14:32:14 UTC (rev 31420)
@@ -302,6 +302,7 @@
         self.identifier = rna_func.identifier
         # self.name = rna_func.name # functions have no name!
         self.description = rna_func.description.strip()
+        self.is_classmethod = rna_func.no_self
 
         self.args = []
         self.return_values = ()

Modified: trunk/blender/source/blender/makesrna/intern/rna_rna.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_rna.c	2010-08-17 14:09:53 UTC (rev 31419)
+++ trunk/blender/source/blender/makesrna/intern/rna_rna.c	2010-08-17 14:32:14 UTC (rev 31420)
@@ -811,6 +811,12 @@
 	return func->flag & FUNC_REGISTER_OPTIONAL;
 }
 
+static int rna_Function_no_self_get(PointerRNA *ptr)
+{
+	FunctionRNA *func= (FunctionRNA*)ptr->data;
+	return func->flag & FUNC_NO_SELF;
+}
+
 /* Blender RNA */
 
 static void rna_BlenderRNA_structs_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@@ -1049,6 +1055,11 @@
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_boolean_funcs(prop, "rna_Function_registered_optional_get", NULL);
 	RNA_def_property_ui_text(prop, "Registered Optionally", "Function is optionally registered as callback part of type registration");
+
+	prop= RNA_def_property(srna, "no_self", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_boolean_funcs(prop, "rna_Function_no_self_get", NULL);
+	RNA_def_property_ui_text(prop, "No Self", "Function does not pass its self as an argument (becomes a class method in python)");
 }
 
 static void rna_def_number_property(StructRNA *srna, PropertyType type)

Modified: trunk/blender/source/blender/makesrna/intern/rna_ui.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_ui.c	2010-08-17 14:09:53 UTC (rev 31419)
+++ trunk/blender/source/blender/makesrna/intern/rna_ui.c	2010-08-17 14:32:14 UTC (rev 31420)
@@ -712,7 +712,7 @@
 
 	/* poll */
 	func= RNA_def_function(srna, "poll", NULL);
-	RNA_def_function_ui_description(func, "If this method returns a non-null output, then the menu can be drawn. This is a static method, hence it is not possible to use 'self' in it.");
+	RNA_def_function_ui_description(func, "If this method returns a non-null output, then the menu can be drawn.");
 	RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_REGISTER|FUNC_REGISTER_OPTIONAL);
 	RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
 	parm= RNA_def_pointer(func, "context", "Context", "", "");

Modified: trunk/blender/source/blender/python/doc/sphinx_doc_gen.py
===================================================================
--- trunk/blender/source/blender/python/doc/sphinx_doc_gen.py	2010-08-17 14:09:53 UTC (rev 31419)
+++ trunk/blender/source/blender/python/doc/sphinx_doc_gen.py	2010-08-17 14:32:14 UTC (rev 31420)
@@ -594,7 +594,7 @@
         for func in struct.functions:
             args_str = ", ".join([prop.get_arg_default(force=False) for prop in func.args])
 
-            fw("   .. method:: %s(%s)\n\n" % (func.identifier, args_str))
+            fw("   .. %s:: %s(%s)\n\n" % ("classmethod" if func.is_classmethod else "method", func.identifier, args_str))
             fw("      %s\n\n" % func.description)
             
             for prop in func.args:





More information about the Bf-blender-cvs mailing list