Update ArmOpenNodeWikiEntry to new wiki page structure

This commit is contained in:
Moritz Brückner 2021-08-19 22:02:01 +02:00
parent 4e526a6dd3
commit 3e22cb3375
2 changed files with 17 additions and 8 deletions

View file

@ -418,10 +418,11 @@ class ArmNodeSearch(bpy.types.Operator):
class ArmNodeCategory:
"""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.icon = icon
self.description = description
self.category_section = category_section
self.node_sections: ODict[str, List[NodeItem]] = OrderedDict()
self.deprecated_nodes: List[NodeItem] = []
@ -502,7 +503,7 @@ def add_category(category: str, section: str = 'default', icon: str = 'BLANK1',
add_category_section(section)
if not category_exists(category):
node_category = ArmNodeCategory(category, icon, description)
node_category = ArmNodeCategory(category, icon, description, section)
category_items[section].append(node_category)
return node_category

View file

@ -204,6 +204,7 @@ class ArmOpenNodeHaxeSource(bpy.types.Operator):
webbrowser.open(f'https://github.com/armory3d/armory/tree/{version}/Sources/armory/logicnode/{name}.hx')
return{'FINISHED'}
class ArmOpenNodePythonSource(bpy.types.Operator):
"""Expose 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')
return{'FINISHED'}
class ArmOpenNodeWikiEntry(bpy.types.Operator):
"""Open the node's documentation in the wiki"""
bl_idname = 'arm.open_node_documentation'
bl_label = 'Open Node Documentation'
def to_wiki_id(self, node_name):
"""convert from the conventional node name to its wiki counterpart's anchor or id
expected node_name format: LN_[a-z_]+
@staticmethod
def to_wiki_id(node_name):
"""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):
if context.selected_nodes is not None:
if len(context.selected_nodes) == 1:
node = context.selected_nodes[0]
if node.bl_idname.startswith('LN') and node.arm_version is not None:
wiki_id = self.to_wiki_id(node.__module__.rsplit('.', 2).pop())
webbrowser.open(f'https://github.com/armory3d/armory/wiki/reference#{wiki_id}')
wiki_id = ArmOpenNodeWikiEntry.to_wiki_id(node.__module__.rsplit('.', 2).pop())
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'}