Created by: portnov
I'm not sure if this is ready to merge yet, but at least we need to discuss, I think.
What this adds is:
- Icons to node creation buttons in T panel
- Proper tooltips (from node docstrings) to buttons in T panel
- Proper tooltips for items in Shift-A menu.
- Possibility to create nodes from standard Blender's Space menu (obviously only in node editor context).
More technical description of changes:
-
Special operator class is registered for each node class. This is done in menu.py.
-
Icons for operators are taken from node's bl_icon property. All icon-handling methods are moved from menu.py to sverchok.ui.sv_icons. This is done to use exactly the same code both for menu and for T panel: these functions are called both from sverchok.menu and from sverchok.ui.nodeview_space_menu.
-
A new, more regular syntax is introduced for node class docstrings. RFC-822 is to be used as a standard, at least for new nodes:
class SvBoxNode(bpy.types.Node, SverchCustomTreeNode): """ Triggers: Box Tooltip: Generate a Box primitive This is the long description in free form, it can include technical or historical remarks. """ bl_idname = 'SvBoxNode' ...
-
For now, only two headers are used: Triggers is a shorthand to be used in Ctrl-Space search menu, and Tooltip is used as a tooltip. Other headers probably will be added in the future. Unknown headers are just ignored. Standard Python's
email
module is used to parse docstrings, so we can be more or less sure that we correctly understand RFC-822 subtle moments (multiline headers, escaping and so on). -
Old
///
syntax for search shorthands is also supported for compatibility. -
To incapsulate docstring parsing logic, there is SvDocstring class in
node_tree.py
introduced. -
An instance of SvDocstring is associated with each node class and can be obtained with
node_class.get_docstring()
. -
New classmethods are introduced for SverchCustomTreeNode:
get_shorthand()
andget_tooltip()
. In the default implementation, they parse node class docstring as described above. Author of specific node can override these methods if he needs to. These new methods are used bysv_extra_search.py
,menu.py
andnodeview_space_menu.py
. -
Box node docstring is updated to be an example of what docstrings should look like.
What I'm not sure about is:
-
Should "enable icons" setting in preferences affect T panel also? -
Will current code play nicely with reloads? -
Can we simplify current code, or make it more robust against upcoming blender API changes (if any)?