Skip to content

Commit f0467dd

Browse files
committed
doc: added comments to new tree interface functions
1 parent 2000967 commit f0467dd

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

ntp_operator.py

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
if bpy.app.version < (4, 0, 0):
77
from bpy.types import NodeSocketInterface
88
else:
9-
from bpy.types import NodeTreeInterfaceItem, NodeTreeInterfacePanel, NodeTreeInterfaceSocket
9+
from bpy.types import NodeTreeInterfacePanel, NodeTreeInterfaceSocket
10+
from bpy.types import NodeTreeInterfaceItem
1011

1112
import os
1213
from typing import TextIO
14+
import shutil
1315

1416
from .ntp_node_tree import NTP_NodeTree
1517
from .utils import *
@@ -179,11 +181,15 @@ def dfs(nt: NodeTree) -> None:
179181

180182
return result
181183

182-
183184
def _process_group_node_tree(self, node: Node, node_var: str, inner: str
184185
) -> None:
185186
"""
186187
Processes node tree of group node if one is present
188+
189+
Parameters:
190+
node (Node): the group node
191+
node_var (str): variable for the group node
192+
inner (str): indentation
187193
"""
188194
node_tree = node.node_tree
189195
if node_tree is None:
@@ -438,6 +444,8 @@ def _set_tree_socket_defaults(self, socket_interface: NodeTreeInterfaceSocket,
438444
"""
439445
Set a node tree input/output's default properties if they exist
440446
447+
Helper function to _create_socket()
448+
441449
Parameters:
442450
socket_interface (NodeTreeInterfaceSocket): socket interface associated
443451
with the input/output
@@ -472,6 +480,20 @@ def _create_socket(self, inner: str, socket: NodeTreeInterfaceSocket,
472480
parent: NodeTreeInterfacePanel,
473481
panel_dict: dict[NodeTreeInterfacePanel, str],
474482
ntp_nt: NTP_NodeTree) -> None:
483+
"""
484+
Initialize a new tree socket
485+
486+
Helper function to _process_items()
487+
488+
Parameters:
489+
inner (str): indentation string
490+
socket (NodeTreeInterfaceSocket): the socket to recreate
491+
parent (NodeTreeInterfacePanel): parent panel of the socket
492+
(possibly None)
493+
panel_dict (dict[NodeTreeInterfacePanel, str]: panel -> variable
494+
ntp_nt (NTP_NodeTree): owner of the socket
495+
"""
496+
475497
self._write(f"{inner}#Socket {socket.name}\n")
476498
# initialization
477499
socket_var = self._create_var(socket.name + "_socket")
@@ -547,6 +569,22 @@ def _create_panel(self, inner: str, panel: NodeTreeInterfacePanel,
547569
panel_dict: dict[NodeTreeInterfacePanel],
548570
items_processed: set[NodeTreeInterfacePanel],
549571
parent: NodeTreeInterfacePanel, ntp_nt: NTP_NodeTree):
572+
"""
573+
Initialize a new tree panel and its subitems
574+
575+
Helper function to _process_items()
576+
577+
Parameters:
578+
inner (str): indentation string
579+
panel (NodeTreeInterfacePanel): the panel to recreate
580+
panel_dict (dict[NodeTreeInterfacePanel, str]: panel -> variable
581+
items_processed (set[NodeTreeInterfacePanel]): set of already
582+
processed items, so none are done twice
583+
parent (NodeTreeInterfacePanel): parent panel of the socket
584+
(possibly None)
585+
ntp_nt (NTP_NodeTree): owner of the socket
586+
"""
587+
550588
self._write(f"{inner}#Panel {panel.name}\n")
551589

552590
panel_var = self._create_var(panel.name + "_panel")
@@ -587,6 +625,21 @@ def _process_items(self, inner: str, parent: NodeTreeInterfacePanel,
587625
panel_dict: dict[NodeTreeInterfacePanel],
588626
items_processed: set[NodeTreeInterfacePanel],
589627
ntp_nt: NTP_NodeTree) -> None:
628+
"""
629+
Recursive function to process all node tree interface items in a
630+
given layer
631+
632+
Helper function to _tree_interface_settings()
633+
634+
Parameters:
635+
inner (str): indentation string
636+
parent (NodeTreeInterfacePanel): parent panel of the layer
637+
(possibly None to signify the base)
638+
panel_dict (dict[NodeTreeInterfacePanel, str]: panel -> variable
639+
items_processed (set[NodeTreeInterfacePanel]): set of already
640+
processed items, so none are done twice
641+
ntp_nt (NTP_NodeTree): owner of the socket
642+
"""
590643
if parent is None:
591644
items = ntp_nt.node_tree.interface.items_tree
592645
else:

0 commit comments

Comments
 (0)