diff --git a/picard/script.py b/picard/script.py
index c5aea9b41..1dbc2b133 100644
--- a/picard/script.py
+++ b/picard/script.py
@@ -152,14 +152,14 @@ class ScriptVariable(object):
class FunctionRegistryItem:
- def __init__(self, function, eval_args, argcount,
- documentation=None,
- name=None):
+ def __init__(self, function, eval_args, argcount, documentation=None,
+ name=None, module=None):
self.function = function
self.eval_args = eval_args
self.argcount = argcount
self.documentation = documentation
self.name = name
+ self.module = module
def __repr__(self):
return '{classname}({me.function}, {me.eval_args}, {me.argcount}, {doc})'.format(
@@ -530,6 +530,7 @@ def register_script_function(function, name=None, eval_args=True,
argcount if argcount and check_argcount else False,
documentation=documentation,
name=name,
+ module=function.__module__,
)
)
)
diff --git a/picard/ui/options/scripting.py b/picard/ui/options/scripting.py
index d73542f60..044cdefa1 100644
--- a/picard/ui/options/scripting.py
+++ b/picard/ui/options/scripting.py
@@ -166,12 +166,17 @@ code {
def process_html(html, function):
if not html:
- return ''
+ html = ''
+ template = '
%s%s%s'
+ if function.module is not None and function.module != 'picard.script':
+ module = ' [' + function.module + ']'
+ else:
+ module = ''
try:
firstline, remaining = html.split("\n", 1)
- return '' + firstline + '' + remaining + ''
+ return template % (firstline, module, remaining)
except ValueError:
- return '$' + function.name + '(...)' + html + ''
+ return template % ("$%s()" % function.name, module, html)
funcdoc = script_function_documentation_all(
fmt='html',
diff --git a/test/test_script.py b/test/test_script.py
index 50ab3f1d7..0f45937e2 100644
--- a/test/test_script.py
+++ b/test/test_script.py
@@ -304,8 +304,8 @@ class ScriptParserTest(PicardTestCase):
def func_somefunc(parser):
return "x"
- def preprocessor(data):
- return 'w' + data + 'y'
+ def preprocessor(data, function):
+ return 'w' + data + function.name + 'y'
docall = script_function_documentation_all(
fmt='html',
@@ -315,7 +315,7 @@ class ScriptParserTest(PicardTestCase):
)
self.assertStartswith(docall, 'w' + pre)
- self.assertEndswith(docall, post + 'y
\n')
+ self.assertEndswith(docall, post + 'somefuncy\n')
def test_unknown_function(self):
areg = r"^\d+:\d+:\$unknownfunction: Unknown function '\$unknownfunction'"