Update ArmOpenNodeWikiEntry to new wiki page structure
This commit is contained in:
parent
4e526a6dd3
commit
3e22cb3375
|
@ -418,10 +418,11 @@ class ArmNodeSearch(bpy.types.Operator):
|
||||||
|
|
||||||
class ArmNodeCategory:
|
class ArmNodeCategory:
|
||||||
"""Represents a category (=directory) of logic nodes."""
|
"""Represents a category (=directory) of logic nodes."""
|
||||||
def __init__(self, name: str, icon: str, description: str):
|
def __init__(self, name: str, icon: str, description: str, category_section: str):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
self.description = description
|
self.description = description
|
||||||
|
self.category_section = category_section
|
||||||
self.node_sections: ODict[str, List[NodeItem]] = OrderedDict()
|
self.node_sections: ODict[str, List[NodeItem]] = OrderedDict()
|
||||||
self.deprecated_nodes: List[NodeItem] = []
|
self.deprecated_nodes: List[NodeItem] = []
|
||||||
|
|
||||||
|
@ -502,7 +503,7 @@ def add_category(category: str, section: str = 'default', icon: str = 'BLANK1',
|
||||||
|
|
||||||
add_category_section(section)
|
add_category_section(section)
|
||||||
if not category_exists(category):
|
if not category_exists(category):
|
||||||
node_category = ArmNodeCategory(category, icon, description)
|
node_category = ArmNodeCategory(category, icon, description, section)
|
||||||
category_items[section].append(node_category)
|
category_items[section].append(node_category)
|
||||||
return node_category
|
return node_category
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,7 @@ class ArmOpenNodeHaxeSource(bpy.types.Operator):
|
||||||
webbrowser.open(f'https://github.com/armory3d/armory/tree/{version}/Sources/armory/logicnode/{name}.hx')
|
webbrowser.open(f'https://github.com/armory3d/armory/tree/{version}/Sources/armory/logicnode/{name}.hx')
|
||||||
return{'FINISHED'}
|
return{'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class ArmOpenNodePythonSource(bpy.types.Operator):
|
class ArmOpenNodePythonSource(bpy.types.Operator):
|
||||||
"""Expose Python source"""
|
"""Expose Python source"""
|
||||||
bl_idname = 'arm.open_node_python_source'
|
bl_idname = 'arm.open_node_python_source'
|
||||||
|
@ -221,24 +222,31 @@ class ArmOpenNodePythonSource(bpy.types.Operator):
|
||||||
webbrowser.open(f'https://github.com/armory3d/armory/tree/{version}/blender/{rel_path}.py')
|
webbrowser.open(f'https://github.com/armory3d/armory/tree/{version}/blender/{rel_path}.py')
|
||||||
return{'FINISHED'}
|
return{'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class ArmOpenNodeWikiEntry(bpy.types.Operator):
|
class ArmOpenNodeWikiEntry(bpy.types.Operator):
|
||||||
"""Open the node's documentation in the wiki"""
|
"""Open the node's documentation in the wiki"""
|
||||||
bl_idname = 'arm.open_node_documentation'
|
bl_idname = 'arm.open_node_documentation'
|
||||||
bl_label = 'Open Node Documentation'
|
bl_label = 'Open Node Documentation'
|
||||||
|
|
||||||
def to_wiki_id(self, node_name):
|
@staticmethod
|
||||||
"""convert from the conventional node name to its wiki counterpart's anchor or id
|
def to_wiki_id(node_name):
|
||||||
expected node_name format: LN_[a-z_]+
|
"""Convert from the conventional node name to its wiki counterpart's anchor or id.
|
||||||
|
Expected node_name format: LN_[a-z_]+
|
||||||
"""
|
"""
|
||||||
return node_name.replace('_','-')[3:]
|
return node_name.replace('_', '-')[3:]
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
if context.selected_nodes is not None:
|
if context.selected_nodes is not None:
|
||||||
if len(context.selected_nodes) == 1:
|
if len(context.selected_nodes) == 1:
|
||||||
node = context.selected_nodes[0]
|
node = context.selected_nodes[0]
|
||||||
if node.bl_idname.startswith('LN') and node.arm_version is not None:
|
if node.bl_idname.startswith('LN') and node.arm_version is not None:
|
||||||
wiki_id = self.to_wiki_id(node.__module__.rsplit('.', 2).pop())
|
wiki_id = ArmOpenNodeWikiEntry.to_wiki_id(node.__module__.rsplit('.', 2).pop())
|
||||||
webbrowser.open(f'https://github.com/armory3d/armory/wiki/reference#{wiki_id}')
|
|
||||||
|
category = node.arm_category
|
||||||
|
if category == arm_nodes.PKG_AS_CATEGORY:
|
||||||
|
category = node.__module__.rsplit('.', 2)[-2].capitalize()
|
||||||
|
category_section = arm_nodes.get_category(category).category_section
|
||||||
|
webbrowser.open(f'https://github.com/armory3d/armory/wiki/reference_{category_section}#{wiki_id}')
|
||||||
return{'FINISHED'}
|
return{'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue