Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-06-02 00:38:40 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-02 00:38:40 +0400
commit0dc84e64e754d0083b7c0c2acdd653aedb8e4890 (patch)
treee04200dd5440a57ac2c309030ce18b82c59c91ad /release/scripts
parente94e7b4c7e323876bd2abcba25fa85e98e54bfe0 (diff)
experenental manual linking from the UI. realize this is an issue which is not agreed on so probably this will be disabled for release.
the data is stored here so more dev can commit: ./release/scripts/addons/modules/rna_wiki_reference.py
Diffstat (limited to 'release/scripts')
-rw-r--r--release/scripts/startup/bl_operators/wm.py113
1 files changed, 81 insertions, 32 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 6fa7cbd0abd..04071ecc72a 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -799,6 +799,85 @@ class WM_OT_path_open(Operator):
return {'FINISHED'}
+
+def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
+ id_split = doc_id.split(".")
+ url = rna = None
+
+ if len(id_split) == 1: # rna, class
+ if do_url:
+ url = "%s/bpy.types.%s.html" % (url_prefix, id_split[0])
+ else:
+ rna = "bpy.types.%s" % id_split[0]
+
+ elif len(id_split) == 2: # rna, class.prop
+ class_name, class_prop = id_split
+
+ if hasattr(bpy.types, class_name.upper() + "_OT_" + class_prop):
+ if do_url:
+ url = ("%s/bpy.ops.%s.html#bpy.ops.%s.%s" % (url_prefix, class_name, class_name, class_prop))
+ else:
+ rna = "bpy.ops.%s.%s" % (class_name, class_prop)
+ else:
+
+ # detect if this is a inherited member and use that name instead
+ rna_parent = getattr(bpy.types, class_name).bl_rna
+ rna_prop = rna_parent.properties[class_prop]
+ rna_parent = rna_parent.base
+ while rna_parent and rna_prop == rna_parent.properties.get(class_prop):
+ class_name = rna_parent.identifier
+ rna_parent = rna_parent.base
+
+ if do_url:
+ url = ("%s/bpy.types.%s.html#bpy.types.%s.%s" % (url_prefix, class_name, class_name, class_prop))
+ else:
+ rna = ("bpy.types.%s.%s" % (class_name, class_prop))
+
+ return url if do_url else rna
+
+
+class WM_OT_doc_view_manual(Operator):
+ '''Load online manual'''
+ bl_idname = "wm.doc_view_manual"
+ bl_label = "View Manual"
+
+ doc_id = doc_id
+
+ @staticmethod
+ def _find_reference(rna_id, url_mapping):
+ from re import match
+ for pattern, url_suffix in url_mapping:
+ if match(pattern, rna_id):
+ return url_suffix
+ return None
+
+ def execute(self, context):
+ rna_id = _wm_doc_get_id(self.doc_id, do_url=False)
+ if rna_id is None:
+ return {'PASS_THROUGH'}
+
+ import rna_wiki_reference
+ rna_ref = self._find_reference(rna_id, rna_wiki_reference.url_manual_mapping)
+
+ if rna_ref is None:
+ self.report({'WARNING'}, "No reference available '%s', "
+ "Update info in %r" %
+ (self.doc_id, rna_wiki_reference.__file__))
+
+ import sys
+ del sys.modules["rna_wiki_reference"]
+
+ if rna_ref is None:
+ return {'CANCELLED'}
+ else:
+ url = rna_wiki_reference.url_manual_prefix + rna_ref
+
+ import webbrowser
+ webbrowser.open(url)
+
+ return {'FINISHED'}
+
+
class WM_OT_doc_view(Operator):
'''Load online reference docs'''
bl_idname = "wm.doc_view"
@@ -812,39 +891,9 @@ class WM_OT_doc_view(Operator):
_prefix = ("http://www.blender.org/documentation/blender_python_api_%s" %
"_".join(str(v) for v in bpy.app.version))
- def _nested_class_string(self, class_string):
- ls = []
- class_obj = getattr(bpy.types, class_string, None).bl_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('.')
- if len(id_split) == 1: # rna, class
- url = '%s/bpy.types.%s.html' % (self._prefix, id_split[0])
- elif len(id_split) == 2: # rna, class.prop
- class_name, class_prop = id_split
-
- if hasattr(bpy.types, class_name.upper() + '_OT_' + class_prop):
- url = ("%s/bpy.ops.%s.html#bpy.ops.%s.%s" %
- (self._prefix, class_name, class_name, class_prop))
- else:
-
- # detect if this is a inherited member and use that name instead
- rna_parent = getattr(bpy.types, class_name).bl_rna
- rna_prop = rna_parent.properties[class_prop]
- rna_parent = rna_parent.base
- while rna_parent and rna_prop == rna_parent.properties.get(class_prop):
- class_name = rna_parent.identifier
- rna_parent = rna_parent.base
-
- #~ class_name_full = self._nested_class_string(class_name)
- url = ("%s/bpy.types.%s.html#bpy.types.%s.%s" %
- (self._prefix, class_name, class_name, class_prop))
-
- else:
+ url = _wm_doc_get_id(self.doc_id, do_url=True, url_prefix=self._prefix)
+ if url is None:
return {'PASS_THROUGH'}
import webbrowser