viewing docs for nested classes would fail, expects bpy.types.Scene.SceneGameData...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 28 Oct 2009 09:03:08 +0000 (09:03 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 28 Oct 2009 09:03:08 +0000 (09:03 +0000)
release/scripts/modules/bpy_ops.py

index c8269e25049d197f0ab6a1bacbd3cad4cd775779..aeb93028e21491402bc388b1325b740387eed17a 100644 (file)
@@ -317,12 +317,22 @@ class WM_OT_context_cycle_enum(bpy.types.Operator):
 doc_id = bpy.props.StringProperty(attr="doc_id", name="Doc ID", description="ID for the documentation", maxlen= 1024, default= "")
 doc_new = bpy.props.StringProperty(attr="doc_new", name="Doc New", description="", maxlen= 1024, default= "")
 
+
 class WM_OT_doc_view(bpy.types.Operator):
        '''Load online reference docs'''
        __idname__ = "wm.doc_view"
        __label__ = "View Documentation"
        __props__ = [doc_id]
        _prefix = 'http://www.blender.org/documentation/250PythonDoc'
+       
+       def _nested_class_string(self, class_string):
+               ls = []
+               class_obj = getattr(bpy.types, class_string, None).__rna__
+               while class_obj:
+                       ls.insert(0, class_obj)
+                       class_obj = class_obj.nested
+               return '.'.join([class_obj.identifier for class_obj in ls])
+       
        def execute(self, context):
                id_split = self.doc_id.split('.')
                # Example url, http://www.graphicall.org/ftp/ideasman42/html/bpy.types.Space3DView-class.html#background_image
@@ -332,10 +342,12 @@ class WM_OT_doc_view(bpy.types.Operator):
                elif len(id_split) == 2: # rna, class.prop
                        class_name, class_prop = id_split
                        
+                       class_name_full = self._nested_class_string(class_name) # It so happens that epydoc nests these
+                       
                        if hasattr(bpy.types, class_name.upper() + '_OT_' + class_prop):
-                               url= '%s/bpy.ops.%s-module.html#%s' % (self._prefix, class_name, class_prop)
+                               url= '%s/bpy.ops.%s-module.html#%s' % (self._prefix, class_name_full, class_prop)
                        else:
-                               url= '%s/bpy.types.%s-class.html#%s' % (self._prefix, class_name, class_prop)
+                               url= '%s/bpy.types.%s-class.html#%s' % (self._prefix, class_name_full, class_prop)
                        
                else:
                        return ('PASS_THROUGH',)