mirror of
https://github.com/fergalmoran/picard.git
synced 2026-05-25 20:36:10 +00:00
Display module for script functions registered outside picard
This commit is contained in:
committed by
Philipp Wolfer
parent
803bc78795
commit
7ec406f8bd
@@ -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__,
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -166,12 +166,17 @@ code {
|
||||
|
||||
def process_html(html, function):
|
||||
if not html:
|
||||
return ''
|
||||
html = ''
|
||||
template = '<dt>%s%s</dt><dd>%s</dd>'
|
||||
if function.module is not None and function.module != 'picard.script':
|
||||
module = ' [' + function.module + ']'
|
||||
else:
|
||||
module = ''
|
||||
try:
|
||||
firstline, remaining = html.split("\n", 1)
|
||||
return '<dt>' + firstline + '</dt><dd>' + remaining + '</dd>'
|
||||
return template % (firstline, module, remaining)
|
||||
except ValueError:
|
||||
return '<dt>$' + function.name + '(...)</dt><dd>' + html + '</dd>'
|
||||
return template % ("$%s()" % function.name, module, html)
|
||||
|
||||
funcdoc = script_function_documentation_all(
|
||||
fmt='html',
|
||||
|
||||
@@ -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, '<div id="test">w' + pre)
|
||||
self.assertEndswith(docall, post + 'y</div>\n')
|
||||
self.assertEndswith(docall, post + 'somefuncy</div>\n')
|
||||
|
||||
def test_unknown_function(self):
|
||||
areg = r"^\d+:\d+:\$unknownfunction: Unknown function '\$unknownfunction'"
|
||||
|
||||
Reference in New Issue
Block a user