Fix T53843: Error opening online manual
This commit is contained in:
@@ -906,6 +906,15 @@ class WM_OT_path_open(Operator):
|
|||||||
|
|
||||||
|
|
||||||
def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
|
def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
|
||||||
|
|
||||||
|
def operator_exists_pair(a, b):
|
||||||
|
# Not fast, this is only for docs.
|
||||||
|
return b in dir(getattr(bpy.ops, a))
|
||||||
|
|
||||||
|
def operator_exists_single(a):
|
||||||
|
a, b = a.partition("_OT_")[::2]
|
||||||
|
return operator_exists_pair(a.lower(), b)
|
||||||
|
|
||||||
id_split = doc_id.split(".")
|
id_split = doc_id.split(".")
|
||||||
url = rna = None
|
url = rna = None
|
||||||
|
|
||||||
@@ -919,7 +928,18 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
|
|||||||
class_name, class_prop = id_split
|
class_name, class_prop = id_split
|
||||||
|
|
||||||
# an operator (common case - just button referencing an op)
|
# an operator (common case - just button referencing an op)
|
||||||
if hasattr(bpy.types, class_name.upper() + "_OT_" + class_prop):
|
if operator_exists_pair(class_name, 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)
|
||||||
|
elif operator_exists_single(class_name):
|
||||||
|
# note: ignore the prop name since we don't have a way to link into it
|
||||||
|
class_name, class_prop = class_name.split("_OT_", 1)
|
||||||
|
class_name = class_name.lower()
|
||||||
if do_url:
|
if do_url:
|
||||||
url = (
|
url = (
|
||||||
"%s/bpy.ops.%s.html#bpy.ops.%s.%s" %
|
"%s/bpy.ops.%s.html#bpy.ops.%s.%s" %
|
||||||
@@ -928,48 +948,31 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
|
|||||||
else:
|
else:
|
||||||
rna = "bpy.ops.%s.%s" % (class_name, class_prop)
|
rna = "bpy.ops.%s.%s" % (class_name, class_prop)
|
||||||
else:
|
else:
|
||||||
|
# an RNA setting, common case
|
||||||
rna_class = getattr(bpy.types, class_name)
|
rna_class = getattr(bpy.types, class_name)
|
||||||
|
|
||||||
# an operator setting (selected from a running operator), rare case
|
# detect if this is a inherited member and use that name instead
|
||||||
# note: Py defined operators are subclass of Operator,
|
rna_parent = rna_class.bl_rna
|
||||||
# C defined operators are subclass of OperatorProperties.
|
rna_prop = rna_parent.properties.get(class_prop)
|
||||||
# we may need to check on this at some point.
|
if rna_prop:
|
||||||
if issubclass(rna_class, (bpy.types.Operator, bpy.types.OperatorProperties)):
|
rna_parent = rna_parent.base
|
||||||
# note: ignore the prop name since we don't have a way to link into it
|
while rna_parent and rna_prop == rna_parent.properties.get(class_prop):
|
||||||
class_name, class_prop = class_name.split("_OT_", 1)
|
class_name = rna_parent.identifier
|
||||||
class_name = class_name.lower()
|
rna_parent = rna_parent.base
|
||||||
|
|
||||||
if do_url:
|
if do_url:
|
||||||
url = (
|
url = (
|
||||||
"%s/bpy.ops.%s.html#bpy.ops.%s.%s" %
|
"%s/bpy.types.%s.html#bpy.types.%s.%s" %
|
||||||
(url_prefix, class_name, class_name, class_prop)
|
(url_prefix, class_name, class_name, class_prop)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
rna = "bpy.ops.%s.%s" % (class_name, class_prop)
|
rna = "bpy.types.%s.%s" % (class_name, class_prop)
|
||||||
else:
|
else:
|
||||||
# an RNA setting, common case
|
# We assume this is custom property, only try to generate generic url/rna_id...
|
||||||
|
if do_url:
|
||||||
# detect if this is a inherited member and use that name instead
|
url = ("%s/bpy.types.bpy_struct.html#bpy.types.bpy_struct.items" % (url_prefix,))
|
||||||
rna_parent = rna_class.bl_rna
|
|
||||||
rna_prop = rna_parent.properties.get(class_prop)
|
|
||||||
if rna_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)
|
|
||||||
else:
|
else:
|
||||||
# We assume this is custom property, only try to generate generic url/rna_id...
|
rna = "bpy.types.bpy_struct"
|
||||||
if do_url:
|
|
||||||
url = ("%s/bpy.types.bpy_struct.html#bpy.types.bpy_struct.items" % (url_prefix,))
|
|
||||||
else:
|
|
||||||
rna = "bpy.types.bpy_struct"
|
|
||||||
|
|
||||||
return url if do_url else rna
|
return url if do_url else rna
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user