3
Name: 'Function Documentation | Ctrl I'
7
Tooltip: 'Attempts to display documentation about the function preceding the cursor.'
10
# Only run if we have the required modules
13
from BPyTextPlugin import *
20
txt = bpy.data.texts.active
24
(line, c) = current_line(txt)
26
# Check we are in a normal context
27
if get_context(txt) != CTX_NORMAL:
30
# Identify the name under the cursor
32
while c<llen and (line[c].isalnum() or line[c]=='_'):
35
targets = get_targets(line, c)
37
# If no name under cursor, look backward to see if we're in function parens
38
if len(targets) == 0 or targets[0] == '':
39
# Look backwards for first '(' without ')'
42
for i in range(c-1, -1, -1):
43
if line[i] == ')': b += 1
50
if found: targets = get_targets(line, c)
51
if len(targets) == 0 or targets[0] == '':
54
obj = resolve_targets(txt, targets)
57
if isinstance(obj, Definition): # Local definition
59
elif hasattr(obj, '__doc__') and obj.__doc__:
60
txt.showDocs(obj.__doc__)
62
# Check we are running as a script and not imported as a module
63
if __name__ == "__main__" and OK:
3
Name: 'Function Documentation | Ctrl I'
7
Tooltip: 'Attempts to display documentation about the function preceding the cursor.'
10
# Only run if we have the required modules
13
from BPyTextPlugin import *
20
txt = bpy.data.texts.active
24
(line, c) = current_line(txt)
26
# Check we are in a normal context
27
if get_context(txt) != CTX_NORMAL:
30
# Identify the name under the cursor
32
while c<llen and (line[c].isalnum() or line[c]=='_'):
35
targets = get_targets(line, c)
37
# If no name under cursor, look backward to see if we're in function parens
38
if len(targets) == 0 or targets[0] == '':
39
# Look backwards for first '(' without ')'
42
for i in range(c-1, -1, -1):
43
if line[i] == ')': b += 1
50
if found: targets = get_targets(line, c)
51
if len(targets) == 0 or targets[0] == '':
54
obj = resolve_targets(txt, targets)
57
if isinstance(obj, Definition): # Local definition
59
elif hasattr(obj, '__doc__') and obj.__doc__:
60
txt.showDocs(obj.__doc__)
62
# Check we are running as a script and not imported as a module
63
if __name__ == "__main__" and OK: