[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60767] trunk/blender/doc/python_api: sphinx docgen wasn' t including example scripts for python methods of RNA types.

Campbell Barton ideasman42 at gmail.com
Tue Oct 15 07:55:51 CEST 2013


Revision: 60767
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60767
Author:   campbellbarton
Date:     2013-10-15 05:55:51 +0000 (Tue, 15 Oct 2013)
Log Message:
-----------
sphinx docgen wasn't including example scripts for python methods of RNA types.

Modified Paths:
--------------
    trunk/blender/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py
    trunk/blender/doc/python_api/sphinx_doc_gen.py

Modified: trunk/blender/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py
===================================================================
--- trunk/blender/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py	2013-10-15 02:23:28 UTC (rev 60766)
+++ trunk/blender/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py	2013-10-15 05:55:51 UTC (rev 60767)
@@ -1,6 +1,4 @@
 """
-Popup Menus
-+++++++++++
 Popup menus can be useful for creating menus without having to register menu classes.
 
 Note that they will not block the scripts execution, so the caller can't wait for user input.

Modified: trunk/blender/doc/python_api/sphinx_doc_gen.py
===================================================================
--- trunk/blender/doc/python_api/sphinx_doc_gen.py	2013-10-15 02:23:28 UTC (rev 60766)
+++ trunk/blender/doc/python_api/sphinx_doc_gen.py	2013-10-15 05:55:51 UTC (rev 60767)
@@ -466,7 +466,9 @@
 MethodDescriptorType = type(dict.get)
 GetSetDescriptorType = type(int.real)
 StaticMethodType = type(staticmethod(lambda: None))
-from types import MemberDescriptorType
+from types import (MemberDescriptorType,
+                   MethodType,
+                   )
 
 _BPY_STRUCT_FAKE = "bpy_struct"
 _BPY_PROP_COLLECTION_FAKE = "bpy_prop_collection"
@@ -629,12 +631,12 @@
         fw("\n")
 
 
-def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True):
+def pyfunc2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_class=True):
     '''
     function or class method to sphinx
     '''
 
-    if type(py_func) == type(bpy.types.Space.draw_handler_add):
+    if type(py_func) == MethodType:
         return
 
     arg_str = inspect.formatargspec(*inspect.getargspec(py_func))
@@ -657,7 +659,12 @@
         write_indented_lines(ident + "   ", fw, py_func.__doc__)
         fw("\n")
 
+    if is_class:
+        write_example_ref(ident + "   ", fw, module_name + "." + type_name + "." + identifier)
+    else:
+        write_example_ref(ident + "   ", fw, module_name + "." + identifier)
 
+
 def py_descr2sphinx(ident, fw, descr, module_name, type_name, identifier):
     if identifier.startswith("_"):
         return
@@ -867,7 +874,7 @@
 
     for attribute, value, value_type in module_dir_value_type:
         if value_type == types.FunctionType:
-            pyfunc2sphinx("", fw, attribute, value, is_class=False)
+            pyfunc2sphinx("", fw, module_name, None, attribute, value, is_class=False)
         elif value_type in (types.BuiltinMethodType, types.BuiltinFunctionType):  # both the same at the moment but to be future proof
             # note: can't get args from these, so dump the string as is
             # this means any module used like this must have fully formatted docstrings.
@@ -1316,7 +1323,7 @@
         py_func = None
 
         for identifier, py_func in py_funcs:
-            pyfunc2sphinx("   ", fw, identifier, py_func, is_class=True)
+            pyfunc2sphinx("   ", fw, "bpy.types", struct_id, identifier, py_func, is_class=True)
         del py_funcs, py_func
 
         py_funcs = struct.get_py_c_functions()




More information about the Bf-blender-cvs mailing list