#!BPY """ Name: 'Function Documentation | Ctrl I' Blender: 246 Group: 'TextPlugin' Shortcut: 'Ctrl+I' Tooltip: 'Attempts to display documentation about the function preceding the cursor.' """ # Only run if we have the required modules try: import bpy from BPyTextPlugin import * except ImportError: OK = False else: OK = True def main(): txt = bpy.data.texts.active if not txt: return (line, c) = current_line(txt) # Check we are in a normal context if get_context(txt) != CTX_NORMAL: return # Look backwards for first '(' without ')' b = 0 found = False for i in range(c-1, -1, -1): if line[i] == ')': b += 1 elif line[i] == '(': b -= 1 if b < 0: found = True c = i break # Otherwise identify the name under the cursor if not found: llen = len(line) while c